You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add QuadraticDiophantineEquations model (#543) (#812)
* feat: add QuadraticDiophantineEquations model (#543)
Add decision problem: given positive integers a, b, c, determine whether
there exist positive integers x, y such that ax^2 + by = c. Single
variable x with y derived; complexity O(sqrt(c)) by trial.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix agentic review issues: rename c_val→c getter, fix paper solve command
- Rename `c_val()` getter to `c()` so user-facing catalog output shows
the mathematical parameter name instead of an implementation detail
- Add `--solver brute-force` to paper's `pred solve` command since
QuadraticDiophantineEquations has no ILP reduction path
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: rename duplicate rhs CLI field to qde_rhs for QuadraticDiophantineEquations
* fix: remove OLA→STMWCT rule file accidentally included from merge
The file was brought in by a contaminated merge commit and does not
belong to the QuadraticDiophantineEquations model PR.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: rename --qde-rhs to --coeff-c for consistency
All three QDE parameters now use the coeff- prefix: --coeff-a, --coeff-b, --coeff-c.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: zazabap <sweynan@icloud.com>
@@ -3257,6 +3258,53 @@ A classical NP-complete problem from Garey and Johnson @garey1979[Ch.~3, p.~76],
3257
3258
]
3258
3259
}
3259
3260
3261
+
#{
3262
+
let x = load-model-example("QuadraticDiophantineEquations")
3263
+
let a = x.instance.a
3264
+
let b = x.instance.b
3265
+
let c = x.instance.c
3266
+
let config = x.optimal_config
3267
+
let xval = config.at(0) + 1
3268
+
let yval = int((c - a * xval * xval) / b)
3269
+
// Enumerate all valid x values for the table
3270
+
let max-x = calc.floor(calc.sqrt(c / a))
3271
+
let rows = range(1, max-x + 1).map(xi => {
3272
+
let rem = c - a * xi * xi
3273
+
let feasible = rem > 0 and calc.rem(rem, b) == 0
3274
+
let yi = if feasible { int(rem / b) } else { none }
3275
+
(xi, rem, feasible, yi)
3276
+
})
3277
+
[
3278
+
#problem-def("QuadraticDiophantineEquations")[
3279
+
Given positive integers $a$, $b$, $c$, determine whether there exist positive integers $x$, $y$ such that $a x^2 + b y = c$.
3280
+
][
3281
+
Quadratic Diophantine equations of the form $a x^2 + b y = c$ form one of the simplest families of mixed-degree Diophantine problems. The variable $y$ is entirely determined by $x$ via $y = (c - a x^2) slash b$, so the decision problem reduces to checking whether any $x in {1, dots, floor(sqrt(c slash a))}$ yields a positive integer $y$. This can be done in $O(sqrt(c))$ time by trial#footnote[No algorithm improving on brute-force trial of all candidate $x$ values is known; the registered complexity `sqrt(c)` reflects this direct enumeration bound.].
3282
+
3283
+
*Example.* Let $a = #a$, $b = #b$, $c = #c$. Then $x$ ranges over $1, dots, #max-x$:
0 commit comments