Commit 86f6e1b
authored
proof(L2): complete L2-modality migration of L1 preservation (Stage A); soundness fix to follow (#294)
## Summary
Completes the **L2-modality migration** of the L1 preservation
development so the Coq formalisation compiles again, and replaces a
**malformed scaffolding rule** discovered en route. This is **Stage A**
of the soundness work; the calculus-level soundness fix (App/Pair gaps +
the false `region_liveness_at_split_l1` axiom) is **Stage B**,
intentionally separated for review (see *Next* below).
## Background
Commit `4e87a05` (`proof/l2-modality`) added the `modality` index to
`has_type_l1` and split `Lam`/`Case`/`If` into `_Linear`/`_Affine`
variants in `TypingL1.v` — but never migrated `Semantics_L1.v` (the
1515-line preservation development) or `Counterexample.v`. The whole
`formal/` build was broken on that branch.
## Changes
**`TypingL1.v` — replace the malformed `T_Forget_Affine_L1`:**
- The committed `T_Forget_Affine_L1` prepended an extra binding to the
output context, **provably falsifying** `typing_preserves_length_l1` and
`value_R_G_preserving_l1` (e.g. `EUnit` typed with output context one
longer than input).
- Replaced with proper per-binder mode splits —
`T_Let_L1_{Linear,Affine}`, `T_LetLin_L1_{Linear,Affine}` — mirroring
the existing `Lam`/`Case` treatment. Affine variants relax the bound-var
output flag to any `u` (the affine implicit-drop), modelled at the
binder so every rule stays length-preserving.
**`Semantics_L1.v` — modality + mode-split migration:**
- Every lemma quantified over explicit `m` (a `Section` variable fails:
`induction Htype` generalises the index, severing cross-references).
- Structural lemmas made case-count-robust; `m`/mode-split threaded
through region-shrink, shift, substitution, and the 33-case preservation
dispatch (`econstructor` auto-selects the mode variant in
congruence-step cases).
- 4 **new** affine-β subcases (`Let`/`LetLin`-Val, `Case`-Inl/Inr) are
admitted with documentation — they need a generalised affine
substitution lemma (bound var may be left unused). These are **L2/affine
follow-up**, distinct from the pre-existing linear soundness gaps.
**`Counterexample.v`:** `bad_input_untypable_l1` /
`t_loc_l1_R_preserving` now quantify over `m` — the bad input is
untypable in **every** modality.
## Verification
- Full development builds clean from scratch: `coqc 8.18`, all 6 modules
(`Syntax Typing TypingL1 Semantics Semantics_L1 Counterexample`), `make
-f build.mk clean && make -f build.mk` → exit 0.
- Legacy `Semantics.v` untouched (its provably-false preservation stays
as-is, per directive).
- No previously-closed case regressed.
## Next (Stage B — needs a design call)
The **linear** soundness gaps remain pre-existing admits/axiom:
- `region_liveness_at_split_l1` is currently a **false `Axiom`**
(general `In rv R → In rv R'`, refuted by `ERegion rv …`) — an
inconsistency that must be removed.
- `S_App_Step2` / `S_Pair_Step2` admits (§4.8 lambda-rigidity + variable
over-permissiveness).
Probing the Option 3 fix (strengthen `T_Var_*_L1` with `incl
(free_regions T) R`) shows it ripples into
`region_shrink_preserves_typing_l1_gen` (type-region variables) and
likely needs pairing with an `T_Lam` restriction to close `S_App_Step2`.
Holding for direction before mechanising.
🤖 Generated with [Claude Code](https://claude.com/claude-code)306 files changed
Lines changed: 1136 additions & 3810 deletions
File tree
- .machine_readable
- bot_directives
- svc/k9
- LICENSES
- audits
- conformance
- invalid
- valid
- contractiles
- intend
- must
- trust
- docs
- accessibility
- coq-rust-bridge
- governance
- reports/audit
- sessions
- specs
- vision
- wikis
- editors/tree-sitter-ephapax
- queries
- ephapax-linear
- grammar
- src
- examples
- advanced
- affine
- concurrency
- error_handling
- ffi
- linear
- modules
- pattern_matching
- patterns
- region
- formal
- idris2/src
- Ephapax
- Affine
- IR
- Parse
- lib
- scripts
- spec
- src
- abi
- Ephapax/ABI
- ephapax-analysis
- src
- ephapax-cli
- src
- tests
- ephapax-desugar
- src
- ephapax-interp
- src
- ephapax-ir
- src
- ephapax-lexer
- src
- ephapax-lsp/src
- ephapax-package
- src
- ephapax-parser
- benches
- src
- ephapax-repl
- src
- ephapax-runtime
- src
- ephapax-stdlib
- src
- ephapax-surface
- src
- ephapax-syntax
- src
- ephapax-tools
- src
- ephapax-typing
- src
- ephapax-vram-cache
- benches
- src
- ephapax-wasm
- src
- formal
- Ephapax/Formal
- stdlib
- tests
- fuzz/src
- parse_fuzzer
- typecheck_fuzzer
- v2-grammar/fixtures
- hypatia-port
- multi-module
- lib
- tools
- ephapax-dap
- src
- ephapax-doc
- ephapax-lsp
- src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| 130 | + | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
0 commit comments