Well-formedness predicate on size-bounded trees #
This file defines the well-formedness predicate WF on the internal size-bounded tree data
structure Impl and proves well-formedness for those operations that aren't per definition.
A central consequence of well-formedness, balancedness, is shown for all well-formed trees.
Well-formedness of tree maps.
- wf {α : Type u} [Ord α] {x✝ : α → Type v} {t : Impl α x✝} : t.Balanced → (∀ [TransOrd α], t.Ordered) → t.WF
This is the actual well-formedness invariant: the tree must be a balanced BST.
- empty {α : Type u} [Ord α] {x✝ : α → Type v} : Impl.empty.WF
The empty tree is well-formed. Later shown to be subsumed by
.wf. - insert {α : Type u} [Ord α] {x✝ : α → Type v} {t : Impl α x✝} {h : t.Balanced} {k : α} {v : x✝ k} : t.WF → (Impl.insert k v t h).impl.WF
- insertIfNew {α : Type u} [Ord α] {x✝ : α → Type v} {t : Impl α x✝} {h : t.Balanced} {k : α} {v : x✝ k} : t.WF → (Impl.insertIfNew k v t h).impl.WF
insertIfNewpreserves well-formedness. Later shown to be subsumed by.wf. - erase {α : Type u} [Ord α] {x✝ : α → Type v} {t : Impl α x✝} {h : t.Balanced} {k : α} : t.WF → (Impl.erase k t h).impl.WF
- alter {α : Type u} [Ord α] {x✝ : α → Type v} [LawfulEqOrd α] {t : Impl α x✝} {h : t.Balanced} {k : α} {f : Option (x✝ k) → Option (x✝ k)} : t.WF → (Impl.alter k f t h).impl.WF
- constAlter {α : Type u} [Ord α] {x✝ : Type v} {t : Impl α fun (x : α) => x✝} {h : t.Balanced} {k : α} {f : Option x✝ → Option x✝} : t.WF → (Const.alter k f t h).impl.WF
- modify {α : Type u} [Ord α] {x✝ : α → Type v} [LawfulEqOrd α] {t : Impl α x✝} {k : α} {f : x✝ k → x✝ k} : t.WF → (Impl.modify k f t).WF
- constModify {α : Type u} [Ord α] {x✝ : Type v} {t : Impl α fun (x : α) => x✝} {k : α} {f : x✝ → x✝} : t.WF → (Const.modify k f t).WF
- containsThenInsert {α : Type u} [Ord α] {x✝ : α → Type v} {t : Impl α x✝} {h : t.Balanced} {k : α} {v : x✝ k} : t.WF → (Impl.containsThenInsert k v t h).snd.impl.WF
containsThenInsertpreserves well-formedness. Later shown to be subsumed by.wf. - containsThenInsertIfNew {α : Type u} [Ord α] {x✝ : α → Type v} {t : Impl α x✝} {h : t.Balanced} {k : α} {v : x✝ k} : t.WF → (Impl.containsThenInsertIfNew k v t h).snd.impl.WF
containsThenInsertIfNewpreserves well-formedness. Later shown to be subsumed by.wf. - filter {α : Type u} [Ord α] {x✝ : α → Type v} {t : Impl α x✝} {h : t.Balanced} {f : (a : α) → x✝ a → Bool} : t.WF → (Impl.filter f t h).impl.WF
- mergeWith {α : Type u} [Ord α] {x✝ : α → Type v} {t₁ t₂ : Impl α x✝} {f : (a : α) → x✝ a → x✝ a → x✝ a} {h : t₁.Balanced} [LawfulEqOrd α] : t₁.WF → (Impl.mergeWith f t₁ t₂ h).impl.WF
- constMergeWith {α : Type u} [Ord α] {x✝ : Type v} {t₁ t₂ : Impl α fun (x : α) => x✝} {f : α → x✝ → x✝ → x✝} {h : t₁.Balanced} : t₁.WF → (Const.mergeWith f t₁ t₂ h).impl.WF
- inter {α : Type u} [Ord α] {x✝ : α → Type v} {t₁ t₂ : Impl α x✝} {h : t₁.Balanced} : t₁.WF → (t₁.inter t₂ h).WF
Instances For
theorem Std.DTreeMap.Internal.Impl.WF.getThenInsertIfNew? {α : Type u} {β : α → Type v} [Ord α] [LawfulEqOrd α] {t : Impl α β} {k : α} {v : β k} {h : t.WF} :
(t.getThenInsertIfNew? k v ⋯).snd.WF
theorem Std.DTreeMap.Internal.Impl.WF.constGetThenInsertIfNew? {α : Type u} {β : Type v} [Ord α] {t : Impl α fun (x : α) => β} {k : α} {v : β} {h : t.WF} :
(Const.getThenInsertIfNew? t k v ⋯).snd.WF