Hoare triple specifications for select functions #
This module contains Hoare triple specifications for some functions in Core.
The specifications follow the Triple x pre post epost argument order, program first.
Lifting MonadStateOf #
Lifting MonadReaderOf #
Lifting MonadExceptOf #
The type of loop invariants used by the specifications of for ... in ... loops.
A loop invariant maps the iteration cursor and accumulator state to an assertion.
The exception postcondition is specified separately as the spec's epost parameter.
Equations
- Std.Internal.Do.Invariant xs β Pred = (xs.Cursor → β → Pred)
Instances For
An invariant combinator for loops with early return, for the new do elaborator which
uses Prod for the state tuple: onContinue is the invariant while iterating, onReturn
holds once the loop returned early with a value.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The type of loop invariants used by the specifications of for ... in ... loops over strings.
A loop invariant is a function mapping the current position and state to a lattice element.
Equations
- Std.Internal.Do.StringInvariant s β Pred = (s.Pos → β → Pred)
Instances For
An invariant combinator for String loops with early return, for the new do elaborator
which uses Prod for the state tuple: onContinue is the invariant while iterating, onReturn
holds once the loop returned early with a value.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The type of loop invariants used by the specifications of for ... in ... loops over string slices.
A loop invariant is a function mapping the current position and state to a lattice element.
Equations
- Std.Internal.Do.StringSliceInvariant s β Pred = (s.Pos → β → Pred)
Instances For
An invariant combinator for String.Slice loops with early return, for the new do
elaborator which uses Prod for the state tuple: onContinue is the invariant while iterating,
onReturn holds once the loop returned early with a value.
Equations
- One or more equations did not get rendered due to their size.
Instances For
An invariant for a repeatM loop, given as a predicate over the α ⊕ β cursor:
.inl a is the continue case at a; .inr b is the break case with result b.
Equations
- Std.Internal.Do.RepeatInvariant α β Pred = (α ⊕ β → Pred)
Instances For
A termination measure for a repeatM loop.
Equations
- Std.Internal.Do.RepeatVariant α = (α → Nat)
Instances For
Specification for repeatM. The user supplies a termination measure, an invariant, and a step
Triple whose post either continues with a strictly smaller measure or finishes with the .inr
invariant.
Construct an invariant from a loop invariant inv and a break condition onBreak.
inv holds at the end of every loop iteration (including the breaking one), and onBreak holds in
addition to inv once the loop is done. For a normal while loop onBreak can be taken as the
negation of the loop condition.
Equations
- Std.Internal.Do.RepeatInvariant.ofInvariantAndBreak inv onBreak (Sum.inl a) = inv a
- Std.Internal.Do.RepeatInvariant.ofInvariantAndBreak inv onBreak (Sum.inr a) = Lean.Order.meet (inv a) (onBreak a)
Instances For
Specification for forIn over a Lean.Loop. The cursor is β ⊕ β: .inl b means
"still iterating with b", .inr b means "finished with result b".