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
meta import Physlib.QFT.PerturbationTheory.WickContraction.InsertAndContractNat
public import Physlib.QFT.PerturbationTheory.WickContraction.InsertAndContractNat
import all Init.Data.Fin.FoldEquivalence extracting element from contraction
@[expose] public sectionAll goals completed! 🐙) c2.2) : c1 = c2 := by n:ℕc1:(c : WickContraction n) × Option ↥c.uncontractedc2:(c : WickContraction n) × Option ↥c.uncontractedh:c1.fst = c2.fstho:c1.snd = (uncontractedCongr ⋯) c2.snd⊢ c1 = c2
cases c1 mk n:ℕc2:(c : WickContraction n) × Option ↥c.uncontractedfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontractedh:⟨fst✝, snd✝⟩.fst = c2.fstho:⟨fst✝, snd✝⟩.snd = (uncontractedCongr ⋯) c2.snd⊢ ⟨fst✝, snd✝⟩ = c2
cases c2 mk.mk n:ℕfst✝¹:WickContraction nsnd✝¹:Option ↥fst✝.uncontractedfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontractedh:⟨fst✝¹, snd✝¹⟩.fst = ⟨fst✝, snd✝⟩.fstho:⟨fst✝¹, snd✝¹⟩.snd = (uncontractedCongr ⋯) ⟨fst✝, snd✝⟩.snd⊢ ⟨fst✝¹, snd✝¹⟩ = ⟨fst✝, snd✝⟩
simp_all only [Sigma.mk.inj_iff] mk.mk n:ℕfst✝¹:WickContraction nsnd✝¹:Option ↥fst✝.uncontractedfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontractedh:⟨fst✝¹, snd✝¹⟩.fst = ⟨fst✝, snd✝⟩.fstho:snd✝¹ = (uncontractedCongr ⋯) snd✝⊢ fst✝¹ = fst✝ ∧ (uncontractedCongr ⋯) snd✝ ≍ snd✝
simp only at h mk.mk n:ℕfst✝¹:WickContraction nsnd✝¹:Option ↥fst✝.uncontractedfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontractedh:fst✝¹ = fst✝ho:snd✝¹ = (uncontractedCongr ⋯) snd✝⊢ fst✝¹ = fst✝ ∧ (uncontractedCongr ⋯) snd✝ ≍ snd✝
subst h mk.mk n:ℕfst✝:WickContraction nsnd✝¹:Option ↥fst✝.uncontractedsnd✝:Option ↥fst✝.uncontractedho:snd✝¹ = (uncontractedCongr ⋯) snd✝⊢ fst✝ = fst✝ ∧ (uncontractedCongr ⋯) snd✝ ≍ snd✝
simp only [uncontractedCongr, Equiv.optionCongr_apply, heq_eq_eq, true_and] mk.mk n:ℕfst✝:WickContraction nsnd✝¹:Option ↥fst✝.uncontractedsnd✝:Option ↥fst✝.uncontractedho:snd✝¹ = (uncontractedCongr ⋯) snd✝⊢ Option.map (⇑(Equiv.subtypeEquivRight ⋯)) snd✝ = snd✝
rename_i a mk.mk n:ℕfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontracteda:Option ↥fst✝.uncontractedho:snd✝¹ = (uncontractedCongr ⋯) snd✝⊢ Option.map (⇑(Equiv.subtypeEquivRight ⋯)) snd✝ = snd✝
match a with
| none => n:ℕfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontracteda:Option ↥fst✝.uncontractedho:snd✝ = (uncontractedCongr ⋯) none⊢ Option.map (⇑(Equiv.subtypeEquivRight ⋯)) none = none simp All goals completed! 🐙
| some a => n:ℕfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontracteda✝:Option ↥fst✝.uncontracteda:↥fst✝.uncontractedho:snd✝ = (uncontractedCongr ⋯) (some a)⊢ Option.map (⇑(Equiv.subtypeEquivRight ⋯)) (some a) = some a
simp only [Option.map_some, Option.some.injEq] n:ℕfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontracteda✝:Option ↥fst✝.uncontracteda:↥fst✝.uncontractedho:snd✝ = (uncontractedCongr ⋯) (some a)⊢ (Equiv.subtypeEquivRight ⋯) a = a
ext n:ℕfst✝:WickContraction nsnd✝:Option ↥fst✝.uncontracteda✝:Option ↥fst✝.uncontracteda:↥fst✝.uncontractedho:snd✝ = (uncontractedCongr ⋯) (some a)⊢ ↑↑((Equiv.subtypeEquivRight ⋯) a) = ↑↑a
simp All goals completed! 🐙
The equivalence between WickContraction n.succ and the sigma type
(c : WickContraction n) × Option c.uncontracted formed by inserting
and erasing elements from a contraction.
def extractEquiv (i : Fin n.succ) : WickContraction n.succ ≃
(c : WickContraction n) × Option c.uncontracted where
toFun := fun c => ⟨erase c i, getDualErase c i⟩
invFun := fun ⟨c, j⟩ => insertAndContractNat c i j
left_inv f := by 𝓕:FieldSpecificationn:ℕc:WickContraction ni:Fin n.succf:WickContraction n.succ⊢ (fun x =>
match x with
| ⟨c, j⟩ => c.insertAndContractNat i j)
((fun c => ⟨c.erase i, c.getDualErase i⟩) f) =
f
simp All goals completed! 🐙
right_inv f := by 𝓕:FieldSpecificationn:ℕc:WickContraction ni:Fin n.succf:(c : WickContraction n) × Option ↥c.uncontracted⊢ (fun c => ⟨c.erase i, c.getDualErase i⟩)
((fun x =>
match x with
| ⟨c, j⟩ => c.insertAndContractNat i j)
f) =
f
refine extractEquiv_equiv ?_ ?_ refine_1 𝓕:FieldSpecificationn:ℕc:WickContraction ni:Fin n.succf:(c : WickContraction n) × Option ↥c.uncontracted⊢ ((fun c => ⟨c.erase i, c.getDualErase i⟩)
((fun x =>
match x with
| ⟨c, j⟩ => c.insertAndContractNat i j)
f)).fst =
f.fstrefine_2 𝓕:FieldSpecificationn:ℕc:WickContraction ni:Fin n.succf:(c : WickContraction n) × Option ↥c.uncontracted⊢ ((fun c => ⟨c.erase i, c.getDualErase i⟩)
((fun x =>
match x with
| ⟨c, j⟩ => c.insertAndContractNat i j)
f)).snd =
(uncontractedCongr ⋯) f.snd
simp only [insertAndContractNat_erase] refine_2 𝓕:FieldSpecificationn:ℕc:WickContraction ni:Fin n.succf:(c : WickContraction n) × Option ↥c.uncontracted⊢ ((fun c => ⟨c.erase i, c.getDualErase i⟩)
((fun x =>
match x with
| ⟨c, j⟩ => c.insertAndContractNat i j)
f)).snd =
(uncontractedCongr ⋯) f.snd
simp only [Nat.succ_eq_add_one] refine_2 𝓕:FieldSpecificationn:ℕc:WickContraction ni:Fin n.succf:(c : WickContraction n) × Option ↥c.uncontracted⊢ (f.fst.insertAndContractNat i f.snd).getDualErase i = (uncontractedCongr ⋯) f.snd
have h1 := insertAndContractNat_getDualErase f.fst i f.snd refine_2 𝓕:FieldSpecificationn:ℕc:WickContraction ni:Fin n.succf:(c : WickContraction n) × Option ↥c.uncontractedh1:(f.fst.insertAndContractNat i f.snd).getDualErase i = (uncontractedCongr ⋯) f.snd⊢ (f.fst.insertAndContractNat i f.snd).getDualErase i = (uncontractedCongr ⋯) f.snd
exact insertAndContractNat_getDualErase _ i _ All goals completed! 🐙lemma extractEquiv_symm_none_uncontracted (i : Fin n.succ) (c : WickContraction n) :
((extractEquiv i).symm ⟨c, none⟩).uncontracted =
(Insert.insert i (c.uncontracted.map i.succAboveEmb)) := by n:ℕi:Fin n.succc:WickContraction n⊢ ((extractEquiv i).symm ⟨c, none⟩).uncontracted = insert i (Finset.map i.succAboveEmb c.uncontracted)
exact insertAndContractNat_none_uncontracted c i All goals completed! 🐙
@[simp]
lemma extractEquiv_apply_congr_symm_apply {n m : ℕ} (k : ℕ)
(hnk : k < n.succ) (hkm : k < m.succ) (hnm : n = m) (c : WickContraction n)
(i : c.uncontracted) : congr (by 𝓕:FieldSpecificationn✝:ℕc✝:WickContraction n✝n:ℕm:ℕk:ℕhnk:k < n.succhkm:k < m.succhnm:n = mc:WickContraction ni:↥c.uncontracted⊢ m = n rw [hnm 𝓕:FieldSpecificationn✝:ℕc✝:WickContraction n✝n:ℕm:ℕk:ℕhnk:k < n.succhkm:k < m.succhnm:n = mc:WickContraction ni:↥c.uncontracted⊢ m = m All goals completed! 🐙] All goals completed! 🐙) ((extractEquiv ⟨k, hkm⟩
(congr (by 𝓕:FieldSpecificationn✝:ℕc✝:WickContraction n✝n:ℕm:ℕk:ℕhnk:k < n.succhkm:k < m.succhnm:n = mc:WickContraction ni:↥c.uncontracted⊢ n.succ = m.succ rw [hnm 𝓕:FieldSpecificationn✝:ℕc✝:WickContraction n✝n:ℕm:ℕk:ℕhnk:k < n.succhkm:k < m.succhnm:n = mc:WickContraction ni:↥c.uncontracted⊢ m.succ = m.succ All goals completed! 🐙] All goals completed! 🐙) ((extractEquiv ⟨k, hnk⟩).symm ⟨c, i⟩)))).1 = c := by n:ℕm:ℕk:ℕhnk:k < n.succhkm:k < m.succhnm:n = mc:WickContraction ni:↥c.uncontracted⊢ (congr ⋯) ((extractEquiv ⟨k, hkm⟩) ((congr ⋯) ((extractEquiv ⟨k, hnk⟩).symm ⟨c, some i⟩))).fst = c
subst hnm n:ℕk:ℕhnk:k < n.succc:WickContraction ni:↥c.uncontractedhkm:k < n.succ⊢ (congr ⋯) ((extractEquiv ⟨k, hkm⟩) ((congr ⋯) ((extractEquiv ⟨k, hnk⟩).symm ⟨c, some i⟩))).fst = c
simp All goals completed! 🐙
The fintype instance of WickContraction 0 defined through its single
element empty.
instance fintype_zero : Fintype (WickContraction 0) where
elems := {empty}
complete := by 𝓕:FieldSpecificationn:ℕc:WickContraction n⊢ ∀ (x : WickContraction 0), x ∈ {empty}
intro c 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0⊢ c ∈ {empty}
simp only [Finset.mem_singleton] 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0⊢ c = empty
apply Subtype.ext 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0⊢ ↑c = ↑empty
simp only [empty] 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0⊢ ↑c = ∅
ext a 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)⊢ a ∈ ↑c ↔ a ∈ ∅
apply Iff.intro mp 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)⊢ a ∈ ↑c → a ∈ ∅mpr 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)⊢ a ∈ ∅ → a ∈ ↑c
· mp 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)⊢ a ∈ ↑c → a ∈ ∅ intro h mp 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)h:a ∈ ↑c⊢ a ∈ ∅
have hc := c.2.1 a h mp 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)h:a ∈ ↑chc:a.card = 2⊢ a ∈ ∅
rw [Finset.card_eq_two mp 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)h:a ∈ ↑chc:∃ x y, x ≠ y ∧ a = {x, y}⊢ a ∈ ∅ mp 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)h:a ∈ ↑chc:∃ x y, x ≠ y ∧ a = {x, y}⊢ a ∈ ∅] at hc mp 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)h:a ∈ ↑chc:∃ x y, x ≠ y ∧ a = {x, y}⊢ a ∈ ∅
obtain ⟨x, y, hxy, ha⟩ := hc mp 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)h:a ∈ ↑cx:Fin 0y:Fin 0hxy:x ≠ yha:a = {x, y}⊢ a ∈ ∅
exact Fin.elim0 x All goals completed! 🐙
· mpr 𝓕:FieldSpecificationn:ℕc✝:WickContraction nc:WickContraction 0a:Finset (Fin 0)⊢ a ∈ ∅ → a ∈ ↑c simp All goals completed! 🐙
lemma sum_WickContraction_nil (f : WickContraction 0 → M) [AddCommMonoid M] :
∑ c, f c = f empty := by M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ ∑ c, f c = f empty
rw [Finset.sum_eq_single_of_mem M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ f ?a = f emptya M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ WickContraction 0h M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ ?a ∈ Finset.univh₀ M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ ∀ b ∈ Finset.univ, b ≠ ?a → f b = 0 h M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ empty ∈ Finset.univh₀ M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ ∀ b ∈ Finset.univ, b ≠ empty → f b = 0] h M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ empty ∈ Finset.univh₀ M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ ∀ b ∈ Finset.univ, b ≠ empty → f b = 0
simp only [Finset.mem_univ] h₀ M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid M⊢ ∀ b ∈ Finset.univ, b ≠ empty → f b = 0
intro b hb h₀ M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid Mb:WickContraction 0hb:b ∈ Finset.univ⊢ b ≠ empty → f b = 0
fin_cases b h₀.«0» M:Type u_1f:WickContraction 0 → Minst✝:AddCommMonoid Mhb:empty ∈ Finset.univ⊢ empty ≠ empty → f empty = 0
simp All goals completed! 🐙
The fintype instance of WickContraction n, for n.succ this is defined
through the equivalence extractEquiv.
instance fintype_succ : (n : ℕ) → Fintype (WickContraction n)
| 0 => fintype_zero
| Nat.succ n => 𝓕:FieldSpecificationn✝:ℕc:WickContraction n✝n:ℕ⊢ Fintype (WickContraction n.succ) by 𝓕:FieldSpecificationn✝:ℕc:WickContraction n✝n:ℕ⊢ Fintype (WickContraction n.succ)
letI := fintype_succ n 𝓕:FieldSpecificationn✝:ℕc:WickContraction n✝n:ℕthis:Fintype (WickContraction n) := fintype_succ n⊢ Fintype (WickContraction n.succ)
exact Fintype.ofEquiv _ (extractEquiv 0).symm All goals completed! 🐙
lemma sum_extractEquiv_congr [AddCommMonoid M] {n m : ℕ} (i : Fin n) (f : WickContraction n → M)
(h : n = m.succ) :
∑ c, f c = ∑ (c : WickContraction m), ∑ (k : Option c.uncontracted),
f (congr h.symm ((extractEquiv (finCongr h i)).symm ⟨c, k⟩)) := by M:Type u_1inst✝:AddCommMonoid Mn:ℕm:ℕi:Fin nf:WickContraction n → Mh:n = m.succ⊢ ∑ c, f c = ∑ c, ∑ k, f ((congr ⋯) ((extractEquiv ((finCongr h) i)).symm ⟨c, k⟩))
subst h M:Type u_1inst✝:AddCommMonoid Mm:ℕi:Fin m.succf:WickContraction m.succ → M⊢ ∑ c, f c = ∑ c, ∑ k, f ((congr ⋯) ((extractEquiv ((finCongr ⋯) i)).symm ⟨c, k⟩))
simp only [finCongr_refl, Equiv.refl_apply, congr_refl] M:Type u_1inst✝:AddCommMonoid Mm:ℕi:Fin m.succf:WickContraction m.succ → M⊢ ∑ c, f c = ∑ x, ∑ x_1, f ((extractEquiv i).symm ⟨x, x_1⟩)
rw [← (extractEquiv i).symm.sum_comp M:Type u_1inst✝:AddCommMonoid Mm:ℕi:Fin m.succf:WickContraction m.succ → M⊢ ∑ i_1, f ((extractEquiv i).symm i_1) = ∑ x, ∑ x_1, f ((extractEquiv i).symm ⟨x, x_1⟩) M:Type u_1inst✝:AddCommMonoid Mm:ℕi:Fin m.succf:WickContraction m.succ → M⊢ ∑ i_1, f ((extractEquiv i).symm i_1) = ∑ x, ∑ x_1, f ((extractEquiv i).symm ⟨x, x_1⟩)] M:Type u_1inst✝:AddCommMonoid Mm:ℕi:Fin m.succf:WickContraction m.succ → M⊢ ∑ i_1, f ((extractEquiv i).symm i_1) = ∑ x, ∑ x_1, f ((extractEquiv i).symm ⟨x, x_1⟩)
rw [Finset.sum_sigma' M:Type u_1inst✝:AddCommMonoid Mm:ℕi:Fin m.succf:WickContraction m.succ → M⊢ ∑ i_1, f ((extractEquiv i).symm i_1) =
∑ x ∈ Finset.univ.sigma fun x => Finset.univ, f ((extractEquiv i).symm ⟨x.fst, x.snd⟩) M:Type u_1inst✝:AddCommMonoid Mm:ℕi:Fin m.succf:WickContraction m.succ → M⊢ ∑ i_1, f ((extractEquiv i).symm i_1) =
∑ x ∈ Finset.univ.sigma fun x => Finset.univ, f ((extractEquiv i).symm ⟨x.fst, x.snd⟩)] M:Type u_1inst✝:AddCommMonoid Mm:ℕi:Fin m.succf:WickContraction m.succ → M⊢ ∑ i_1, f ((extractEquiv i).symm i_1) =
∑ x ∈ Finset.univ.sigma fun x => Finset.univ, f ((extractEquiv i).symm ⟨x.fst, x.snd⟩)
rfl All goals completed! 🐙
For n = 3 there are 4 possible Wick contractions:
∅, corresponding to the case where no fields are contracted.
{{0, 1}}, corresponding to the case where the field at position 0 and 1 are contracted.
{{0, 2}}, corresponding to the case where the field at position 0 and 2 are contracted.
{{1, 2}}, corresponding to the case where the field at position 1 and 2 are contracted.
The proof of this result uses the fact that Lean is an executable programming language
and can calculate all Wick contractions for a given n.
lemma mem_three (c : WickContraction 3) : c.1 ∈ ({∅, {{0, 1}}, {{0, 2}}, {{1, 2}}} :
Finset (Finset (Finset (Fin 3)))) := by c:WickContraction 3⊢ ↑c ∈ {∅, {{0, 1}}, {{0, 2}}, {{1, 2}}}
revert c ⊢ ∀ (c : WickContraction 3), ↑c ∈ {∅, {{0, 1}}, {{0, 2}}, {{1, 2}}}
decide +kernel All goals completed! 🐙
For n = 4 there are 10 possible Wick contractions including e.g.
∅, corresponding to the case where no fields are contracted.
{{0, 1}, {2, 3}}, corresponding to the case where the fields at position 0 and 1 are
contracted, and the fields at position 2 and 3 are contracted.
{{0, 2}, {1, 3}}, corresponding to the case where the fields at position 0 and 2 are
contracted, and the fields at position 1 and 3 are contracted.
The proof of this result uses the fact that Lean is an executable programming language
and can calculate all Wick contractions for a given n.
lemma mem_four (c : WickContraction 4) : c.1 ∈ ({∅,
{{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}, {{1, 3}}, {{2,3}},
{{0, 1}, {2, 3}}, {{0, 2}, {1, 3}}, {{0, 3}, {1, 2}}} :
Finset (Finset (Finset (Fin 4)))) := by c:WickContraction 4⊢ ↑c ∈
{∅, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}, {{1, 3}}, {{2, 3}}, {{0, 1}, {2, 3}}, {{0, 2}, {1, 3}}, {{0, 3}, {1, 2}}}
revert c ⊢ ∀ (c : WickContraction 4),
↑c ∈
{∅, {{0, 1}}, {{0, 2}}, {{0, 3}}, {{1, 2}}, {{1, 3}}, {{2, 3}}, {{0, 1}, {2, 3}}, {{0, 2}, {1, 3}},
{{0, 3}, {1, 2}}}
decide +kernel All goals completed! 🐙