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

tactic: rw [show self.rootD _ = (self.findAux ⟨_, self.parent'_lt x⟩).root from _]
state_before: self : UnionFind
x : Fin self.size
⊢ (self.findAux x).s =
    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 }
state_after: self : UnionFind
x : Fin self.size
⊢ (self.findAux x).s =
    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.findAux ⟨(self.arr.get x).parent, ⋯⟩).root, rank := s.rank }

self : UnionFind
x : Fin self.size
⊢ self.rootD ↑x = ↑(self.findAux ⟨(self.arr.get x).parent, ⋯⟩).root

tactic: rw [findAux]
state_before: self : UnionFind
x : Fin self.size
⊢ (self.findAux x).s =
    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.findAux ⟨(self.arr.get x).parent, ⋯⟩).root, rank := s.rank }
state_after: self : UnionFind
x : Fin self.size
⊢ (if h : (self.arr.get x).parent = ↑x then { s := self.arr, root := x, size_eq := ⋯ }
      else
        let_fun this := ⋯;
        match self.findAux ⟨(self.arr.get x).parent, ⋯⟩ with
        | { s := arr₁, root := root, size_eq := H } =>
          { s := arr₁.modify ↑x fun s => { parent := ↑root, rank := s.rank }, root := root, size_eq := ⋯ }).s =
    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.findAux ⟨(self.arr.get x).parent, ⋯⟩).root, rank := s.rank }

tactic: split <;> rfl
state_before: self : UnionFind
x : Fin self.size
⊢ (if h : (self.arr.get x).parent = ↑x then { s := self.arr, root := x, size_eq := ⋯ }
      else
        let_fun this := ⋯;
        match self.findAux ⟨(self.arr.get x).parent, ⋯⟩ with
        | { s := arr₁, root := root, size_eq := H } =>
          { s := arr₁.modify ↑x fun s => { parent := ↑root, rank := s.rank }, root := root, size_eq := ⋯ }).s =
    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.findAux ⟨(self.arr.get x).parent, ⋯⟩).root, rank := s.rank }
state_after: no goals

tactic: rw [← rootD_parent, parent, parentD_eq]
state_before: self : UnionFind
x : Fin self.size
⊢ self.rootD ↑x = ↑(self.findAux ⟨(self.arr.get x).parent, ⋯⟩).root
state_after: self : UnionFind
x : Fin self.size
⊢ self.rootD (self.arr.get x).parent = ↑(self.findAux ⟨(self.arr.get x).parent, ⋯⟩).root

tactic: simp [findAux_root, rootD]
state_before: self : UnionFind
x : Fin self.size
⊢ self.rootD (self.arr.get x).parent = ↑(self.findAux ⟨(self.arr.get x).parent, ⋯⟩).root
state_after: self : UnionFind
x : Fin self.size
⊢ (if h : self.arr[↑x].parent < self.arr.size then ↑(self.root ⟨self.arr[↑x].parent, ⋯⟩) else self.arr[↑x].parent) =
    ↑(self.root ⟨self.arr[↑x].parent, ⋯⟩)

tactic: apply dif_pos
state_before: self : UnionFind
x : Fin self.size
⊢ (if h : self.arr[↑x].parent < self.arr.size then ↑(self.root ⟨self.arr[↑x].parent, ⋯⟩) else self.arr[↑x].parent) =
    ↑(self.root ⟨self.arr[↑x].parent, ⋯⟩)
state_after: case hc
self : UnionFind
x : Fin self.size
⊢ self.arr[↑x].parent < self.arr.size

tactic: exact parent'_lt ..
state_before: case hc
self : UnionFind
x : Fin self.size
⊢ self.arr[↑x].parent < self.arr.size
state_after: no goals