Commit 2c29af4
authored
feat(formal): discharge optimize_is_permutation — axiom to theorem, in both modules (#206)
feat(formal): discharge optimize_is_permutation — axiom to theorem, in
both modules
`optimize_is_permutation` was an `Axiom` in `formal/Planner.v` and,
separately,
a second identical `Axiom` in `formal/PlannerSemantic.v`. Both are now
gone.
**It was not merely unproven — it was unprovable.** `optimize` was a
`Parameter`, so nothing constrained it: `fun _ => []` inhabits the
parameter and
refutes `forall lp, Permutation lp (optimize lp)`. Assuming the
statement was
assuming the conclusion, and no amount of proof effort against that
signature
would have worked. Discharging it *requires* replacing the parameter
with a
definition, which is what this does:
* `modality` becomes an `Inductive` with the six constructors of
`crate::Modality`, and `execution_priority` transcribes the Rust match
arms
(Temporal 10, Vector 20, Document 30, Graph 40, Tensor 50, Semantic 90).
* `optimize` becomes `Coq.Sorting.Mergesort`'s `sort` under `node_leb` —
execution priority first, cost as tie-breaker, i.e. the key
`Optimizer::optimize`'s `sort_by` comparator actually uses.
* The permutation property falls out of the standard library's
`Permuted_sort`,
which is itself closed under the global context.
All five call sites were left untouched and still compile: the theorem
statement is character-for-character what the axiom asserted.
`PlannerSemantic.v` claimed in a comment to be "reusing Planner.v
abstractions"
while in fact re-declaring its own `modality`, `condition`, `node`,
`optimize`
and a duplicate axiom. The two files agreed only by coincidence, and the
duplicate meant discharging Planner's axiom would have left an identical
assumption standing next door. It now genuinely `Require Import
Planner`, and
`formal/Justfile` gains the `planner-semantic: planner` dependency edge
that
this makes necessary.
**Whitelists tightened — this is the acceptance test, not bookkeeping.**
The
guards enforce "exactly these assumptions", never "no assumptions", so
leaving
`optimize_is_permutation` listed would have let it return silently:
* Planner: `modality|condition|optimize|optimize_is_permutation` ->
`condition|node_cost`
* PlannerSemantic: drops `modality`, `optimize`,
`optimize_is_permutation`
Both `formal/Justfile` and `.github/workflows/coq-build.yml` updated
together.
Two `Parameter`s remain **by design**, and being parametric in them
makes the
result stronger, not weaker — it holds for *any* condition
representation and
*any* cost function: `condition` (the Rust `ConditionKind`'s nine
constructors
are irrelevant to whether nodes are reordered or lost) and `node_cost`
(abstracts `CostModel::estimate`'s `time_ms`).
Two honest model-vs-code gaps, both recorded in the module header rather
than
elided, neither affecting the permutation property:
* `node_cost` returns `nat`; the Rust tie-breaker is `f64` compared with
`partial_cmp(...).unwrap_or(Equal)`. A NaN would make that comparator
non-transitive and violate `sort_by`'s contract. NaN is unreachable
today —
the only division in `CostModel::estimate` is guarded and feeds
`selectivity`,
not `time_ms` — but nothing in the Rust types enforces that.
* Rust `optimize` is partial (`PlannerError::EmptyPlan`); `sort []` is
`[]`.
`exec_node_comm` deliberately stays. It is a genuine spec axiom over an
uninterpreted `exec_node` and needs per-operator semantics to discharge
— not
something this change touches, and it should not look like collateral.
Verified:
* Clean build: `just -f formal/Justfile all` and `check-assumptions`
both exit 0,
9/9 OK, with the tightened whitelists.
* `optimize_is_permutation` appears zero times in either module's
`Print Assumptions` output, and no `Axiom optimize_is_permutation`
remains
anywhere (was 2).
* **Negative control** — reintroducing an axiom a theorem depends on is
caught:
`ERROR(Planner): unexpected axiom: sneaky_regression`, gate exit 1. The
tightened whitelist genuinely fails rather than passing vacuously.
* Stub `coqc` still drives the gate to exit 127, so #202's fix is
intact.
* `reuse lint` compliant.1 parent 27dfa66 commit 2c29af4
4 files changed
Lines changed: 156 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
158 | 166 | | |
159 | 167 | | |
160 | | - | |
| 168 | + | |
161 | 169 | | |
162 | 170 | | |
163 | 171 | | |
164 | 172 | | |
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
168 | | - | |
| 176 | + | |
169 | 177 | | |
170 | 178 | | |
171 | 179 | | |
| |||
219 | 227 | | |
220 | 228 | | |
221 | 229 | | |
222 | | - | |
| 230 | + | |
223 | 231 | | |
224 | 232 | | |
225 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
| 84 | + | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
29 | 65 | | |
30 | 66 | | |
31 | 67 | | |
32 | 68 | | |
33 | 69 | | |
34 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
35 | 75 | | |
36 | 76 | | |
37 | 77 | | |
| |||
42 | 82 | | |
43 | 83 | | |
44 | 84 | | |
45 | | - | |
46 | | - | |
47 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
48 | 117 | | |
49 | 118 | | |
50 | 119 | | |
| |||
60 | 129 | | |
61 | 130 | | |
62 | 131 | | |
63 | | - | |
| 132 | + | |
64 | 133 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
68 | 137 | | |
69 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
70 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
71 | 179 | | |
72 | 180 | | |
73 | 181 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
62 | 73 | | |
63 | | - | |
64 | | - | |
65 | 74 | | |
66 | 75 | | |
67 | | - | |
68 | | - | |
| 76 | + | |
69 | 77 | | |
70 | 78 | | |
71 | 79 | | |
| |||
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
96 | | - | |
97 | | - | |
98 | | - | |
| 104 | + | |
99 | 105 | | |
100 | | - | |
101 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
102 | 110 | | |
103 | 111 | | |
104 | 112 | | |
| |||
0 commit comments