Discharging a procedure's contract #
Ways to establish a Procedure.contractTriple, and the bridges that make a concrete
procedure's contract decidable. The definitions being established live in
Strata.Languages.Core.Logic.ContractToHoareTriple.
Key results #
Procedure.contractTriple_of— supplies the procedure and body, discharging the name lookup and the.structuredobligation once.Procedure.contractTriple_of_coreandProcedure.contractTriple_of_core_typed— retain the concrete Core entry facts needed by evaluator-sensitive body proofs.Procedure.contractTriple_nilandProcedure.contractTriple_nil_of_ensuresAmongRequires— an empty body meets a contract whose non-freeensuresclauses are all among itsrequires.Procedure.contractTriple_singleton_cmd— a one-command body, reduced to a single obligation about that command'sEvalCommandstep.Procedure.preAsPredicate_of_preHoldsAtandProcedure.not_postAsPredicate_of_postRefutedAt— the decidable bridges, which let a concrete procedure be settled bydecide/native_deciderather than by unfolding a translated AST by hand.preAsPredicate_of_eqPairsandpostAsPredicate_of_eqPairs— establish contract clauses that are equalities between variables with matching canonical bindings.assertionsValid_defaultAssertEvents— turns true non-freecontract clauses into a valid assertion-event trace.
A snapshot of a procedure's non-free contract clauses as assert events is
assertion-valid whenever every such clause evaluates to true in that snapshot.
If every requires is an equality between a listed variable pair whose two
bindings hold the same canonical value, all preconditions hold.
Postcondition analogue of preAsPredicate_of_eqPairs: free clauses are
exempt, and each remaining equality follows from matching canonical bindings.
Build a contractTriple from the name lookup, body, and body judgement.
The factory, old-inout, and input-typing clauses of contractTriple's
precondition are discarded by weakening, so the body proof needs none of them.
Build a contractTriple whose body proof may assume the concrete factory and
old-inout relation but does not need input-value typing.
Build a contractTriple while retaining every entry fact, including values
matching the types of the procedure's input and inout formals.
A contract whose every non-free ensures is literally one of the
requires is met by an empty body: nothing runs, so the precondition still
holds at the end.
The workhorse is skip_block plus consequence; no reasoning about
Expression.eval is involved, because the same check expression carries
from the precondition to the postcondition.
The decidable check preHoldsAt discharges the proposition preAsPredicate.
The decidable check postRefutedAt refutes the proposition postAsPredicate:
the clause it finds is a non-free ensures that does not hold.
An empty body meets a contract whose non-free ensures clauses are all among its
requires, with the containment settled by the decidable ensuresAmongRequires.
A one-command body. The cmd rule reduces a contract over [.cmd c] to a
single semantic obligation about c. hsem receives the precondition clauses,
concrete factory, and old-inout relation; signature typing is weakened away because
this constructor does not require it. hpost_proj ensures the postcondition names no
variable declared by c, since the block drops those.