Separation logic, typed #
A solver's heap is declared once, at the Lean types of its locations and data. The two constructors
that depend on it hang off the handle declareSepHeap answers, so a location or a datum of the
wrong type does not compile:
let h ← s.declareSepHeap Int Int
s.assert (← h.pto x y) -- `x y : Term Int`
let n ← h.nil -- `n : Term Int`
sepEmp, sepStar and sepWand need no heap. getValueSepHeap and getValueSepNil describe the
model's heap as formulas.
sepStar over two or more terms.
Equations
- Cvc.Typed.Term.sepStarN terms atLeastTwoElements = Cvc.Untyped.Term.sepStarN terms atLeastTwoElements
Instances For
Holds exactly when the heap is empty.
Instances For
Sep's operators with a result of sort Bool.
- sepEmp
[Ω]
: OnBool
Holds exactly when the heap is empty.
- sepStar
[Ω]
(kids : Kids Bool)
: OnBool
Separating conjunction: the heap splits in two, one part satisfying each side.
kidsholds every operand, two or more. - sepWand
[Ω]
(lft rgt : Term Bool)
: OnBool
Separating implication, the magic wand.
Instances For
The heap of a solver, at the Lean types of its locations and its data.
Produced by declareSepHeap, and the only way to Heap.pto or Heap.nil.
- untyped : Cvc.Untyped.Solver.Heap solver
Instances For
The sort-erased heap it wraps, which carries α and β as Srts; free.
Equations
Instances For
The sort-erased heap it wraps, which carries α and β as Srts; free.
Instances For
Types a sort-erased heap at locations α and data β, checking its two sorts against theirs.
toTyped infers α and β from the expected type; typeCheckAs and typeCheck are the same two
functions under the names that say what they do.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Types a sort-erased heap at locations α and data β, checking its two sorts against theirs.
toTyped infers α and β from the expected type; typeCheckAs and typeCheck are the same two
functions under the names that say what they do.
Equations
Instances For
Types a sort-erased heap at locations α and data β, checking its two sorts against theirs.
toTyped infers α and β from the expected type; typeCheckAs and typeCheck are the same two
functions under the names that say what they do.
Instances For
Types a sort-erased heap at locations α and data β, checking its two sorts against theirs.
toTyped infers α and β from the expected type; typeCheckAs and typeCheck are the same two
functions under the names that say what they do.
Instances For
Declares the heap's location and data sorts, and answers the handle they are reached through.
cvc5 allows this once per solver, and rejects a second call even at the same sorts. It has to come before any separation-logic constraint: asserting one against an undeclared heap is an error.
Equations
- s.declareSepHeap α β = do let loc ← Cvc.Srt.of α let data ← Cvc.Srt.of β let __do_lift ← Cvc.Untyped.Solver.declareSepHeap s loc data pure { untyped := __do_lift }
Instances For
The points-to constraint: loc points to data in a heap holding nothing else.
The operands are the heap's own indices, so the mismatch the sort-erased version has to check is not expressible here.
Instances For
Reading a heap back #
Both answer a formula describing the model's heap rather than a value, so both are Term Bool
whatever the heap's types.
A formula describing the model's heap, such as (pto (as @Loc_1 Loc) 0); not a value.