crosslang/common-lean/Common/Instances.lean
Maximus Gorog 4bf2dd38cd Add 'common-lean/' from commit 'a0b719e170f66a736093d0d1c51b9d5883471db2'
git-subtree-dir: common-lean
git-subtree-mainline: bd2e14214d
git-subtree-split: a0b719e170
2026-05-12 02:59:14 -06:00

46 lines
1.6 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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