A new Lake project with path dependencies on the three sibling kernels
(golang-lean, octive-lean, tsm-lean). Provides typeclass abstractions
that capture what's structurally shared.
Common/ — three files:
Lang.lean — two typeclasses:
BigStepLang: Term, Value, State, Eval, deterministic.
Captures TGC's and TOC's big-step shape.
SmallStepLang: State, step.
Captures TSM's small-step shape (determinism is
automatic from `step` being a function).
Generic theorems exported once:
BigStepLang.unique_value, BigStepLang.unique_state
SmallStepLang.step_deterministic
Plus a `CompileCorrect` structure for substrate-projection
theorems (the categorical kernel of CompCert-style results).
Instances.lean — three instances:
TGCLang : BigStepLang (State := Heap × Env)
TOCLang : BigStepLang (State := Env)
TSMLang : SmallStepLang (State := TSM.State)
Each instance bridges the local kernel's existing
`BigStep`/`step` + `deterministic` proof into the typeclass.
Demo.lean — three application examples:
The SAME `BigStepLang.unique_value` theorem applied to TGC and
TOC; `SmallStepLang.step_deterministic` to TSM. One abstract
definition, three concrete payoffs.
The factoring is real: any new theorem stated over the typeclasses
applies to all instances. Future theorems (compilation correctness,
type soundness, simulation) can be expressed abstractly and proved
once.
Zero sorries / axioms / admits across all four projects.
46 lines
1.6 KiB
Text
46 lines
1.6 KiB
Text
import Common.Lang
|
||
import GolangLean.Core.Determinism
|
||
import OctiveLean.Core.Determinism
|
||
import TsmLean.Core.Determinism
|
||
|
||
namespace Common
|
||
|
||
/-! # Instances — TGC, TOC, TSM as `Common` languages.
|
||
|
||
Each kernel's existing types, semantics, and determinism theorem
|
||
package as a typeclass instance. The shared abstractions in
|
||
`Common.Lang` then apply uniformly. -/
|
||
|
||
/-! ## TGC (golang-lean) — big-step over `Heap × Env`. -/
|
||
|
||
instance TGCLang : BigStepLang where
|
||
Term := GolangLean.Core.Term
|
||
Value := GolangLean.Core.Value
|
||
State := GolangLean.Core.Heap × GolangLean.Core.Env
|
||
Eval := fun (he : GolangLean.Core.Heap × GolangLean.Core.Env)
|
||
(t : GolangLean.Core.Term)
|
||
(v : GolangLean.Core.Value)
|
||
(he' : GolangLean.Core.Heap × GolangLean.Core.Env) =>
|
||
GolangLean.Core.BigStep he.1 he.2 t v he'.1 ∧ he.2 = he'.2
|
||
deterministic := by
|
||
rintro ⟨h, env⟩ t v₁ v₂ ⟨h₁, env₁⟩ ⟨h₂, env₂⟩ ⟨D₁, henv₁⟩ ⟨D₂, henv₂⟩
|
||
have ⟨hv, hh⟩ := GolangLean.Core.BigStep.deterministic D₁ D₂
|
||
subst henv₁; subst henv₂; subst hh
|
||
exact ⟨hv, rfl⟩
|
||
|
||
/-! ## TOC (octive-lean) — big-step over `Env`. -/
|
||
|
||
instance TOCLang : BigStepLang where
|
||
Term := OctiveLean.Core.Term
|
||
Value := OctiveLean.Core.Value
|
||
State := OctiveLean.Core.Env
|
||
Eval := OctiveLean.Core.BigStep
|
||
deterministic := fun D₁ D₂ => OctiveLean.Core.BigStep.deterministic D₁ D₂
|
||
|
||
/-! ## TSM (tsm-lean) — small-step over `State`. -/
|
||
|
||
instance TSMLang : SmallStepLang where
|
||
State := TsmLean.Core.State
|
||
step := TsmLean.Core.step
|
||
|
||
end Common
|