refactor: Lint

This commit is contained in:
jstoobysmith 2024-08-15 10:53:30 -04:00
parent 3693dee740
commit 1c9d66ee19
12 changed files with 79 additions and 138 deletions

View file

@ -12,13 +12,11 @@ import HepLean.SpaceTime.LorentzTensor.IndexNotation.Basic
namespace IndexNotation
namespace IndexList
variable {X : Type} [IndexNotation X] [Fintype X] [DecidableEq X]
variable (l l2 l3 : IndexList X)
/-!
## Are dual indices
@ -74,7 +72,6 @@ lemma append_inr_inl (l l2 : IndexList X) (i : Fin l2.length) (j : Fin l.length)
end AreDualInSelf
namespace AreDualInOther
variable {l l2 l3 : IndexList X} {i : Fin l.length} {j : Fin l2.length}

View file

@ -243,7 +243,6 @@ instance : Fintype l.toPosSet where
def toPosFinset (l : IndexList X) : Finset (Fin l.length × Index X) :=
l.toPosSet.toFinset
/-- The construction of a list of indices from a map
from `Fin n` to `Index X`. -/
def fromFinMap {n : } (f : Fin n → Index X) : IndexList X where
@ -368,7 +367,6 @@ lemma colorMap_sumELim (l1 l2 : IndexList X) :
| Sum.inl i => simp
| Sum.inr i => simp
end append
end IndexList

View file

