Documentation

CslibFrontier.Computability.PointerMachine.Notation

Notation for structured pointer-machine programs #

pm[ s₁; s₂; … ] writes a structured program (Cslib.PointerMachine.Code) as a sequence of statements, one per data instruction, in the style of the pseudocode of [Tar79]. Registers and fields are named by identifiers, for instance local abbreviations of elements of Fin n. Pointer and data registers are different kinds of registers that may have the same type, so the assignment sign tells them apart: ← assigns a pointer and := assigns a datum.

The statements on pointers are:

The statements on data are:

The tests are r = r' and r ≠ r' on pointer registers, and p s₁ s₂ and ¬p s₁ s₂ for a predicate p of the model on data registers, given by name or as a term in parentheses. The control statements are:

The notation unfolds to the constructors of Code, so it adds nothing to the semantics. The machine jumps when a test holds, so a conditional on a negated test exchanges its alternatives, and a loop on a negated test is Code.loopUntil, the cheaper loop; while r ≠ nil do [ … ] costs one test and one jump per iteration.

It is scoped: open Cslib.PointerMachine enables it. Only the categories pmStmt and pmTest and the syntax abbreviation pmBlock are global, since Lean cannot scope them; without the open they have no rules. Its only new tokens are pm[ and the internal pm_stmt%, pm_block%, pm_branch% and pm_while%, so it reserves no identifiers: null and new remain ordinary names, except that a pointer register cannot be copied from one named null or new.

Main definitions #

Tactics #

References #

A statement of a structured pointer-machine program.

A test of a structured pointer-machine program.

A block of statements, separated by semicolons.

A structured pointer-machine program, written as a block of statements.

Internal: a nested block of statements, as a structured program.

Internal: a single statement, as a structured program.

Internal: a conditional on a test, with its alternatives as terms.

Internal: a loop on a test, with its body as a term.

Two pointer registers are equal.

A predicate of the model, given by name, holds of two data registers.

A predicate of the model, given as a term, holds of two data registers.

A predicate of the model, given by name, fails on two data registers.

A predicate of the model, given as a term, fails on two data registers.

An operation of the model on two data registers.

A conditional without second alternative.

A structured program given as a term.

pm_straight proves a goal ExecWithin c x ?y T for straight-line code c: a sequence of data instructions. It runs them in order, so that ?y becomes the state reached, in closed form as nested Op.effect, and proves by omega that their number is at most T. At a conditional, a loop or a program given by ⟪…⟫ it stops and leaves the execution of that part as a goal.