git-subtree-dir: golang-lean git-subtree-mainline:6487c7046fgit-subtree-split:f5f1701922
36 lines
1.3 KiB
Text
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
|