@ -20,7 +20,6 @@ a Tensor Color structure.
namespace IndexNotation
namespace IndexList
variable {𝓒 : TensorColor}
@ -158,7 +157,6 @@ lemma triple_drop_mid (hu : (l ++ l2 ++ l3).withUniqueDual = (l ++ l2 ++ l3).wit
rw [append_withDual_eq_withUniqueDual_symm, append_assoc] at hu
exact append_withDual_eq_withUniqueDual_inr _ _ hu
lemma swap (hu : (l ++ l2 ++ l3).withUniqueDual = (l ++ l2 ++ l3).withDual)
(h : ColorCond (l ++ l2 ++ l3)) :
ColorCond (l2 ++ l ++ l3) := by
@ -268,11 +266,8 @@ lemma iff_bool : l.ColorCond ↔ bool l := by
end ColorCond
end IndexList
variable (𝓒 : TensorColor)
variable [IndexNotation 𝓒.Color] [Fintype 𝓒.Color] [DecidableEq 𝓒.Color]
@ -317,7 +312,6 @@ lemma ext {l l' : ColorIndexList 𝓒} (h : l.val = l'.val) : l = l' := by
apply IndexList.ext
exact h
/-! TODO: `orderEmbOfFin_univ` should be replaced with a mathlib lemma if possible. -/
lemma orderEmbOfFin_univ (n m : ) (h : n = m) :
Finset.orderEmbOfFin (Finset.univ : Finset (Fin n)) (by simp [h]: Finset.univ.card = m) =
@ -332,7 +326,6 @@ lemma orderEmbOfFin_univ (n m : ) (h : n = m):
exact fun ⦃a b⦄ a => a
exact Eq.symm (Fin.orderEmbedding_eq (congrArg Set.range (id (Eq.symm h1))))
/-!
## Contracting an `ColorIndexList`
@ -388,7 +381,6 @@ lemma contr_areDualInSelf (i j : Fin l.contr.length) :
l.contr.AreDualInSelf i j ↔ False := by
simp [contr]
/-!
## Contract equiv
@ -558,7 +550,6 @@ lemma iff_bool (l l2 : ColorIndexList 𝓒) : AppendCond l l2 ↔ bool l.toIndex
end AppendCond
end ColorIndexList
end IndexNotation

View file

@ -14,7 +14,6 @@ import Mathlib.Data.Finset.Sort
namespace IndexNotation
namespace IndexList
variable {X : Type} [IndexNotation X] [Fintype X] [DecidableEq X]
@ -167,7 +166,6 @@ lemma contrIndexList_getDualInOther?_self (i : Fin l.contrIndexList.length) :
exact (contrIndexList_areDualInSelf_false l i j).mp h
exact Fin.ge_of_eq (id (Eq.symm h1))
/-!
## Splitting withUniqueDual
@ -281,8 +279,6 @@ def withUniqueLTGTEquiv : l.withUniqueDualLT ⊕ l.withUniqueDualLT ≃ l.withUn
apply (Equiv.subtypeEquivRight (by simp only [l.withUniqueDualLT_union_withUniqueDualGT,
implies_true]))
/-!
## withUniqueDualInOther equal univ

View file

@ -16,13 +16,11 @@ We define the functions `getDual?` and `getDualInOther?` which return the
namespace IndexNotation
namespace IndexList
variable {X : Type} [IndexNotation X] [Fintype X] [DecidableEq X]
variable (l l2 : IndexList X)
/-!
## The getDual? Function
@ -34,13 +32,11 @@ variable (l l2 : IndexList X)
def getDual? (i : Fin l.length) : Option (Fin l.length) :=
Fin.find (fun j => l.AreDualInSelf i j)
/-- Given an `i`, if a dual exists in the other list,
outputs the first such dual, otherwise outputs `none`. -/
def getDualInOther? (i : Fin l.length) : Option (Fin l2.length) :=
Fin.find (fun j => l.AreDualInOther l2 i j)
/-!
## Basic properties of getDual?

View file

@ -18,7 +18,6 @@ namespace IndexList
variable {X : Type} [IndexNotation X] [Fintype X] [DecidableEq X]
variable (l l2 l3 : IndexList X)
/-!
## withDual equal to withUniqueDual
@ -179,14 +178,12 @@ lemma withUniqueDualInOther_eq_withDualInOther_of_append_symm :
exact l.withUniqueDualInOther_eq_withDualInOther_of_append_symm' l2 l3
exact l.withUniqueDualInOther_eq_withDualInOther_of_append_symm' l3 l2
/-!
## withDual equal to withUniqueDual append conditions
-/
lemma append_withDual_eq_withUniqueDual_iff :
(l ++ l2).withUniqueDual = (l ++ l2).withDual ↔
((l.withUniqueDual ∩ (l.withDualInOther l2)ᶜ) l.withUniqueDualInOther l2)
@ -292,7 +289,6 @@ lemma append_withDual_eq_withUniqueDual_swap :
rw [withUniqueDualInOther_eq_withDualInOther_of_append_symm]
rw [withUniqueDualInOther_eq_withDualInOther_append_of_symm]
end IndexList
end IndexNotation

View file

@ -18,7 +18,6 @@ a Tensor Color structure.
namespace IndexNotation
namespace ColorIndexList
variable {𝓒 : TensorColor} [IndexNotation 𝓒.Color] [Fintype 𝓒.Color] [DecidableEq 𝓒.Color]
@ -63,7 +62,6 @@ namespace ContrPerm
variable {l l' l2 l3 : ColorIndexList 𝓒}
@[symm]
lemma symm (h : ContrPerm l l') : ContrPerm l' l := by
rw [ContrPerm] at h ⊢
@ -148,7 +146,6 @@ lemma contrPermEquiv_colorMap_iso' {l l' : ColorIndexList 𝓒} (h : ContrPerm l
rw [ColorMap.MapIso.symm']
exact contrPermEquiv_colorMap_iso h
@[simp]
lemma contrPermEquiv_refl : contrPermEquiv (@ContrPerm.refl 𝓒 _ l) = Equiv.refl _ := by
simp [contrPermEquiv, ContrPerm.refl]

View file

@ -74,7 +74,6 @@ lemma ext {T₁ T₂ : 𝓣.TensorIndex} (hi : T₁.toColorIndexList = T₂.toCo
subst hi
simp_all
lemma index_eq_of_eq {T₁ T₂ : 𝓣.TensorIndex} (h : T₁ = T₂) :
T₁.toColorIndexList = T₂.toColorIndexList := by
cases h
@ -197,8 +196,6 @@ lemma smul_contr (r : R) (T : 𝓣.TensorIndex) : (r • T).contr = r • T.cont
-/
/-- An (equivalence) relation on two `TensorIndex`.
The point in this equivalence relation is that certain things (like the
permutation of indices, the contraction of indices, or rising or lowering indices) can be placed
@ -320,10 +317,8 @@ lemma rel_left {T₁ T₁' T₂ : 𝓣.TensorIndex} (h : AddCond T₁ T₂) (h'
lemma rel_right {T₁ T₂ T₂' : 𝓣.TensorIndex} (h : AddCond T₁ T₂) (h' : T₂ ≈ T₂') :
AddCond T₁ T₂' := h.trans h'.1
end AddCond
/-- The equivalence between indices after contraction given a `AddCond`. -/
@[simp]
def addCondEquiv {T₁ T₂ : 𝓣.TensorIndex} (h : AddCond T₁ T₂) :
@ -486,7 +481,6 @@ lemma add_assoc {T₁ T₂ T₃ : 𝓣.TensorIndex} {h' : AddCond T₁ T₂} (h
-/
/-- The condition on two `TensorIndex` which is true if and only if their `ColorIndexList`s
are related by the condition `AppendCond`. That is, they can be appended to form a
`ColorIndexList`. -/
@ -515,7 +509,6 @@ lemma prod_toColorIndexList (T₁ T₂ : 𝓣.TensorIndex) (h : ProdCond T₁ T
lemma prod_toIndexList (T₁ T₂ : 𝓣.TensorIndex) (h : ProdCond T₁ T₂) :
(prod T₁ T₂ h).toIndexList = T₁.toIndexList ++ T₂.toIndexList := rfl
end TensorIndex
end
end TensorStructure

View file

@ -13,10 +13,8 @@ We define the finite sets of indices in an index list which have a dual
-/
namespace IndexNotation
namespace IndexList
variable {X : Type} [IndexNotation X] [Fintype X] [DecidableEq X]
@ -65,7 +63,6 @@ lemma mem_withDual_iff_exists : i ∈ l.withDual ↔ ∃ j, l.AreDualInSelf i j
-/
@[simp]
lemma mem_withInDualOther_iff_isSome (i : Fin l.length) :
i ∈ l.withDualInOther l2 ↔ (l.getDualInOther? l2 i).isSome := by
@ -114,7 +111,6 @@ lemma append_withDualInOther_eq :
| Sum.inr k =>
simp
lemma withDualInOther_append_eq : l.withDualInOther (l2 ++ l3) =
l.withDualInOther l2 l.withDualInOther l3 := by
ext i

View file

@ -15,13 +15,11 @@ Finite sets of indices with a unique dual.
namespace IndexNotation
namespace IndexList
variable {X : Type} [IndexNotation X] [Fintype X] [DecidableEq X]
variable (l l2 l3 : IndexList X)
/-!
## Unique duals
@ -61,8 +59,6 @@ lemma mem_withDual_of_withUniqueDual (i : l.withUniqueDual) :
i.1 ∈ l.withDual :=
mem_withDual_of_mem_withUniqueDual l (↑i) i.2
/-!
## Basic properties of withUniqueDualInOther
@ -168,7 +164,6 @@ lemma getDual?_get_of_mem_withUnique_mem (i : Fin l.length) (h : i ∈ l.withUni
subst h1
exact Eq.symm (getDual?_getDual?_get_of_withUniqueDual l i h)
/-!
## Properties of getDualInOther? and withUniqueDualInOther
@ -285,17 +280,12 @@ lemma getDualInOther?_get_of_mem_withUniqueInOther_mem (i : Fin l.length)
rw [Fin.find_eq_none_iff] at h
simp_all only
@[simp]
lemma getDualInOther?_self_of_mem_withUniqueInOther (i : Fin l.length)
(h : i ∈ l.withUniqueDualInOther l) :
l.getDualInOther? l i = some i := by
rw [all_dual_eq_of_withUniqueDualInOther l l i h i rfl]
/-!
## Properties of getDual?, withUniqueDual and append
@ -319,7 +309,6 @@ lemma append_inl_not_mem_withDual_of_withDualInOther (i : Fin l.length)
simp only [getDual?_isSome_append_inl_iff] at ht
simp_all
lemma append_inr_not_mem_withDual_of_withDualInOther (i : Fin l2.length)
(h : appendEquiv (Sum.inr i) ∈ (l ++ l2).withUniqueDual) :
i ∈ l2.withDual ↔ ¬ i ∈ l2.withDualInOther l := by
@ -337,7 +326,6 @@ lemma append_inr_not_mem_withDual_of_withDualInOther (i : Fin l2.length)
simp only [getDual?_isSome_append_inr_iff] at ht
simp_all
lemma getDual?_append_symm_of_withUniqueDual_of_inl (i : Fin l.length) (k : Fin l2.length)
(h : appendEquiv (Sum.inl i) ∈ (l ++ l2).withUniqueDual) :
(l ++ l2).getDual? (appendEquiv (Sum.inl i)) = some (appendEquiv (Sum.inr k))
@ -660,8 +648,6 @@ lemma append_withUniqueDual_disjSum : (l ++ l2).withUniqueDual =
-/
lemma mem_append_withUniqueDualInOther_symm (i : Fin l.length) :
appendEquiv (Sum.inl i) ∈ (l ++ l2).withUniqueDualInOther l3 ↔
appendEquiv (Sum.inr i) ∈ (l2 ++ l).withUniqueDualInOther l3 := by
@ -744,7 +730,6 @@ lemma getDualInOther?_append_symm_of_withUniqueDual_of_inr (i : Fin l.length)
<;> by_cases ho : (l.getDualInOther? l3 i).isSome
<;> simp_all [hs]
lemma mem_withUniqueDualInOther_symm' (i : Fin l.length)
(h : i ∈ l.withUniqueDualInOther (l2 ++ l3)) :
i ∈ l.withUniqueDualInOther (l3 ++ l2) := by
@ -803,7 +788,6 @@ lemma mem_withUniqueDualInOther_symm (i : Fin l.length) :
i ∈ l.withUniqueDualInOther (l2 ++ l3) ↔ i ∈ l.withUniqueDualInOther (l3 ++ l2) :=
Iff.intro (l.mem_withUniqueDualInOther_symm' l2 l3 i) (l.mem_withUniqueDualInOther_symm' l3 l2 i)
/-!
## The equivalence defined by getDual?
@ -847,7 +831,6 @@ lemma getDualInOtherEquiv_self_refl : l.getDualInOtherEquiv l = Equiv.refl _ :=
intro x
simp [getDualInOtherEquiv]
end IndexList
end IndexNotation

View file

@ -89,7 +89,6 @@ noncomputable def fromIndexStringColor {cn : Fin n → realTensorColor.Color}
IndexList.ColorCond.iff_bool.mpr hC⟩ hn
(TensorColor.ColorMap.DualMap.boolFin_DualMap hd)
/-- A tactic used to prove `boolFin` for real Lornetz tensors. -/
macro "dualMapTactic" : tactic =>
`(tactic| {
@ -114,7 +113,6 @@ macro "prodTactic" : tactic =>
/-- The product of Real Lorentz tensors. Conditions on indices are checked automatically. -/
notation:10 T "⊗ᵀ" S:11 => TensorIndex.prod T S (by prodTactic)
/-- An example showing the allowed constructions. -/
example (T : (realLorentzTensor d).Tensor ![ColorType.up, ColorType.down]) : True := by
let _ := T|"ᵤ₁ᵤ₂" ⊗ᵀ T|"ᵘ³ᵤ₄" ⊗ᵀ T|"ᵘ⁴ᵤ₃"