internlm/Lean-Github huggingface dataset:
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_1
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
⊢ ↑i < 0 ∨ ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
Tactic:
intro hi
Proof state after:
case succ.refine_1
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
hi : ↑i < 0 ∨ ↑j < k
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_1
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
hi : ↑i < 0 ∨ ↑j < k
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
Tactic:
cases hi with
| inl hi => cases hi
| inr hj => exact IH hj
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_1.inl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
hi : ↑i < 0
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
Tactic:
cases hi
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_1.inr
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
hj : ↑j < k
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
Tactic:
exact IH hj
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
⊢ ∀ (i_1 : Nat) (hi : i_1 < k) (a : Array (Inversion x)),
    (↑i < i_1 ∨ ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ a) →
      ↑i < i_1 + 1 ∨ ↑j < k →
        { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
          if h : x[i_1] > x[k] then
            Array.push a
              { fst := { val := i_1, isLt := (_ : i_1 < n) }, snd := { val := k, isLt := hk },
                lt := (_ : { val := i_1, isLt := (_ : i_1 < n) } < { val := k, isLt := hk }),
                inverted := (_ : x[↑{ val := i_1, isLt := (_ : i_1 < n) }] > x[↑{ val := k, isLt := hk }]) }
          else a
Tactic:
intro l hl invs' IH' hil
Proof state after:
case succ.refine_2
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
l : Nat
hl : l < k
invs' : Array (Inversion x)
IH' : ↑i < l ∨ ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < k
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[l] > x[k] then
      Array.push invs'
        { 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 invs'
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
l : Nat
hl : l < k
invs' : Array (Inversion x)
IH' : ↑i < l ∨ ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < k
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[l] > x[k] then
      Array.push invs'
        { 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 invs'
Tactic:
cases Nat.eq_or_lt_of_le (Nat.le_of_succ_le_succ hjk) with
| inl heq =>
  cases heq
  have : i.1 ≤ l :=
    Nat.le_of_succ_le_succ (Or.resolve_right hil j.1.lt_irrefl)
  cases Nat.eq_or_lt_of_le this with
  | inl heq =>
    cases heq; rewrite [dif_pos hinv]
    exact Array.mem_push.mpr <| Or.inr rfl
  | inr hlt =>
    specialize IH' (Or.inl hlt)
    if hx : x[l]'(Nat.lt_trans hl j.2) > x[j.1] then
      rewrite [dif_pos hx]
      exact Array.mem_push.mpr <| Or.inl IH'
    else
      rewrite [dif_neg hx]; exact IH'
| inr hlt =>
  specialize IH' (Or.inr hlt)
  if hx : x[l]'(Nat.lt_trans hl hk) > x[k]'hk then
    rewrite [dif_pos hx]
    exact Array.mem_push.mpr <| Or.inl IH'
  else
    rewrite [dif_neg hx]; exact IH'
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
l : Nat
hl : l < k
invs' : Array (Inversion x)
IH' : ↑i < l ∨ ↑j < k → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < k
heq : ↑j = k
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[l] > x[k] then
      Array.push invs'
        { 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 invs'
Tactic:
cases heq
Proof state after:
case succ.refine_2.inl.refl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this : ↑i < ↑j
hl : l < ↑j
IH' : ↑i < l ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < ↑j
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inl.refl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this : ↑i < ↑j
hl : l < ↑j
IH' : ↑i < l ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < ↑j
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Tactic:
have : i.1 ≤ l :=
  Nat.le_of_succ_le_succ (Or.resolve_right hil j.1.lt_irrefl)
Proof state after:
case succ.refine_2.inl.refl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
IH' : ↑i < l ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inl.refl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
IH' : ↑i < l ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Tactic:
cases Nat.eq_or_lt_of_le this with
| inl heq =>
  cases heq; rewrite [dif_pos hinv]
  exact Array.mem_push.mpr <| Or.inr rfl
| inr hlt =>
  specialize IH' (Or.inl hlt)
  if hx : x[l]'(Nat.lt_trans hl j.2) > x[j.1] then
    rewrite [dif_pos hx]
    exact Array.mem_push.mpr <| Or.inl IH'
  else
    rewrite [dif_neg hx]; exact IH'
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inl.refl.inl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
IH' : ↑i < l ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
heq : ↑i = l
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Tactic:
cases heq
Proof state after:
case succ.refine_2.inl.refl.inl.refl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ hl : ↑i < ↑j
IH' : ↑i < ↑i ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < ↑i + 1 ∨ ↑j < ↑j
this : ↑i ≤ ↑i
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[↑i] > x[↑j] then
      Array.push invs'
        { fst := { val := ↑i, isLt := (_ : ↑i < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := ↑i, isLt := (_ : ↑i < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := ↑i, isLt := (_ : ↑i < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inl.refl.inl.refl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ hl : ↑i < ↑j
IH' : ↑i < ↑i ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < ↑i + 1 ∨ ↑j < ↑j
this : ↑i ≤ ↑i
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    if h : x[↑i] > x[↑j] then
      Array.push invs'
        { fst := { val := ↑i, isLt := (_ : ↑i < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := ↑i, isLt := (_ : ↑i < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := ↑i, isLt := (_ : ↑i < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Tactic:
rewrite [dif_pos hinv]
Proof state after:
case succ.refine_2.inl.refl.inl.refl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ hl : ↑i < ↑j
IH' : ↑i < ↑i ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < ↑i + 1 ∨ ↑j < ↑j
this : ↑i ≤ ↑i
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    Array.push invs'
      { fst := { val := ↑i, isLt := (_ : ↑i < n) }, snd := { val := ↑j, isLt := hk },
        lt := (_ : { val := ↑i, isLt := (_ : ↑i < n) } < { val := ↑j, isLt := hk }),
        inverted := (_ : x[↑{ val := ↑i, isLt := (_ : ↑i < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inl.refl.inl.refl
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt : i < j
hinv : x[↑i] > x[↑j]
invs invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ hl : ↑i < ↑j
IH' : ↑i < ↑i ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt, inverted := hinv } ∈ invs'
hil : ↑i < ↑i + 1 ∨ ↑j < ↑j
this : ↑i ≤ ↑i
⊢ { fst := i, snd := j, lt := hlt, inverted := hinv } ∈
    Array.push invs'
      { fst := { val := ↑i, isLt := (_ : ↑i < n) }, snd := { val := ↑j, isLt := hk },
        lt := (_ : { val := ↑i, isLt := (_ : ↑i < n) } < { val := ↑j, isLt := hk }),
        inverted := (_ : x[↑{ val := ↑i, isLt := (_ : ↑i < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
Tactic:
exact Array.mem_push.mpr <| Or.inr rfl
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inl.refl.inr
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
IH' : ↑i < l ∨ ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Tactic:
specialize IH' (Or.inl hlt)
Proof state after:
case succ.refine_2.inl.refl.inr
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inl.refl.inr
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Tactic:
if hx : x[l]'(Nat.lt_trans hl j.2) > x[j.1] then
  rewrite [dif_pos hx]
  exact Array.mem_push.mpr <| Or.inl IH'
else
  rewrite [dif_neg hx]; exact IH'
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
hx : x[l] > x[↑j]
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Tactic:
rewrite [dif_pos hx]
Proof state after:
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
hx : x[l] > x[↑j]
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    Array.push invs'
      { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
        lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
        inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
Theorem: Permutation.mem_inversions
Proof state before:
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
hx : x[l] > x[↑j]
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    Array.push invs'
      { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
        lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
        inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
Tactic:
exact Array.mem_push.mpr <| Or.inl IH'
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
hx : ¬x[l] > x[↑j]
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    if h : x[l] > x[↑j] then
      Array.push invs'
        { fst := { val := l, isLt := (_ : l < n) }, snd := { val := ↑j, isLt := hk },
          lt := (_ : { val := l, isLt := (_ : l < n) } < { val := ↑j, isLt := hk }),
          inverted := (_ : x[↑{ val := l, isLt := (_ : l < n) }] > x[↑{ val := ↑j, isLt := hk }]) }
    else invs'
Tactic:
rewrite [dif_neg hx]
Proof state after:
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
hx : ¬x[l] > x[↑j]
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
Theorem: Permutation.mem_inversions
Proof state before:
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
invs : Array (Inversion x)
l : Nat
invs' : Array (Inversion x)
hk : ↑j < n
IH : ↑j < ↑j → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < ↑j + 1
this✝ : ↑i < ↑j
hl : l < ↑j
hil : ↑i < l + 1 ∨ ↑j < ↑j
this : ↑i ≤ l
hlt : ↑i < l
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
hx : ¬x[l] > x[↑j]
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
Tactic:
exact IH'
Proof state after:
no goals
Theorem: Permutation.mem_inversions
Proof state before:
case succ.refine_2.inr
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
l : Nat
hl : l < k
invs' : Array (Inversion x)
IH' : ↑i < l ∨ ↑j < k → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
hil : ↑i < l + 1 ∨ ↑j < k
hlt : ↑j < k
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    if h : x[l] > x[k] then
      Array.push invs'
        { 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 invs'
Tactic:
specialize IH' (Or.inr hlt)
Proof state after:
case succ.refine_2.inr
n : Nat
x : Permutation n
iv : Inversion x
i j : Fin n
hlt✝ : i < j
hinv : x[↑i] > x[↑j]
k : Nat
hk : k < n
invs : Array (Inversion x)
IH : ↑j < k → { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs
hjk : ↑j < k + 1
this : ↑i < k
l : Nat
hl : l < k
invs' : Array (Inversion x)
hil : ↑i < l + 1 ∨ ↑j < k
hlt : ↑j < k
IH' : { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈ invs'
⊢ { fst := i, snd := j, lt := hlt✝, inverted := hinv } ∈
    if h : x[l] > x[k] then
      Array.push invs'
        { 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 invs'