Monorepo: golang-lean (TGC) + octive-lean (TOC) + tsm-lean (TSM) + common-lean (cross-language apex).
OctiveLean/Core/ — the kernel-level formal layer that octive-lean's
existing surface BigStep didn't have. Six files:
Syntax.lean — Term, BinOp. Twelve constructors: ten shared
with TGC plus assign (var mutation in env) and
whileT (loop). No refs (Octave has no &/*).
Semantics.lean — Value, EnvList, BigStep. Signature
`BigStep : Env -> Term -> Value -> Env -> Prop`
threading env (vs TGC's `Heap x Env`).
Determinism.lean — BigStep.deterministic. Same case shapes as TGC
for the shared ten constructors. The whileFR/whileTR
cross-case mirrors TGC's ifTR/ifFR via Bool.noConfusion.
Eval.lean — fuel-bounded eval + eval_sound. whileT recursion
consumes one fuel unit per iteration. Function
calls discard the body's post-env (Octave/MATLAB
local-scope semantics).
Types.lean — Ty (no ref), TyEnv, HasType. Twelve typing rules
mirroring the constructors.
TypeSoundness.lean — HasTypeV inductive, function-form HasTypeEnv.
vClos uses two-part formulation (he_dom + he_typed)
instead of nested existential — Lean's kernel rejects
the natural ∃-form due to nested-inductive parameter
restrictions. extend_typed (assign preservation) and
extend_letIn (letIn preservation) lemmas.
Cross-language symmetry surfaced this iteration:
* Determinism proof: ten cases mirror TGC line-for-line. Two new
cases (assign, while) follow the same three structural shapes.
* Eval signature: state type differs (Env vs Heap×Env), constructors'
eval recurrences are otherwise isomorphic.
* Type system: Ty diverges (no ref vs no whileT/assign), but the
typing-rule shapes are identical — variables, let, app, if, binop, seq.
* Typing of runtime data is where the languages most diverge:
TGC's structural HasTypeEnv works because env is scoped; TOC needs
function-form because env mutates. This is the *real* asymmetry that
a cross-language layer would have to abstract over.
Preservation deferred — has a soundness gap with letIn-shadowing-then-
assign that needs a freshness premise on letIn typing. To follow.
Zero sorries / axioms / admits. Full lake build clean (73 jobs).
|
||
|---|---|---|
| .github/workflows | ||
| corpus | ||
| OctiveLean | ||
| widget/js | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| CONTRIBUTING.md | ||
| CorpusCheck.lean | ||
| justfile | ||
| lake-manifest.json | ||
| lakefile.toml | ||
| lean-toolchain | ||
| Main.lean | ||
| NumericalTutorial.lean | ||
| OctiveLean.lean | ||
| PlotDemo.lean | ||
| README.md | ||
| RosettaStone.lean | ||
| tutorial.m | ||
octive-lean
A Lean 4 reimplementation of GNU Octave — the MATLAB-compatible numerical language — aiming to be more versatile than upstream.
Build
lake build
Requires the Lean toolchain pinned in lean-toolchain. elan will pick it up automatically.
Run
# REPL
lake exe octive-lean
# Run an .m script
lake exe octive-lean path/to/script.m
# Verify the corpus against expected outputs
lake build corpus-check
lake exe corpus-check
Layout
| Path | What's there |
|---|---|
OctiveLean/ |
Library: Lexer, Parser, AST, Eval, Builtins, REPL, BigStep, PlotSVG, … |
Main.lean |
Entry point — REPL or file runner |
CorpusCheck.lean |
Test driver for corpus/ |
corpus/ |
.m test cases paired with .expected outputs |
NumericalTutorial.lean, RosettaStone.lean |
Lean-side tutorials and Octave⇄Lean translations |
PlotDemo.lean, widget/ |
Plotting via ProofWidgets + SVG |
octave-upstream/ |
Shallow clone of GNU Octave (gitignored, used as reference) |
Status
Working interpreter: matrices, arithmetic, control flow, functions (incl. recursion, closures, anonymous @(x)), cell arrays, structs, printf-family, REPL, file execution. See corpus/ for what's covered.
Tests
lake build && lake exe corpus-check
Pass --update to regenerate .expected files after intentional behavior changes.