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

tactic: rw [findAux_s, if_pos h']
state_before: i : Nat
self : UnionFind
x : Fin self.size
h' : (self.arr.get x).parent = ↑x
⊢ parentD (self.findAux x).s i ≠ i → self.rank i < self.rank (parentD (self.findAux x).s i)
state_after: i : Nat
self : UnionFind
x : Fin self.size
h' : (self.arr.get x).parent = ↑x
⊢ parentD self.arr i ≠ i → self.rank i < self.rank (parentD self.arr i)

tactic: apply self.rank_lt
state_before: i : Nat
self : UnionFind
x : Fin self.size
h' : (self.arr.get x).parent = ↑x
⊢ parentD self.arr i ≠ i → self.rank i < self.rank (parentD self.arr i)
state_after: no goals

tactic: rw [parentD_findAux]
state_before: i : Nat
self : UnionFind
x : Fin self.size
h' : ¬(self.arr.get x).parent = ↑x
⊢ parentD (self.findAux x).s i ≠ i → self.rank i < self.rank (parentD (self.findAux x).s i)
state_after: i : Nat
self : UnionFind
x : Fin self.size
h' : ¬(self.arr.get x).parent = ↑x
⊢ (if i = ↑x then self.rootD ↑x else parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i) ≠ i →
    self.rank i < self.rank (if i = ↑x then self.rootD ↑x else parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i)

tactic: split <;> rename_i h <;> intro h'
state_before: i : Nat
self : UnionFind
x : Fin self.size
h' : ¬(self.arr.get x).parent = ↑x
⊢ (if i = ↑x then self.rootD ↑x else parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i) ≠ i →
    self.rank i < self.rank (if i = ↑x then self.rootD ↑x else parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i)
state_after: case isTrue
i : Nat
self : UnionFind
x : Fin self.size
h'✝ : ¬(self.arr.get x).parent = ↑x
h : i = ↑x
h' : self.rootD ↑x ≠ i
⊢ self.rank i < self.rank (self.rootD ↑x)

case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h'✝ : ¬(self.arr.get x).parent = ↑x
h : ¬i = ↑x
h' : parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i ≠ i
⊢ self.rank i < self.rank (parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i)

tactic: subst i
state_before: case isTrue
i : Nat
self : UnionFind
x : Fin self.size
h'✝ : ¬(self.arr.get x).parent = ↑x
h : i = ↑x
h' : self.rootD ↑x ≠ i
⊢ self.rank i < self.rank (self.rootD ↑x)
state_after: case isTrue
self : UnionFind
x : Fin self.size
h'✝ : ¬(self.arr.get x).parent = ↑x
h' : self.rootD ↑x ≠ ↑x
⊢ self.rank ↑x < self.rank (self.rootD ↑x)

tactic: rwa [lt_rank_root, Ne, ← rootD_eq_self]
state_before: case isTrue
self : UnionFind
x : Fin self.size
h'✝ : ¬(self.arr.get x).parent = ↑x
h' : self.rootD ↑x ≠ ↑x
⊢ self.rank ↑x < self.rank (self.rootD ↑x)
state_after: no goals

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'✝ : ¬(self.arr.get x).parent = ↑x
h : ¬i = ↑x
h' : parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i ≠ i
⊢ self.rank i < self.rank (parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i)
state_after: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h'✝ : ¬(self.arr.get x).parent = ↑x
h : ¬i = ↑x
h' : parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i ≠ i
this : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
⊢ self.rank i < self.rank (parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i)

tactic: apply lt_rankD_findAux h'
state_before: case isFalse
i : Nat
self : UnionFind
x : Fin self.size
h'✝ : ¬(self.arr.get x).parent = ↑x
h : ¬i = ↑x
h' : parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i ≠ i
this : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
⊢ self.rank i < self.rank (parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i)
state_after: no goals