git-subtree-dir: common-lean git-subtree-mainline:bd2e14214dgit-subtree-split:a0b719e170
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
|