Imports
/-
Copyright (c) 2025 Joseph Tooby-Smith. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Tooby-Smith
-/
module
public import Physlib.QFT.PerturbationTheory.WickContraction.ExtractEquivList of uncontracted elements of a Wick contraction
@[expose] public sectionSome properties of lists of fin
lemma fin_list_sorted_monotone_sorted {n m : ℕ} (l: List (Fin n)) (hl : l.Pairwise (· ≤ ·))
(f : Fin n → Fin m) (hf : StrictMono f) : (List.map f l).Pairwise (· ≤ ·) :=
hl.map f fun _ _ hab => hf.monotone hablemma fin_list_sorted_succAboveEmb_sorted (l: List (Fin n)) (hl : l.Pairwise (· ≤ ·))
(i : Fin n.succ) : ((List.map i.succAboveEmb l)).Pairwise (· ≤ ·) := n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin n.succ⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.map (⇑i.succAboveEmb) l)
n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin n.succ⊢ StrictMono ⇑i.succAboveEmb
All goals completed! 🐙n:ℕm:ℕa:Finset (Fin n)f:Fin n ↪ Fin mhf:StrictMono ⇑fh1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.map (⇑f) (a.sort fun x1 x2 => x1 ≤ x2))h2:(List.map (⇑f) (a.sort fun x1 x2 => x1 ≤ x2)).Noduph3:(List.map (⇑f) (a.sort fun x1 x2 => x1 ≤ x2)).toFinset = Finset.map f a⊢ List.map (⇑f) (a.sort fun x1 x2 => x1 ≤ x2) =
(List.map (⇑f) (a.sort fun x1 x2 => x1 ≤ x2)).toFinset.sort fun x1 x2 => x1 ≤ x2
exact ((List.toFinset_sort (· ≤ ·) h2).mpr h1).symm All goals completed! 🐙
lemma fin_list_sorted_split :
(l : List (Fin n)) → (hl : l.Pairwise (· ≤ ·)) → (i : ℕ) →
l = l.filter (fun x => x.1 < i) ++ l.filter (fun x => i ≤ x.1)
| [], _, _ => n:ℕx✝¹:List.Pairwise (fun x1 x2 => x1 ≤ x2) []x✝:ℕ⊢ [] = List.filter (fun x => decide (↑x < x✝)) [] ++ List.filter (fun x => decide (x✝ ≤ ↑x)) [] by n:ℕx✝¹:List.Pairwise (fun x1 x2 => x1 ≤ x2) []x✝:ℕ⊢ [] = List.filter (fun x => decide (↑x < x✝)) [] ++ List.filter (fun x => decide (x✝ ≤ ↑x)) [] simp All goals completed! 🐙
| a :: l, hl, i => n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:ℕ⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l) by n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:ℕ⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
simp only [List.pairwise_cons] at hl n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) l⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
by_cases ha : a < i pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < i⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
· pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l) conv_lhs => rw [fin_list_sorted_split l hl.2 i] n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i| a :: (List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) l)
rw [← List.cons_append pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ a :: List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) l =
List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l) pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ a :: List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) l =
List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)] pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ a :: List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) l =
List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
rw [List.filter_cons_of_pos, pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ a :: List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) l =
a :: List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ decide (↑a < i) = true pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ ¬decide (i ≤ ↑a) = truepos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ decide (↑a < i) = true List.filter_cons_of_neg pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ a :: List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) l =
a :: List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lpos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ ¬decide (i ≤ ↑a) = truepos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ decide (↑a < i) = truepos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ ¬decide (i ≤ ↑a) = truepos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ decide (↑a < i) = true]pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ ¬decide (i ≤ ↑a) = truepos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ decide (↑a < i) = true
simp only [decide_eq_true_eq, not_le, ha] pos n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:↑a < i⊢ decide (↑a < i) = true
simp [ha] All goals completed! 🐙
· neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < i⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l) have hx : List.filter (fun x => decide (x.1 < i)) (a :: l) = [] := by
simp only [ha, decide_false, Bool.false_eq_true, not_false_eq_true, List.filter_cons_of_neg,
List.filter_eq_nil_iff, decide_eq_true_eq, not_lt] n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < i⊢ ∀ a ∈ l, i ≤ ↑a neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
intro b hb n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ib:Fin nhb:b ∈ l⊢ i ≤ ↑bneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
have hb' := hl.1 b hb n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ib:Fin nhb:b ∈ lhb':a ≤ b⊢ i ≤ ↑bneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
omeganeg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
simp only [hx, List.nil_append] neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = List.filter (fun x => decide (i ≤ ↑x)) (a :: l)
rw [List.filter_cons_of_pos neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = a :: List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = a :: List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true]neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ a :: l = a :: List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
simp only [List.cons.injEq, true_and] neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
have hl' := fin_list_sorted_split l hl.2 i neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) l⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
have hx : List.filter (fun x => decide (x.1 < i)) l = [] := by n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:ℕ⊢ a :: l = List.filter (fun x => decide (↑x < i)) (a :: l) ++ List.filter (fun x => decide (i ≤ ↑x)) (a :: l) neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx✝:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lhx:List.filter (fun x => decide (↑x < i)) l = []⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
simp only [List.filter_eq_nil_iff, decide_eq_true_eq, not_lt] n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) l⊢ ∀ a ∈ l, i ≤ ↑aneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx✝:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lhx:List.filter (fun x => decide (↑x < i)) l = []⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
intro b hb n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lb:Fin nhb:b ∈ l⊢ i ≤ ↑bneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx✝:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lhx:List.filter (fun x => decide (↑x < i)) l = []⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
have hb' := hl.1 b hb n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lb:Fin nhb:b ∈ lhb':a ≤ b⊢ i ≤ ↑bneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx✝:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lhx:List.filter (fun x => decide (↑x < i)) l = []⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
omeganeg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx✝:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lhx:List.filter (fun x => decide (↑x < i)) l = []⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = trueneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx✝:List.filter (fun x => decide (↑x < i)) (a :: l) = []hl':l = List.filter (fun x => decide (↑x < i)) l ++ List.filter (fun x => decide (i ≤ ↑x)) lhx:List.filter (fun x => decide (↑x < i)) l = []⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
simp only [hx, List.nil_append] at hl' neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx✝:List.filter (fun x => decide (↑x < i)) (a :: l) = []hx:List.filter (fun x => decide (↑x < i)) l = []hl':l = List.filter (fun x => decide (i ≤ ↑x)) l⊢ l = List.filter (fun x => decide (i ≤ ↑x)) lneg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ decide (i ≤ ↑a) = true
conv_lhs => rw [hl'] n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx✝:List.filter (fun x => decide (↑x < i)) (a :: l) = []hx:List.filter (fun x => decide (↑x < i)) l = []hl':l = List.filter (fun x => decide (i ≤ ↑x)) l| List.filter (fun x => decide (i ≤ ↑x)) l
simp only [decide_eq_true_eq] neg n:ℕa:Fin nl:List (Fin n)i:ℕhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬↑a < ihx:List.filter (fun x => decide (↑x < i)) (a :: l) = []⊢ i ≤ ↑a
omega All goals completed! 🐙
lemma fin_list_sorted_indexOf_filter_le_mem :
(l : List (Fin n)) → (hl : l.Pairwise (· ≤ ·)) → (i : Fin n) →
(hl : i ∈ l) →
List.idxOf i (List.filter (fun x => decide (↑i ≤ ↑x)) l) = 0
| [], _, _, _ => n:ℕx✝²:List.Pairwise (fun x1 x2 => x1 ≤ x2) []x✝¹:Fin nx✝:x✝¹ ∈ []⊢ List.idxOf x✝¹ (List.filter (fun x => decide (x✝¹ ≤ x)) []) = 0 by n:ℕx✝²:List.Pairwise (fun x1 x2 => x1 ≤ x2) []x✝¹:Fin nx✝:x✝¹ ∈ []⊢ List.idxOf x✝¹ (List.filter (fun x => decide (x✝¹ ≤ x)) []) = 0 simp All goals completed! 🐙
| a :: l, hl, i, hi => n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:Fin nhi:i ∈ a :: l⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0 by n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:Fin nhi:i ∈ a :: l⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0
simp only [List.pairwise_cons] at hl n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) l⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0
by_cases ha : i ≤ a pos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ a⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0neg n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0
· pos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ a⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0 simp only [ha, decide_true, List.filter_cons_of_pos] pos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ a⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0
have ha : a = i := by n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:Fin nhi:i ∈ a :: l⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0 pos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aha:a = i⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0
simp only [List.mem_cons] at hi n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ahi:i = a ∨ i ∈ l⊢ a = i pos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aha:a = i⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0
rcases hi with rfl | hi inl n:ℕl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, i ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ i⊢ i = iinr n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ahi:i ∈ l⊢ a = ipos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aha:a = i⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0
· inl n:ℕl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, i ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ i⊢ i = ipos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aha:a = i⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0 rfl All goals completed! 🐙pos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aha:a = i⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0
· inr n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ahi:i ∈ l⊢ a = ipos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aha:a = i⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0 exact Fin.le_antisymm (hl.1 i hi) hapos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aha:a = i⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0pos n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aha:a = i⊢ List.idxOf i (a :: List.filter (fun x => decide (i ≤ x)) l) = 0
subst ha pos n:ℕa:Fin nl:List (Fin n)hl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lhi:a ∈ a :: lha:a ≤ a⊢ List.idxOf a (a :: List.filter (fun x => decide (a ≤ x)) l) = 0
simp All goals completed! 🐙
· neg n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0 simp only [not_le] at ha neg n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) (a :: l)) = 0
rw [List.filter_cons_of_neg (by n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ ¬decide (i ≤ a) = true neg n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) l) = 0 simpa using ha All goals completed! 🐙neg n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) l) = 0)]neg n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ List.idxOf i (List.filter (fun x => decide (i ≤ x)) l) = 0
rw [fin_list_sorted_indexOf_filter_le_mem l hl.2 neg n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ 0 = 0neg.hl n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ i ∈ l neg.hl n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ i ∈ l]neg.hl n:ℕa:Fin nl:List (Fin n)i:Fin nhi:i ∈ a :: lhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < i⊢ i ∈ l
simp only [List.mem_cons] at hi neg.hl n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < ihi:i = a ∨ i ∈ l⊢ i ∈ l
rcases hi with hi | hi neg.hl.inl n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < ihi:i = a⊢ i ∈ lneg.hl.inr n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < ihi:i ∈ l⊢ i ∈ l
· neg.hl.inl n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < ihi:i = a⊢ i ∈ l omega All goals completed! 🐙
· neg.hl.inr n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:a < ihi:i ∈ l⊢ i ∈ l exact hi All goals completed! 🐙
lemma fin_list_sorted_indexOf_mem :
(l : List (Fin n)) → (hl : l.Pairwise (· ≤ ·)) → (i : Fin n) →
(hi : i ∈ l) →
l.idxOf i = (l.filter (fun x => x.1 < i.1)).length := by n:ℕ⊢ ∀ (l : List (Fin n)),
List.Pairwise (fun x1 x2 => x1 ≤ x2) l → ∀ i ∈ l, List.idxOf i l = (List.filter (fun x => decide (↑x < ↑i)) l).length
intro l hl i hi n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ List.idxOf i l = (List.filter (fun x => decide (↑x < ↑i)) l).length
conv_lhs => rw [fin_list_sorted_split l hl i] n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l| List.idxOf i (List.filter (fun x => decide (↑x < ↑i)) l ++ List.filter (fun x => decide (↑i ≤ ↑x)) l)
rw [List.idxOf_append_of_notMem n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ (List.filter (fun x => decide (↑x < ↑i)) l).length + List.idxOf i (List.filter (fun x => decide (↑i ≤ ↑x)) l) =
(List.filter (fun x => decide (↑x < ↑i)) l).lengthn:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ i ∉ List.filter (fun x => decide (↑x < ↑i)) l n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ (List.filter (fun x => decide (↑x < ↑i)) l).length + List.idxOf i (List.filter (fun x => decide (↑i ≤ ↑x)) l) =
(List.filter (fun x => decide (↑x < ↑i)) l).lengthn:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ i ∉ List.filter (fun x => decide (↑x < ↑i)) l] n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ (List.filter (fun x => decide (↑x < ↑i)) l).length + List.idxOf i (List.filter (fun x => decide (↑i ≤ ↑x)) l) =
(List.filter (fun x => decide (↑x < ↑i)) l).lengthn:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ i ∉ List.filter (fun x => decide (↑x < ↑i)) l
· n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ (List.filter (fun x => decide (↑x < ↑i)) l).length + List.idxOf i (List.filter (fun x => decide (↑i ≤ ↑x)) l) =
(List.filter (fun x => decide (↑x < ↑i)) l).length erw [fin_list_sorted_indexOf_filter_le_mem l hl i hi n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ (List.filter (fun x => decide (↑x < ↑i)) l).length + 0 = (List.filter (fun x => decide (↑x < ↑i)) l).length] n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ (List.filter (fun x => decide (↑x < ↑i)) l).length + 0 = (List.filter (fun x => decide (↑x < ↑i)) l).length
simp All goals completed! 🐙
· n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nhi:i ∈ l⊢ i ∉ List.filter (fun x => decide (↑x < ↑i)) l simp All goals completed! 🐙
lemma orderedInsert_of_fin_list_sorted :
(l : List (Fin n)) → (hl : l.Pairwise (· ≤ ·)) → (i : Fin n) →
List.orderedInsert (· ≤ ·) i l = l.filter (fun x => x.1 < i.1) ++
i :: l.filter (fun x => i.1 ≤ x.1)
| [], _, _ => n:ℕx✝¹:List.Pairwise (fun x1 x2 => x1 ≤ x2) []x✝:Fin n⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) x✝ [] =
List.filter (fun x => decide (↑x < ↑x✝)) [] ++ x✝ :: List.filter (fun x => decide (↑x✝ ≤ ↑x)) [] by n:ℕx✝¹:List.Pairwise (fun x1 x2 => x1 ≤ x2) []x✝:Fin n⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) x✝ [] =
List.filter (fun x => decide (↑x < ↑x✝)) [] ++ x✝ :: List.filter (fun x => decide (↑x✝ ≤ ↑x)) [] simp All goals completed! 🐙
| a :: l, hl, i => n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:Fin n⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l) by n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:Fin n⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l)
simp only [List.pairwise_cons] at hl n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) l⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l)
by_cases ha : i ≤ a pos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ a⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l)neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l)
· pos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ a⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l) simp only [List.orderedInsert_cons, ha, ↓reduceIte, Fin.val_fin_lt, decide_eq_true_eq,
not_lt, List.filter_cons_of_neg, Fin.val_fin_le, decide_true, List.filter_cons_of_pos] pos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ a⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
have h1 : List.filter (fun x => decide (↑x < ↑i)) l = [] := by n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:Fin n⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l) pos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
simp only [List.filter_eq_nil_iff, decide_eq_true_eq, not_lt] n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ a⊢ ∀ a ∈ l, i ≤ a pos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
intro a ha n:ℕa✝:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aa:Fin nha:a ∈ l⊢ i ≤ apos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
have ha' := hl.1 a ha n:ℕa✝:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha✝:i ≤ aa:Fin nha:a ∈ lha':a✝ ≤ a⊢ i ≤ apos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
omegapos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) lpos n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
have hl : l = List.filter (fun x => decide (i ≤ x)) l := by n:ℕa:Fin nl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) (a :: l)i:Fin n⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l) pos n:ℕa:Fin nl:List (Fin n)i:Fin nhl✝:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []hl:l = List.filter (fun x => decide (i ≤ x)) l⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
conv_lhs => rw [fin_list_sorted_split l hl.2 i] n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []| List.filter (fun x => decide (↑x < ↑i)) l ++ List.filter (fun x => decide (↑i ≤ ↑x)) lpos n:ℕa:Fin nl:List (Fin n)i:Fin nhl✝:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []hl:l = List.filter (fun x => decide (i ≤ x)) l⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
simp [h1]pos n:ℕa:Fin nl:List (Fin n)i:Fin nhl✝:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []hl:l = List.filter (fun x => decide (i ≤ x)) l⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) lpos n:ℕa:Fin nl:List (Fin n)i:Fin nhl✝:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:i ≤ ah1:List.filter (fun x => decide (x < i)) l = []hl:l = List.filter (fun x => decide (i ≤ x)) l⊢ i :: a :: l = List.filter (fun x => decide (x < i)) l ++ i :: a :: List.filter (fun x => decide (i ≤ x)) l
simp [← hl, h1] All goals completed! 🐙
· neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (a :: l) =
List.filter (fun x => decide (↑x < ↑i)) (a :: l) ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) (a :: l) simp only [List.orderedInsert_cons, ha, ↓reduceIte, Fin.val_fin_lt, Fin.val_fin_le,
decide_false, Bool.false_eq_true, not_false_eq_true, List.filter_cons_of_neg] neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ a :: List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l =
List.filter (fun x => decide (x < i)) (a :: l) ++ i :: List.filter (fun x => decide (i ≤ x)) l
rw [List.filter_cons_of_pos neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ a :: List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l =
a :: List.filter (fun x => decide (x < i)) l ++ i :: List.filter (fun x => decide (i ≤ x)) lneg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ decide (a < i) = true neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ a :: List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l =
a :: List.filter (fun x => decide (x < i)) l ++ i :: List.filter (fun x => decide (i ≤ x)) lneg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ decide (a < i) = true]neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ a :: List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l =
a :: List.filter (fun x => decide (x < i)) l ++ i :: List.filter (fun x => decide (i ≤ x)) lneg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ decide (a < i) = true
rw [orderedInsert_of_fin_list_sorted l hl.2 i neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ a :: (List.filter (fun x => decide (↑x < ↑i)) l ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) l) =
a :: List.filter (fun x => decide (x < i)) l ++ i :: List.filter (fun x => decide (i ≤ x)) lneg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ decide (a < i) = true neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ a :: (List.filter (fun x => decide (↑x < ↑i)) l ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) l) =
a :: List.filter (fun x => decide (x < i)) l ++ i :: List.filter (fun x => decide (i ≤ x)) lneg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ decide (a < i) = true]neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ a :: (List.filter (fun x => decide (↑x < ↑i)) l ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) l) =
a :: List.filter (fun x => decide (x < i)) l ++ i :: List.filter (fun x => decide (i ≤ x)) lneg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ decide (a < i) = true
simp only [Fin.val_fin_lt, Fin.val_fin_le, List.cons_append] neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ decide (a < i) = true
simp only [decide_eq_true_eq] neg n:ℕa:Fin nl:List (Fin n)i:Fin nhl:(∀ a' ∈ l, a ≤ a') ∧ List.Pairwise (fun x1 x2 => x1 ≤ x2) lha:¬i ≤ a⊢ a < i
omega All goals completed! 🐙
lemma orderedInsert_eq_insertIdx_of_fin_list_sorted (l : List (Fin n)) (hl : l.Pairwise (· ≤ ·))
(i : Fin n) :
List.orderedInsert (· ≤ ·) i l = l.insertIdx (l.filter (fun x => x.1 < i.1)).length i := by n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin n⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l = l.insertIdx (List.filter (fun x => decide (↑x < ↑i)) l).length i
let n : Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, by n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin n⊢ (List.filter (fun x => decide (x < i)) l).length < l.length.succ n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l = l.insertIdx (List.filter (fun x => decide (↑x < ↑i)) l).length i
have h1 := l.length_filter_le (fun x => x.1 < i.1) n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nh1:(List.filter (fun x => decide (↑x < ↑i)) l).length ≤ l.length⊢ (List.filter (fun x => decide (x < i)) l).length < l.length.succ n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l = l.insertIdx (List.filter (fun x => decide (↑x < ↑i)) l).length i
simp only [Fin.val_fin_lt] at h1 n:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nh1:(List.filter (fun x => decide (x < i)) l).length ≤ l.length⊢ (List.filter (fun x => decide (x < i)) l).length < l.length.succ n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l = l.insertIdx (List.filter (fun x => decide (↑x < ↑i)) l).length i
omega All goals completed! 🐙 n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l = l.insertIdx (List.filter (fun x => decide (↑x < ↑i)) l).length i⟩ n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l = l.insertIdx (List.filter (fun x => decide (↑x < ↑i)) l).length i
simp only [Fin.val_fin_lt] n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i l = l.insertIdx (List.filter (fun x => decide (x < i)) l).length i
conv_rhs => rw [insertIdx_eq_take_drop _ _ n] n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩| List.take (↑n) l ++ i :: List.drop (↑n) l
rw [orderedInsert_of_fin_list_sorted l hl i n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.filter (fun x => decide (↑x < ↑i)) l ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) l =
List.take (↑n) l ++ i :: List.drop (↑n) l n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.filter (fun x => decide (↑x < ↑i)) l ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) l =
List.take (↑n) l ++ i :: List.drop (↑n) l] n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.filter (fun x => decide (↑x < ↑i)) l ++ i :: List.filter (fun x => decide (↑i ≤ ↑x)) l =
List.take (↑n) l ++ i :: List.drop (↑n) l
congr e_a n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.filter (fun x => decide (↑x < ↑i)) l = List.take (↑n) le_a.e_tail n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩⊢ List.filter (fun x => decide (↑i ≤ ↑x)) l = List.drop (↑n) l
all_goals
conv_rhs =>
rhs n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩| l
rw [fin_list_sorted_split l hl i] n✝:ℕl:List (Fin n)hl:List.Pairwise (fun x1 x2 => x1 ≤ x2) li:Fin nn:Fin l.length.succ := ⟨(List.filter (fun x => decide (x < i)) l).length, ⋯⟩| List.filter (fun x => decide (↑x < ↑i)) l ++ List.filter (fun x => decide (↑i ≤ ↑x)) l
simp [n] All goals completed! 🐙Uncontracted List
Given a Wick contraction c, the ordered list of elements of Fin n which are not contracted,
i.e. do not appear anywhere in c.1.
def uncontractedList : List (Fin n) := List.filter (fun x => x ∈ c.uncontracted) (List.finRange n)lemma uncontractedList_mem_iff (i : Fin n) :
i ∈ c.uncontractedList ↔ i ∈ c.uncontracted := by n:ℕc:WickContraction ni:Fin n⊢ i ∈ c.uncontractedList ↔ i ∈ c.uncontracted
simp [uncontractedList] All goals completed! 🐙@[simp]
lemma uncontractedList_empty : (empty (n := n)).uncontractedList = List.finRange n := by n:ℕ⊢ empty.uncontractedList = List.finRange n
simp [uncontractedList] All goals completed! 🐙lemma nil_zero_uncontractedList : (empty (n := 0)).uncontractedList = [] := by ⊢ empty.uncontractedList = []
simp [empty, uncontractedList] All goals completed! 🐙lemma congr_uncontractedList {n m : ℕ} (h : n = m) (c : WickContraction n) :
((congr h) c).uncontractedList = List.map (finCongr h) c.uncontractedList := by n:ℕm:ℕh:n = mc:WickContraction n⊢ ((congr h) c).uncontractedList = List.map (⇑(finCongr h)) c.uncontractedList
subst h n:ℕc:WickContraction n⊢ ((congr ⋯) c).uncontractedList = List.map (⇑(finCongr ⋯)) c.uncontractedList
simp [congr] All goals completed! 🐙lemma uncontractedList_get_mem_uncontracted (i : Fin c.uncontractedList.length) :
c.uncontractedList.get i ∈ c.uncontracted := by n:ℕc:WickContraction ni:Fin c.uncontractedList.length⊢ c.uncontractedList.get i ∈ c.uncontracted
simp [← uncontractedList_mem_iff] All goals completed! 🐙
lemma uncontractedList_sorted : List.Pairwise (· ≤ ·) c.uncontractedList := by n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) c.uncontractedList
rw [uncontractedList n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n)) n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n))] n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n))
apply List.Pairwise.filter n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.finRange n)
rw [← List.ofFn_id n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.ofFn id) n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.ofFn id)] n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.ofFn id)
exact List.pairwise_ofFn.mpr fun _ _ h => h.le All goals completed! 🐙
lemma uncontractedList_sorted_lt : List.Pairwise (· < ·) c.uncontractedList := by n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 < x2) c.uncontractedList
rw [uncontractedList n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 < x2) (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n)) n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 < x2) (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n))] n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 < x2) (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n))
apply List.Pairwise.filter n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 < x2) (List.finRange n)
rw [← List.ofFn_id n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 < x2) (List.ofFn id) n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 < x2) (List.ofFn id)] n:ℕc:WickContraction n⊢ List.Pairwise (fun x1 x2 => x1 < x2) (List.ofFn id)
exact List.pairwise_ofFn.mpr fun ⦃i j⦄ a => a All goals completed! 🐙
lemma uncontractedList_nodup : c.uncontractedList.Nodup := by n:ℕc:WickContraction n⊢ c.uncontractedList.Nodup
rw [uncontractedList n:ℕc:WickContraction n⊢ (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n)).Nodup n:ℕc:WickContraction n⊢ (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n)).Nodup] n:ℕc:WickContraction n⊢ (List.filter (fun x => decide (x ∈ c.uncontracted)) (List.finRange n)).Nodup
exact (List.nodup_finRange n).filter _ All goals completed! 🐙lemma uncontractedList_toFinset (c : WickContraction n) :
c.uncontractedList.toFinset = c.uncontracted := by n:ℕc:WickContraction n⊢ c.uncontractedList.toFinset = c.uncontracted
simp [uncontractedList] All goals completed! 🐙
lemma uncontractedList_eq_sort (c : WickContraction n) :
c.uncontractedList = c.uncontracted.sort (· ≤ ·) := by n:ℕc:WickContraction n⊢ c.uncontractedList = c.uncontracted.sort fun x1 x2 => x1 ≤ x2
symm n:ℕc:WickContraction n⊢ (c.uncontracted.sort fun x1 x2 => x1 ≤ x2) = c.uncontractedList
rw [← uncontractedList_toFinset n:ℕc:WickContraction n⊢ (c.uncontractedList.toFinset.sort fun x1 x2 => x1 ≤ x2) = c.uncontractedList n:ℕc:WickContraction n⊢ (c.uncontractedList.toFinset.sort fun x1 x2 => x1 ≤ x2) = c.uncontractedList] n:ℕc:WickContraction n⊢ (c.uncontractedList.toFinset.sort fun x1 x2 => x1 ≤ x2) = c.uncontractedList
exact (List.toFinset_sort (α := Fin n) (· ≤ ·) (uncontractedList_nodup c)).mpr
(uncontractedList_sorted c) All goals completed! 🐙
lemma uncontractedList_length_eq_card (c : WickContraction n) :
c.uncontractedList.length = c.uncontracted.card := by n:ℕc:WickContraction n⊢ c.uncontractedList.length = c.uncontracted.card
rw [uncontractedList_eq_sort, n:ℕc:WickContraction n⊢ (c.uncontracted.sort fun x1 x2 => x1 ≤ x2).length = c.uncontracted.card All goals completed! 🐙 Finset.length_sort n:ℕc:WickContraction n⊢ c.uncontracted.card = c.uncontracted.card All goals completed! 🐙] All goals completed! 🐙
lemma filter_uncontractedList (c : WickContraction n) (p : Fin n → Prop) [DecidablePred p] :
(c.uncontractedList.filter p) = (c.uncontracted.filter p).sort (· ≤ ·) := by n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred p⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2
have h1 : (c.uncontractedList.filter p).Pairwise (· ≤ ·) := (uncontractedList_sorted c).filter _ n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2
have h2 : (c.uncontractedList.filter p).Nodup := (uncontractedList_nodup c).filter _ n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Nodup⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2
have h3 : (c.uncontractedList.filter p).toFinset = c.uncontracted.filter p := by
ext a n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Nodupa:Fin n⊢ a ∈ (List.filter (fun b => decide (p b)) c.uncontractedList).toFinset ↔ a ∈ Finset.filter p c.uncontracted n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Noduph3:(List.filter (fun b => decide (p b)) c.uncontractedList).toFinset = Finset.filter p c.uncontracted⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2
simp only [List.toFinset_filter, decide_eq_true_eq, Finset.mem_filter, List.mem_toFinset,
and_congr_left_iff] n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Nodupa:Fin n⊢ p a → (a ∈ c.uncontractedList ↔ a ∈ c.uncontracted) n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Noduph3:(List.filter (fun b => decide (p b)) c.uncontractedList).toFinset = Finset.filter p c.uncontracted⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2
rw [uncontractedList_mem_iff n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Nodupa:Fin n⊢ p a → (a ∈ c.uncontracted ↔ a ∈ c.uncontracted) n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Nodupa:Fin n⊢ p a → (a ∈ c.uncontracted ↔ a ∈ c.uncontracted) n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Noduph3:(List.filter (fun b => decide (p b)) c.uncontractedList).toFinset = Finset.filter p c.uncontracted⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2] n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Nodupa:Fin n⊢ p a → (a ∈ c.uncontracted ↔ a ∈ c.uncontracted) n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Noduph3:(List.filter (fun b => decide (p b)) c.uncontractedList).toFinset = Finset.filter p c.uncontracted⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2
simp n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Noduph3:(List.filter (fun b => decide (p b)) c.uncontractedList).toFinset = Finset.filter p c.uncontracted⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2 n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Noduph3:(List.filter (fun b => decide (p b)) c.uncontractedList).toFinset = Finset.filter p c.uncontracted⊢ List.filter (fun b => decide (p b)) c.uncontractedList = (Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2
rw [← (List.toFinset_sort (· ≤ ·) h2).mpr h1, n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Noduph3:(List.filter (fun b => decide (p b)) c.uncontractedList).toFinset = Finset.filter p c.uncontracted⊢ ((List.filter (fun b => decide (p b)) c.uncontractedList).toFinset.sort fun x1 x2 => x1 ≤ x2) =
(Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2 All goals completed! 🐙 h3 n:ℕc:WickContraction np:Fin n → Propinst✝:DecidablePred ph1:List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.filter (fun b => decide (p b)) c.uncontractedList)h2:(List.filter (fun b => decide (p b)) c.uncontractedList).Noduph3:(List.filter (fun b => decide (p b)) c.uncontractedList).toFinset = Finset.filter p c.uncontracted⊢ ((Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2) =
(Finset.filter p c.uncontracted).sort fun x1 x2 => x1 ≤ x2 All goals completed! 🐙] All goals completed! 🐙uncontractedIndexEquiv
The equivalence between the positions of c.uncontractedList i.e. elements of
Fin (c.uncontractedList).length and the finite set c.uncontracted considered as a finite type.
def uncontractedIndexEquiv (c : WickContraction n) :
Fin (c.uncontractedList).length ≃ c.uncontracted where
toFun i := ⟨c.uncontractedList.get i, c.uncontractedList_get_mem_uncontracted i⟩
invFun i := ⟨List.idxOf i.1 c.uncontractedList,
List.idxOf_lt_length_iff.mpr ((c.uncontractedList_mem_iff i.1).mpr i.2)⟩
left_inv i := by 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction ni:Fin c.uncontractedList.length⊢ (fun i => ⟨List.idxOf (↑i) c.uncontractedList, ⋯⟩) ((fun i => ⟨c.uncontractedList.get i, ⋯⟩) i) = i
ext 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction ni:Fin c.uncontractedList.length⊢ ↑((fun i => ⟨List.idxOf (↑i) c.uncontractedList, ⋯⟩) ((fun i => ⟨c.uncontractedList.get i, ⋯⟩) i)) = ↑i
exact List.get_idxOf (uncontractedList_nodup c) _ All goals completed! 🐙
right_inv i := by 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction ni:↥c.uncontracted⊢ (fun i => ⟨c.uncontractedList.get i, ⋯⟩) ((fun i => ⟨List.idxOf (↑i) c.uncontractedList, ⋯⟩) i) = i
ext 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction ni:↥c.uncontracted⊢ ↑↑((fun i => ⟨c.uncontractedList.get i, ⋯⟩) ((fun i => ⟨List.idxOf (↑i) c.uncontractedList, ⋯⟩) i)) = ↑↑i
simp All goals completed! 🐙@[simp]
lemma uncontractedList_getElem_uncontractedIndexEquiv_symm (k : c.uncontracted) :
c.uncontractedList[(c.uncontractedIndexEquiv.symm k).val] = k := by n:ℕc:WickContraction nk:↥c.uncontracted⊢ c.uncontractedList[↑(c.uncontractedIndexEquiv.symm k)] = ↑k
simp [uncontractedIndexEquiv] All goals completed! 🐙
lemma uncontractedIndexEquiv_symm_eq_filter_length (k : c.uncontracted) :
(c.uncontractedIndexEquiv.symm k).val =
(List.filter (fun i => i < k.val) c.uncontractedList).length := by n:ℕc:WickContraction nk:↥c.uncontracted⊢ ↑(c.uncontractedIndexEquiv.symm k) = (List.filter (fun i => decide (i < ↑k)) c.uncontractedList).length
simp only [uncontractedIndexEquiv, List.get_eq_getElem, Equiv.coe_fn_symm_mk] n:ℕc:WickContraction nk:↥c.uncontracted⊢ List.idxOf (↑k) c.uncontractedList = (List.filter (fun i => decide (i < ↑k)) c.uncontractedList).length
rw [fin_list_sorted_indexOf_mem _ (uncontractedList_sorted c) _
((c.uncontractedList_mem_iff _).mpr k.2) n:ℕc:WickContraction nk:↥c.uncontracted⊢ (List.filter (fun x => decide (↑x < ↑↑k)) c.uncontractedList).length =
(List.filter (fun i => decide (i < ↑k)) c.uncontractedList).length n:ℕc:WickContraction nk:↥c.uncontracted⊢ (List.filter (fun x => decide (↑x < ↑↑k)) c.uncontractedList).length =
(List.filter (fun i => decide (i < ↑k)) c.uncontractedList).length] n:ℕc:WickContraction nk:↥c.uncontracted⊢ (List.filter (fun x => decide (↑x < ↑↑k)) c.uncontractedList).length =
(List.filter (fun i => decide (i < ↑k)) c.uncontractedList).length
simp All goals completed! 🐙
lemma take_uncontractedIndexEquiv_symm (k : c.uncontracted) :
c.uncontractedList.take (c.uncontractedIndexEquiv.symm k).val =
c.uncontractedList.filter (fun i => i < k.val) := by n:ℕc:WickContraction nk:↥c.uncontracted⊢ List.take (↑(c.uncontractedIndexEquiv.symm k)) c.uncontractedList =
List.filter (fun i => decide (i < ↑k)) c.uncontractedList
conv_lhs =>
rhs n:ℕc:WickContraction nk:↥c.uncontracted| c.uncontractedList
rw [fin_list_sorted_split c.uncontractedList (uncontractedList_sorted c) k.val] n:ℕc:WickContraction nk:↥c.uncontracted| List.filter (fun x => decide (↑x < ↑↑k)) c.uncontractedList ++
List.filter (fun x => decide (↑↑k ≤ ↑x)) c.uncontractedList
rw [uncontractedIndexEquiv_symm_eq_filter_length n:ℕc:WickContraction nk:↥c.uncontracted⊢ List.take (List.filter (fun i => decide (i < ↑k)) c.uncontractedList).length
(List.filter (fun x => decide (↑x < ↑↑k)) c.uncontractedList ++
List.filter (fun x => decide (↑↑k ≤ ↑x)) c.uncontractedList) =
List.filter (fun i => decide (i < ↑k)) c.uncontractedList n:ℕc:WickContraction nk:↥c.uncontracted⊢ List.take (List.filter (fun i => decide (i < ↑k)) c.uncontractedList).length
(List.filter (fun x => decide (↑x < ↑↑k)) c.uncontractedList ++
List.filter (fun x => decide (↑↑k ≤ ↑x)) c.uncontractedList) =
List.filter (fun i => decide (i < ↑k)) c.uncontractedList] n:ℕc:WickContraction nk:↥c.uncontracted⊢ List.take (List.filter (fun i => decide (i < ↑k)) c.uncontractedList).length
(List.filter (fun x => decide (↑x < ↑↑k)) c.uncontractedList ++
List.filter (fun x => decide (↑↑k ≤ ↑x)) c.uncontractedList) =
List.filter (fun i => decide (i < ↑k)) c.uncontractedList
simp All goals completed! 🐙Uncontracted List get
Given a Wick Contraction φsΛ of a list φs of 𝓕.FieldOp. The list
φsΛ.uncontractedListGet of 𝓕.FieldOp is defined as the list φs with
all contracted positions removed, leaving the uncontracted 𝓕.FieldOp.
The notation [φsΛ]ᵘᶜ is used for φsΛ.uncontractedListGet.
def uncontractedListGet {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) :
List 𝓕.FieldOp := φsΛ.uncontractedList.map φs.get@[inherit_doc uncontractedListGet]
scoped[WickContraction] notation "[" φsΛ "]ᵘᶜ" => uncontractedListGet φsΛ@[simp]
lemma uncontractedListGet_empty {φs : List 𝓕.FieldOp} :
(empty (n := φs.length)).uncontractedListGet = φs := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOp⊢ [empty]ᵘᶜ = φs
simp [uncontractedListGet] All goals completed! 🐙uncontractedFieldOpEquiv
The equivalence between the type Option c.uncontracted for WickContraction φs.length and
Option (Fin (c.uncontractedList.map φs.get).length), that is optional positions of
c.uncontractedList.map φs.get induced by uncontractedIndexEquiv.
def uncontractedFieldOpEquiv (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) :
Option φsΛ.uncontracted ≃ Option (Fin [φsΛ]ᵘᶜ.length) :=
Equiv.optionCongr (φsΛ.uncontractedIndexEquiv.symm.trans
(finCongr (by 𝓕:FieldSpecificationn:ℕc:WickContraction nφs:List 𝓕.FieldOpφsΛ:WickContraction φs.length⊢ φsΛ.uncontractedList.length = [φsΛ]ᵘᶜ.length simp [uncontractedListGet] All goals completed! 🐙)))@[simp]
lemma uncontractedFieldOpEquiv_none (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) :
(uncontractedFieldOpEquiv φs φsΛ).toFun none = none := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.length⊢ (uncontractedFieldOpEquiv φs φsΛ).toFun none = none
simp [uncontractedFieldOpEquiv] All goals completed! 🐙
lemma uncontractedFieldOpEquiv_list_sum [AddCommMonoid α] (φs : List 𝓕.FieldOp)
(φsΛ : WickContraction φs.length) (f : Option (Fin [φsΛ]ᵘᶜ.length) → α) :
∑ (i : Option (Fin [φsΛ]ᵘᶜ.length)), f i =
∑ (i : Option φsΛ.uncontracted), f (φsΛ.uncontractedFieldOpEquiv φs i) := by 𝓕:FieldSpecificationα:Type u_1inst✝:AddCommMonoid αφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthf:Option (Fin [φsΛ]ᵘᶜ.length) → α⊢ ∑ i, f i = ∑ i, f ((uncontractedFieldOpEquiv φs φsΛ) i)
rw [(φsΛ.uncontractedFieldOpEquiv φs).sum_comp 𝓕:FieldSpecificationα:Type u_1inst✝:AddCommMonoid αφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthf:Option (Fin [φsΛ]ᵘᶜ.length) → α⊢ ∑ i, f i = ∑ i, f i All goals completed! 🐙] All goals completed! 🐙uncontractedListEmd
The embedding of Fin [φsΛ]ᵘᶜ.length into Fin φs.length.
def uncontractedListEmd {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length} :
Fin [φsΛ]ᵘᶜ.length ↪ Fin φs.length := ((finCongr (by 𝓕:FieldSpecificationn:ℕc:WickContraction nφs:List 𝓕.FieldOpφsΛ:WickContraction φs.length⊢ [φsΛ]ᵘᶜ.length = φsΛ.uncontractedList.length simp [uncontractedListGet] All goals completed! 🐙)).trans
φsΛ.uncontractedIndexEquiv).toEmbedding.trans
(Function.Embedding.subtype fun x => x ∈ φsΛ.uncontracted)lemma uncontractedListEmd_congr {φs : List 𝓕.FieldOp} {φsΛ φsΛ' : WickContraction φs.length}
(h : φsΛ = φsΛ') : φsΛ.uncontractedListEmd =
(finCongr (by 𝓕:FieldSpecificationn:ℕc:WickContraction nφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthφsΛ':WickContraction φs.lengthh:φsΛ = φsΛ'⊢ [φsΛ]ᵘᶜ.length = [φsΛ']ᵘᶜ.length simp [h] All goals completed! 🐙)).toEmbedding.trans φsΛ'.uncontractedListEmd := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthφsΛ':WickContraction φs.lengthh:φsΛ = φsΛ'⊢ uncontractedListEmd = (finCongr ⋯).toEmbedding.trans uncontractedListEmd
subst h 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.length⊢ uncontractedListEmd = (finCongr ⋯).toEmbedding.trans uncontractedListEmd
rfl All goals completed! 🐙lemma uncontractedListEmd_toFun_eq_get (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) :
(uncontractedListEmd (φsΛ := φsΛ)).toFun =
φsΛ.uncontractedList.get ∘ (finCongr (by 𝓕:FieldSpecificationn:ℕc:WickContraction nφs:List 𝓕.FieldOpφsΛ:WickContraction φs.length⊢ [φsΛ]ᵘᶜ.length = φsΛ.uncontractedList.length simp [uncontractedListGet] All goals completed! 🐙)) := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.length⊢ uncontractedListEmd.toFun = φsΛ.uncontractedList.get ∘ ⇑(finCongr ⋯)
rfl All goals completed! 🐙lemma uncontractedListEmd_strictMono {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length}
{i j : Fin [φsΛ]ᵘᶜ.length} (h : i < j) : uncontractedListEmd i < uncontractedListEmd j := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin [φsΛ]ᵘᶜ.lengthj:Fin [φsΛ]ᵘᶜ.lengthh:i < j⊢ uncontractedListEmd i < uncontractedListEmd j
simp only [uncontractedListEmd, uncontractedIndexEquiv, List.get_eq_getElem,
Equiv.trans_toEmbedding, Function.Embedding.trans_apply, Equiv.coe_toEmbedding, finCongr_apply,
Equiv.coe_fn_mk, Fin.val_cast, Function.Embedding.coe_subtype] 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin [φsΛ]ᵘᶜ.lengthj:Fin [φsΛ]ᵘᶜ.lengthh:i < j⊢ φsΛ.uncontractedList[↑i] < φsΛ.uncontractedList[↑j]
exact φsΛ.uncontractedList_sorted_lt.sortedLT.strictMono_get h All goals completed! 🐙lemma uncontractedListEmd_mem_uncontracted {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length}
(i : Fin [φsΛ]ᵘᶜ.length) : uncontractedListEmd i ∈ φsΛ.uncontracted := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin [φsΛ]ᵘᶜ.length⊢ uncontractedListEmd i ∈ φsΛ.uncontracted
simp [uncontractedListEmd] All goals completed! 🐙lemma uncontractedListEmd_surjective_mem_uncontracted {φs : List 𝓕.FieldOp}
{φsΛ : WickContraction φs.length} (i : Fin φs.length) (hi : i ∈ φsΛ.uncontracted) :
∃ j, φsΛ.uncontractedListEmd j = i := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin φs.lengthhi:i ∈ φsΛ.uncontracted⊢ ∃ j, uncontractedListEmd j = i
simp only [uncontractedListEmd, Equiv.trans_toEmbedding, Function.Embedding.trans_apply,
Equiv.coe_toEmbedding, finCongr_apply, Function.Embedding.coe_subtype] 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin φs.lengthhi:i ∈ φsΛ.uncontracted⊢ ∃ j, ↑(φsΛ.uncontractedIndexEquiv (Fin.cast ⋯ j)) = i
have hj : ∃ j, φsΛ.uncontractedIndexEquiv j = ⟨i, hi⟩ :=
φsΛ.uncontractedIndexEquiv.surjective ⟨i, hi⟩ 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin φs.lengthhi:i ∈ φsΛ.uncontractedhj:∃ j, φsΛ.uncontractedIndexEquiv j = ⟨i, hi⟩⊢ ∃ j, ↑(φsΛ.uncontractedIndexEquiv (Fin.cast ⋯ j)) = i
generalize_proofs h1 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin φs.lengthhi:i ∈ φsΛ.uncontractedhj:∃ j, φsΛ.uncontractedIndexEquiv j = ⟨i, hi⟩h1:[φsΛ]ᵘᶜ.length = φsΛ.uncontractedList.length⊢ ∃ j, ↑(φsΛ.uncontractedIndexEquiv (Fin.cast h1 j)) = i
obtain ⟨j, hj⟩ := hj 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin φs.lengthhi:i ∈ φsΛ.uncontractedh1:[φsΛ]ᵘᶜ.length = φsΛ.uncontractedList.lengthj:Fin φsΛ.uncontractedList.lengthhj:φsΛ.uncontractedIndexEquiv j = ⟨i, hi⟩⊢ ∃ j, ↑(φsΛ.uncontractedIndexEquiv (Fin.cast h1 j)) = i
obtain ⟨j', rfl⟩ := (finCongr h1).surjective j 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin φs.lengthhi:i ∈ φsΛ.uncontractedh1:[φsΛ]ᵘᶜ.length = φsΛ.uncontractedList.lengthj':Fin [φsΛ]ᵘᶜ.lengthhj:φsΛ.uncontractedIndexEquiv ((finCongr h1) j') = ⟨i, hi⟩⊢ ∃ j, ↑(φsΛ.uncontractedIndexEquiv (Fin.cast h1 j)) = i
use j' h 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin φs.lengthhi:i ∈ φsΛ.uncontractedh1:[φsΛ]ᵘᶜ.length = φsΛ.uncontractedList.lengthj':Fin [φsΛ]ᵘᶜ.lengthhj:φsΛ.uncontractedIndexEquiv ((finCongr h1) j') = ⟨i, hi⟩⊢ ↑(φsΛ.uncontractedIndexEquiv (Fin.cast h1 j')) = i
erw [hj h 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthi:Fin φs.lengthhi:i ∈ φsΛ.uncontractedh1:[φsΛ]ᵘᶜ.length = φsΛ.uncontractedList.lengthj':Fin [φsΛ]ᵘᶜ.lengthhj:φsΛ.uncontractedIndexEquiv ((finCongr h1) j') = ⟨i, hi⟩⊢ ↑⟨i, hi⟩ = i] All goals completed! 🐙
@[simp]
lemma uncontractedListEmd_finset_disjoint_left {φs : List 𝓕.FieldOp}
{φsΛ : WickContraction φs.length} (a : Finset (Fin [φsΛ]ᵘᶜ.length))
(b : Finset (Fin φs.length)) (hb : b ∈ φsΛ.1) : Disjoint (a.map uncontractedListEmd) b := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛ⊢ Disjoint (Finset.map uncontractedListEmd a) b
rw [Finset.disjoint_left 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛ⊢ ∀ ⦃a_1 : Fin φs.length⦄, a_1 ∈ Finset.map uncontractedListEmd a → a_1 ∉ b 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛ⊢ ∀ ⦃a_1 : Fin φs.length⦄, a_1 ∈ Finset.map uncontractedListEmd a → a_1 ∉ b] 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛ⊢ ∀ ⦃a_1 : Fin φs.length⦄, a_1 ∈ Finset.map uncontractedListEmd a → a_1 ∉ b
intro x hx 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛx:Fin φs.lengthhx:x ∈ Finset.map uncontractedListEmd a⊢ x ∉ b
simp only [Finset.mem_map] at hx 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛx:Fin φs.lengthhx:∃ a_1 ∈ a, uncontractedListEmd a_1 = x⊢ x ∉ b
obtain ⟨x, hx, rfl⟩ := hx 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛx:Fin [φsΛ]ᵘᶜ.lengthhx:x ∈ a⊢ uncontractedListEmd x ∉ b
have h1 := uncontractedListEmd_mem_uncontracted x 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛx:Fin [φsΛ]ᵘᶜ.lengthhx:x ∈ ah1:uncontractedListEmd x ∈ φsΛ.uncontracted⊢ uncontractedListEmd x ∉ b
rw [mem_uncontracted_iff_not_contracted 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛx:Fin [φsΛ]ᵘᶜ.lengthhx:x ∈ ah1:∀ p ∈ ↑φsΛ, uncontractedListEmd x ∉ p⊢ uncontractedListEmd x ∉ b 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛx:Fin [φsΛ]ᵘᶜ.lengthhx:x ∈ ah1:∀ p ∈ ↑φsΛ, uncontractedListEmd x ∉ p⊢ uncontractedListEmd x ∉ b] at h1 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)b:Finset (Fin φs.length)hb:b ∈ ↑φsΛx:Fin [φsΛ]ᵘᶜ.lengthhx:x ∈ ah1:∀ p ∈ ↑φsΛ, uncontractedListEmd x ∉ p⊢ uncontractedListEmd x ∉ b
exact h1 b hb All goals completed! 🐙lemma uncontractedListEmd_finset_not_mem {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length}
(a : Finset (Fin [φsΛ]ᵘᶜ.length)) :
a.map uncontractedListEmd ∉ φsΛ.1 := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)⊢ Finset.map uncontractedListEmd a ∉ ↑φsΛ
by_contra hn 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)hn:Finset.map uncontractedListEmd a ∈ ↑φsΛ⊢ False
have h1 := uncontractedListEmd_finset_disjoint_left a (a.map uncontractedListEmd) hn 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)hn:Finset.map uncontractedListEmd a ∈ ↑φsΛh1:Disjoint (Finset.map uncontractedListEmd a) (Finset.map uncontractedListEmd a)⊢ False
simp only [disjoint_self, Finset.bot_eq_empty, Finset.map_eq_empty] at h1 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)hn:Finset.map uncontractedListEmd a ∈ ↑φsΛh1:a = ∅⊢ False
have h2 := φsΛ.2.1 (a.map uncontractedListEmd) hn 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengtha:Finset (Fin [φsΛ]ᵘᶜ.length)hn:Finset.map uncontractedListEmd a ∈ ↑φsΛh1:a = ∅h2:(Finset.map uncontractedListEmd a).card = 2⊢ False
simp [h1] at h2 All goals completed! 🐙@[simp]
lemma getElem_uncontractedListEmd {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length}
(k : Fin [φsΛ]ᵘᶜ.length) : φs[(uncontractedListEmd k).1] = [φsΛ]ᵘᶜ[k.1] := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthk:Fin [φsΛ]ᵘᶜ.length⊢ φs[↑(uncontractedListEmd k)] = [φsΛ]ᵘᶜ[↑k]
simp only [uncontractedListGet, List.getElem_map, List.get_eq_getElem] 𝓕:FieldSpecificationφs:List 𝓕.FieldOpφsΛ:WickContraction φs.lengthk:Fin [φsΛ]ᵘᶜ.length⊢ φs[↑(uncontractedListEmd k)] = φs[↑φsΛ.uncontractedList[↑k]]
rfl All goals completed! 🐙@[simp]
lemma uncontractedListEmd_empty {φs : List 𝓕.FieldOp} :
(empty (n := φs.length)).uncontractedListEmd = (finCongr (by 𝓕:FieldSpecificationn:ℕc:WickContraction nφs:List 𝓕.FieldOp⊢ [empty]ᵘᶜ.length = φs.length simp All goals completed! 🐙)).toEmbedding := by 𝓕:FieldSpecificationφs:List 𝓕.FieldOp⊢ uncontractedListEmd = (finCongr ⋯).toEmbedding
ext x 𝓕:FieldSpecificationφs:List 𝓕.FieldOpx:Fin [empty]ᵘᶜ.length⊢ ↑(uncontractedListEmd x) = ↑((finCongr ⋯).toEmbedding x)
simp [uncontractedListEmd, uncontractedIndexEquiv] All goals completed! 🐙Uncontracted List for extractEquiv symm none
lemma uncontractedList_succAboveEmb_sorted (c : WickContraction n) (i : Fin n.succ) :
((List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := by n:ℕc:WickContraction ni:Fin n.succ⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.map (⇑i.succAboveEmb) c.uncontractedList)
exact fin_list_sorted_succAboveEmb_sorted _ (uncontractedList_sorted c) i All goals completed! 🐙lemma uncontractedList_succAboveEmb_nodup (c : WickContraction n) (i : Fin n.succ) :
((List.map i.succAboveEmb c.uncontractedList)).Nodup := by n:ℕc:WickContraction ni:Fin n.succ⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).Nodup
exact (uncontractedList_nodup c).map i.succAboveEmb.injective All goals completed! 🐙lemma uncontractedList_succAbove_orderedInsert_nodup (c : WickContraction n) (i : Fin n.succ) :
(List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).Nodup := by n:ℕc:WickContraction ni:Fin n.succ⊢ (List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).Nodup
apply (List.perm_orderedInsert (· ≤ ·) i _).symm.nodup n:ℕc:WickContraction ni:Fin n.succ⊢ (i :: List.map (⇑i.succAboveEmb) c.uncontractedList).Nodup
simp only [Nat.succ_eq_add_one, List.nodup_cons, List.mem_map, not_exists, not_and] n:ℕc:WickContraction ni:Fin n.succ⊢ (∀ x ∈ c.uncontractedList, ¬i.succAboveEmb x = i) ∧ (List.map (⇑i.succAboveEmb) c.uncontractedList).Nodup
exact ⟨fun x _ => Fin.succAbove_ne i x, uncontractedList_succAboveEmb_nodup c i⟩ All goals completed! 🐙lemma uncontractedList_succAbove_orderedInsert_sorted (c : WickContraction n) (i : Fin n.succ) :
(List.orderedInsert (· ≤ ·) i
(List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := by n:ℕc:WickContraction ni:Fin n.succ⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2)
(List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList))
exact List.Pairwise.orderedInsert i _ (uncontractedList_succAboveEmb_sorted c i) All goals completed! 🐙
lemma uncontractedList_succAbove_orderedInsert_toFinset (c : WickContraction n) (i : Fin n.succ) :
(List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).toFinset =
(Insert.insert i (Finset.map i.succAboveEmb c.uncontracted)) := by n:ℕc:WickContraction ni:Fin n.succ⊢ (List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).toFinset =
insert i (Finset.map i.succAboveEmb c.uncontracted)
ext a n:ℕc:WickContraction ni:Fin n.succa:Fin n.succ⊢ a ∈ (List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).toFinset ↔
a ∈ insert i (Finset.map i.succAboveEmb c.uncontracted)
rw [← uncontractedList_toFinset n:ℕc:WickContraction ni:Fin n.succa:Fin n.succ⊢ a ∈ (List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).toFinset ↔
a ∈ insert i (Finset.map i.succAboveEmb c.uncontractedList.toFinset) n:ℕc:WickContraction ni:Fin n.succa:Fin n.succ⊢ a ∈ (List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).toFinset ↔
a ∈ insert i (Finset.map i.succAboveEmb c.uncontractedList.toFinset)] n:ℕc:WickContraction ni:Fin n.succa:Fin n.succ⊢ a ∈ (List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).toFinset ↔
a ∈ insert i (Finset.map i.succAboveEmb c.uncontractedList.toFinset)
simp All goals completed! 🐙
lemma uncontractedList_succAbove_orderedInsert_eq_sort (c : WickContraction n) (i : Fin n.succ) :
(List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)) =
(Insert.insert i (Finset.map i.succAboveEmb c.uncontracted)).sort (· ≤ ·) := by n:ℕc:WickContraction ni:Fin n.succ⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList) =
(insert i (Finset.map i.succAboveEmb c.uncontracted)).sort fun x1 x2 => x1 ≤ x2
rw [← uncontractedList_succAbove_orderedInsert_toFinset n:ℕc:WickContraction ni:Fin n.succ⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList) =
(List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).toFinset.sort
fun x1 x2 => x1 ≤ x2 n:ℕc:WickContraction ni:Fin n.succ⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList) =
(List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).toFinset.sort
fun x1 x2 => x1 ≤ x2] n:ℕc:WickContraction ni:Fin n.succ⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList) =
(List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)).toFinset.sort
fun x1 x2 => x1 ≤ x2
exact ((List.toFinset_sort (α := Fin n.succ) (· ≤ ·)
(uncontractedList_succAbove_orderedInsert_nodup c i)).mpr
(uncontractedList_succAbove_orderedInsert_sorted c i)).symm All goals completed! 🐙
lemma uncontractedList_extractEquiv_symm_none (c : WickContraction n) (i : Fin n.succ) :
((extractEquiv i).symm ⟨c, none⟩).uncontractedList =
List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList) := by n:ℕc:WickContraction ni:Fin n.succ⊢ ((extractEquiv i).symm ⟨c, none⟩).uncontractedList =
List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList)
rw [uncontractedList_eq_sort, n:ℕc:WickContraction ni:Fin n.succ⊢ (((extractEquiv i).symm ⟨c, none⟩).uncontracted.sort fun x1 x2 => x1 ≤ x2) =
List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList) All goals completed! 🐙 extractEquiv_symm_none_uncontracted, n:ℕc:WickContraction ni:Fin n.succ⊢ ((insert i (Finset.map i.succAboveEmb c.uncontracted)).sort fun x1 x2 => x1 ≤ x2) =
List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList) All goals completed! 🐙
uncontractedList_succAbove_orderedInsert_eq_sort n:ℕc:WickContraction ni:Fin n.succ⊢ ((insert i (Finset.map i.succAboveEmb c.uncontracted)).sort fun x1 x2 => x1 ≤ x2) =
(insert i (Finset.map i.succAboveEmb c.uncontracted)).sort fun x1 x2 => x1 ≤ x2 All goals completed! 🐙] All goals completed! 🐙Uncontracted List for extractEquiv symm some
lemma uncontractedList_succAboveEmb_eraseIdx_toFinset (c : WickContraction n) (i : Fin n.succ)
(k : ℕ) (hk : k < c.uncontractedList.length) :
((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).toFinset =
(c.uncontracted.map i.succAboveEmb).erase (i.succAboveEmb c.uncontractedList[k]) := by n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.length⊢ ((List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k).toFinset =
(Finset.map i.succAboveEmb c.uncontracted).erase (i.succAboveEmb c.uncontractedList[k])
ext a n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ a ∈ ((List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k).toFinset ↔
a ∈ (Finset.map i.succAboveEmb c.uncontracted).erase (i.succAboveEmb c.uncontractedList[k])
simp only [Fin.coe_succAboveEmb, List.mem_toFinset, Fin.succAboveEmb_apply, Finset.mem_erase,
ne_eq, Finset.mem_map] n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ a ∈ (List.map i.succAbove c.uncontractedList).eraseIdx k ↔
¬a = i.succAbove c.uncontractedList[k] ∧ ∃ a_1 ∈ c.uncontracted, i.succAbove a_1 = a
rw [mem_eraseIdx_nodup _ _ _ (by n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ k < (List.map i.succAbove c.uncontractedList).length n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ a ∈ List.map i.succAbove c.uncontractedList ∧ a ≠ (List.map i.succAbove c.uncontractedList)[k] ↔
¬a = i.succAbove c.uncontractedList[k] ∧ ∃ a_1 ∈ c.uncontracted, i.succAbove a_1 = an:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ (List.map i.succAbove c.uncontractedList).Nodup simpa using hk All goals completed! 🐙 n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ a ∈ List.map i.succAbove c.uncontractedList ∧ a ≠ (List.map i.succAbove c.uncontractedList)[k] ↔
¬a = i.succAbove c.uncontractedList[k] ∧ ∃ a_1 ∈ c.uncontracted, i.succAbove a_1 = an:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ (List.map i.succAbove c.uncontractedList).Nodup)] n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ a ∈ List.map i.succAbove c.uncontractedList ∧ a ≠ (List.map i.succAbove c.uncontractedList)[k] ↔
¬a = i.succAbove c.uncontractedList[k] ∧ ∃ a_1 ∈ c.uncontracted, i.succAbove a_1 = an:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ (List.map i.succAbove c.uncontractedList).Nodup
· n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ a ∈ List.map i.succAbove c.uncontractedList ∧ a ≠ (List.map i.succAbove c.uncontractedList)[k] ↔
¬a = i.succAbove c.uncontractedList[k] ∧ ∃ a_1 ∈ c.uncontracted, i.succAbove a_1 = a simp only [List.mem_map, List.getElem_map, ne_eq, uncontractedList_mem_iff] n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ (∃ a_1 ∈ c.uncontracted, i.succAbove a_1 = a) ∧ ¬a = i.succAbove c.uncontractedList[k] ↔
¬a = i.succAbove c.uncontractedList[k] ∧ ∃ a_1 ∈ c.uncontracted, i.succAbove a_1 = a
tauto All goals completed! 🐙
· n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.lengtha:Fin (n + 1)⊢ (List.map i.succAbove c.uncontractedList).Nodup exact uncontractedList_succAboveEmb_nodup c i All goals completed! 🐙lemma uncontractedList_succAboveEmb_eraseIdx_sorted (c : WickContraction n) (i : Fin n.succ)
(k: ℕ) : ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Pairwise (· ≤ ·) := by n:ℕc:WickContraction ni:Fin n.succk:ℕ⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) ((List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k)
apply Physlib.List.eraseIdx_sorted n:ℕc:WickContraction ni:Fin n.succk:ℕ⊢ List.Pairwise (fun x1 x2 => x1 ≤ x2) (List.map (⇑i.succAboveEmb) c.uncontractedList)
exact uncontractedList_succAboveEmb_sorted c i All goals completed! 🐙lemma uncontractedList_succAboveEmb_eraseIdx_nodup (c : WickContraction n) (i : Fin n.succ) (k: ℕ) :
((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Nodup := by n:ℕc:WickContraction ni:Fin n.succk:ℕ⊢ ((List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k).Nodup
exact (uncontractedList_succAboveEmb_nodup c i).eraseIdx k All goals completed! 🐙
lemma uncontractedList_succAboveEmb_eraseIdx_eq_sort (c : WickContraction n) (i : Fin n.succ)
(k : ℕ) (hk : k < c.uncontractedList.length) :
((List.map i.succAboveEmb c.uncontractedList).eraseIdx k) =
((c.uncontracted.map i.succAboveEmb).erase
(i.succAboveEmb c.uncontractedList[k])).sort (· ≤ ·) := by n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.length⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k =
((Finset.map i.succAboveEmb c.uncontracted).erase (i.succAboveEmb c.uncontractedList[k])).sort fun x1 x2 => x1 ≤ x2
rw [← uncontractedList_succAboveEmb_eraseIdx_toFinset n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.length⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k =
((List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k).toFinset.sort fun x1 x2 => x1 ≤ x2 n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.length⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k =
((List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k).toFinset.sort fun x1 x2 => x1 ≤ x2] n:ℕc:WickContraction ni:Fin n.succk:ℕhk:k < c.uncontractedList.length⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k =
((List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx k).toFinset.sort fun x1 x2 => x1 ≤ x2
exact ((List.toFinset_sort (α := Fin n.succ) (· ≤ ·)
(uncontractedList_succAboveEmb_eraseIdx_nodup c i k)).mpr
(uncontractedList_succAboveEmb_eraseIdx_sorted c i k)).symm All goals completed! 🐙
lemma uncontractedList_extractEquiv_symm_some (c : WickContraction n) (i : Fin n.succ)
(k : c.uncontracted) : ((extractEquiv i).symm ⟨c, some k⟩).uncontractedList =
((c.uncontractedList).map i.succAboveEmb).eraseIdx (c.uncontractedIndexEquiv.symm k) := by n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ ((extractEquiv i).symm ⟨c, some k⟩).uncontractedList =
(List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx ↑(c.uncontractedIndexEquiv.symm k)
rw [uncontractedList_eq_sort, n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ (((extractEquiv i).symm ⟨c, some k⟩).uncontracted.sort fun x1 x2 => x1 ≤ x2) =
(List.map (⇑i.succAboveEmb) c.uncontractedList).eraseIdx ↑(c.uncontractedIndexEquiv.symm k) n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ (((extractEquiv i).symm ⟨c, some k⟩).uncontracted.sort fun x1 x2 => x1 ≤ x2) =
((Finset.map i.succAboveEmb c.uncontracted).erase
(i.succAboveEmb c.uncontractedList[↑(c.uncontractedIndexEquiv.symm k)])).sort
fun x1 x2 => x1 ≤ x2hk n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ ↑(c.uncontractedIndexEquiv.symm k) < c.uncontractedList.length uncontractedList_succAboveEmb_eraseIdx_eq_sort n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ (((extractEquiv i).symm ⟨c, some k⟩).uncontracted.sort fun x1 x2 => x1 ≤ x2) =
((Finset.map i.succAboveEmb c.uncontracted).erase
(i.succAboveEmb c.uncontractedList[↑(c.uncontractedIndexEquiv.symm k)])).sort
fun x1 x2 => x1 ≤ x2hk n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ ↑(c.uncontractedIndexEquiv.symm k) < c.uncontractedList.length n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ (((extractEquiv i).symm ⟨c, some k⟩).uncontracted.sort fun x1 x2 => x1 ≤ x2) =
((Finset.map i.succAboveEmb c.uncontracted).erase
(i.succAboveEmb c.uncontractedList[↑(c.uncontractedIndexEquiv.symm k)])).sort
fun x1 x2 => x1 ≤ x2hk n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ ↑(c.uncontractedIndexEquiv.symm k) < c.uncontractedList.length] n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ (((extractEquiv i).symm ⟨c, some k⟩).uncontracted.sort fun x1 x2 => x1 ≤ x2) =
((Finset.map i.succAboveEmb c.uncontracted).erase
(i.succAboveEmb c.uncontractedList[↑(c.uncontractedIndexEquiv.symm k)])).sort
fun x1 x2 => x1 ≤ x2hk n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ ↑(c.uncontractedIndexEquiv.symm k) < c.uncontractedList.length
swap hk n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ ↑(c.uncontractedIndexEquiv.symm k) < c.uncontractedList.lengthn:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ (((extractEquiv i).symm ⟨c, some k⟩).uncontracted.sort fun x1 x2 => x1 ≤ x2) =
((Finset.map i.succAboveEmb c.uncontracted).erase
(i.succAboveEmb c.uncontractedList[↑(c.uncontractedIndexEquiv.symm k)])).sort
fun x1 x2 => x1 ≤ x2
simp only [Fin.is_lt] n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ (((extractEquiv i).symm ⟨c, some k⟩).uncontracted.sort fun x1 x2 => x1 ≤ x2) =
((Finset.map i.succAboveEmb c.uncontracted).erase
(i.succAboveEmb c.uncontractedList[↑(c.uncontractedIndexEquiv.symm k)])).sort
fun x1 x2 => x1 ≤ x2
congr e_s n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ ((extractEquiv i).symm ⟨c, some k⟩).uncontracted =
(Finset.map i.succAboveEmb c.uncontracted).erase
(i.succAboveEmb c.uncontractedList[↑(c.uncontractedIndexEquiv.symm k)])
simp only [Nat.succ_eq_add_one, extractEquiv, Equiv.coe_fn_symm_mk,
uncontractedList_getElem_uncontractedIndexEquiv_symm, Fin.succAboveEmb_apply] e_s n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ (c.insertAndContractNat i (some k)).uncontracted = (Finset.map i.succAboveEmb c.uncontracted).erase (i.succAbove ↑k)
rw [insertAndContractNat_some_uncontracted e_s n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ Finset.map i.succAboveEmb (c.uncontracted.erase ↑k) = (Finset.map i.succAboveEmb c.uncontracted).erase (i.succAbove ↑k) e_s n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ Finset.map i.succAboveEmb (c.uncontracted.erase ↑k) = (Finset.map i.succAboveEmb c.uncontracted).erase (i.succAbove ↑k)]e_s n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracted⊢ Finset.map i.succAboveEmb (c.uncontracted.erase ↑k) = (Finset.map i.succAboveEmb c.uncontracted).erase (i.succAbove ↑k)
ext a e_s n:ℕc:WickContraction ni:Fin n.succk:↥c.uncontracteda:Fin (n + 1)⊢ a ∈ Finset.map i.succAboveEmb (c.uncontracted.erase ↑k) ↔
a ∈ (Finset.map i.succAboveEmb c.uncontracted).erase (i.succAbove ↑k)
simp All goals completed! 🐙
lemma uncontractedList_succAboveEmb_toFinset (c : WickContraction n) (i : Fin n.succ) :
(List.map i.succAboveEmb c.uncontractedList).toFinset =
(Finset.map i.succAboveEmb c.uncontracted) := by n:ℕc:WickContraction ni:Fin n.succ⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).toFinset = Finset.map i.succAboveEmb c.uncontracted
ext a n:ℕc:WickContraction ni:Fin n.succa:Fin (n + 1)⊢ a ∈ (List.map (⇑i.succAboveEmb) c.uncontractedList).toFinset ↔ a ∈ Finset.map i.succAboveEmb c.uncontracted
rw [← c.uncontractedList_toFinset n:ℕc:WickContraction ni:Fin n.succa:Fin (n + 1)⊢ a ∈ (List.map (⇑i.succAboveEmb) c.uncontractedList).toFinset ↔ a ∈ Finset.map i.succAboveEmb c.uncontractedList.toFinset n:ℕc:WickContraction ni:Fin n.succa:Fin (n + 1)⊢ a ∈ (List.map (⇑i.succAboveEmb) c.uncontractedList).toFinset ↔ a ∈ Finset.map i.succAboveEmb c.uncontractedList.toFinset] n:ℕc:WickContraction ni:Fin n.succa:Fin (n + 1)⊢ a ∈ (List.map (⇑i.succAboveEmb) c.uncontractedList).toFinset ↔ a ∈ Finset.map i.succAboveEmb c.uncontractedList.toFinset
simp All goals completed! 🐙uncontractedListOrderPos
Given a Wick contraction c : WickContraction n and a Fin n.succ, the number of elements
of c.uncontractedList which are less than i.
Suppose we want to insert into c at position i, then this is the position we would
need to insert into c.uncontractedList.
def uncontractedListOrderPos (c : WickContraction n) (i : Fin n.succ) : ℕ :=
(List.filter (fun x => x.1 < i.1) c.uncontractedList).length@[simp]
lemma uncontractedListOrderPos_le_length (c : WickContraction n) (i : Fin n.succ) :
c.uncontractedListOrderPos i ≤ c.uncontractedList.length := by n:ℕc:WickContraction ni:Fin n.succ⊢ c.uncontractedListOrderPos i ≤ c.uncontractedList.length
simpa only [uncontractedListOrderPos] using
c.uncontractedList.length_filter_le fun x => x.1 < i.1 All goals completed! 🐙lemma take_uncontractedListOrderPos_eq_filter (c : WickContraction n) (i : Fin n.succ) :
(c.uncontractedList.take (c.uncontractedListOrderPos i)) =
c.uncontractedList.filter (fun x => x.1 < i.1) := by n:ℕc:WickContraction ni:Fin n.succ⊢ List.take (c.uncontractedListOrderPos i) c.uncontractedList = List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList
nth_rewrite 1 [fin_list_sorted_split c.uncontractedList (uncontractedList_sorted c) i] n:ℕc:WickContraction ni:Fin n.succ⊢ List.take (c.uncontractedListOrderPos i)
(List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList ++
List.filter (fun x => decide (↑i ≤ ↑x)) c.uncontractedList) =
List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList
simp only [uncontractedListOrderPos, Nat.succ_eq_add_one, List.take_left'] All goals completed! 🐙
lemma take_uncontractedListOrderPos_eq_filter_sort (c : WickContraction n) (i : Fin n.succ) :
(c.uncontractedList.take (c.uncontractedListOrderPos i)) =
(c.uncontracted.filter (fun x => x.1 < i.1)).sort (· ≤ ·) := by n:ℕc:WickContraction ni:Fin n.succ⊢ List.take (c.uncontractedListOrderPos i) c.uncontractedList = {x ∈ c.uncontracted | ↑x < ↑i}.sort fun x1 x2 => x1 ≤ x2
rw [take_uncontractedListOrderPos_eq_filter n:ℕc:WickContraction ni:Fin n.succ⊢ List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList = {x ∈ c.uncontracted | ↑x < ↑i}.sort fun x1 x2 => x1 ≤ x2 n:ℕc:WickContraction ni:Fin n.succ⊢ List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList = {x ∈ c.uncontracted | ↑x < ↑i}.sort fun x1 x2 => x1 ≤ x2] n:ℕc:WickContraction ni:Fin n.succ⊢ List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList = {x ∈ c.uncontracted | ↑x < ↑i}.sort fun x1 x2 => x1 ≤ x2
exact filter_uncontractedList c fun x => x.1 < i.1 All goals completed! 🐙
lemma orderedInsert_succAboveEmb_uncontractedList_eq_insertIdx (c : WickContraction n)
(i : Fin n.succ) :
(List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)) =
(List.map i.succAboveEmb c.uncontractedList).insertIdx (uncontractedListOrderPos c i) i := by n:ℕc:WickContraction ni:Fin n.succ⊢ List.orderedInsert (fun x1 x2 => x1 ≤ x2) i (List.map (⇑i.succAboveEmb) c.uncontractedList) =
(List.map (⇑i.succAboveEmb) c.uncontractedList).insertIdx (c.uncontractedListOrderPos i) i
rw [orderedInsert_eq_insertIdx_of_fin_list_sorted _ (uncontractedList_succAboveEmb_sorted c i) n:ℕc:WickContraction ni:Fin n.succ⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).insertIdx
(List.filter (fun x => decide (↑x < ↑i)) (List.map (⇑i.succAboveEmb) c.uncontractedList)).length i =
(List.map (⇑i.succAboveEmb) c.uncontractedList).insertIdx (c.uncontractedListOrderPos i) i n:ℕc:WickContraction ni:Fin n.succ⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).insertIdx
(List.filter (fun x => decide (↑x < ↑i)) (List.map (⇑i.succAboveEmb) c.uncontractedList)).length i =
(List.map (⇑i.succAboveEmb) c.uncontractedList).insertIdx (c.uncontractedListOrderPos i) i] n:ℕc:WickContraction ni:Fin n.succ⊢ (List.map (⇑i.succAboveEmb) c.uncontractedList).insertIdx
(List.filter (fun x => decide (↑x < ↑i)) (List.map (⇑i.succAboveEmb) c.uncontractedList)).length i =
(List.map (⇑i.succAboveEmb) c.uncontractedList).insertIdx (c.uncontractedListOrderPos i) i
congr 1 e_i n:ℕc:WickContraction ni:Fin n.succ⊢ (List.filter (fun x => decide (↑x < ↑i)) (List.map (⇑i.succAboveEmb) c.uncontractedList)).length =
c.uncontractedListOrderPos i
simp only [Nat.succ_eq_add_one, Fin.val_fin_lt, Fin.coe_succAboveEmb, uncontractedListOrderPos] e_i n:ℕc:WickContraction ni:Fin n.succ⊢ (List.filter (fun x => decide (x < i)) (List.map i.succAbove c.uncontractedList)).length =
(List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList).length
rw [List.filter_map e_i n:ℕc:WickContraction ni:Fin n.succ⊢ (List.map i.succAbove (List.filter ((fun x => decide (x < i)) ∘ i.succAbove) c.uncontractedList)).length =
(List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList).length e_i n:ℕc:WickContraction ni:Fin n.succ⊢ (List.map i.succAbove (List.filter ((fun x => decide (x < i)) ∘ i.succAbove) c.uncontractedList)).length =
(List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList).length]e_i n:ℕc:WickContraction ni:Fin n.succ⊢ (List.map i.succAbove (List.filter ((fun x => decide (x < i)) ∘ i.succAbove) c.uncontractedList)).length =
(List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList).length
simp only [List.length_map] e_i n:ℕc:WickContraction ni:Fin n.succ⊢ (List.filter ((fun x => decide (x < i)) ∘ i.succAbove) c.uncontractedList).length =
(List.filter (fun x => decide (↑x < ↑i)) c.uncontractedList).length
congr e_i.e_p n:ℕc:WickContraction ni:Fin n.succ⊢ (fun x => decide (x < i)) ∘ i.succAbove = fun x => decide (↑x < ↑i)
funext x e_i.e_p n:ℕc:WickContraction ni:Fin n.succx:Fin n⊢ ((fun x => decide (x < i)) ∘ i.succAbove) x = decide (↑x < ↑i)
simp only [Function.comp_apply, Fin.succAbove, decide_eq_decide] e_i.e_p n:ℕc:WickContraction ni:Fin n.succx:Fin n⊢ (if x.castSucc < i then x.castSucc else x.succ) < i ↔ ↑x < ↑i
split e_i.e_p.isTrue n:ℕc:WickContraction ni:Fin n.succx:Fin nh✝:x.castSucc < i⊢ x.castSucc < i ↔ ↑x < ↑ie_i.e_p.isFalse n:ℕc:WickContraction ni:Fin n.succx:Fin nh✝:¬x.castSucc < i⊢ x.succ < i ↔ ↑x < ↑i
· e_i.e_p.isTrue n:ℕc:WickContraction ni:Fin n.succx:Fin nh✝:x.castSucc < i⊢ x.castSucc < i ↔ ↑x < ↑i simp only [Fin.lt_def, Fin.val_castSucc] All goals completed! 🐙
· e_i.e_p.isFalse n:ℕc:WickContraction ni:Fin n.succx:Fin nh✝:¬x.castSucc < i⊢ x.succ < i ↔ ↑x < ↑i rename_i h e_i.e_p.isFalse n:ℕc:WickContraction ni:Fin n.succx:Fin nh:¬x.castSucc < i⊢ x.succ < i ↔ ↑x < ↑i
simp_all only [Fin.lt_def, Fin.val_castSucc, not_lt, Fin.val_succ] e_i.e_p.isFalse n:ℕc:WickContraction ni:Fin n.succx:Fin nh:↑i ≤ ↑x⊢ ↑x + 1 < ↑i ↔ ↑x < ↑i
omega All goals completed! 🐙