Equations
- UFModel.empty = { parent := fun (i : Fin 0) => Fin.elim0 i, rank := fun (x : ℕ) => 0, rank_lt := UFModel.empty.proof_1 }
Instances For
- mk: ∀ {α : Type u_1} {β : Sort u_2} {arr : Array α} {f : α → β}, UFModel.Agrees arr f fun (i : Fin (Array.size arr)) => f (Array.get arr i)
Instances For
theorem
UFModel.Agrees.mk'
{α : Type u_1}
{β : Sort u_2}
{arr : Array α}
{f : α → β}
{n : ℕ}
{g : Fin n → β}
(e : n = Array.size arr)
(H : ∀ (i : ℕ) (h₁ : i < Array.size arr) (h₂ : i < n),
f (Array.get arr { val := i, isLt := h₁ }) = g { val := i, isLt := h₂ })
:
UFModel.Agrees arr f g
theorem
UFModel.Agrees.size_eq
{α : Type u_1}
{n : ℕ}
{β : Sort u_2}
{f : α → β}
{arr : Array α}
{m : Fin n → β}
(H : UFModel.Agrees arr f m)
:
n = Array.size arr
theorem
UFModel.Agrees.get_eq
{α : Type u_1}
{β : Sort u_2}
{f : α → β}
{arr : Array α}
{n : ℕ}
{m : Fin n → β}
(H : UFModel.Agrees arr f m)
(i : ℕ)
(h₁ : i < Array.size arr)
(h₂ : i < n)
:
theorem
UFModel.Agrees.get_eq'
{α : Type u_1}
{β : Sort u_2}
{f : α → β}
{arr : Array α}
{m : Fin (Array.size arr) → β}
(H : UFModel.Agrees arr f m)
(i : Fin (Array.size arr))
:
theorem
UFModel.Agrees.empty
{α : Type u_1}
{β : Sort u_2}
{f : α → β}
{g : Fin 0 → β}
:
UFModel.Agrees #[] f g
theorem
UFModel.Agrees.push
{α : Type u_1}
{β : Sort u_2}
{f : α → β}
{arr : Array α}
{n : ℕ}
{m : Fin n → β}
(H : UFModel.Agrees arr f m)
(k : ℕ)
(hk : k = n + 1)
(x : α)
(m' : Fin k → β)
(hm₁ : ∀ (i : Fin k) (h : ↑i < n), m' i = m { val := ↑i, isLt := h })
(hm₂ : ∀ (h : n < k), f x = m' { val := n, isLt := h })
:
UFModel.Agrees (Array.push arr x) f m'
theorem
UFModel.Agrees.set
{α : Type u_1}
{β : Sort u_2}
{f : α → β}
{arr : Array α}
{n : ℕ}
{m : Fin n → β}
(H : UFModel.Agrees arr f m)
{i : Fin (Array.size arr)}
{x : α}
{m' : Fin n → β}
(hm₁ : ∀ (j : Fin n), ↑j ≠ ↑i → m' j = m j)
(hm₂ : ∀ (h : ↑i < n), f x = m' { val := ↑i, isLt := h })
:
UFModel.Agrees (Array.set arr i x) f m'
theorem
UFModel.Models.size_eq
{α : Type u_1}
{arr : Array (UFNode α)}
{n : ℕ}
{m : UFModel n}
(H : UFModel.Models arr m)
:
n = Array.size arr
theorem
UFModel.Models.parent_eq
{α : Type u_1}
{arr : Array (UFNode α)}
{n : ℕ}
{m : UFModel n}
(H : UFModel.Models arr m)
(i : ℕ)
(h₁ : i < Array.size arr)
(h₂ : i < n)
:
arr[i].parent = ↑(m.parent { val := i, isLt := h₂ })
theorem
UFModel.Models.parent_eq'
{α : Type u_1}
{arr : Array (UFNode α)}
{m : UFModel (Array.size arr)}
(H : UFModel.Models arr m)
(i : Fin (Array.size arr))
:
arr[↑i].parent = ↑(m.parent i)
theorem
UFModel.Models.rank_eq
{α : Type u_1}
{arr : Array (UFNode α)}
{n : ℕ}
{m : UFModel n}
(H : UFModel.Models arr m)
(i : ℕ)
(h : i < Array.size arr)
:
arr[i].rank = m.rank i
theorem
UFModel.Models.push
{α : Type u_1}
{arr : Array (UFNode α)}
{n : ℕ}
{m : UFModel n}
(H : UFModel.Models arr m)
(k : ℕ)
(hk : k = n + 1)
(x : α)
:
UFModel.Models (Array.push arr { parent := n, value := x, rank := 0 }) (UFModel.push m k (_ : n ≤ k))
theorem
UFModel.Models.setParent
{α : Type u_1}
{arr : Array (UFNode α)}
{n : ℕ}
{m : UFModel n}
(hm : UFModel.Models arr m)
(i : Fin n)
(j : Fin n)
(H : m.rank ↑i < m.rank ↑j)
(hi : ↑i < Array.size arr)
(x : UFNode α)
(hp : x.parent = ↑j)
(hrk : x.rank = arr[i].rank)
:
UFModel.Models (Array.set arr { val := ↑i, isLt := hi } x) (UFModel.setParent m i j H)
Equations
- UnionFind.size self = Array.size self.arr
Instances For
theorem
UnionFind.model'
{α : Type u_1}
(self : UnionFind α)
:
∃ (m : UFModel (Array.size self.arr)), UFModel.Models self.arr m
Equations
- UnionFind.empty = { arr := #[], model := (_ : ∃ (n : ℕ), ∃ (m : UFModel n), UFModel.Models #[] m) }
Instances For
Equations
- UnionFind.mkEmpty c = { arr := Array.mkEmpty c, model := (_ : ∃ (n : ℕ), ∃ (m : UFModel n), UFModel.Models (Array.mkEmpty c) m) }
Instances For
Equations
- UnionFind.rank self i = if h : i < UnionFind.size self then (Array.get self.arr { val := i, isLt := h }).rank else 0
Instances For
Equations
- One or more equations did not get rendered due to their size.
- UnionFind.rankMaxAux self 0 = { val := 0, property := (_ : ∀ (a : ℕ), a < 0 → ∀ (a_2 : a < Array.size self.arr), (Array.get self.arr { val := a, isLt := a_2 }).rank ≤ 0) }
Instances For
Equations
- UnionFind.rankMax self = (UnionFind.rankMaxAux self (UnionFind.size self)).val + 1
Instances For
theorem
UnionFind.lt_rankMax'
{α : Type u_1}
(self : UnionFind α)
(i : Fin (UnionFind.size self))
:
(Array.get self.arr i).rank < UnionFind.rankMax self
theorem
UnionFind.lt_rankMax
{α : Type u_1}
(self : UnionFind α)
(i : ℕ)
:
UnionFind.rank self i < UnionFind.rankMax self
theorem
UnionFind.rank_eq
{α : Type u_1}
(self : UnionFind α)
{n : ℕ}
{m : UFModel n}
(H : UFModel.Models self.arr m)
{i : ℕ}
(h : i < UnionFind.size self)
:
UnionFind.rank self i = m.rank i
theorem
UnionFind.rank_lt
{α : Type u_1}
(self : UnionFind α)
{i : ℕ}
(h : i < Array.size self.arr)
:
self.arr[i].parent ≠ i → UnionFind.rank self i < UnionFind.rank self self.arr[i].parent
theorem
UnionFind.parent_lt
{α : Type u_1}
(self : UnionFind α)
(i : ℕ)
(h : i < Array.size self.arr)
:
self.arr[i].parent < UnionFind.size self
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
UnionFind.find
{α : Type u_1}
(self : UnionFind α)
(x : Fin (UnionFind.size self))
:
(s : UnionFind α) ×
(root : Fin (UnionFind.size s)) ×' UnionFind.size s = UnionFind.size self ∧ (Array.get s.arr root).parent = ↑root
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
UnionFind.link
{α : Type u_1}
(self : UnionFind α)
(x : Fin (UnionFind.size self))
(y : Fin (UnionFind.size self))
(yroot : (Array.get self.arr y).parent = ↑y)
:
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
UnionFind.union
{α : Type u_1}
(self : UnionFind α)
(x : Fin (UnionFind.size self))
(y : Fin (UnionFind.size self))
:
Equations
- One or more equations did not get rendered due to their size.