Commit baf5db7
committed
feat(abi): close TacticRecord round-trip lemmas (closes #152)
Discharges the two round-trip lemmas deferred at lines 88-93 and
187-196 of `src/abi/EchidnaABI/TacticRecord.idr`:
natToFinToNat : Nat → 0 LT n (S MaxConfidence) →
finToNat (natToFinLT n) = n
clampRoundtripInRange: Nat → LT n (S MaxConfidence) →
finToNat (clampConfidence n) = n
Approach — what the original deferral comment got nearly right:
The note "requires careful LTE-weakening that has not yet been spelled
out structurally" identified a real symptom but mis-located the cause.
The trap is a unification artefact, not a missing weakening lemma:
specialising the round-trip at `S MaxConfidence` forces the recursive
call to discharge `LTE (S k) (S MaxConfidence)` while the LTESucc
pattern only hands you `LTE (S k) MaxConfidence` — the same proposition
off-by-one. Explicit weakening with `lteSuccRight` works but is
inelegant.
Cleaner shape: introduce a polymorphic helper
finToNatNatToFinLT :
(n : Nat) -> {m : Nat} -> (0 prf : LT n m) ->
finToNat (natToFinLT n {prf}) = n
with `m` implicit so the recursive call's `m` is structurally inferred
to the predecessor — the LTESucc constraint then matches exactly,
no glue. The `S MaxConfidence` instance specialises in one line.
`clampRoundtripInRange` closes by `with`-abstracting on the same
`isLT n (S MaxConfidence)` that `clampConfidence` inspects: the Yes
branch reduces and discharges via `natToFinToNat`, the No branch is
contradicted by the in-range hypothesis via `absurd`.
Verification:
- Module type-checks clean on Idris2 0.8.0
`idris2 --check EchidnaABI/TacticRecord.idr` → 1/1: Building OK
- All three new lemmas confirmed total via `:total` REPL
- Constraint preserved: zero believe_me, zero postulates, zero admits,
zero assert_total. Only standard-library inhabitants used.
Refs the deferred proof debt called out in commit 4118893 (the
introducing change for TacticRecord.idr).1 parent 78a65dc commit baf5db7
1 file changed
Lines changed: 44 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 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 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
94 | 120 | | |
95 | 121 | | |
96 | 122 | | |
| |||
188 | 214 | | |
189 | 215 | | |
190 | 216 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
0 commit comments