Monorepo: golang-lean (TGC) + octive-lean (TOC) + tsm-lean (TSM) + common-lean (cross-language apex).
Find a file
Maximus Gorog 567d3d1902 Add Tiny Octave Core (TOC) parallel to golang-lean's TGC.
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).
2026-05-10 04:26:12 -06:00
.github/workflows Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
corpus Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
OctiveLean Add Tiny Octave Core (TOC) parallel to golang-lean's TGC. 2026-05-10 04:26:12 -06:00
widget/js Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
.editorconfig Add README, CONTRIBUTING, editorconfig, gitattributes, justfile 2026-04-29 09:44:24 -06:00
.gitattributes Add README, CONTRIBUTING, editorconfig, gitattributes, justfile 2026-04-29 09:44:24 -06:00
.gitignore Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
CONTRIBUTING.md Add README, CONTRIBUTING, editorconfig, gitattributes, justfile 2026-04-29 09:44:24 -06:00
CorpusCheck.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
justfile Add README, CONTRIBUTING, editorconfig, gitattributes, justfile 2026-04-29 09:44:24 -06:00
lake-manifest.json Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
lakefile.toml Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
lean-toolchain Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
Main.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
NumericalTutorial.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
OctiveLean.lean Add Tiny Octave Core (TOC) parallel to golang-lean's TGC. 2026-05-10 04:26:12 -06:00
PlotDemo.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
README.md Add README, CONTRIBUTING, editorconfig, gitattributes, justfile 2026-04-29 09:44:24 -06:00
RosettaStone.lean Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00
tutorial.m Initial commit: Lean 4 reimplementation of GNU Octave 2026-04-29 09:40:46 -06:00

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.