crosslang/OctiveLean
Maximus Gorog d86d500b4f Prove preservation theorem for TOC big-step semantics.
OctiveLean/Core/Preservation.lean — the TOC analogue of TGC's
preservation. Statement:

  HasType Γ e T  ∧  HasTypeEnv env Γ  ∧  BigStep env e v env'
    ⟹  HasTypeV v T  ∧  HasTypeEnv env' Γ

No heap-typing extension (Octave has no heap). Γ is unchanged across
big-steps (assign requires x already typed).

Three structural changes were required to make preservation provable
under env-mutation, all small:

  * letIn semantics shifted to scope-restoring: BigStep.letInR now
    returns env1 (the env after evaluating the bound expression)
    rather than env2 (after the body). This drops body's mutations
    at scope-end, matching the lambda-calculus tradition. Determinism
    and Eval updated to match.

  * HasTypeV.vClos uses a two-part premise (he_dom + he_typed)
    instead of nested ∃ — the kernel rejects nested inductive
    parameters with locally-bound vars. The two parts are equivalent
    to HasTypeEnv via the new HasTypeV.vClos_to_env inversion lemma.

  * Inversion via HasTypeV.vClos_to_env exposes the closure's typing
    context as an existential — preservation's appR case uses this
    to construct the body's HasTypeEnv via extend_letIn.

The cross-language symmetry that emerged:

  TGC preservation  : threads heap-typings, weakens via extension.
  TOC preservation  : threads env directly, no extension needed.

In both, the rule cases collapse into the same three structural
shapes — terminal, IH-chain, contradiction-collapse. The case bodies
differ in HOW state is propagated (heap-typing for TGC, env for TOC)
but the SHAPE of each case is identical. That's the cross-language
abstraction speaking.

Zero sorries / axioms / admits across both projects.
2026-05-10 04:32:52 -06:00
..
Core Prove preservation theorem for TOC big-step semantics. 2026-05-10 04:32:52 -06:00
AST.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Basic.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
BigStep.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Builtins.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Corpus.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
DSL.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Env.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Error.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Eval.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Lexer.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Parser.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
PlotBuiltins.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
PlotData.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
PlotSVG.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
PlotWidget.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
PureEval.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
REPL.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Value.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
ValueEquiv.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00