Documentation

CslibFrontier.Tactic.Realize

The realize tactic #

The tactic is available inside Cslib.WordRAM, or after open Cslib.WordRAM or open scoped Cslib.WordRAM. Importing this module alone does not activate its syntax.

realize proves a goal Realizes B p input output safe work for a memory client p. It walks the client syntax, unfolding definitions, with one rule per form:

Operands are located among the live words by definitional equality. An operand that is not a live word is first computed by an inserted pure, preserving the program by a checked equality.

Exact subtraction, division and remainder add their definedness conditions to the visible domain. The common glue envelope is the maximum of every intermediate value; realize proves that it fits from the fit of the live words, from the domain, and from the fit of the values it cannot derive, which become the visible fit conditions. A value is derived when another fitting value dominates it, for example a - b and b by a, or the summands by a sum.

Fixed glue and finite control work is absorbed (Realizes.mono_mul). Called methods retain their work; binds sum it and branches select only the reached alternative's work. Loops retain iterationWork or whileWork, including one control unit per reached iteration. A zero-work body that begins with a query keeps the existing query-paid rule (iterate₀ or while₀). Intermediate domains and grades are stated in the client's own terms, with the replies of earlier queries written as s.mem a, s.frontier, updated memories, or the interpreter's result of a called method; a loop contributes its iterationSafe or whileSafe domain.

After composition, realize introduces w d s hwords hmem h: the word width, the environment, memory, input fits, memory well-formedness and the goal's domain. Nonzero generated work also adds the client's valid history as hv. It splits conjunctions and ifs of the domain, then leaves the generated work's comparison with the requested budget under the same entry assumptions. Zero work and definitionally matching budgets close automatically. Local method certificates are tried in context order; the remaining rule selection follows the client syntax, without searching for bounds. An unsupported form is reported with its subterm. A called method whose arguments are not all live words first stages its whole encoded argument with a charged pure step. This also supports custom input encodings without requiring a WordEncoding instance for the method's argument type.

realize [certificate₁, …] first adds the supplied proof terms as local facts in list order, then runs the same tactic. Existing local certificates retain priority.

Each certificate is stated for the client form as written, with its domain in the client's terms (certify), so certificates compose syntactically. A bind's continuation domain is stated at the first client's reply and next memory in closed form (Realizes.bind₀_of_run), not at the interpreter's run. The kernel checks, locally at each form, that the rule's statement agrees.

Main definitions #

Word glue #

Realization #

Prove Realizes B p input output safe work, leaving genuine fit, domain and budget conditions in the entry context, with valid history also available for nonzero generated work.

Instances For

    Supply method certificates as local facts before running realize.

    Instances For