Notation for structured word-RAM programs over the exact basis #
ram_exact[ s₁; s₂; … ] is ram[ s₁; s₂; … ] over the exact basis
Cslib.WordRAM.Basis.exact: it has the same statements, but a binary operation d ← i - j,
d ← i / j, … is the instruction Cslib.WordRAM.Op.exactBin, which faults where its exact value
is undefined (subtraction below zero, division and remainder by zero), and d ← width% is
Cslib.WordRAM.Op.exactWidth. The tactic ram_exact_eval is ram_eval for such programs.
The notation, with its expansions and the tactic, is scoped to Cslib.WordRAM, alongside the
wramStmt statement syntax of CslibFrontier/Computability/WordRAM/Notation.lean.
Main definitions #
ram_exact[ s₁; s₂; … ]: structured word-RAM programs over the exact basis.ram_exact_eval: symbolic execution of such programs.
Tactics #
ram_exact_eval,ram_exact_eval n: asram_eval. A subtraction runs when the simp lemmas show that its right operand is at most its left one, and a division or remainder when they show that its divisor is nonzero.
References #
The statements are those of the ram[ notation (WordRAM.Notation), whose forms follow the
word-RAM notation of Algolean.
A structured word-RAM program over the exact basis, written as a block of statements.
Internal: a nested block of statements, as a structured program over the exact basis.
Internal: a single statement, as a structured program over the exact basis.
Symbolically execute structured code over the exact basis 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 subtractions stay at or above zero and which divisors are
nonzero. Whether a written number fits a word is decided by omega from the Fits hypotheses
in context (Cslib.WordRAM.reduceFits), or by the given simp lemmas.
On failure the error names the step that failed, as for ram_eval: the goal has neither form, a
given simp lemma does not elaborate, simp cannot evaluate the program, the interpreter returns
none (a fault such as a subtraction below zero, or too few loop iterations), a branch or Fits
condition remains (shown), or omega cannot prove the instruction bound (shown).