Structured RAM syntax examples #
Scale an array in place and accumulate its new elements. Word arithmetic wraps as usual; an exact-integer specification additionally needs range proofs.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Ram.DSL.Examples.scaleAndSum_expands :
scaleAndSum = { params := 3, locals := 5,
body :=
(Stmt.assign 3 (Expr.const 0)).seq
((Stmt.assign 4 (Expr.const 0)).seq
(Stmt.while (Expr.bin BinOp.ult (Expr.var 3) (Expr.var 1))
((Stmt.store (Expr.bin BinOp.add (Expr.var 0) (Expr.var 3))
(Expr.bin BinOp.mul (Expr.bin BinOp.add (Expr.var 0) (Expr.var 3)).load (Expr.var 2))).seq
((Stmt.assign 4 (Expr.bin BinOp.add (Expr.var 4) (Expr.bin BinOp.add (Expr.var 0) (Expr.var 3)).load)).seq
(Stmt.assign 3 (Expr.bin BinOp.add (Expr.var 3) (Expr.const 1))))))),
results := [Expr.var 4] }
A static function-table name. Putting euclid at index zero makes the
call below recursive; the syntax does not inline it or assume it terminates.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Direct statement syntax also accepts caller-provided Lean register names.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
Ram.DSL.Examples.readStoreWrite_expands
(base value : Reg)
:
readStoreWrite base value = (Stmt.read value).seq
((Stmt.store (Expr.bin BinOp.add (Expr.var base) (Expr.const 2)) (Expr.var value)).seq
(Stmt.write (Expr.bin BinOp.add (Expr.var base) (Expr.const 2)).load))
A local may share a spelling with a host constant or legacy function label. Only variable positions use its register number.
Equations
Instances For
Equations
- Ram.DSL.Examples.separateScopes = { params := 1, locals := 2, body := Ram.Stmt.call [1] Ram.DSL.Examples.outerTarget [Ram.Expr.var 0], results := [Ram.Expr.const Ram.DSL.Examples.outerTarget] }