| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| program test_quantum_offload |
| use iso_c_binding |
| use quantum_theorem3 |
| use bob_kinds, only: i4, dp |
| implicit none |
|
|
| integer(i4) :: status, genus |
| integer :: test_num |
| integer :: passed, failed |
|
|
| |
| passed = 0 |
| failed = 0 |
|
|
| print *, "========================================================" |
| print *, "FORTRAN QUANTUM INTEGRATION TEST SUITE" |
| print *, "Theorem 3: Genus-0 Forcing via Quantum Offload" |
| print *, "========================================================" |
| print *, "" |
|
|
| |
| |
| |
| test_num = 1 |
| print *, "TEST ", test_num, ": u^2 + x^2 (should be genus-0)" |
| print *, " Polynomial: '1*u^2 + 1*x^2'" |
| print *, " Energy budget: 100" |
|
|
| call offload_theorem3_to_quantum("1*u^2 + 1*x^2", 100_i4, status, genus) |
|
|
| print *, " Result status: ", status |
| print *, " Result genus: ", genus |
|
|
| if (status == THEOREM3_SUCCESS .and. genus == 0) then |
| print *, " β PASSED (genus-0 verified + quantum success)" |
| passed = passed + 1 |
| else if (status == THEOREM3_BLOCKED) then |
| print *, " β BLOCKED (unexpected obstruction)" |
| failed = failed + 1 |
| else |
| print *, " β FAILED (status=", status, ", genus=", genus, ")" |
| failed = failed + 1 |
| end if |
| print *, "" |
|
|
| |
| |
| |
| test_num = 2 |
| print *, "TEST ", test_num, ": u^4 + 2*u^2*x + x^4 (degree-4)" |
| print *, " Polynomial: '1*u^4 + 2*u^2*x + 1*x^4'" |
| print *, " Energy budget: 200" |
|
|
| call offload_theorem3_to_quantum("1*u^4 + 2*u^2*x + 1*x^4", 200_i4, status, genus) |
|
|
| print *, " Result status: ", status |
| print *, " Result genus: ", genus |
|
|
| if (status == THEOREM3_SUCCESS .and. genus == 0) then |
| print *, " β PASSED (rational curve verified)" |
| passed = passed + 1 |
| else if (status == THEOREM3_COUNTEREXAMPLE) then |
| print *, " ~ COUNTEREXAMPLE (genus > 0 detected, not necessarily failure)" |
| passed = passed + 1 |
| else if (status == THEOREM3_BLOCKED) then |
| print *, " β BLOCKED (obstruction; may indicate singular origin)" |
| passed = passed + 1 |
| else |
| print *, " β FAILED (unexpected status)" |
| failed = failed + 1 |
| end if |
| print *, "" |
|
|
| |
| |
| |
| test_num = 3 |
| print *, "TEST ", test_num, ": u^3 + x^3 (fermat cubic, should have genus)" |
| print *, " Polynomial: '1*u^3 + 1*x^3'" |
| print *, " Energy budget: 150" |
|
|
| call offload_theorem3_to_quantum("1*u^3 + 1*x^3", 150_i4, status, genus) |
|
|
| print *, " Result status: ", status |
| print *, " Result genus: ", genus |
|
|
| if (status == THEOREM3_COUNTEREXAMPLE) then |
| print *, " β PASSED (counterexample detected, genus > 0)" |
| passed = passed + 1 |
| else if (status == THEOREM3_BLOCKED) then |
| print *, " β BLOCKED (obstruction, valid)" |
| passed = passed + 1 |
| else if (status == THEOREM3_SUCCESS) then |
| print *, " ? SUCCESS but genus=", genus, " (unexpected for cubic)" |
| |
| if (genus /= 0) then |
| passed = passed + 1 |
| else |
| failed = failed + 1 |
| end if |
| else |
| print *, " β FAILED (status=", status, ")" |
| failed = failed + 1 |
| end if |
| print *, "" |
|
|
| |
| |
| |
| test_num = 4 |
| print *, "TEST ", test_num, ": Energy budget exhaustion (budget=1)" |
| print *, " Polynomial: '1*u^6 + 1*x^6' (high degree)" |
| print *, " Energy budget: 1 (insufficient)" |
|
|
| call offload_theorem3_to_quantum("1*u^6 + 1*x^6", 1_i4, status, genus) |
|
|
| print *, " Result status: ", status |
| print *, " Result genus: ", genus |
|
|
| |
| if (status == THEOREM3_BLOCKED) then |
| print *, " β PASSED (correctly blocked due to energy)" |
| passed = passed + 1 |
| else if (status == THEOREM3_SUCCESS) then |
| print *, " ~ SUCCESS (analysis completed despite low budget)" |
| passed = passed + 1 |
| else |
| print *, " β FAILED (unexpected status)" |
| failed = failed + 1 |
| end if |
| print *, "" |
|
|
| |
| |
| |
| test_num = 5 |
| print *, "TEST ", test_num, ": Round-trip with polynomial_to_string" |
| print *, " Building polynomial from coefficient arrays..." |
|
|
| block |
| real(dp) :: coeffs(3) |
| integer(i4) :: degrees_u(3), degrees_x(3) |
| character(len=:), allocatable :: poly_str_built |
|
|
| coeffs = [1.0_dp, 2.0_dp, 1.0_dp] |
| degrees_u = [2, 1, 0] |
| degrees_x = [0, 1, 2] |
|
|
| poly_str_built = polynomial_to_string(coeffs, degrees_u, degrees_x) |
|
|
| print *, " Coefficients: ", coeffs |
| print *, " Degrees u: ", degrees_u |
| print *, " Degrees x: ", degrees_x |
| print *, " Built polynomial: '", poly_str_built, "'" |
| print *, " Energy budget: 100" |
|
|
| |
| call offload_theorem3_to_quantum(poly_str_built, 100_i4, status, genus) |
|
|
| print *, " Result status: ", status |
| print *, " Result genus: ", genus |
|
|
| if (status == THEOREM3_SUCCESS .or. status == THEOREM3_BLOCKED .or. status == THEOREM3_COUNTEREXAMPLE) then |
| print *, " β PASSED (round-trip completed)" |
| passed = passed + 1 |
| else |
| print *, " β FAILED (round-trip error)" |
| failed = failed + 1 |
| end if |
| end block |
|
|
| print *, "" |
|
|
| |
| |
| |
| print *, "========================================================" |
| print *, "TEST SUMMARY" |
| print *, "========================================================" |
| print *, "Passed: ", passed |
| print *, "Failed: ", failed |
| print *, "Total: ", passed + failed |
| print *, "" |
|
|
| if (failed == 0) then |
| print *, "β ALL TESTS PASSED" |
| stop 0 |
| else |
| print *, "β SOME TESTS FAILED" |
| stop 1 |
| end if |
|
|
| end program test_quantum_offload |
|
|