crosslang/golang-lean/GolangLean/Core/Syntax.lean
Maximus Gorog fd3d42ae33 Add 'golang-lean/' from commit 'f5f17019224c6a6c319387214ceb8e29d09251c6'
git-subtree-dir: golang-lean
git-subtree-mainline: 6487c7046f
git-subtree-split: f5f1701922
2026-05-12 02:59:14 -06:00

36 lines
1.3 KiB
Text

namespace GolangLean.Core
/-! # Tiny Go Core (TGC) — abstract syntax.
A small calculus that captures the *essential computation* of Go's
sequential fragment: variables, functions, mutable references (Go's `&`/`*`),
sequencing, and conditionals. Everything in surface Go is intended to
desugar into this kernel.
What is *not* here: types (introduced in a later module), goroutines,
channels, structs, slices, methods, interfaces. The point of starting tiny
is that every theorem we prove about TGC carries over once those
extensions are added compositionally. -/
inductive BinOp where
| add | sub | mul
| eq | lt
deriving Repr, BEq, DecidableEq, Inhabited
inductive Term where
| unitT : Term
| intLit : Int → Term
| boolLit : Bool → Term
| var : String → Term
| lam : String → Term → Term -- λ x. e
| app : Term → Term → Term
| letIn : String → Term → Term → Term -- let x = e₁ in e₂
| ifte : Term → Term → Term → Term
| binop : BinOp → Term → Term → Term
| refMk : Term → Term -- &e (allocate)
| deref : Term → Term -- *e (read)
| assign : Term → Term → Term -- *p = e
| seq : Term → Term → Term
deriving Repr, Inhabited
end GolangLean.Core