import TsmLean.Core.Syntax namespace TsmLean.Compile.Source /-! # Source language for compilation (v0.4). Integer/bool literals + arithmetic. The compile function takes an offset (infrastructure for future control-flow constructs that require absolute jump addresses). For the constructs in v0.4, the offset doesn't change the compile output — it's just threaded. -/ inductive Expr where | intLit : Int → Expr | boolLit : Bool → Expr | add : Expr → Expr → Expr | sub : Expr → Expr → Expr | mul : Expr → Expr → Expr deriving Repr, Inhabited abbrev Value := TsmLean.Core.Value inductive Eval : Expr → Value → Prop where | intLit (n : Int) : Eval (.intLit n) (.vInt n) | boolLit (b : Bool) : Eval (.boolLit b) (.vBool b) | add {e1 e2 a b} (h1 : Eval e1 (.vInt a)) (h2 : Eval e2 (.vInt b)) : Eval (.add e1 e2) (.vInt (a + b)) | sub {e1 e2 a b} (h1 : Eval e1 (.vInt a)) (h2 : Eval e2 (.vInt b)) : Eval (.sub e1 e2) (.vInt (a - b)) | mul {e1 e2 a b} (h1 : Eval e1 (.vInt a)) (h2 : Eval e2 (.vInt b)) : Eval (.mul e1 e2) (.vInt (a * b)) end TsmLean.Compile.Source