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
{{ message }}
Repository navigation
Commit fbf7a76
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .claude/CLAUDE.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -228,7 +228,7 @@ fields to issue templates. Changes to issue templates require user approval.
228
228
### Paper (docs/paper/reductions.typ)
229
229
-`problem-def(name)[def][body]` — defines a problem with auto-generated schema, reductions list, and label `<def:ProblemName>`. Title comes from `display-name` dict.
230
230
-`reduction-rule(source, target, example: bool, ...)[rule][proof]` — generates a theorem with label `<thm:Source-to-Target>` and registers in `covered-rules` state. Overhead auto-derived from JSON edge data.
231
-
- Every directed reduction needs its own `reduction-rule` entry (except trivial Decision↔Optimization pairs which are auto-filtered)
231
+
- Every directed reduction needs its own `reduction-rule` entry (except trivial Decision↔Optimization pairs and pure `One → i64 → f64` numeric casts, which are auto-filtered)
232
232
- Completeness warnings auto-check that all JSON graph nodes/edges are covered in the paper; `Decision<P> ↔ P` edges are excluded since they are trivial solve-and-compare reductions
233
233
-`display-name` dict maps `ProblemName` to display text
234
234
@@ -302,7 +302,7 @@ Also add to the `display-name` dictionary:
302
302
]
303
303
```
304
304
305
-
Every directed reduction in the graph needs its own `reduction-rule` entry. The paper auto-checks completeness against the generated `reduction_graph.json` export.
305
+
Every nontrivial directed reduction in the graph needs its own `reduction-rule` entry. Do not add paper explanations for pure `One → i64 → f64` numeric casts. Other same-model variant reductions, such as graph transformations and bounded-integer encodings, still require entries. The paper auto-checks completeness against the generated `reduction_graph.json` export.
Copy file name to clipboardExpand all lines: .claude/skills/how-to-code/SKILL.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ Traits and helpers: `src/rules/traits.rs`, `src/rules/test_helpers.rs`, `src/rul
95
95
and parameter counts vs the transform (reuse existing inputs; the shared executable-rule check lives in `src/unit_tests/parameter_formula_validation.rs`), and one test per malformed representation the decoder
`extract_value` against `BruteForce::solve` on both sides.
98
-
5. Paper `reduction-rule` entry — how-to-write-manual (adapt the how-to-verify proof, don't rewrite).
98
+
5. Paper `reduction-rule` entry — how-to-write-manual (adapt the how-to-verify proof, don't rewrite). Pure `One -> i64 -> f64` numeric casts are exempt; other same-model variant reductions still need entries.
example-caption:, extra:)[statement][proof]` auto-derives overhead from the graph export and
26
26
registers the edge for the completeness check; label `<thm:Source-to-Target>`.
27
-
- Every directed reduction needs its own entry, including reverses. Only `Decision<P> <-> P` pairs are
28
-
exempt. The completeness warning block at the end of the paper lists missing edges; your change
27
+
- Every directed reduction needs its own entry, including reverses. `Decision<P> <-> P` pairs and pure `One -> i64 -> f64` numeric casts are
28
+
exempt; do not explain numeric casts in the paper. Nontrivial same-model variant reductions still require entries. The completeness warning block at the end of the paper lists missing edges; your change
Copy file name to clipboardExpand all lines: docs/paper/reductions.typ
+25-43Lines changed: 25 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -3287,7 +3287,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
3287
3287
]
3288
3288
}
3289
3289
#{
3290
-
let x = load-model-example("SteinerTree")
3290
+
let x = load-model-example("SteinerTree", variant: (graph: "SimpleGraph", weight: "i64"))
3291
3291
let nv = graph-num-vertices(x.instance)
3292
3292
let ne = graph-num-edges(x.instance)
3293
3293
let edges = x.instance.graph.edges
@@ -4451,7 +4451,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
4451
4451
}
4452
4452
4453
4453
#{
4454
-
let x = load-model-example("ComparativeContainment")
4454
+
let x = load-model-example("ComparativeContainment", variant: (weight: "i64"))
4455
4455
let n = x.instance.universe_size
4456
4456
let R = x.instance.r_sets
4457
4457
let S = x.instance.s_sets
@@ -4994,7 +4994,7 @@ In all graph problems below, $G = (V, E)$ denotes an undirected graph with $|V|
4994
4994
#problem-def("QUBO")[
4995
4995
Given $n$ binary variables $x_i in {0, 1}$ and an upper-triangular matrix $Q$, minimize $f(bold(x)) = sum_(i=1)^n Q_(i i) x_i + sum_(i < j) Q_(i j) x_i x_j$ (using $x_i^2 = x_i$ for binary variables). The registered variants use either exact integer coefficients $Q in ZZ^(n times n)$ (the default) or finite floating-point coefficients $Q in RR^(n times n)$.
4996
4996
][
4997
-
Equivalent to the Ising model via the linear substitution $s_i = 2x_i - 1$. The native formulation for quantum annealing hardware (e.g., D-Wave) and a standard target for penalty-method reductions @glover2019. QUBO unifies many combinatorial problems into a single unconstrained binary framework, making it a universal intermediate representation for quantum and classical optimization. The integer variant stores exact coefficients, the floating-point variant stores finite real coefficients, and their explicit reduction converts exactly representable integers through `i64_to_exact_f64`. The best known general algorithm runs in $O^*(2^n)$ by brute-force enumeration#footnote[QUBO inherits the Ising model's complexity; no algorithm improving on brute-force is known for the general case.].
4997
+
Equivalent to the Ising model via the linear substitution $s_i = 2x_i - 1$. The native formulation for quantum annealing hardware (e.g., D-Wave) and a standard target for penalty-method reductions @glover2019. QUBO unifies many combinatorial problems into a single unconstrained binary framework, making it a universal intermediate representation for quantum and classical optimization. The integer variant stores exact coefficients, the floating-point variant stores finite real coefficients. The best known general algorithm runs in $O^*(2^n)$ by brute-force enumeration#footnote[QUBO inherits the Ising model's complexity; no algorithm improving on brute-force is known for the general case.].
4998
4998
4999
4999
*Example.* Consider $n = #n$ with $Q = mat(#mat-rows)$. The objective is $f(bold(x)) = -x_1 - x_2 - x_3 + 2x_1 x_2 + 2x_2 x_3$. Evaluating all $2^#n$ assignments: $f(0,0,0) = 0$, $f(1,0,0) = -1$, $f(0,1,0) = -1$, $f(0,0,1) = -1$, $f(1,1,0) = 0$, $f(0,1,1) = 0$, $f(1,0,1) = -2$, $f(1,1,1) = 1$. The minimum is $f^* = #fstar$ at $bold(x)^* = (#fmt-values(xstar))$: selecting #selected.join(" and ") avoids the penalty terms #unselected-pairs.join(" and ").
5000
5000
@@ -16827,15 +16827,14 @@ See #link("https://github.com/CodingThrust/problem-reductions/blob/main/examples
16827
16827
Problems parameterized by graph type, weight type, target type, or clause width ($k$) use explicit reductions between registered variants. Each rule constructs the target representation, registers an exact size map, and preserves the witness representation.
Explicit MIS variant reductions convert King's and triangular lattice graphs to unit-disk graphs, unit-disk graphs to simple adjacency graphs, and unit weights to integer weights. Every rule preserves the vertex indices and has an exact identity size map.
16830
+
Explicit MIS variant reductions convert King's and triangular lattice graphs to unit-disk graphs, and unit-disk graphs to simple adjacency graphs. Every rule preserves the vertex indices and has an exact identity size map.
16831
16831
][
16832
16832
_Construction._ The registered rules use these concrete maps:
16833
16833
- _KingsSubgraph $arrow.r$ UnitDiskGraph:_ integer grid positions $(i, j)$ map to float coordinates with radius $r = 1.5$.
16834
16834
- _TriangularSubgraph $arrow.r$ UnitDiskGraph:_ triangular lattice positions map to float coordinates with radius $r = 1.1$.
16835
16835
- _UnitDiskGraph $arrow.r$ SimpleGraph:_ discard coordinates, retain only the adjacency edge list.
16836
-
- _One $arrow.r$ i64:_ each unit weight maps to $1_ZZ$.
16837
16836
16838
-
_Correctness._ Each graph conversion preserves the adjacency relation, and the weight conversion preserves every unit objective contribution as the integer one. Since the MIS objective $max sum_(v in S) w(v)$ depends only on adjacency and weights, feasible sets and their objective values are preserved.
16837
+
_Correctness._ Each graph conversion preserves the adjacency relation. Since the MIS objective $max sum_(v in S) w(v)$ depends only on adjacency and weights, feasible sets and their objective values are preserved.
16839
16838
16840
16839
_Solution extraction._ Return the target configuration unchanged (identity map on vertices).
16841
16840
]
@@ -16860,44 +16859,27 @@ Problems parameterized by graph type, weight type, target type, or clause width
16860
16859
_Solution extraction._ Return the target configuration unchanged.
16861
16860
]
16862
16861
16863
-
#reduction-rule("SpinGlass", "SpinGlass")[
16864
-
An Ising spin-glass instance with integer couplings and fields ($J_(i j), h_i in ZZ$) converts to the floating-point variant ($J_(i j), h_i in RR$) through exact `i64_to_exact_f64` embeddings. The graph topology is preserved.
16865
-
][
16866
-
_Construction._ Given $"SpinGlass"(G, bold(J), bold(h))$ with $J_(i j) in ZZ$ and $h_i in ZZ$, construct $"SpinGlass"(G, bold(J)', bold(h)')$ with $J'_(i j) = J_(i j) in RR$ and $h'_i = h_i in RR$.
16867
-
16868
-
_Correctness._ The spin-glass Hamiltonian $H(bold(s)) = sum_((i,j) in E) J_(i j) s_i s_j + sum_i h_i s_i$ is preserved exactly under the integer-to-float embedding (no rounding). Spin configurations and the objective value are unchanged.
16869
-
16870
-
_Solution extraction._ Return the target configuration unchanged.
A Maximum Set Packing instance converts unit weights to integer weights ($"One" arrow.r ZZ$) and integer weights to exactly represented floating weights ($ZZ arrow.r RR$). The set family and universe are preserved.
16875
-
][
16876
-
_Construction._ Given $"MSP"(cal(S), bold(w))$, construct $"MSP"(cal(S), bold(w)')$ using:
16877
-
- _One $arrow.r$ i64:_ each unit weight maps to $1_ZZ$.
16878
-
- _i64 $arrow.r$ f64:_ each integer weight maps through `i64_to_exact_f64`.
16879
-
16880
-
_Correctness._ The packing constraint (no two selected sets share a universe element) depends only on set membership, not on weights. The objective $max sum_(i in P) w_i$ is preserved under the type embedding. Optimality is unchanged.
16881
-
16882
-
_Solution extraction._ Return the target configuration unchanged.
16883
-
]
16884
-
16885
-
16886
-
#reduction-rule("QUBO", "QUBO")[
16887
-
An integer QUBO converts to the floating-coefficient variant by embedding every matrix coefficient with `i64_to_exact_f64`.
16888
-
][
16889
-
_Construction._ Given $Q in ZZ^(n times n)$, construct $Q' in RR^(n times n)$ with $Q'_(i j) = "f64"(Q_(i j))$ for every exactly representable coefficient $|Q_(i j)| lt.eq 2^53 - 1$.
16890
-
16891
-
_Correctness._ For every binary vector $bold(x)$, exact coefficient conversion gives $bold(x)^top Q' bold(x) = bold(x)^top Q bold(x)$. The objective ordering and minimizers are preserved.
16892
-
16893
-
_Solution extraction._ Return the binary vector unchanged.
16894
-
]
16895
16862
16896
16863
// Completeness check: warn about reduction rules in JSON but missing from paper
16897
16864
#context {
16898
16865
let covered = covered-rules.final()
16899
16866
let json-edges = {
16900
-
let edges = graph-data.edges.map(e => (graph-data.nodes.at(e.source).name, graph-data.nodes.at(e.target).name))
16867
+
let is-numeric-cast(src, tgt) = {
16868
+
src.name == tgt.name and ("weight", "coefficient").any(field => {
16869
+
let from = src.variant.at(field, default: none)
16870
+
let to = tgt.variant.at(field, default: none)
16871
+
let promotion = (from == "One" and to == "i64") or (from == "i64" and to == "f64")
16872
+
let promoted = src.variant
16873
+
promoted.insert(field, to)
16874
+
promotion and promoted == tgt.variant
16875
+
})
16876
+
}
16877
+
let source = (name: "MaximumIndependentSet", variant: (graph: "SimpleGraph", weight: "One"))
if unique.find(u => u.at(0) == e.at(0) and u.at(1) == e.at(1)) == none {
@@ -17149,13 +17131,13 @@ The following table shows concrete target-variable counts for example instances,
17149
17131
// === Non-ILP reduction rules ===
17150
17132
17151
17133
#reduction-rule("ILP", "ILP")[
17152
-
ILP variants convert between binary and bounded integer variable domains and between exact-integer and floating-point coefficients. The independent bounds dimension defaults to general; the bounded integer variant requires finite lower and upper endpoints for every variable. Binary variables embed into bounded integer ILP, which embeds into general integer ILP while retaining all stored bounds. A bounded integer variable is encoded by binary variables with truncated positional weights. Integer coefficients are embedded only when every stored coefficient and right-hand side has an exact `f64` representation.
17134
+
ILP variants convert between binary and bounded integer variable domains. The independent bounds dimension defaults to general; the bounded integer variant requires finite lower and upper endpoints for every variable. Binary variables embed into bounded integer ILP, which embeds into general integer ILP while retaining all stored bounds. A bounded integer variable is encoded by binary variables with truncated positional weights.
17153
17135
][
17154
-
_Construction._ For the binary-to-bounded-integer and bounded-to-general edges, copy the variables, constraints, objective, and optimization direction unchanged. For an integer variable $x_i in [L_i, U_i]$, let $D_i = U_i - L_i$ and choose positive truncated binary weights $w_(i j)$ whose subset sums represent every integer from $0$ through $D_i$; substitute $x_i = L_i + sum_j w_(i j)y_(i j)$ into every constraint and objective term. This edge is registered only for the bounded integer variant; its constructor requires two finite bounds for every variable. For the coefficient edge, copy the variable bounds and optimization direction and convert each entry of the constraint matrix, right-hand side, and objective independently; reject the instance if any integer lies outside the exactly representable `f64` integer range.
17136
+
_Construction._ For the binary-to-bounded-integer and bounded-to-general edges, copy the variables, constraints, objective, and optimization direction unchanged. For an integer variable $x_i in [L_i, U_i]$, let $D_i = U_i - L_i$ and choose positive truncated binary weights $w_(i j)$ whose subset sums represent every integer from $0$ through $D_i$; substitute $x_i = L_i + sum_j w_(i j)y_(i j)$ into every constraint and objective term. This edge is registered only for the bounded integer variant; its constructor requires two finite bounds for every variable.
17155
17137
17156
-
_Correctness._ The binary-to-bounded-integer and bounded-to-general embeddings change no mathematical expression. For bounded integer variables, every $x_i in [L_i,U_i]$ has a truncated binary representation, and every binary assignment decodes inside that interval; substitution preserves all constraints and changes the stored objective only by the constant lower-bound contribution, so optimal assignments are preserved. Exact conversion preserves every stored coefficient, so it constructs the same formal linear objective and constraints over the same integer variables.
17138
+
_Correctness._ The binary-to-bounded-integer and bounded-to-general embeddings change no mathematical expression. For bounded integer variables, every $x_i in [L_i,U_i]$ has a truncated binary representation, and every binary assignment decodes inside that interval; substitution preserves all constraints and changes the stored objective only by the constant lower-bound contribution, so optimal assignments are preserved.
17157
17139
17158
-
_Solution extraction._ Binary-to-bounded-integer, bounded-to-general, and coefficient conversions preserve the assignment; coefficient conversion additionally checks the assignment against the source integer ILP. Binary encoding returns $x_i = L_i + sum_j w_(i j)y_(i j)$.
17140
+
_Solution extraction._ Binary-to-bounded-integer and bounded-to-generalconversions preserve the assignment. Binary encoding returns $x_i = L_i + sum_j w_(i j)y_(i j)$.
0 commit comments