Notation for structured word-RAM programs #
ram[ s₁; s₂; … ] writes a structured program (Cslib.WordRAM.Code) as a sequence of statements,
one per data instruction, in the style of word-RAM pseudocode. Registers are named by identifiers,
for instance local abbreviations of elements of Fin r. The statements are:
d ← #v: set registerdto the constantv;d ← s: copy registersinto registerd;d ← i + j, and likewise-,*,/,%,&&&,|||,^^^,<<<,>>>: a binary operation (Cslib.WordRAM.BinOp) on registersiandj;d ← *a,*a ← s: load from and store to the memory cell whose address is in registera;d ← width%: set registerdto the word size;if i = j then [ … ] else [ … ],if i < j then [ … ] else [ … ]: a conditional;while i = j do [ … ],while i < j do [ … ]: a loop;⟪c⟫: the structured programc, for instance a subroutine.
The notation unfolds to the constructors of Cslib.WordRAM.Code, so it adds nothing to the
semantics. The binary operations and width% are instructions of the standard basis
(Cslib.WordRAM.Op.bin, Cslib.WordRAM.Op.width); the other statements work over every basis.
It is scoped: open Cslib.WordRAM enables it. Its statement forms follow the word-RAM notation of
Algolean. Its only new tokens are ram[, width% and the
internal ram_stmt% and ram_block%, so it reserves no identifiers: ram and width remain
ordinary names.
Main definitions #
ram[ s₁; s₂; … ]: scoped notation for structured word-RAM programs (Cslib.WordRAM.Code).ram_eval: symbolic execution tactic forCslib.WordRAM.ExecWithinandCslib.WordRAM.Execgoals.
Tactics #
ram_eval,ram_eval n: symbolic execution. On a goalCslib.WordRAM.ExecWithin w c x y TorCslib.WordRAM.Exec w c x y T, it runs the interpreterCslib.WordRAM.Code.evaloncandxwithsimp, allowing each loopniterations (default0, for loop-free code), and closes the goal when the result isywithin (exactly, forExec)Tinstructions; withya metavariable, it determinesy. Which constants and results fit a word is decided for numerals and otherwise taken from the given simp lemmas, stated withCslib.WordRAM.Fits. Programs given by name are unfolded by passing their definitions among the simp lemmas, as inram_eval [myProgram, h].
References #
A statement of a structured word-RAM program.
Instances For
A block of statements, separated by semicolons.
Instances For
A structured word-RAM program, written as a block of statements.
Instances For
Internal: a nested block of statements, as a structured program.
Instances For
Internal: a single statement, as a structured program.
Instances For
Load from the memory cell whose address is in a register.
Instances For
Store to the memory cell whose address is in a register.
Instances For
A conditional on the equality of two registers.
Instances For
A conditional on the comparison of two registers.
Instances For
A loop while two registers are equal.
Instances For
A loop while one register is smaller than another.
Instances For
A structured program given as a term.
Instances For
Symbolically execute structured code on a goal ExecWithin w c x y T or Exec w c x y T,
allowing each loop the given number of iterations (default 0), and deciding with the given simp
lemmas which written numbers fit a word.