intro l hl ivs' ivs'_nodup ivs'_lt
case refine_2.refl.refine_2
n : Nat
x : Permutation n
k : Nat
hk : k < n
ivs : Array (Inversion x)
ivs_nodup : Array.Nodup ivs
ivs_lt : ∀ (iv : Inversion x), iv ∈ ivs → ↑iv.snd < k
⊢ ∀ (i : Nat) (hi : i < k) (a : Array (Inversion x)),
    Array.Nodup a →
      (∀ (iv : Inversion x), iv ∈ a → ↑iv.snd < k ∨ ↑iv.snd = k ∧ ↑iv.fst < i) →
        Array.Nodup
            (if h : x[i] > x[k] then
              Array.push a
                { fst := { val := i, isLt := (_ : i < n) }, snd := { val := k, isLt := hk },
                  lt := (_ : { val := i, isLt := (_ : i < n) } < { val := k, isLt := hk }),
                  inverted := (_ : x[↑{ val := i, isLt := (_ : i < n) }] > x[↑{ val := k, isLt := hk }]) }
            else a) ∧
          ∀ (iv : Inversion x),
            (iv ∈
                if h : x[i] > x[k] then
                  Array.push a
                    { fst := { val := i, isLt := (_ : i < n) }, snd := { val := k, isLt := hk },
                      lt := (_ : { val := i, isLt := (_ : i < n) } < { val := k, isLt := hk }),
                      inverted := (_ : x[↑{ val := i, isLt := (_ : i < n) }] > x[↑{ val := k, isLt := hk }]) }
                else a) →
              ↑iv.snd < k ∨ ↑iv.snd = k ∧ ↑iv.fst < i + 1
case refine_2.refl.refine_2
n : Nat
x : Permutation n
k : Nat
hk : k < n
ivs : Array (Inversion x)
ivs_nodup : Array.Nodup ivs
ivs_lt : ∀ (iv : Inversion x), iv ∈ ivs → ↑iv.snd < k
l : Nat
hl : l < k
ivs' : Array (Inversion x)
ivs'_nodup : Array.Nodup ivs'
ivs'_lt : ∀ (iv : Inversion x), iv ∈ ivs' → ↑iv.snd < k ∨ ↑iv.snd = k ∧ ↑iv.fst < l
⊢ Array.Nodup
      (if h : x[l] > x[k] then
        Array.push ivs'
          { fst := { val := l, isLt := (_ : l < n) }, snd := { val := k, isLt := hk },
            lt := (_ : { val := l, isLt := (_ : l < n) } < { val := k, isLt := hk }),
            inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := k, isLt := hk }]) }
      else ivs') ∧
    ∀ (iv : Inversion x),
      (iv ∈
          if h : x[l] > x[k] then
            Array.push ivs'
              { fst := { val := l, isLt := (_ : l < n) }, snd := { val := k, isLt := hk },
                lt := (_ : { val := l, isLt := (_ : l < n) } < { val := k, isLt := hk }),
                inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := k, isLt := hk }]) }
          else ivs') →
        ↑iv.snd < k ∨ ↑iv.snd = k ∧ ↑iv.fst < l + 1