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

tactic: if h' : (self.arr.get x).parent = x then
  rw [findAux_s, if_pos h']; exact .inr rfl
else
  rw [parentD_findAux]; split <;> [simp [*]; skip]
  have := Nat.sub_lt_sub_left (self.lt_rankMax x) (self.rank'_lt _ ‹_›)
  exact (parentD_findAux_or self ⟨_, self.parent'_lt x⟩ i).imp_left <| .imp_right fun h => by
    simp only [h, ← parentD_eq, rootD_parent, Array.data_length]
state_before: self : UnionFind
x : Fin self.size
i : Nat
⊢ parentD (self.findAux x).s i = self.rootD i ∧ self.rootD i = self.rootD ↑x ∨
    parentD (self.findAux x).s i = self.parent i
state_after: no goals

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

tactic: exact .inr rfl
state_before: self : UnionFind
x : Fin self.size
i : Nat
h' : (self.arr.get x).parent = ↑x
⊢ parentD self.arr i = self.rootD i ∧ self.rootD i = self.rootD ↑x ∨ parentD self.arr i = self.parent i
state_after: no goals

tactic: rw [parentD_findAux]
state_before: self : UnionFind
x : Fin self.size
i : Nat
h' : ¬(self.arr.get x).parent = ↑x
⊢ parentD (self.findAux x).s i = self.rootD i ∧ self.rootD i = self.rootD ↑x ∨
    parentD (self.findAux x).s i = self.parent i
state_after: self : UnionFind
x : Fin self.size
i : Nat
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) = self.rootD i ∧
      self.rootD i = self.rootD ↑x ∨
    (if i = ↑x then self.rootD ↑x else parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i) = self.parent i

tactic: split <;> [simp [*]; skip]
state_before: self : UnionFind
x : Fin self.size
i : Nat
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) = self.rootD i ∧
      self.rootD i = self.rootD ↑x ∨
    (if i = ↑x then self.rootD ↑x else parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i) = self.parent i
state_after: case isFalse
self : UnionFind
x : Fin self.size
i : Nat
h' : ¬(self.arr.get x).parent = ↑x
h✝ : ¬i = ↑x
⊢ parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i = self.rootD i ∧ self.rootD i = self.rootD ↑x ∨
    parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i = self.parent i

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

tactic: exact (parentD_findAux_or self ⟨_, self.parent'_lt x⟩ i).imp_left <| .imp_right fun h => by
  simp only [h, ← parentD_eq, rootD_parent, Array.data_length]
state_before: case isFalse
self : UnionFind
x : Fin self.size
i : Nat
h' : ¬(self.arr.get x).parent = ↑x
h✝ : ¬i = ↑x
this : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
⊢ parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i = self.rootD i ∧ self.rootD i = self.rootD ↑x ∨
    parentD (self.findAux ⟨(self.arr.get x).parent, ⋯⟩).s i = self.parent i
state_after: no goals

tactic: simp only [h, ← parentD_eq, rootD_parent, Array.data_length]
state_before: self : UnionFind
x : Fin self.size
i : Nat
h' : ¬(self.arr.get x).parent = ↑x
h✝ : ¬i = ↑x
this : self.rankMax - self.rank (self.arr.get x).parent < self.rankMax - self.rank ↑x
h : self.rootD i = self.rootD ↑⟨(self.arr.get x).parent, ⋯⟩
⊢ self.rootD i = self.rootD ↑x
state_after: no goals