Runs as functions of the state #
Under INV-S, the run of a group is determined by the element list and the elements' grp
fields: it is the sublist of the elements in that group. Likewise for the groups of a chunk.
So the cost invariants can be stated in terms of the element list L and the state alone, and
transported along the M2 lemmas, which keep L but give the new nesting only existentially.
The run of group g: the elements of L in g, in list order.
Equations
- OrderMaintenance.Proof.runOf s L g = List.filter (fun (e : ℕ) => decide (OrderMaintenance.Proof.eG s e = g)) L
Instances For
The groups of chunk c, in list order.
Equations
- OrderMaintenance.Proof.grpsOf s Ls c = List.filter (fun (g : ℕ) => decide (OrderMaintenance.Proof.gC s g = c)) Ls
Instances For
Lists #
theorem
OrderMaintenance.Proof.filter_insertAfterL
(p : ℕ → Bool)
(x y : ℕ)
(L : List ℕ)
(hxy : p x = p y)
:
List.filter p (Spec.insertAfterL x y L) = if p x = true then Spec.insertAfterL x y (List.filter p L) else List.filter p L
theorem
OrderMaintenance.Proof.isChain_insert'
{R : ℕ → ℕ → Prop}
{l1 l2 : List ℕ}
{x y : ℕ}
{f f' : ℕ → ℕ}
(hs : List.IsChain R (List.map f (l1 ++ x :: l2)))
(hagree : ∀ z ∈ l1 ++ x :: l2, f' z = f z)
(hxy : R (f x) (f' y))
(hy2 : ∀ w ∈ l2.head?, R (f' y) (f w))
:
List.IsChain R (List.map f' (l1 ++ x :: y :: l2))
IsChain survives inserting y right after x, for any relation.