Commit a63252f
## Summary
Continues the Idris2 F1.4 substitution-lemma port (#108). Builds on the
foundation merged in #113 (append algebra + shape invariant) by landing
the **`has_var` weakening lemma `hvShift`** — the lynchpin of the shift
layer (4b).
Two Idris-specific techniques here unblock the rest of the port (the Coq
proof gets both "for free" via `Prop` erasure + `inversion`):
1. **Structural shift index `shiftIdx`** (not `if n < c`): `shiftIdx Z n
= S n`, `shiftIdx (S c) Z = Z`, `shiftIdx (S c)(S n) = S (shiftIdx c
n)`. Every index step is now **definitional** — no fighting Idris's
lazy-`if` / `Ord`-unfolding inside `rewrite` (which was mangling `LT`
into metavariables). The bridge to the kernel `shift` (which uses `if`)
is `shiftIdxCorrect`, proven **once** (the only place the `if`-reasoning
is needed).
2. **`HasVar` inversion lemma `varInv`** → `VarInvR` with
**propositional** equalities + **erased** witnesses. Idris can't
pattern-match `HVHere` when the usage is a stuck term (`uappend dg di`):
its index `USnoc (uzero g) One` won't unify. The lemma returns the
constructor disjunction as equations the caller consumes without
matching. `hvShift` then cases `n` (Z/S) to recover a relevant index and
recurses on `i`, reconstructing the `HVHere` context via
`uappendInj`/`uzeroTappend`.
## Verification (Idris2 0.7.0)
```
idris2 --build solo-core.ipkg # 8/8, exit 0
```
- Only hole remains `?todo_preservation`; no
`believe_me`/`assert_total`/`postulate`.
## Remaining (this branch, toward closing #108)
`htShift` (15-case term weakening; uses `hvShift` for `Var`, `shiftIdx`
under binders) → `htShift0`/`weakeningAppend` → substitution core
(`hvSubst`/`htSubst`) → `substLemma0`/`subst2Lemma` → `preservation`.
The index friction (the worst part) is now solved by `shiftIdx`; the
rest is mechanical-but-long, each inversion at a known term constructor
matching directly (the usage is a free field on `THApp`/`THLam`/… so no
inversion lemma needed there).
## Test plan
- [x] `idris2 --build solo-core.ipkg` exits 0;
`hvShift`/`shiftIdxCorrect`/`varInv` verified
- [ ] `htShift` and onward
- [ ] `?todo_preservation` discharged (closes #108)
Refs #108
https://claude.ai/code/session_01BwV2DWsjkBiNP3oscimMLV
---
_Generated by [Claude
Code](https://claude.ai/code/session_01BwV2DWsjkBiNP3oscimMLV)_
---------
Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
1 parent c5e0cbf commit a63252f
1 file changed
Lines changed: 90 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
0 commit comments