What the top structure and the priority queue may change #
Same s s': every field INV-S reads is unchanged (tags included).Safe s s': the links are unchanged, and INV-S is preserved. Tags may change, but only by guarded writes (guardedSetTag).
The priority queue, the top tree's tables, paths and jobs, and the sizes and states of groups
and chunks are invisible to INV-S, so every function that touches only them preserves Same;
the top structure's tag writes preserve Safe.
Preserve all structural links and every chunk order tag.
Equations
- OrderMaintenance.Proof.Same s s' = (OrderMaintenance.Proof.SameLinks s s' ∧ ∀ (c : ℕ), OrderMaintenance.Proof.cT s' c = OrderMaintenance.Proof.cT s c)
Instances For
Preserve structural links and carry every established core invariant to the new state.
Equations
- OrderMaintenance.Proof.Safe s s' = (OrderMaintenance.Proof.SameLinks s s' ∧ ∀ (A : OrderMaintenance.Proof.Abs), OrderMaintenance.Proof.INV s A → OrderMaintenance.Proof.INV s' A)
Instances For
Close a goal ∀ s, Same s (f s) for a state update f that leaves INV-S's fields alone.
Equations
- OrderMaintenance.Proof.tacticSame = Lean.ParserDescr.node `OrderMaintenance.Proof.tacticSame 1024 (Lean.ParserDescr.nonReservedSymbol "same" false)
Instances For
Reads #
theorem
OrderMaintenance.Proof.pres_getE
{R : Model.Core → Model.Core → Prop}
[IsPre R]
(i : ℕ)
:
Pres R (Model.getE i)
theorem
OrderMaintenance.Proof.pres_getG
{R : Model.Core → Model.Core → Prop}
[IsPre R]
(i : ℕ)
:
Pres R (Model.getG i)
theorem
OrderMaintenance.Proof.pres_getC
{R : Model.Core → Model.Core → Prop}
[IsPre R]
(i : ℕ)
:
Pres R (Model.getC i)
theorem
OrderMaintenance.Proof.pres_getN
{R : Model.Core → Model.Core → Prop}
[IsPre R]
(i : ℕ)
:
Pres R (Model.getN i)
theorem
OrderMaintenance.Proof.pres_getPath
{R : Model.Core → Model.Core → Prop}
[IsPre R]
(c : ℕ)
:
Pres R (Model.getPath c)
theorem
OrderMaintenance.Proof.pres_getLpar
{R : Model.Core → Model.Core → Prop}
[IsPre R]
(c : ℕ)
:
Pres R (Model.getLpar c)
Top structure: tables, paths, nodes #
theorem
OrderMaintenance.Proof.pres_modN
(i : ℕ)
(f : Model.Node → Model.Node)
:
Pres Same (Model.modN i f)
theorem
OrderMaintenance.Proof.pres_setInTables
(e h : ℕ)
(l : List ℕ)
:
Pres Same (Model.setInTables e h l)
theorem
OrderMaintenance.Proof.pres_roomNextTo
(t e : ℕ)
(b : Bool)
:
Pres Same (Model.roomNextTo t e b)
theorem
OrderMaintenance.Proof.pres_tableInsert
(t e new : ℕ)
(b : Bool)
(lab : ℕ)
:
Pres Same (Model.tableInsert t e new b lab)
Priority queue, sizes and states #
theorem
OrderMaintenance.Proof.pres_chunkSize
(c : ℕ)
(inc : Bool)
:
Pres Same (Model.chunkSize c inc)
Guarded tag writes #
The guard of a tag write: t lies strictly between the tags of c's neighbours.
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
OrderMaintenance.Proof.guardTag_run
(c t : ℕ)
(s : Model.Core)
:
EStateM.run (Model.guardTag c t) s = EStateM.Result.ok () s ∧ TagOK s c t ∨ ∃ (msg : String), EStateM.run (Model.guardTag c t) s = EStateM.Result.error (Model.Err.guard msg) s
theorem
OrderMaintenance.Proof.inv_setTag
{s : Model.Core}
{A : Abs}
(h : INV s A)
{c t : ℕ}
(hg : TagOK s c t)
:
INV
{ P := s.P, E := s.E, Gs := s.Gs,
C :=
s.C.modify c fun (C : Model.Chunk) =>
{ next := C.next, prev := C.prev, first := C.first, last := C.last, size := C.size, st := C.st, src := C.src,
l := C.l, r := C.r, tag := t, alive := C.alive },
freeG := s.freeG, count := s.count, head := s.head, tail := s.tail, firstGroup := s.firstGroup,
firstChunk := s.firstChunk, ready := s.ready, prep := s.prep, resJob := s.resJob, fallbacks := s.fallbacks,
pqHead := s.pqHead, pqNext := s.pqNext, pqPrev := s.pqPrev, pqWhere := s.pqWhere, nbNext := s.nbNext,
nbPrev := s.nbPrev, pqHi := s.pqHi, pqLo := s.pqLo, nodes := s.nodes, path := s.path, cin := s.cin, lpar := s.lpar }
A
Writing a tag that passed its guard preserves INV-S.
The top structure's jobs #
theorem
OrderMaintenance.Proof.pres_belowOf
{R : Model.Core → Model.Core → Prop}
[IsPre R]
(h y : ℕ)
:
Pres R (Model.belowOf h y)
theorem
OrderMaintenance.Proof.pres_fundLoop
(j : Model.Job)
(v up src k : ℕ)
:
Pres Safe (Model.fundLoop j v up src k)
theorem
OrderMaintenance.Proof.pres_afterDrain
(j : Model.Job)
(v up : ℕ)
:
Pres Safe (Model.afterDrain j v up)
theorem
OrderMaintenance.Proof.pres_walkBody
(j : Model.Job)
(v : ℕ)
:
Pres Safe (Model.walkBody j v)