Theorem: Batteries.UnionFind.rankD_findAux
File: .lake/packages/batteries/Batteries/Data/UnionFind/Basic.lean

tactic: if h : i < self.size then
  rw [findAux_s]; split <;> [rfl; skip]
  have := Nat.sub_lt_sub_left (self.lt_rankMax x) (self.rank'_lt _ ‹_›)
  have := lt_of_parentD (by rwa [parentD_eq])
  rw [rankD_eq' (by simp [FindAux.size_eq, h]), Array.get_modify (by rwa [FindAux.size_eq])]
  split <;> simp [← rankD_eq, rankD_findAux (x := ⟨_, self.parent'_lt x⟩), -Array.get_eq_getElem]
else
  simp [rank, rankD]; rw [dif_neg (by rwa [FindAux.size_eq]), dif_neg h]
state_before: i : Nat
self : UnionFind
x : Fin self.size
⊢ rankD (self.findAux x).s i = self.rank i
state_after: no goals

tactic: rw [findAux_s]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
⊢ rankD (self.findAux x).s i = self.rank i
state_after: i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
⊢ rankD
      (if (self.arr.get x).parent = ↑x then self.arr
      else (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank })
      i =
    self.rank i

tactic: split <;> [rfl; skip]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
⊢ rankD
      (if (self.arr.get x).parent = ↑x then self.arr
      else (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank })
      i =
    self.rank i
state_after: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
⊢ rankD ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank })
      i =
    self.rank i

tactic: have := Nat.sub_lt_sub_left (self.lt_rankMax x) (self.rank'_lt _ ‹_›)
state_before: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
⊢ rankD ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank })
      i =
    self.rank i
state_after: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
⊢ rankD ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank })
      i =
    self.rank i

tactic: have := lt_of_parentD (by rwa [parentD_eq])
state_before: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
⊢ rankD ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank })
      i =
    self.rank i
state_after: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this✝ : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
this : ↑x < self.arr.size
⊢ rankD ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank })
      i =
    self.rank i

tactic: rw [rankD_eq' (by simp [FindAux.size_eq, h]), Array.get_modify (by rwa [FindAux.size_eq])]
state_before: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this✝ : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
this : ↑x < self.arr.size
⊢ rankD ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank })
      i =
    self.rank i
state_after: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this✝ : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
this : ↑x < self.arr.size
⊢ (if ↑x = i then { parent := self.rootD ↑x, rank := ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.get ⟨i, ⋯⟩).rank }
      else (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.get ⟨i, ⋯⟩).rank =
    self.rank i

tactic: split <;> simp [← rankD_eq, rankD_findAux (x := ⟨_, self.parent'_lt x⟩), -Array.get_eq_getElem]
state_before: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this✝ : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
this : ↑x < self.arr.size
⊢ (if ↑x = i then { parent := self.rootD ↑x, rank := ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.get ⟨i, ⋯⟩).rank }
      else (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.get ⟨i, ⋯⟩).rank =
    self.rank i
state_after: no goals

tactic: rwa [parentD_eq]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
⊢ parentD ?m.50228 ?m.50229 ≠ ?m.50229
state_after: no goals

tactic: simp [FindAux.size_eq, h]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this✝ : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
this : ↑x < self.arr.size
⊢ i <
    ((self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.modify ↑x fun s => { parent := self.rootD ↑x, rank := s.rank }).size
state_after: no goals

tactic: rwa [FindAux.size_eq]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h : i < self.size
h✝ : ¬(self.arr.get x).parent = ↑x
this✝ : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
this : ↑x < self.arr.size
⊢ i < (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s.size
state_after: no goals

tactic: simp [rank, rankD]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h : ¬i < self.size
⊢ rankD (self.findAux x).s i = self.rank i
state_after: i : Nat
self : UnionFind
x : Fin self.size
h : ¬i < self.size
⊢ (if h : i < (self.findAux x).s.size then (self.findAux x).s[i].rank else 0) =
    if h : i < self.arr.size then self.arr[i].rank else 0

tactic: rw [dif_neg (by rwa [FindAux.size_eq]), dif_neg h]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h : ¬i < self.size
⊢ (if h : i < (self.findAux x).s.size then (self.findAux x).s[i].rank else 0) =
    if h : i < self.arr.size then self.arr[i].rank else 0
state_after: no goals

tactic: rwa [FindAux.size_eq]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h : ¬i < self.size
⊢ ¬i < (self.findAux x).s.size
state_after: no goals