NLA-lib Explorer

The tactics of a program proof

Library · Source module

The tactics of a program proof

Each tactic has one goal shape and either closes its goal, or leaves exactly the goals its docstring names (under those names), or fails with a message naming the goal it could not prove. None of them can prove something false: they build ordinary proof terms, checked by the kernel. None of them silently leaves a side goal for the end of the proof.

* step h [facts] as m₁ with x hx: goal Wp … (.seq (.call …) c) … m, Wp … (.call …) … m, or Writes … of them. Leaves the continuation from the fresh memory m₁, with the outputs x and the contract's relation hx; the running frame, the lengths and the kept reads updated. * frame [facts]: goal s.EqOff F s', s' a chain of updates over s or over a store with a frame in the context. Leaves nothing. * fp_mem [facts], fp_sub [facts]: goals F b i, ¬ F b i, F ≤ G. Leave nothing. * disjoint [facts]: goals Fp.Disj F G, Fp.Apart zs ls, handles different. Leaves nothing. * idx [facts]: offset arithmetic. Leaves nothing. * checkpoint m₁: goal Wp … m with m a chain of updates. Leaves the goal at the fresh m₁, with its frame and reads. * alloc as t₁ … tₖ: goal Writes … (.allocAs …) or Writes … (Stmt.allocs …). Leaves the body at a fresh store, with the handles tᵢ and their lengths. * loop_inv F P with …: goal Writes … (.loop …), alone or at the start of a sequence. Leaves the initial invariant, round and continuation when they need proofs. * keep: after a step. Restates for the new memory every read fact of the context that is off the step's footprint. * decode: layer-1 vectors and matrices of stored blocks. Leaves the mathematical goal. * count_eval: stmtCost s idx = C. Leaves nothing.

step is the call step of NLAlib.Ops.Tactic (wp_call) on the footprint rules (NLAlib.Ops.writes_call and its shapes): it applies Writes.then_ (or Writes.seq), picks the rule by the shape of the outputs, discharges the side goals with store_simp, store_side, idx, disjoint and the facts, unifies the inputs read with the reads in the context, and introduces the fresh memory and the outputs. The running frame hfr : m₀.store.EqOff F m.store of the block is replaced by hfr.trans' hfr₁, the lengths hlen : ∀ b, m₁.store.len b = … are restated, and keep restates the reads. A side goal it cannot discharge makes it fail, naming the goal (step! leaves it instead, under its name: hadm, hpre, hap).

The allocation, counted-loop and call tactics use the proved footprint rules. decode is provisional.

Main results

The tactics step, frame, fp_sub, checkpoint, alloc, loop_inv, keep, decode (and fp_mem, disjoint, idx, count_eval in their files).

Declarations