From de9673eb2f7a47a0f11fefa4ea00882765b9a1c1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:11:40 -0700 Subject: [PATCH 001/498] refactor(units): golf wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/Basic.lean | 21 +++-------- Physlib/Units/Dimension.lean | 8 +--- Physlib/Units/WithDim/Basic.lean | 55 ++++++++-------------------- 3 files changed, 23 insertions(+), 61 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 20e3fbe16..3d9ffa7fe 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -81,9 +81,8 @@ structure Time where namespace Time lemma val_injective : Function.Injective val := by - intro t1 t2 h - ext - exact h + intro _ _ h + exact Time.ext h /-! @@ -189,13 +188,8 @@ instance : PartialOrder Time where lemma lt_def (t1 t2 : Time) : t1 < t2 ↔ t1.val < t2.val := by - constructor - · intro h - exact lt_iff_le_not_ge.mpr h - · intro h - apply lt_iff_le_not_ge.mpr - simp_all [le_def] - apply le_of_lt h + change t1.val ≤ t2.val ∧ ¬ t2.val ≤ t1.val ↔ t1.val < t2.val + rw [lt_iff_le_not_ge] /-! @@ -429,8 +423,7 @@ lemma finRank_eq_one : Module.finrank ℝ Time = 1 := by simp [one_val] instance : FiniteDimensional ℝ Time := by - refine Module.finite_of_rank_eq_one ?_ - simp + exact Module.finite_of_rank_eq_one rank_eq_one lemma volume_eq_basis_addHaar : (volume (α := Time)) = basis.toBasis.addHaar := by @@ -468,9 +461,7 @@ noncomputable def toRealLIE : Time ≃ₗᵢ[ℝ] ℝ where right_inv x := by rfl map_add' := by simp map_smul' := by simp - norm_map' x := by - simp - rfl + norm_map' x := rfl lemma eq_one_smul (t : Time) : t = t.val • 1 := by diff --git a/Physlib/Units/Dimension.lean b/Physlib/Units/Dimension.lean index 3b59e8a3b..4e5b4da29 100644 --- a/Physlib/Units/Dimension.lean +++ b/Physlib/Units/Dimension.lean @@ -100,9 +100,7 @@ lemma one_temperature : (1 : Dimension).temperature = 0 := rfl instance : CommGroup Dimension where mul_assoc a b c := by ext - all_goals - simp only [length_mul, time_mul, mass_mul, charge_mul, temperature_mul] - ring + all_goals simp [add_assoc] one_mul a := by ext all_goals @@ -117,9 +115,7 @@ instance : CommGroup Dimension where all_goals simp mul_comm a b := by ext - all_goals - simp only [length_mul, time_mul, mass_mul, charge_mul, temperature_mul] - ring + all_goals simp [add_comm] @[simp] lemma inv_length (d : Dimension) : d⁻¹.length = -d.length := rfl diff --git a/Physlib/Units/WithDim/Basic.lean b/Physlib/Units/WithDim/Basic.lean index 5f9687c67..8d7dcf78e 100644 --- a/Physlib/Units/WithDim/Basic.lean +++ b/Physlib/Units/WithDim/Basic.lean @@ -75,47 +75,31 @@ lemma val_sub {d : Dimension} {M : Type} [Sub M] (m1 m2 : WithDim d M) : instance (d : Dimension) (M : Type) [AddSemigroup M] : AddSemigroup (WithDim d M) where - add_assoc m1 m2 m3 := by - ext - simp [add_assoc] + add_assoc m1 m2 m3 := WithDim.ext _ _ (add_assoc m1.val m2.val m3.val) instance (d : Dimension) (M : Type) [AddCommSemigroup M] : AddCommSemigroup (WithDim d M) where - add_comm m1 m2 := by - ext - simp [add_comm] + add_comm m1 m2 := WithDim.ext _ _ (add_comm m1.val m2.val) instance (d : Dimension) (M : Type) [AddMonoid M] : AddMonoid (WithDim d M) where - zero_add m := by - ext - simp [zero_add] - add_zero m := by - ext - simp [add_zero] + zero_add m := WithDim.ext _ _ (zero_add m.val) + add_zero m := WithDim.ext _ _ (add_zero m.val) nsmul := nsmulRec instance (d : Dimension) (M : Type) [AddCommMonoid M] : AddCommMonoid (WithDim d M) where - add_comm m1 m2 := by - ext - simp [add_comm] + add_comm m1 m2 := WithDim.ext _ _ (add_comm m1.val m2.val) instance (d : Dimension) (M : Type) [AddGroup M] : AddGroup (WithDim d M) where - sub_eq_add_neg m1 m2 := by - ext - simp [sub_eq_add_neg] - neg_add_cancel m := by - ext - simp [neg_add_cancel] + sub_eq_add_neg m1 m2 := WithDim.ext _ _ (sub_eq_add_neg m1.val m2.val) + neg_add_cancel m := WithDim.ext _ _ (neg_add_cancel m.val) zsmul := zsmulRec instance (d : Dimension) (M : Type) [AddCommGroup M] : AddCommGroup (WithDim d M) where - add_comm m1 m2 := by - ext - simp [add_comm] + add_comm m1 m2 := WithDim.ext _ _ (add_comm m1.val m2.val) instance (d : Dimension) (M : Type) [LE M] : LE (WithDim d M) where le m1 m2 := m1.val ≤ m2.val @@ -133,27 +117,20 @@ lemma lt_def {d : Dimension} {M : Type} [LT M] (m1 m2 : WithDim d M) : instance (d : Dimension) (M : Type) [Preorder M] : Preorder (WithDim d M) where - le_refl m := by - exact le_refl m.val - le_trans m1 m2 m3 h12 h23 := by - change m1.val ≤ m3.val - exact le_trans h12 h23 + le_refl m := le_refl m.val + le_trans m1 m2 m3 h12 h23 := le_trans h12 h23 lt_iff_le_not_ge m1 m2 := by change m1.val < m2.val ↔ m1.val ≤ m2.val ∧ ¬ m2.val ≤ m1.val exact lt_iff_le_not_ge instance (d : Dimension) (M : Type) [PartialOrder M] : PartialOrder (WithDim d M) where - le_antisymm m1 m2 h12 h21 := by - ext - exact le_antisymm h12 h21 + le_antisymm _ _ h12 h21 := WithDim.ext _ _ (le_antisymm h12 h21) instance (d : Dimension) (M : Type) [MulAction ℝ≥0 M] : MulAction ℝ≥0 (WithDim d M) where smul a m := ⟨a • m.val⟩ one_smul m := ext _ _ (one_smul ℝ≥0 m.val) - mul_smul a b m := by - ext - exact mul_smul a b m.val + mul_smul a b m := WithDim.ext _ _ (mul_smul a b m.val) @[simp] lemma smul_val {d : Dimension} {M : Type} [MulAction ℝ≥0 M] (a : ℝ≥0) (m : WithDim d M) : @@ -182,21 +159,19 @@ open UnitDependent @[simp] lemma val_mul_eq_mul {d1 d2 : Dimension} (m1 : WithDim d1 ℝ) (m2 : WithDim d2 ℝ) : - m1.val * m2.val = (m1 * m2).val := by - simp only [withDim_hMul_val] + m1.val * m2.val = (m1 * m2).val := rfl @[simp] lemma val_pow_two_eq_mul {d1 : Dimension} (m1 : WithDim d1 ℝ) : m1.val ^ 2 = (m1 * m1).val := by - rw [sq] - rfl + simp [sq] @[simp] lemma scaleUnit_val_eq_scaleUnit_val {d : Dimension} (M : Type) [MulAction ℝ≥0 M] (u1 u2 : UnitChoices) (m1 m2 : WithDim d M) : (scaleUnit u1 u2 m1).val = (scaleUnit u1 u2 m2).val ↔ m1.val = m2.val := by rw [← WithDim.ext_iff] - simp only [scaleUnit_injective] + rw [scaleUnit_injective] exact WithDim.ext_iff lemma scaleUnit_val_eq_scaleUnit_val_of_dim_eq {d1 d2 : Dimension} {M : Type} [MulAction ℝ≥0 M] From 89ecfbef5248ab625524de32340f6c0501c9a6cb Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:13:31 -0700 Subject: [PATCH 002/498] refactor(units): golf unit-dependent map proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 42 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 735268ecf..af1705de1 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -291,15 +291,11 @@ noncomputable instance {M : Type} [AddCommMonoid M] [Module ℝ M] noncomputable instance {M1 M2 : Type} [UnitDependent M2] : UnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => scaleUnit u1 u2 (f m1) - scaleUnit_trans u1 u2 u3 f := by - funext m1 - exact scaleUnit_trans u1 u2 u3 (f m1) - scaleUnit_trans' u1 u2 u3 f := by - funext m1 - exact scaleUnit_trans' u1 u2 u3 (f m1) - scaleUnit_id u f := by - funext m1 - exact scaleUnit_id u (f m1) + scaleUnit_trans u1 u2 u3 f := funext fun m1 => + scaleUnit_trans u1 u2 u3 (f m1) + scaleUnit_trans' u1 u2 u3 f := funext fun m1 => + scaleUnit_trans' u1 u2 u3 (f m1) + scaleUnit_id u f := funext fun m1 => scaleUnit_id u (f m1) @[simp] lemma UnitDependent.scaleUnit_apply_fun_right {M1 M2 : Type} [UnitDependent M2] @@ -314,15 +310,11 @@ noncomputable instance {M1 M2 : Type} [AddCommMonoid M1] [Module ℝ M1] toFun m1 := scaleUnit u1 u2 (f m1) map_add' m1 m2 := by simp [scaleUnit_add] map_smul' := by simp [scaleUnit_smul]} - scaleUnit_trans u1 u2 u3 f := by - ext m1 - exact scaleUnit_trans u1 u2 u3 (f m1) - scaleUnit_trans' u1 u2 u3 f := by - ext m1 - exact scaleUnit_trans' u1 u2 u3 (f m1) - scaleUnit_id u f := by - ext m1 - exact scaleUnit_id u (f m1) + scaleUnit_trans u1 u2 u3 f := LinearMap.ext fun m1 => + scaleUnit_trans u1 u2 u3 (f m1) + scaleUnit_trans' u1 u2 u3 f := LinearMap.ext fun m1 => + scaleUnit_trans' u1 u2 u3 (f m1) + scaleUnit_id u f := LinearMap.ext fun m1 => scaleUnit_id u (f m1) scaleUnit_add u1 u2 f1 f2 := by ext m simp [scaleUnit_add] @@ -340,15 +332,11 @@ noncomputable instance {M1 M2 : Type} [AddCommGroup M1] [Module ℝ M1] scaleUnit u1 u2 f := ContinuousLinearEquiv.arrowCongr (ContinuousLinearEquiv.refl ℝ _) (scaleUnitContLinearEquiv u1 u2) f - scaleUnit_trans u1 u2 u3 f := by - ext m1 - exact scaleUnit_trans u1 u2 u3 (f m1) - scaleUnit_trans' u1 u2 u3 f := by - ext m1 - exact scaleUnit_trans' u1 u2 u3 (f m1) - scaleUnit_id u f := by - ext m1 - exact scaleUnit_id u (f m1) + scaleUnit_trans u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => + scaleUnit_trans u1 u2 u3 (f m1) + scaleUnit_trans' u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => + scaleUnit_trans' u1 u2 u3 (f m1) + scaleUnit_id u f := ContinuousLinearMap.ext fun m1 => scaleUnit_id u (f m1) scaleUnit_add u1 u2 f1 f2 := by simp scaleUnit_smul u1 u2 r f := by simp scaleUnit_cont u1 u2 := ContinuousLinearEquiv.continuous From 45934f0b3abb66bcc6e4d699062735ac483a16af Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:14:59 -0700 Subject: [PATCH 003/498] refactor(units): golf two-sided unit-dependent proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 39 +++++++++++--------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index af1705de1..567801f6f 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -345,14 +345,11 @@ noncomputable instance {M1 M2 : Type} [AddCommGroup M1] [Module ℝ M1] noncomputable instance {M1 M2 : Type} [UnitDependent M1] : UnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => f (scaleUnit u2 u1 m1) - scaleUnit_trans u1 u2 u3 f := by - funext m1 + scaleUnit_trans u1 u2 u3 f := funext fun m1 => by simp [scaleUnit_trans] - scaleUnit_trans' u1 u2 u3 f := by - funext m1 + scaleUnit_trans' u1 u2 u3 f := funext fun m1 => by simp [scaleUnit_trans'] - scaleUnit_id u f := by - funext m1 + scaleUnit_id u f := funext fun m1 => by simp [scaleUnit_id] @[simp] @@ -364,14 +361,11 @@ noncomputable instance instUnitDependentTwoSided {M1 M2 : Type} [UnitDependent M1] [UnitDependent M2] : UnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => scaleUnit u1 u2 (f (scaleUnit u2 u1 m1)) - scaleUnit_trans u1 u2 u3 f := by - funext m1 + scaleUnit_trans u1 u2 u3 f := funext fun m1 => by simp [scaleUnit_trans] - scaleUnit_trans' u1 u2 u3 f := by - funext m1 + scaleUnit_trans' u1 u2 u3 f := funext fun m1 => by simp [scaleUnit_trans'] - scaleUnit_id u f := by - funext m1 + scaleUnit_id u f := funext fun m1 => by simp [scaleUnit_id] @[simp] @@ -383,17 +377,13 @@ noncomputable instance instUnitDependentTwoSidedMul {M1 M2 : Type} [UnitDependent M1] [MulAction ℝ≥0 M2] [MulUnitDependent M2] : MulUnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => scaleUnit u1 u2 (f (scaleUnit u2 u1 m1)) - scaleUnit_trans u1 u2 u3 f := by - funext m1 + scaleUnit_trans u1 u2 u3 f := funext fun m1 => by simp [scaleUnit_trans] - scaleUnit_trans' u1 u2 u3 f := by - funext m1 + scaleUnit_trans' u1 u2 u3 f := funext fun m1 => by simp [scaleUnit_trans'] - scaleUnit_id u f := by - funext m1 + scaleUnit_id u f := funext fun m1 => by simp [scaleUnit_id] - scaleUnit_mul u1 u2 r f := by - funext m1 + scaleUnit_mul u1 u2 r f := funext fun m1 => by simp [MulUnitDependent.scaleUnit_mul] open LinearUnitDependent ContinuousLinearUnitDependent in @@ -407,14 +397,11 @@ noncomputable instance instContinuousLinearUnitDependentMap scaleUnit u1 u2 f := ContinuousLinearEquiv.arrowCongr (scaleUnitContLinearEquiv u1 u2) (scaleUnitContLinearEquiv u1 u2) f - scaleUnit_trans u1 u2 u3 f := by - ext m1 + scaleUnit_trans u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => by simp [scaleUnit_trans] - scaleUnit_trans' u1 u2 u3 f := by - ext m1 + scaleUnit_trans' u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => by simp [scaleUnit_trans'] - scaleUnit_id u f := by - ext m1 + scaleUnit_id u f := ContinuousLinearMap.ext fun m1 => by simp [scaleUnit_id] scaleUnit_add u1 u2 f1 f2 := by simp scaleUnit_smul u1 u2 r f := by simp From 290053dd2231db77d747beeba984cc47c3e7aec2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:16:06 -0700 Subject: [PATCH 004/498] refactor(units): golf linear scaleUnit proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 567801f6f..a8580109a 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -315,11 +315,9 @@ noncomputable instance {M1 M2 : Type} [AddCommMonoid M1] [Module ℝ M1] scaleUnit_trans' u1 u2 u3 f := LinearMap.ext fun m1 => scaleUnit_trans' u1 u2 u3 (f m1) scaleUnit_id u f := LinearMap.ext fun m1 => scaleUnit_id u (f m1) - scaleUnit_add u1 u2 f1 f2 := by - ext m + scaleUnit_add u1 u2 f1 f2 := LinearMap.ext fun m => by simp [scaleUnit_add] - scaleUnit_smul u1 u2 r f := by - ext m + scaleUnit_smul u1 u2 r f := LinearMap.ext fun m => by simp [scaleUnit_smul] open LinearUnitDependent ContinuousLinearUnitDependent in From d09299c837f842f361044a806b726957c38092d3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:18:14 -0700 Subject: [PATCH 005/498] refactor(units): golf dimensioned unit conversions Co-authored-by: Claude Opus 4.8 --- Physlib/Units/WithDim/Area.lean | 11 +++++------ Physlib/Units/WithDim/Speed.lean | 23 ++++++++--------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/Physlib/Units/WithDim/Area.lean b/Physlib/Units/WithDim/Area.lean index ca58d950c..ca0eb3e93 100644 --- a/Physlib/Units/WithDim/Area.lean +++ b/Physlib/Units/WithDim/Area.lean @@ -68,17 +68,17 @@ lemma squareMeter_in_SI : squareMeter.1 SI = ⟨1⟩ := by @[simp] lemma squareFoot_in_SI : squareFoot.1 SI = ⟨0.09290304⟩ := by - simp [squareFoot, dimScale, LengthUnit.feet, toDimensionful_apply_apply,] ext - simp [NNReal.coe_ofScientific] + norm_num [squareFoot, dimScale, LengthUnit.feet, toDimensionful_apply_apply, + NNReal.coe_ofScientific] rw [toReal] norm_num @[simp] lemma squareMile_in_SI : squareMile.1 SI = ⟨2589988.110336⟩ := by - simp [squareMile, dimScale, LengthUnit.miles, toDimensionful_apply_apply] ext - simp [NNReal.coe_ofScientific] + norm_num [squareMile, dimScale, LengthUnit.miles, toDimensionful_apply_apply, + NNReal.coe_ofScientific] rw [toReal] norm_num @@ -107,8 +107,7 @@ lemma acre_in_SI : acre.1 SI = ⟨4046.8564224⟩ := by /-- One acre is exactly `43560` square feet. -/ lemma acre_eq_mul_squareFeet : acre = (43560 : ℝ≥0) • squareFoot := by apply (toDimensionful SI).symm.injective - simp [toDimensionful] ext - norm_num + norm_num [toDimensionful] end DimArea diff --git a/Physlib/Units/WithDim/Speed.lean b/Physlib/Units/WithDim/Speed.lean index aa76ce536..7364b9fd5 100644 --- a/Physlib/Units/WithDim/Speed.lean +++ b/Physlib/Units/WithDim/Speed.lean @@ -65,29 +65,25 @@ lemma oneMeterPerSecond_in_SI : oneMeterPerSecond SI = ⟨1⟩ := by @[simp] lemma oneMilePerHour_in_SI : oneMilePerHour SI = ⟨0.44704⟩ := by - simp [oneMilePerHour, dimScale, LengthUnit.miles, TimeUnit.hours, toDimensionful_apply_apply] ext - simp [NNReal.coe_ofScientific] + norm_num [oneMilePerHour, dimScale, LengthUnit.miles, TimeUnit.hours, + toDimensionful_apply_apply, NNReal.coe_ofScientific] rw [toReal] norm_num @[simp] lemma oneKilometerPerHour_in_SI : oneKilometerPerHour SI = ⟨5/18⟩ := by - simp [oneKilometerPerHour, dimScale, - LengthUnit.kilometers, TimeUnit.hours, toDimensionful_apply_apply] ext - simp only [WithDim.smul_val, smul_eq_mul, mul_one, NNReal.coe_mul, coe_rpow, NNReal.coe_div, - NNReal.coe_ofNat] + norm_num [oneKilometerPerHour, dimScale, LengthUnit.kilometers, TimeUnit.hours, + toDimensionful_apply_apply] rw [toReal] norm_num @[simp] lemma oneKnot_in_SI : oneKnot SI = ⟨463/900⟩ := by - simp [oneKnot, dimScale, LengthUnit.nauticalMiles, TimeUnit.hours, toDimensionful_apply_apply] ext - simp only [WithDim.smul_val, smul_eq_mul, mul_one, NNReal.coe_mul, coe_rpow, NNReal.coe_div, - NNReal.coe_ofNat] + norm_num [oneKnot, dimScale, LengthUnit.nauticalMiles, TimeUnit.hours, toDimensionful_apply_apply] rw [toReal] norm_num @@ -104,22 +100,19 @@ lemma speedOfLight_in_SI : speedOfLight SI = ⟨299792458⟩ := by lemma oneKnot_eq_mul_oneKilometerPerHour : oneKnot = (1.852 : ℝ≥0) • oneKilometerPerHour := by apply (toDimensionful SI).symm.injective - simp [toDimensionful] ext - norm_num + norm_num [toDimensionful] lemma oneKilometerPerHour_eq_mul_oneKnot: oneKilometerPerHour = (250/463 : ℝ≥0) • oneKnot := by apply (toDimensionful SI).symm.injective - simp [toDimensionful] ext - norm_num + norm_num [toDimensionful] lemma oneMeterPerSecond_eq_mul_oneMilePerHour : oneMeterPerSecond = (3125/1397 : ℝ≥0) • oneMilePerHour := by apply (toDimensionful SI).symm.injective - simp [toDimensionful] ext - norm_num + norm_num [toDimensionful] end DimSpeed From 53420e03394071108571d9eb382a6e6e427ec866 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:19:10 -0700 Subject: [PATCH 006/498] refactor(units): golf acre SI conversion Co-authored-by: Claude Opus 4.8 --- Physlib/Units/WithDim/Area.lean | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Physlib/Units/WithDim/Area.lean b/Physlib/Units/WithDim/Area.lean index ca0eb3e93..0327509bb 100644 --- a/Physlib/Units/WithDim/Area.lean +++ b/Physlib/Units/WithDim/Area.lean @@ -92,9 +92,9 @@ lemma hectare_in_SI : hectare.1 SI = ⟨10000⟩ := by @[simp] lemma acre_in_SI : acre.1 SI = ⟨4046.8564224⟩ := by - simp [acre, dimScale, LengthUnit.miles, toDimensionful_apply_apply] ext - simp [NNReal.coe_ofScientific] + norm_num [acre, dimScale, LengthUnit.miles, toDimensionful_apply_apply, + NNReal.coe_ofScientific] rw [toReal] norm_num From 6e8de41182c68e6e34cc774316b5696c4d6df22d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:22:11 -0700 Subject: [PATCH 007/498] refactor(time): golf algebra wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/Basic.lean | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 3d9ffa7fe..6355d3b5c 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -250,23 +250,23 @@ lemma smul_real_val (k : ℝ) (t : Time) : -/ instance : AddGroup Time where - add_assoc t1 t2 t3 := by ext; simp [add_assoc] - zero_add t := by ext; simp [zero_add] - add_zero t := by ext; simp [add_zero] - neg_add_cancel t := by ext; simp [neg_add_cancel] + add_assoc t1 t2 t3 := Time.ext (by simp [add_assoc]) + zero_add t := Time.ext (by simp) + add_zero t := Time.ext (by simp) + neg_add_cancel t := Time.ext (by simp) nsmul := nsmulRec zsmul := zsmulRec instance : AddCommGroup Time where - add_comm := by intros; ext; simp [add_comm] + add_comm t1 t2 := Time.ext (by simp [add_comm]) instance : Module ℝ Time where - one_smul t := by ext; simp - smul_add k t1 t2 := by ext; simp [mul_add] - smul_zero k := by ext; simp [mul_zero] - add_smul k1 k2 t := by ext; simp [add_mul] - mul_smul k1 k2 t := by ext; simp [mul_assoc] - zero_smul t := by ext; simp + one_smul t := Time.ext (by simp) + smul_add k t1 t2 := Time.ext (by simp [mul_add]) + smul_zero k := Time.ext (by simp) + add_smul k1 k2 t := Time.ext (by simp [add_mul]) + mul_smul k1 k2 t := Time.ext (by simp [mul_assoc]) + zero_smul t := Time.ext (by simp) /-! @@ -464,9 +464,7 @@ noncomputable def toRealLIE : Time ≃ₗᵢ[ℝ] ℝ where norm_map' x := rfl lemma eq_one_smul (t : Time) : - t = t.val • 1 := by - ext - simp [one_val] + t = t.val • 1 := Time.ext (by simp [one_val]) @[fun_prop] lemma val_measurable : Measurable Time.val := by From de4e0ee032d1ad5a42af9b2c25a4c2e86d6ed112 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:24:19 -0700 Subject: [PATCH 008/498] refactor(time): golf definitional map proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/Basic.lean | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 6355d3b5c..dcce44b93 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -287,7 +287,7 @@ lemma dist_eq_val (t1 t2 : Time) : dist t1 t2 = ‖t1.val - t2.val‖ := rfl lemma dist_eq_real_dist (t1 t2 : Time) : - dist t1 t2 = dist t1.val t2.val := by rfl + dist t1 t2 = dist t1.val t2.val := rfl instance : SeminormedAddCommGroup Time where dist_self t := by simp [dist_eq_real_dist] @@ -351,7 +351,7 @@ noncomputable instance : DecidableEq Time := fun t1 t2 => instance : MeasurableSpace Time := borel Time instance : BorelSpace Time where - measurable_eq := by rfl + measurable_eq := rfl /-! @@ -439,29 +439,29 @@ lemma volume_eq_basis_addHaar : noncomputable def toRealCLM : Time →L[ℝ] ℝ := LinearMap.toContinuousLinearMap { toFun := Time.val - map_add' := by simp - map_smul' := by simp } + map_add' _ _ := rfl + map_smul' _ _ := rfl } /-- The continuous linear equivalence from `Time` to `ℝ`. -/ noncomputable def toRealCLE : Time ≃L[ℝ] ℝ := LinearEquiv.toContinuousLinearEquiv { toFun := Time.val invFun := fun x => ⟨x⟩ - left_inv x := by rfl - right_inv x := by rfl - map_add' := by simp - map_smul' := by simp + left_inv _ := rfl + right_inv _ := rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl } /-- The linear isometry equivalence from `Time` to `ℝ`. -/ noncomputable def toRealLIE : Time ≃ₗᵢ[ℝ] ℝ where toFun := Time.val invFun := fun x => ⟨x⟩ - left_inv x := by rfl - right_inv x := by rfl - map_add' := by simp - map_smul' := by simp - norm_map' x := rfl + left_inv _ := rfl + right_inv _ := rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl + norm_map' _ := rfl lemma eq_one_smul (t : Time) : t = t.val • 1 := Time.ext (by simp [one_val]) From b8c24e3486bdba398315650d6d2a81a7789b4178 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:28:21 -0700 Subject: [PATCH 009/498] refactor(units): golf example dimensional proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Units/Examples.lean | 14 +++++++------- Physlib/Units/FDeriv.lean | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Physlib/Units/Examples.lean b/Physlib/Units/Examples.lean index 6d05e321d..e8546fbd3 100644 --- a/Physlib/Units/Examples.lean +++ b/Physlib/Units/Examples.lean @@ -33,9 +33,9 @@ noncomputable def meters400 : Dimensionful (WithDim L𝓭 ℝ) := toDimensionful /-- Changing that length to miles. 400 meters is very almost a quarter of a mile. -/ example : meters400 {SI with length := LengthUnit.miles} = ⟨1/4 - 73/50292⟩ := by - simp [meters400, toDimensionful_apply_apply, dimScale, LengthUnit.miles] ext - show (1609.344 : ℝ)⁻¹ * 400 = _ + norm_num [meters400, toDimensionful_apply_apply, dimScale, LengthUnit.miles, NNReal.smul_def] + rw [NNReal.toReal] norm_num /-! @@ -90,8 +90,8 @@ def EnergyMassWithDim (m : WithDim M𝓭 ℝ) (E : WithDim (M𝓭 * L𝓭 * L lemma energyMassWithDim_isDimensionallyCorrect : IsDimensionallyCorrect EnergyMassWithDim := by simp [funext_iff, EnergyMassWithDim] - intros - rw [WithDim.scaleUnit_val_eq_scaleUnit_val_of_dim_eq] + intro _ _ _ _ _ + exact WithDim.scaleUnit_val_eq_scaleUnit_val_of_dim_eq /-- An example of dimensions corresponding to `F = m a` using `WithDim` with `.val`. -/ def NewtonsSecondWithDim (m : WithDim M𝓭 ℝ) (F : WithDim (M𝓭 * L𝓭 * T𝓭⁻¹ * T𝓭⁻¹) ℝ) @@ -101,8 +101,8 @@ def NewtonsSecondWithDim (m : WithDim M𝓭 ℝ) (F : WithDim (M𝓭 * L𝓭 * T lemma newtonsSecondWithDim_isDimensionallyCorrect : IsDimensionallyCorrect NewtonsSecondWithDim := by simp [funext_iff, NewtonsSecondWithDim] - intros - rw [WithDim.scaleUnit_val_eq_scaleUnit_val_of_dim_eq] + intro _ _ _ _ _ + exact WithDim.scaleUnit_val_eq_scaleUnit_val_of_dim_eq /-- An example of dimensions corresponding to `E = m c` using `WithDim` with `.val`, which is not dimensionally correct. -/ @@ -164,7 +164,7 @@ We now explore the consequences of `energyMass_isDimensionallyCorrect` and how w -/ lemma example1_energyMass : EnergyMass ⟨2⟩ ⟨2 * 299792458 ^ 2⟩ SI := by - simp [EnergyMass, speedOfLight, toDimensionful_apply_apply, dimScale, SI] + norm_num [EnergyMass, speedOfLight, toDimensionful_apply_apply, dimScale, SI] /- The lemma `energyMass_isDimensionallyCorrect` allows us to scale the units of `example1_energyMass`, that is - we proved it in one set of units, but we get the result diff --git a/Physlib/Units/FDeriv.lean b/Physlib/Units/FDeriv.lean index f015b8ebe..2d6a2be3e 100644 --- a/Physlib/Units/FDeriv.lean +++ b/Physlib/Units/FDeriv.lean @@ -52,10 +52,10 @@ lemma fderiv_isDimensionallyCorrect (f : M1 → M2) (hf : IsDimensionallyCorrect IsDimensionallyCorrect (fderiv ℝ f) := by simp only [isDimensionallyCorrect_fun_iff] intro u1 u2 m - ext m' - simp only [ContinuousLinearUnitDependent.scaleUnit_apply_fun] - rw [fderiv_apply_scaleUnit u1 u2 m (scaleUnit u2 u1 m') f hf f_diff] - simp [HasDim.scaleUnit_apply, smul_smul] + exact ContinuousLinearMap.ext fun m' => by + simp only [ContinuousLinearUnitDependent.scaleUnit_apply_fun] + rw [fderiv_apply_scaleUnit u1 u2 m (scaleUnit u2 u1 m') f hf f_diff] + simp [HasDim.scaleUnit_apply, smul_smul] /-- The expression `fderiv ℝ f x dm = v.1` for a fixed `dm` and for `v` with dimension `d M2 * (d M1)⁻¹` is dimensionally correct. This is the From a3f713a8eafa1600782fb32f7929ea76aadfdb5e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:29:47 -0700 Subject: [PATCH 010/498] refactor(time): golf transitive manifold wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index 9dd46be15..c5dfc6e89 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -85,10 +85,8 @@ lemma val_inducing : Topology.IsInducing TimeTransMan.val where eq_induced := rfl lemma val_injective : Function.Injective TimeTransMan.val := by - intro t1 t2 h - cases t1 - cases t2 - simp_all + intro _ _ h + exact ext_of h lemma val_isOpenEmbedding : Topology.IsOpenEmbedding TimeTransMan.val where eq_induced := rfl @@ -175,14 +173,8 @@ lemma vadd_val (p : ℝ) (t : TimeTransMan) : (p +ᵥ t).val = p + t.val := rfl instance : AddAction ℝ TimeTransMan where - zero_vadd t := by - cases t - ext - simp - add_vadd p1 p2 t := by - ext - simp only [vadd_val] - ring + zero_vadd t := ext_of (by simp) + add_vadd p1 p2 t := ext_of (by simp [add_assoc]) /-! From 20593ff35f9708adc1bd93a36dc7e6e895655f24 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:31:16 -0700 Subject: [PATCH 011/498] refactor(time): golf toTime wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 26 +++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index c5dfc6e89..b38955e9b 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -321,10 +321,8 @@ noncomputable def neg (zero : TimeTransMan) (t : TimeTransMan) : TimeTransMan := negMetric zero default t lemma neg_eq_negMetric (zero : TimeTransMan) (x : TimeUnit) (t : TimeTransMan) : - neg zero t = negMetric zero x t := by - simp [neg, negMetric] - ext - simp [addTime_val, diff_eq_val] + neg zero t = negMetric zero x t := + ext_of (by simp [neg, negMetric, addTime_val, diff_eq_val]) /-! @@ -367,23 +365,18 @@ noncomputable def toTime (zero : TimeTransMan) (x : TimeUnit) : TimeTransMan ≃ @[simp] lemma toTime_zero (zero : TimeTransMan) (x : TimeUnit) : - toTime zero x zero = 0 := by - ext - simp [toTime, diff_eq_val] + toTime zero x zero = 0 := Time.ext (by simp [toTime, diff_eq_val]) @[simp] lemma toTime_symm_zero_add (zero : TimeTransMan) (x : TimeUnit) : - (toTime zero x).symm 0 = zero := by - ext - simp [toTime, addTime_val, diff_eq_val] + (toTime zero x).symm 0 = zero := + ext_of (by simp [toTime, addTime_val, diff_eq_val]) lemma toTime_val (zero : TimeTransMan) (x : TimeUnit) (t : TimeTransMan) : - (toTime zero x t).val = diff x t zero := by rfl + (toTime zero x t).val = diff x t zero := rfl lemma toTime_symm_val (zero : TimeTransMan) (x : TimeUnit) (r : Time) : - (toTime zero x).symm r = addTime x r zero := by - ext - simp [toTime, addTime_val, diff_eq_val] + (toTime zero x).symm r = addTime x r zero := rfl @[simp] lemma toTime_addTime (zero : TimeTransMan) (x : TimeUnit) (r : ℝ) (τ : TimeTransMan) : @@ -422,9 +415,8 @@ lemma toTime_neg (zero : TimeTransMan) (x : TimeUnit) (t : TimeTransMan) : ring lemma toTime_symm_neg (zero : TimeTransMan) (x : TimeUnit) (t : Time) : - (toTime zero x).symm (- t) = neg zero ((toTime zero x).symm t) := by - ext - simp [toTime_symm_val, addTime_val, diff_eq_val, neg, negMetric] + (toTime zero x).symm (- t) = neg zero ((toTime zero x).symm t) := + ext_of (by simp [toTime_symm_val, addTime_val, diff_eq_val, neg, negMetric]) lemma toTime_symm_sub (zero : TimeTransMan) (x : TimeUnit) (t1 t2 : Time) : (toTime zero x).symm (t1 - t2) = From e87acdd9e6f65edef93727974ff4a0cad62d8403 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:33:35 -0700 Subject: [PATCH 012/498] refactor(units): golf scale composition proofs Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/Mass/MassUnit.lean | 3 +-- Physlib/Electromagnetism/Charge/ChargeUnit.lean | 3 +-- Physlib/SpaceAndTime/Space/LengthUnit.lean | 3 +-- Physlib/SpaceAndTime/Time/TimeUnit.lean | 3 +-- Physlib/Thermodynamics/Temperature/TemperatureUnits.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/Mass/MassUnit.lean b/Physlib/ClassicalMechanics/Mass/MassUnit.lean index 2c0599458..01e6a008b 100644 --- a/Physlib/ClassicalMechanics/Mass/MassUnit.lean +++ b/Physlib/ClassicalMechanics/Mass/MassUnit.lean @@ -125,8 +125,7 @@ lemma scale_div_scale (x1 x2 : MassUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 < @[simp] lemma scale_scale (x : MassUnit) (r1 r2 : ℝ) (hr1 : 0 < r1) (hr2 : 0 < r2) : scale r1 (scale r2 x hr2) hr1 = scale (r1 * r2) x (mul_pos hr1 hr2) := by - simp [scale] - ring + simp [scale, mul_assoc] /-! diff --git a/Physlib/Electromagnetism/Charge/ChargeUnit.lean b/Physlib/Electromagnetism/Charge/ChargeUnit.lean index 805677145..149a4bed0 100644 --- a/Physlib/Electromagnetism/Charge/ChargeUnit.lean +++ b/Physlib/Electromagnetism/Charge/ChargeUnit.lean @@ -130,8 +130,7 @@ lemma scale_div_scale (x1 x2 : ChargeUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 @[simp] lemma scale_scale (x : ChargeUnit) (r1 r2 : ℝ) (hr1 : 0 < r1) (hr2 : 0 < r2) : scale r1 (scale r2 x hr2) hr1 = scale (r1 * r2) x (mul_pos hr1 hr2) := by - simp [scale] - ring + simp [scale, mul_assoc] /-! diff --git a/Physlib/SpaceAndTime/Space/LengthUnit.lean b/Physlib/SpaceAndTime/Space/LengthUnit.lean index e4d32fea5..e64202b3a 100644 --- a/Physlib/SpaceAndTime/Space/LengthUnit.lean +++ b/Physlib/SpaceAndTime/Space/LengthUnit.lean @@ -125,8 +125,7 @@ lemma scale_div_scale (x1 x2 : LengthUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 @[simp] lemma scale_scale (x : LengthUnit) (r1 r2 : ℝ) (hr1 : 0 < r1) (hr2 : 0 < r2) : scale r1 (scale r2 x hr2) hr1 = scale (r1 * r2) x (mul_pos hr1 hr2) := by - simp [scale] - ring + simp [scale, mul_assoc] /-! ## Specific choices of Length units diff --git a/Physlib/SpaceAndTime/Time/TimeUnit.lean b/Physlib/SpaceAndTime/Time/TimeUnit.lean index 2da8bd01b..91d53d9c8 100644 --- a/Physlib/SpaceAndTime/Time/TimeUnit.lean +++ b/Physlib/SpaceAndTime/Time/TimeUnit.lean @@ -127,8 +127,7 @@ lemma self_div_scale (x : TimeUnit) (r : ℝ) (hr : 0 < r) : @[simp] lemma scale_scale (x : TimeUnit) (r1 r2 : ℝ) (hr1 : 0 < r1) (hr2 : 0 < r2) : scale r1 (scale r2 x hr2) hr1 = scale (r1 * r2) x (mul_pos hr1 hr2) := by - simp [scale] - ring + simp [scale, mul_assoc] /-! ## Specific choices of time units diff --git a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean index 0b61fad11..220ceed83 100644 --- a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean +++ b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean @@ -127,8 +127,7 @@ lemma scale_div_scale (x1 x2 : TemperatureUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr @[simp] lemma scale_scale (x : TemperatureUnit) (r1 r2 : ℝ) (hr1 : 0 < r1) (hr2 : 0 < r2) : scale r1 (scale r2 x hr2) hr1 = scale (r1 * r2) x (mul_pos hr1 hr2) := by - simp [scale] - ring + simp [scale, mul_assoc] /-! From e1f3b7394edbe2ca85260e5fb56ba009534dabc8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:36:08 -0700 Subject: [PATCH 013/498] refactor(units): golf definitional unit lemmas Co-authored-by: Claude Opus 4.8 --- Physlib/Units/Basic.lean | 5 ++--- Physlib/Units/Integral.lean | 2 +- Physlib/Units/UnitDependent.lean | 5 +++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Physlib/Units/Basic.lean b/Physlib/Units/Basic.lean index b604f276d..55b4243d8 100644 --- a/Physlib/Units/Basic.lean +++ b/Physlib/Units/Basic.lean @@ -309,8 +309,7 @@ def HasDimension {M : Type} [CarriesDimension M] (f : UnitChoices → M) : Prop lemma hasDimension_iff {M : Type} [CarriesDimension M] (f : UnitChoices → M) : HasDimension f ↔ ∀ u1 u2 : UnitChoices, f u2 = - UnitChoices.dimScale u1 u2 (dim M) • f u1 := by - rfl + UnitChoices.dimScale u1 u2 (dim M) • f u1 := Iff.rfl /-- The subtype of functions `UnitChoices → M`, for which `M` carries a dimension, which `HasDimension`. -/ @@ -365,4 +364,4 @@ noncomputable def CarriesDimension.toDimensionful {M : Type} [CarriesDimension M lemma CarriesDimension.toDimensionful_apply_apply {M : Type} [CarriesDimension M] (u1 u2 : UnitChoices) (m : M) : - (toDimensionful u1 m).1 u2 = (u1.dimScale u2 (dim M)) • m := by rfl + (toDimensionful u1 m).1 u2 = (u1.dimScale u2 (dim M)) • m := rfl diff --git a/Physlib/Units/Integral.lean b/Physlib/Units/Integral.lean index ae28cffb6..1f5eb481d 100644 --- a/Physlib/Units/Integral.lean +++ b/Physlib/Units/Integral.lean @@ -55,7 +55,7 @@ variable {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] [HasDim M] [NormedAddCommGroup G] [NormedSpace ℝ G] [HasDim G] lemma scaleUnit_measure (u1 u2 : UnitChoices) (μ : MeasureTheory.Measure M) : - scaleUnit u1 u2 μ = μ.map (fun m => scaleUnit u1 u2 m) := by rfl + scaleUnit u1 u2 μ = μ.map (fun m => scaleUnit u1 u2 m) := rfl /-- The statement that for a measure `μ` of dimension `d`, and a function `f : M → G` of dimension `(CarriesDimension.d G * d⁻¹)` (where `CarriesDimension.d G` diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index a8580109a..1c9157018 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -438,7 +438,7 @@ def IsDimensionallyCorrect {M : Type} [UnitDependent M] (m : M) : Prop := lemma isDimensionallyCorrect_iff {M : Type} [UnitDependent M] (m : M) : IsDimensionallyCorrect m ↔ ∀ u1 u2 : UnitChoices, - scaleUnit u1 u2 m = m := by rfl + scaleUnit u1 u2 m = m := Iff.rfl @[simp] lemma isDimensionallyCorrect_fun_iff {M1 M2 : Type} [UnitDependent M1] [UnitDependent M2] @@ -526,4 +526,5 @@ lemma scaleUnit_dimSet_val {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] rfl lemma DimSet.mem_iff {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) (m : M) : - m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := by rfl + m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := + Iff.rfl From 8d55056fa7022242299bd74ba7d56bab258e819c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:41:24 -0700 Subject: [PATCH 014/498] refactor(space): golf wrapper algebra proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/Basic.lean | 11 ++--- Physlib/SpaceAndTime/Space/Module.lean | 64 +++++++------------------- 2 files changed, 19 insertions(+), 56 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Basic.lean b/Physlib/SpaceAndTime/Space/Basic.lean index 794987c57..ee2ee428d 100644 --- a/Physlib/SpaceAndTime/Space/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Basic.lean @@ -151,7 +151,7 @@ lemma vadd_val {d} (v : EuclideanSpace ℝ (Fin d)) (s : Space d) : @[simp] lemma vadd_apply {d} (v : EuclideanSpace ℝ (Fin d)) (s : Space d) (i : Fin d) : - (v +ᵥ s) i = v i + s i := by rfl + (v +ᵥ s) i = v i + s i := rfl lemma vadd_transitive {d} (s1 s2 : Space d) : ∃ v : EuclideanSpace ℝ (Fin d), v +ᵥ s1 = s2 := by @@ -160,13 +160,8 @@ lemma vadd_transitive {d} (s1 s2 : Space d) : simp noncomputable instance : AddAction (EuclideanSpace ℝ (Fin d)) (Space d) where - zero_vadd s := by - ext i - simp - add_vadd v1 v2 s := by - ext i - simp only [vadd_apply, PiLp.add_apply] - ring + zero_vadd s := eq_of_apply fun i => by simp + add_vadd v1 v2 s := eq_of_apply fun i => by simp [add_assoc] /-! diff --git a/Physlib/SpaceAndTime/Space/Module.lean b/Physlib/SpaceAndTime/Space/Module.lean index 94afdb17f..4376bc1db 100644 --- a/Physlib/SpaceAndTime/Space/Module.lean +++ b/Physlib/SpaceAndTime/Space/Module.lean @@ -68,22 +68,10 @@ lemma add_apply {d : ℕ} (x y : Space d) (i : Fin d) : simp [add_val] instance {d} : AddCommMonoid (Space d) where - add_assoc a b c:= by - apply eq_of_val - simp only [add_val] - ring - zero_add a := by - apply eq_of_val - simp only [zero_val, add_val, add_eq_right] - rfl - add_zero a := by - apply eq_of_val - simp only [zero_val, add_val, add_eq_left] - rfl - add_comm a b := by - apply eq_of_val - simp only [add_val] - ring + add_assoc a b c := eq_of_apply fun i => by simp [add_assoc] + zero_add a := eq_of_apply fun i => by simp + add_zero a := eq_of_apply fun i => by simp + add_comm a b := eq_of_apply fun i => by simp [add_comm] nsmul n a := ⟨fun i => n • a.val i⟩ @[simp] @@ -92,7 +80,7 @@ lemma nsmul_val {d : ℕ} (n : ℕ) (a : Space d) : @[simp] lemma nsmul_apply {d : ℕ} (n : ℕ) (a : Space d) (i : Fin d) : - (n • a) i = n • (a i) := by rfl + (n • a) i = n • (a i) := rfl lemma eq_vadd_zero {d} (s : Space d) : ∃ v : EuclideanSpace ℝ (Fin d), s = v +ᵥ (0 : Space d) := by @@ -130,27 +118,12 @@ lemma smul_vadd_zero {d} (k : ℝ) (v : EuclideanSpace ℝ (Fin d)) : simp instance {d} : Module ℝ (Space d) where - one_smul x := by - ext i - simp - mul_smul a b x := by - ext i - simp only [smul_apply] - ring - smul_add a x y := by - ext i - simp only [smul_apply, add_apply] - ring - smul_zero a := by - ext i - simp - add_smul a b x := by - ext i - simp only [smul_apply, add_apply] - ring - zero_smul x := by - ext i - simp + one_smul x := eq_of_apply fun i => by simp + mul_smul a b x := eq_of_apply fun i => by simp [mul_assoc] + smul_add a x y := eq_of_apply fun i => by simp [mul_add] + smul_zero a := eq_of_apply fun i => by simp + add_smul a b x := eq_of_apply fun i => by simp [add_mul] + zero_smul x := eq_of_apply fun i => by simp /-! @@ -161,8 +134,7 @@ instance {d} : Module ℝ (Space d) where noncomputable instance {d} : Norm (Space d) where norm p := √ (∑ i, (p i)^2) -lemma norm_eq {d} (p : Space d) : ‖p‖ = √ (∑ i, (p i) ^ 2) := by - rfl +lemma norm_eq {d} (p : Space d) : ‖p‖ = √ (∑ i, (p i) ^ 2) := rfl @[simp] lemma abs_eval_le_norm {d} (p : Space d) (i : Fin d) : @@ -197,16 +169,12 @@ lemma neg_val {d : ℕ} (p : Space d) : @[simp] lemma neg_apply {d : ℕ} (p : Space d) (i : Fin d) : - (-p) i = - (p i) := by rfl + (-p) i = - (p i) := rfl noncomputable instance {d} : AddCommGroup (Space d) where zsmul z p := ⟨fun i => z * p.val i⟩ - neg_add_cancel p := by - ext i - simp - zsmul_zero' p := by - ext i - simp + neg_add_cancel p := eq_of_apply fun i => by simp + zsmul_zero' p := eq_of_apply fun i => by simp zsmul_succ' n p := by ext i simp only [Nat.succ_eq_add_one, Nat.cast_add, Nat.cast_one, Int.cast_add, Int.cast_natCast, @@ -225,7 +193,7 @@ lemma sub_apply {d} (p q : Space d) (i : Fin d) : @[simp] lemma sub_val {d} (p q : Space d) : - (p - q).val = fun i => p.val i - q.val i := by rfl + (p - q).val = fun i => p.val i - q.val i := rfl @[simp] lemma vadd_zero_sub_vadd_zero {d} (v1 v2 : EuclideanSpace ℝ (Fin d)) : From 3dbdbcace3e1c3e8b28b437a97af9b98df2b3a90 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:46:08 -0700 Subject: [PATCH 015/498] refactor(space): golf derivative and basis proofs Co-authored-by: Claude Opus 4.8 --- .../SpaceAndTime/Space/Derivatives/Basic.lean | 6 +-- .../SpaceAndTime/Space/Derivatives/Grad.lean | 21 ++------ Physlib/SpaceAndTime/Space/Module.lean | 49 +++++++------------ Physlib/SpaceAndTime/Space/Slice.lean | 2 +- 4 files changed, 24 insertions(+), 54 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index b0b16689f..c19c5e7ca 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -80,15 +80,15 @@ macro "∂[" i:term "]" : term => `(deriv $i) lemma deriv_eq [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (μ : Fin d) (f : Space d → M) (x : Space d) : - deriv μ f x = fderiv ℝ f x (basis μ) := by rfl + deriv μ f x = fderiv ℝ f x (basis μ) := rfl lemma deriv_eq_fderiv_fun [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (μ : Fin d) (f : Space d → M) : - deriv μ f = fun x => fderiv ℝ (fun x => f x) x (basis μ) := by rfl + deriv μ f = fun x => fderiv ℝ (fun x => f x) x (basis μ) := rfl lemma deriv_eq_fderiv_basis [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (μ : Fin d) (f : Space d → M) (x : Space d) : - deriv μ f x = fderiv ℝ f x (basis μ) := by rfl + deriv μ f x = fderiv ℝ f x (basis μ) := rfl lemma fderiv_eq_sum_deriv {M d} [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (f : Space d → M) (x y : Space d) : diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean index 38eb0f25c..9c68cd40b 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean @@ -96,13 +96,8 @@ lemma grad_zero : ∇ (0 : Space d → ℝ) = 0 := by lemma grad_add (f1 f2 : Space d → ℝ) (hf1 : Differentiable ℝ f1) (hf2 : Differentiable ℝ f2) : ∇ (f1 + f2) = ∇ f1 + ∇ f2 := by - unfold grad ext x i - simp only [Pi.add_apply] - rw [deriv_add] - rfl - exact hf1 - exact hf2 + simp [grad, deriv_add f1 f2 hf1 hf2] @[simp] lemma grad_fun_add_const (f : Space d → ℝ) (c : ℝ) : @@ -132,12 +127,8 @@ lemma grad_const : ∇ (fun _ : Space d => c) = 0 := by lemma grad_smul (f : Space d → ℝ) (k : ℝ) (hf : Differentiable ℝ f) : ∇ (k • f) = k • ∇ f := by - unfold grad ext x i - simp only [Pi.smul_apply] - rw [deriv_const_smul] - rfl - exact hf + simp [grad, deriv_const_smul k hf] /-! @@ -183,13 +174,7 @@ lemma grad_eq_sum {d} (f : Space d → ℝ) (x : Space d) : -/ lemma grad_apply {d} (f : Space d → ℝ) (x : Space d) (i : Fin d) : - (∇ f x) i = ∂[i] f x := by - rw [grad_eq_sum] - change WithLp.linearEquiv 2 ℝ (Fin d → ℝ) (∑ x_1, (fderiv ℝ f x) (basis x_1) • - EuclideanSpace.single x_1 1) i = _ - rw [map_sum, Finset.sum_apply] - simp [Pi.single_apply] - rfl + (∇ f x) i = ∂[i] f x := rfl /-! diff --git a/Physlib/SpaceAndTime/Space/Module.lean b/Physlib/SpaceAndTime/Space/Module.lean index 4376bc1db..b6880ea72 100644 --- a/Physlib/SpaceAndTime/Space/Module.lean +++ b/Physlib/SpaceAndTime/Space/Module.lean @@ -109,13 +109,12 @@ lemma smul_val {d : ℕ} (c : ℝ) (p : Space d) : @[simp] lemma smul_apply {d : ℕ} (c : ℝ) (p : Space d) (i : Fin d) : - (c • p) i = c * (p i) := by rfl + (c • p) i = c * (p i) := rfl @[simp] lemma smul_vadd_zero {d} (k : ℝ) (v : EuclideanSpace ℝ (Fin d)) : - k • (v +ᵥ (0 : Space d)) = (k • v) +ᵥ (0 : Space d) := by - ext i - simp + k • (v +ᵥ (0 : Space d)) = (k • v) +ᵥ (0 : Space d) := + eq_of_apply fun i => by simp instance {d} : Module ℝ (Space d) where one_smul x := eq_of_apply fun i => by simp @@ -152,8 +151,7 @@ lemma norm_sq_eq {d} (p : Space d) : positivity lemma point_dim_zero_eq (p : Space 0) : p = 0 := by - ext i - fin_cases i + exact eq_of_apply fun i => by fin_cases i @[simp] lemma norm_vadd_zero {d} (v : EuclideanSpace ℝ (Fin d)) : @@ -188,8 +186,7 @@ noncomputable instance {d} : AddCommGroup (Space d) where @[simp] lemma sub_apply {d} (p q : Space d) (i : Fin d) : - (p - q) i = p i - q i := by - simp [sub_eq_add_neg, neg_apply, add_apply] + (p - q) i = p i - q i := rfl @[simp] lemma sub_val {d} (p q : Space d) : @@ -197,9 +194,8 @@ lemma sub_val {d} (p q : Space d) : @[simp] lemma vadd_zero_sub_vadd_zero {d} (v1 v2 : EuclideanSpace ℝ (Fin d)) : - (v1 +ᵥ (0 : Space d)) - (v2 +ᵥ (0 : Space d)) = (v1 - v2) +ᵥ (0 : Space d) := by - ext i - simp [sub_apply, vadd_apply] + (v1 +ᵥ (0 : Space d)) - (v2 +ᵥ (0 : Space d)) = (v1 - v2) +ᵥ (0 : Space d) := + eq_of_apply fun i => by simp [sub_apply, vadd_apply] @[simp] lemma dist_eq_norm {d} (p q : Space d) : @@ -231,7 +227,7 @@ lemma inner_vadd_zero {d} (v1 v2 : EuclideanSpace ℝ (Fin d)) : ring lemma inner_apply {d} (p q : Space d) : - inner ℝ p q = ∑ i, p i * q i := by rfl + inner ℝ p q = ∑ i, p i * q i := rfl instance {d} : InnerProductSpace ℝ (Space d) where norm_smul_le a x := by @@ -272,7 +268,7 @@ lemma norm_smul_sphere {d : ℕ} (n : ↑(Metric.sphere (0 : Space d) 1)) noncomputable instance {d : ℕ} : MeasurableSpace (Space d) := borel (Space d) instance {d : ℕ} : BorelSpace (Space d) where - measurable_eq := by rfl + measurable_eq := rfl /-! @@ -287,8 +283,7 @@ instance {d : ℕ} : BorelSpace (Space d) where -/ lemma inner_eq_sum {d} (p q : Space d) : - inner ℝ p q = ∑ i, p i * q i := by - simp [inner] + inner ℝ p q = ∑ i, p i * q i := inner_apply p q @[simp] lemma sum_apply {ι : Type} [Fintype ι] (f : ι → Space d) (i : Fin d) : @@ -330,34 +325,24 @@ noncomputable def basis {d} : OrthonormalBasis (Fin d) ℝ (Space d) where repr := { toFun p := WithLp.toLp 2 fun i => p i invFun := fun v => ⟨v⟩ - left_inv := by - intro p - rfl - right_inv := by - intro v - rfl - map_add' := by - intro v1 v2 - rfl - map_smul' := by - intro c v - rfl + left_inv := fun p => rfl + right_inv := fun v => rfl + map_add' := fun v1 v2 => rfl + map_smul' := fun c v => rfl norm_map' := by intro x simp [norm_eq, PiLp.norm_eq_of_L2]} lemma apply_eq_basis_repr_apply {d} (p : Space d) (i : Fin d) : - p i = basis.repr p i := by - simp [basis] + p i = basis.repr p i := rfl @[simp] lemma basis_repr_apply {d} (p : Space d) (i : Fin d) : - basis.repr p i = p i := by - simp [apply_eq_basis_repr_apply] + basis.repr p i = p i := rfl @[simp] lemma basis_repr_symm_apply {d} (v : EuclideanSpace ℝ (Fin d)) (i : Fin d) : - basis.repr.symm v i = v i := by rfl + basis.repr.symm v i = v i := rfl lemma basis_apply {d} (i j : Fin d) : basis i j = if i = j then 1 else 0 := by diff --git a/Physlib/SpaceAndTime/Space/Slice.lean b/Physlib/SpaceAndTime/Space/Slice.lean index 4487e19d3..0fd5eed09 100644 --- a/Physlib/SpaceAndTime/Space/Slice.lean +++ b/Physlib/SpaceAndTime/Space/Slice.lean @@ -101,7 +101,7 @@ def slice {d} (i : Fin d.succ) : Space d.succ ≃L[ℝ] ℝ × Space d where lemma slice_symm_apply {d : ℕ} (i : Fin d.succ) (r : ℝ) (x : Space d) : (slice i).symm (r, x) = fun j => - Fin.insertNthEquiv (fun _ => ℝ) i (r, x) j := by rfl + Fin.insertNthEquiv (fun _ => ℝ) i (r, x) j := rfl @[simp] lemma slice_symm_apply_self {d : ℕ} (i : Fin d.succ) (r : ℝ) (x : Space d) : From 1f18574809957b2e4bbfcf612e26edd267e30dac Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:49:25 -0700 Subject: [PATCH 016/498] refactor(space): golf derivative operator proofs Co-authored-by: Claude Opus 4.8 --- .../SpaceAndTime/Space/Derivatives/Div.lean | 12 ++++-------- .../SpaceAndTime/Space/Derivatives/Grad.lean | 19 ++++++------------- .../Space/Derivatives/Laplacian.lean | 4 +--- .../Space/Derivatives/MatrixDiv.lean | 5 +---- .../Space/Derivatives/MultiIndex.lean | 4 +--- 5 files changed, 13 insertions(+), 31 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Div.lean b/Physlib/SpaceAndTime/Space/Derivatives/Div.lean index 92f8daac2..1fe06db93 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Div.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Div.lean @@ -83,10 +83,8 @@ lemma div_eq_sum_fderiv {d} (f : Space d → EuclideanSpace ℝ (Fin d)) @[simp] lemma div_zero : ∇ ⬝ (0 : Space d → EuclideanSpace ℝ (Fin d)) = 0 := by - unfold div Space.deriv Finset.sum - simp only [Pi.ofNat_apply, fderiv_fun_const, _root_.zero_apply, Multiset.map_const', - Finset.card_val, Finset.card_univ, Fintype.card_fin, Multiset.sum_replicate, smul_zero] - rfl + ext x + simp [div, Space.deriv] /-! @@ -96,10 +94,8 @@ lemma div_zero : ∇ ⬝ (0 : Space d → EuclideanSpace ℝ (Fin d)) = 0 := by @[simp] lemma div_const : ∇ ⬝ (fun _ : Space d => v) = 0 := by - unfold div Space.deriv Finset.sum - simp only [fderiv_fun_const, Pi.ofNat_apply, _root_.zero_apply, Multiset.map_const', - Finset.card_val, Finset.card_univ, Fintype.card_fin, Multiset.sum_replicate, smul_zero] - rfl + ext x + simp [div, Space.deriv] /-! diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean index 9c68cd40b..dd46d0b26 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean @@ -82,9 +82,8 @@ scoped[Space] notation "∇" => grad @[simp] lemma grad_zero : ∇ (0 : Space d → ℝ) = 0 := by - unfold grad Space.deriv - simp only [fderiv_zero, Pi.zero_apply, _root_.zero_apply] - rfl + ext x i + simp [grad, Space.deriv] /-! @@ -113,9 +112,8 @@ lemma grad_fun_add_const (f : Space d → ℝ) (c : ℝ) : @[simp] lemma grad_const : ∇ (fun _ : Space d => c) = 0 := by - unfold grad Space.deriv - simp only [fderiv_fun_const, Pi.ofNat_apply, _root_.zero_apply] - rfl + ext x i + simp [grad, Space.deriv] /-! @@ -139,11 +137,8 @@ lemma grad_smul (f : Space d → ℝ) (k : ℝ) @[to_fun] lemma grad_neg (f : Space d → ℝ) : ∇ (- f) = - ∇ f := by - unfold grad ext x i - simp only [Pi.neg_apply] - rw [Space.deriv_eq, fderiv_neg] - rfl + simp [grad, Space.deriv, fderiv_neg] /-! @@ -186,9 +181,7 @@ open InnerProductSpace lemma grad_inner_single {d} (f : Space d → ℝ) (x : Space d) (i : Fin d) : ⟪∇ f x, EuclideanSpace.single i 1⟫_ℝ = ∂[i] f x := by - simp only [EuclideanSpace.inner_single_right, conj_trivial, - one_mul] - exact rfl + simpa only [EuclideanSpace.inner_single_right, conj_trivial, one_mul] using grad_apply f x i lemma grad_inner_eq {d} (f : Space d → ℝ) (x : Space d) (y : EuclideanSpace ℝ (Fin d)) : ⟪∇ f x, y⟫_ℝ = ∑ i, y i * ∂[i] f x:= by diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean b/Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean index dcdb7a4b6..361b7bdbe 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean @@ -57,9 +57,7 @@ scoped[Space] notation "Δ" => laplacian -/ lemma laplacian_eq_sum_snd_deriv {d} (f : Space d → ℝ) : - Δ f = fun x => ∑ i, ∂[i] (∂[i] f) x := by - unfold laplacian div grad - simp + Δ f = fun x => ∑ i, ∂[i] (∂[i] f) x := rfl /-! diff --git a/Physlib/SpaceAndTime/Space/Derivatives/MatrixDiv.lean b/Physlib/SpaceAndTime/Space/Derivatives/MatrixDiv.lean index c7a61b815..3899baae6 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/MatrixDiv.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/MatrixDiv.lean @@ -69,8 +69,7 @@ noncomputable def matrixDiv (d : ℕ) (T : Space d → Matrix (Fin d) (Fin d) @[simp] lemma matrixDiv_apply (d : ℕ) (T : Space d → Matrix (Fin d) (Fin d) ℝ) (x : Space d) (i : Fin d) : - matrixDiv d T x i = ∑ j, ∂[j] (fun x => T x i j) x := by - simp [matrixDiv, div] + matrixDiv d T x i = ∑ j, ∂[j] (fun x => T x i j) x := rfl /-! @@ -82,7 +81,6 @@ lemma matrixDiv_apply (d : ℕ) (T : Space d → Matrix (Fin d) (Fin d) ℝ) lemma matrixDiv_zero (d : ℕ) : matrixDiv d (0 : Space d → Matrix (Fin d) (Fin d) ℝ) = 0 := by ext x i - change (∑ j : Fin d, ∂[j] (fun _ : Space d => (0 : ℝ)) x) = 0 simp /-! @@ -95,7 +93,6 @@ lemma matrixDiv_zero (d : ℕ) : lemma matrixDiv_const (d : ℕ) (T : Matrix (Fin d) (Fin d) ℝ) : matrixDiv d (fun _ : Space d => T) = 0 := by ext x i - change (∑ j : Fin d, ∂[j] (fun _ : Space d => T i j) x) = 0 simp /-! diff --git a/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean b/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean index 999ac2613..92c1cfac3 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean @@ -142,9 +142,7 @@ def toList : {d : ℕ} → MultiIndex d → List (Fin d) | _ + 1, I => List.replicate (I 0) 0 ++ (toList (tail I)).map Fin.succ @[simp] -lemma tail_zero : tail (0 : MultiIndex d.succ) = 0 := by - ext i - rfl +lemma tail_zero : tail (0 : MultiIndex d.succ) = 0 := rfl @[simp] lemma tail_increment_zero (I : MultiIndex d.succ) : tail (increment I 0) = tail I := by From bba8105ea551fb0534ff47c387a9f58b9989bfe3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:52:07 -0700 Subject: [PATCH 017/498] refactor(space): golf wrapper coercion proofs Co-authored-by: Claude Opus 4.8 --- .../SpaceAndTime/Space/ConstantSliceDist.lean | 6 ++--- Physlib/SpaceAndTime/Space/Module.lean | 22 ++++++++----------- Physlib/SpaceAndTime/Space/Origin.lean | 4 +--- Physlib/SpaceAndTime/Space/Translations.lean | 4 +--- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index e1f7f1918..acd0b4304 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -576,8 +576,7 @@ def sliceSchwartz {d : ℕ} (i : Fin d.succ) : rfl lemma sliceSchwartz_apply {d : ℕ} (i : Fin d.succ) (η : 𝓢(Space d.succ, ℝ)) (x : Space d) : - sliceSchwartz i η x = ∫ (r : ℝ), η ((slice i).symm (r, x)) := by - rfl + sliceSchwartz i η x = ∫ (r : ℝ), η ((slice i).symm (r, x)) := rfl /-! ## B. Constant slice distribution @@ -598,8 +597,7 @@ def constantSliceDist {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : lemma constantSliceDist_apply {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : ℕ} (i : Fin d.succ) (f : (Space d) →d[ℝ] M) (η : 𝓢(Space d.succ, ℝ)) : - constantSliceDist i f η = f (sliceSchwartz i η) := by - rfl + constantSliceDist i f η = f (sliceSchwartz i η) := rfl /-! diff --git a/Physlib/SpaceAndTime/Space/Module.lean b/Physlib/SpaceAndTime/Space/Module.lean index b6880ea72..629148a99 100644 --- a/Physlib/SpaceAndTime/Space/Module.lean +++ b/Physlib/SpaceAndTime/Space/Module.lean @@ -90,9 +90,8 @@ lemma eq_vadd_zero {d} (s : Space d) : @[simp] lemma add_vadd_zero {d} (v1 v2 : EuclideanSpace ℝ (Fin d)) : - (v1 +ᵥ (0 : Space d)) + (v2 +ᵥ (0 : Space d)) = (v1 + v2) +ᵥ (0 : Space d) := by - ext i - simp + (v1 +ᵥ (0 : Space d)) + (v2 +ᵥ (0 : Space d)) = (v1 + v2) +ᵥ (0 : Space d) := + eq_of_apply fun i => by simp /-! @@ -450,8 +449,7 @@ lemma coord_contDiff {i} : ContDiff ℝ ∞ (fun x : Space d => x.coord i) := by fun_prop lemma coordCLM_apply (μ : Fin d) (p : Space d) : - coordCLM μ p = coord μ p := by - rfl + coordCLM μ p = coord μ p := rfl @[inherit_doc coord] scoped notation "𝔁" => coord @@ -596,8 +594,8 @@ noncomputable def oneEquiv : Space 1 ≃ₗᵢ[ℝ] ℝ where left_inv x := by ext i; fin_cases i; simp right_inv x := by simp - map_add' x y := by rfl - map_smul' c x := by rfl + map_add' x y := rfl + map_smul' c x := rfl norm_map' x := by simp only [Fin.isValue, LinearEquiv.coe_mk, LinearMap.coe_mk, AddHom.coe_mk, Real.norm_eq_abs] rw [norm_eq] @@ -605,12 +603,10 @@ noncomputable def oneEquiv : Space 1 ≃ₗᵢ[ℝ] ℝ where exact Eq.symm (Real.sqrt_sq_eq_abs (x 0)) lemma oneEquiv_coe : - (oneEquiv : Space 1 → ℝ) = fun x => x 0 := by - rfl + (oneEquiv : Space 1 → ℝ) = fun x => x 0 := rfl lemma oneEquiv_symm_coe : - (oneEquiv.symm : ℝ → Space 1) = (fun x => ⟨fun _ => x⟩) := by - rfl + (oneEquiv.symm : ℝ → Space 1) = (fun x => ⟨fun _ => x⟩) := rfl lemma oneEquiv_symm_apply (x : ℝ) (i : Fin 1) : oneEquiv.symm x i = x := by @@ -661,8 +657,8 @@ lemma oneEquiv_symm_measurableEmbedding : MeasurableEmbedding oneEquiv.symm wher lemma oneEquiv_measurePreserving : MeasurePreserving oneEquiv volume volume := LinearIsometryEquiv.measurePreserving oneEquiv -lemma oneEquiv_symm_measurePreserving : MeasurePreserving oneEquiv.symm volume volume := by - exact LinearIsometryEquiv.measurePreserving oneEquiv.symm +lemma oneEquiv_symm_measurePreserving : MeasurePreserving oneEquiv.symm volume volume := + LinearIsometryEquiv.measurePreserving oneEquiv.symm /-! diff --git a/Physlib/SpaceAndTime/Space/Origin.lean b/Physlib/SpaceAndTime/Space/Origin.lean index 360d10492..5f236d8d2 100644 --- a/Physlib/SpaceAndTime/Space/Origin.lean +++ b/Physlib/SpaceAndTime/Space/Origin.lean @@ -33,8 +33,7 @@ lemma zero_val {d : ℕ} : (0 : Space d).val = fun _ => 0 := rfl @[simp] lemma zero_apply {d : ℕ} (i : Fin d) : - (0 : Space d) i = 0 := by - simp [zero_val] + (0 : Space d) i = 0 := rfl /-- A Euclidean vector, based at the chosen origin, viewed as a point of `Space d`. -/ noncomputable def vectorToSpace {d : ℕ} (v : EuclideanSpace ℝ (Fin d)) : Space d := @@ -48,7 +47,6 @@ lemma vectorToSpace_apply {d : ℕ} (v : EuclideanSpace ℝ (Fin d)) (i : Fin d) @[simp] lemma vectorToSpace_vsub_zero {d : ℕ} (v : EuclideanSpace ℝ (Fin d)) : vectorToSpace v -ᵥ (0 : Space d) = v := by - ext i simp [vectorToSpace] /-- The standard chart `Space d ≃ᵃⁱ[ℝ] EuclideanSpace ℝ (Fin d)`, `p ↦ p -ᵥ 0`, identifying a point diff --git a/Physlib/SpaceAndTime/Space/Translations.lean b/Physlib/SpaceAndTime/Space/Translations.lean index 7ce7c116d..d171b19e0 100644 --- a/Physlib/SpaceAndTime/Space/Translations.lean +++ b/Physlib/SpaceAndTime/Space/Translations.lean @@ -89,9 +89,7 @@ lemma translateSchwartz_apply {d : ℕ} (a : EuclideanSpace ℝ (Fin d)) lemma translateSchwartz_coe_eq {d : ℕ} (a : EuclideanSpace ℝ (Fin d)) (η : 𝓢(Space d, X)) : - (translateSchwartz a η : Space d → X) = fun x => η (x - basis.repr.symm a) := by - ext - simp + (translateSchwartz a η : Space d → X) = fun x => η (x - basis.repr.symm a) := rfl /-- The continuous linear map translating distributions. -/ noncomputable def distTranslate {d : ℕ} (a : EuclideanSpace ℝ (Fin d)) : From 0dc13d05c2461e7977b5f448ab4353e8e2cf60c3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:55:42 -0700 Subject: [PATCH 018/498] refactor(space): golf euclidean group proofs Co-authored-by: Claude Opus 4.8 --- .../Space/EuclideanGroup/AffineGroup.lean | 14 ++++---------- .../SpaceAndTime/Space/EuclideanGroup/Basic.lean | 8 +++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean index 5e57a6106..c0cfc4827 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean @@ -76,12 +76,8 @@ noncomputable def toAffineIsometryHom : AffineIsometryEquiv ℝ (EuclideanSpace ℝ (Fin n)) (EuclideanSpace ℝ (Fin n)) where toFun A := AffineIsometryEquiv.constVAdd ℝ (EuclideanSpace ℝ (Fin n)) A.translation * (orthogonalToLinearIsometryEquiv A.linear).toAffineIsometryEquiv - map_one' := by - apply AffineIsometryEquiv.ext - intro x; simp - map_mul' A B := by - apply AffineIsometryEquiv.ext - intro x + map_one' := AffineIsometryEquiv.ext fun x => by simp + map_mul' A B := AffineIsometryEquiv.ext fun x => by simp [mul_smul, add_assoc] /-- Unfolds `toAffineIsometryHom` into its translation and linear factors. -/ @@ -96,10 +92,8 @@ noncomputable def _root_.AffineIsometryEquiv.toAffineEquivHom : AffineIsometryEquiv ℝ (EuclideanSpace ℝ (Fin n)) (EuclideanSpace ℝ (Fin n)) →* AffineEquiv ℝ (EuclideanSpace ℝ (Fin n)) (EuclideanSpace ℝ (Fin n)) where toFun e := e.toAffineEquiv - map_one' := by - apply AffineEquiv.ext; intro x; trivial - map_mul' e e' := by - apply AffineEquiv.ext; intro x; simp + map_one' := AffineEquiv.ext fun x => by trivial + map_mul' e e' := AffineEquiv.ext fun x => by simp /-- The inclusion of the Euclidean group into Mathlib's affine automorphism group: the composite of the two legs `toAffineIsometryHom` and `AffineIsometryEquiv.toAffineEquivHom`. -/ diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean index cb378c177..119b848e9 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean @@ -125,7 +125,7 @@ noncomputable def TranslationGroup.incl (n : ℕ) : def translationVector.incl (n : ℕ) : Multiplicative (EuclideanSpace ℝ (Fin n)) →* EuclideanGroup n where toFun v := ⟨v.toAdd, 1⟩ - map_one' := by rfl + map_one' := rfl map_mul' x y := by refine EuclideanGroup.ext ?_ ?_ · show Multiplicative.toAdd (x * y) = @@ -355,10 +355,8 @@ noncomputable def specialOrthogonal.fromRotation (n : ℕ) : the forward leg of the isomorphism `specialOrthogonalEquiv`. -/ lemma specialOrthogonal.fromRotation_comp_toRotation : (specialOrthogonal.fromRotation n).comp (specialOrthogonal.toRotation n) = - MonoidHom.id (Matrix.specialOrthogonalGroup (Fin n) ℝ) := by - apply MonoidHom.ext - intro x - rfl + MonoidHom.id (Matrix.specialOrthogonalGroup (Fin n) ℝ) := + MonoidHom.ext fun _ => rfl /-- `specialOrthogonal.fromRotation n` followed by `specialOrthogonal.toRotation n` is the identity; the backward leg of the isomorphism `specialOrthogonalEquiv`. -/ From 0b79d4663b87aa53fa1fa4fa9d7e32f7abf2e382 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 09:59:53 -0700 Subject: [PATCH 019/498] refactor(space): golf integral wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/DistOfFunction.lean | 4 ++-- Physlib/SpaceAndTime/Space/Integrals/Basic.lean | 7 +++---- .../SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean | 3 +-- Physlib/SpaceAndTime/Space/LengthUnit.lean | 3 +-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/DistOfFunction.lean b/Physlib/SpaceAndTime/Space/DistOfFunction.lean index 8fbc194ba..7234f56e3 100644 --- a/Physlib/SpaceAndTime/Space/DistOfFunction.lean +++ b/Physlib/SpaceAndTime/Space/DistOfFunction.lean @@ -116,8 +116,8 @@ lemma distOfFunction_smul_fun {d : ℕ} (f : Space d → F) lemma distOfFunction_mul_fun {d : ℕ} (f : Space d → ℝ) (hf : IsDistBounded f) (c : ℝ) : - distOfFunction (fun x => c * f x) (by fun_prop) = c • distOfFunction f hf := by - exact distOfFunction_smul_fun f hf c + distOfFunction (fun x => c * f x) (by fun_prop) = c • distOfFunction f hf := + distOfFunction_smul_fun f hf c lemma distOfFunction_neg {d : ℕ} (f : Space d → F) (hf : IsDistBounded (fun x => - f x)) : diff --git a/Physlib/SpaceAndTime/Space/Integrals/Basic.lean b/Physlib/SpaceAndTime/Space/Integrals/Basic.lean index 1a957df94..addda4ca7 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/Basic.lean @@ -42,8 +42,8 @@ open InnerProductSpace MeasureTheory -/ -lemma volume_eq_addHaar {d} : (volume (α := Space d)) = Space.basis.toBasis.addHaar := by - exact (OrthonormalBasis.addHaar_eq_volume _).symm +lemma volume_eq_addHaar {d} : (volume (α := Space d)) = Space.basis.toBasis.addHaar := + (OrthonormalBasis.addHaar_eq_volume _).symm @[simp] lemma volume_metricBall_three : @@ -58,8 +58,7 @@ lemma volume_metricBall_three : lemma volume_metricBall_two : volume (Metric.ball (0 : Space 2) 1) = ENNReal.ofReal Real.pi := by rw [InnerProductSpace.volume_ball_of_dim_even (k := 1)] - simp [finrank_eq_dim] - simp [finrank_eq_dim] + all_goals simp [finrank_eq_dim] @[simp] lemma volume_metricBall_two_real : diff --git a/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean b/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean index bfc387228..b20ea1e63 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean @@ -69,8 +69,7 @@ def radialAngularMeasure {d : ℕ} : Measure (Space d) := -/ lemma radialAngularMeasure_eq_volume_withDensity {d : ℕ} : radialAngularMeasure = - volume.withDensity (fun x : Space d => ENNReal.ofReal (1 / ‖x‖ ^ (d - 1))) := by - rfl + volume.withDensity (fun x : Space d => ENNReal.ofReal (1 / ‖x‖ ^ (d - 1))) := rfl @[simp] lemma radialAngularMeasure_zero_eq_volume : diff --git a/Physlib/SpaceAndTime/Space/LengthUnit.lean b/Physlib/SpaceAndTime/Space/LengthUnit.lean index e64202b3a..bb90e9ac5 100644 --- a/Physlib/SpaceAndTime/Space/LengthUnit.lean +++ b/Physlib/SpaceAndTime/Space/LengthUnit.lean @@ -36,8 +36,7 @@ structure LengthUnit where namespace LengthUnit @[simp] -lemma val_ne_zero (x : LengthUnit) : x.val ≠ 0 := by - exact Ne.symm (ne_of_lt x.property) +lemma val_ne_zero (x : LengthUnit) : x.val ≠ 0 := Ne.symm (ne_of_lt x.property) lemma val_pos (x : LengthUnit) : 0 < x.val := x.property From 14594df873564baf7ce5adb61dccfa91b857c742 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:03:48 -0700 Subject: [PATCH 020/498] refactor(space): golf boundedness wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/Mass/MassUnit.lean | 3 +-- .../Electromagnetism/Charge/ChargeUnit.lean | 3 +-- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 24 +++++++++---------- .../Temperature/TemperatureUnits.lean | 3 +-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Physlib/ClassicalMechanics/Mass/MassUnit.lean b/Physlib/ClassicalMechanics/Mass/MassUnit.lean index 01e6a008b..43db8c757 100644 --- a/Physlib/ClassicalMechanics/Mass/MassUnit.lean +++ b/Physlib/ClassicalMechanics/Mass/MassUnit.lean @@ -39,8 +39,7 @@ structure MassUnit where namespace MassUnit @[simp] -lemma val_ne_zero (x : MassUnit) : x.val ≠ 0 := by - exact Ne.symm (ne_of_lt x.property) +lemma val_ne_zero (x : MassUnit) : x.val ≠ 0 := Ne.symm (ne_of_lt x.property) lemma val_pos (x : MassUnit) : 0 < x.val := x.property diff --git a/Physlib/Electromagnetism/Charge/ChargeUnit.lean b/Physlib/Electromagnetism/Charge/ChargeUnit.lean index 149a4bed0..2a3593808 100644 --- a/Physlib/Electromagnetism/Charge/ChargeUnit.lean +++ b/Physlib/Electromagnetism/Charge/ChargeUnit.lean @@ -44,8 +44,7 @@ structure ChargeUnit where namespace ChargeUnit @[simp] -lemma val_ne_zero (x : ChargeUnit) : x.val ≠ 0 := by - exact Ne.symm (ne_of_lt x.property) +lemma val_ne_zero (x : ChargeUnit) : x.val ≠ 0 := Ne.symm (ne_of_lt x.property) lemma val_pos (x : ChargeUnit) : 0 < x.val := x.property diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index ac8f3095a..1e171ceaa 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -236,20 +236,20 @@ lemma integrable_space {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) @[fun_prop] lemma integrable_space_mul {d : ℕ} {f : Space d → ℝ} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) : - Integrable (fun x : Space d => η x * f x) volume := by - exact hf.integrable_space η + Integrable (fun x : Space d => η x * f x) volume := + hf.integrable_space η @[fun_prop] lemma integrable_space_fderiv {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) (y : Space d) : - Integrable (fun x : Space d => fderiv ℝ η x y • f x) volume := by - exact hf.integrable_space (LineDeriv.lineDerivOpCLM ℝ _ y η) + Integrable (fun x : Space d => fderiv ℝ η x y • f x) volume := + hf.integrable_space (LineDeriv.lineDerivOpCLM ℝ _ y η) @[fun_prop] lemma integrable_space_fderiv_mul {d : ℕ} {f : Space d → ℝ} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) (y : Space d) : - Integrable (fun x : Space d => fderiv ℝ η x y * f x) volume := by - exact hf.integrable_space (LineDeriv.lineDerivOpCLM ℝ _ y η) + Integrable (fun x : Space d => fderiv ℝ η x y * f x) volume := + hf.integrable_space (LineDeriv.lineDerivOpCLM ℝ _ y η) /-! @@ -635,8 +635,8 @@ lemma add {d : ℕ} {f g : Space d → F} @[fun_prop] lemma fun_add {d : ℕ} {f g : Space d → F} - (hf : IsDistBounded f) (hg : IsDistBounded g) : IsDistBounded (fun x => f x + g x) := by - exact hf.add hg + (hf : IsDistBounded f) (hg : IsDistBounded g) : IsDistBounded (fun x => f x + g x) := + hf.add hg /-! @@ -916,8 +916,8 @@ lemma inv_shift {d : ℕ} (g : Space d) (hd : 2 ≤ d := by omega) : simp @[fun_prop] lemma nat_pow {d : ℕ} (n : ℕ) : - IsDistBounded (d := d) (fun x => ‖x‖ ^ n) := by - exact IsDistBounded.pow (d := d) (n : ℤ) (by omega) + IsDistBounded (d := d) (fun x => ‖x‖ ^ n) := + IsDistBounded.pow (d := d) (n : ℤ) (by omega) @[fun_prop] lemma norm_add_nat_pow {d : ℕ} (n : ℕ) (a : ℝ) : @@ -949,8 +949,8 @@ lemma norm_add_pos_nat_zpow {d : ℕ} (n : ℤ) (a : ℝ) (ha : 0 < a) : @[fun_prop] lemma nat_pow_shift {d : ℕ} (n : ℕ) (g : Space d) : - IsDistBounded (d := d) (fun x => ‖x - g‖ ^ n) := by - exact IsDistBounded.pow_shift (d := d) (n : ℤ) g (by omega) + IsDistBounded (d := d) (fun x => ‖x - g‖ ^ n) := + IsDistBounded.pow_shift (d := d) (n : ℤ) g (by omega) @[fun_prop] lemma norm_sub {d : ℕ} (g : Space d) : diff --git a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean index 220ceed83..4ada64e15 100644 --- a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean +++ b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean @@ -40,8 +40,7 @@ structure TemperatureUnit where namespace TemperatureUnit @[simp] -lemma val_ne_zero (x : TemperatureUnit) : x.val ≠ 0 := by - exact Ne.symm (ne_of_lt x.property) +lemma val_ne_zero (x : TemperatureUnit) : x.val ≠ 0 := Ne.symm (ne_of_lt x.property) lemma val_pos (x : TemperatureUnit) : 0 < x.val := x.property From 9704ec624a8f26947991abf959693739bd9a3592 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:07:51 -0700 Subject: [PATCH 021/498] refactor(electromagnetism): golf smoothness wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../Electromagnetism/Dynamics/Lagrangian.lean | 8 +++---- .../Kinematics/MagneticField.lean | 24 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/Lagrangian.lean b/Physlib/Electromagnetism/Dynamics/Lagrangian.lean index eefd5262d..3728da388 100644 --- a/Physlib/Electromagnetism/Dynamics/Lagrangian.lean +++ b/Physlib/Electromagnetism/Dynamics/Lagrangian.lean @@ -163,8 +163,8 @@ noncomputable def gradFreeCurrentPotential {d} (A : ElectromagneticPotential d) lemma gradFreeCurrentPotential_eq_sum_basis {d} (A : ElectromagneticPotential d) (hA : ContDiff ℝ ∞ A) (J : LorentzCurrentDensity d) (hJ : ContDiff ℝ ∞ J) : - A.gradFreeCurrentPotential J = (∑ μ, fun x => (η μ μ * J x μ) • Lorentz.Vector.basis μ) := by - exact (freeCurrentPotential_hasVarGradientAt A hA J hJ).varGradient + A.gradFreeCurrentPotential J = (∑ μ, fun x => (η μ μ * J x μ) • Lorentz.Vector.basis μ) := + (freeCurrentPotential_hasVarGradientAt A hA J hJ).varGradient lemma gradFreeCurrentPotential_eq_chargeDensity_currentDensity {d} (𝓕 : FreeSpace) (A : ElectromagneticPotential d) @@ -285,8 +285,8 @@ noncomputable def gradLagrangian {d} (𝓕 : FreeSpace) (A : ElectromagneticPote lemma gradLagrangian_eq_kineticTerm_sub {𝓕 : FreeSpace} (A : ElectromagneticPotential d) (hA : ContDiff ℝ ∞ A) (J : LorentzCurrentDensity d) (hJ : ContDiff ℝ ∞ J) : - A.gradLagrangian 𝓕 J = A.gradKineticTerm 𝓕 - A.gradFreeCurrentPotential J := by - exact (lagrangian_hasVarGradientAt_eq_add_gradKineticTerm A hA J hJ).varGradient + A.gradLagrangian 𝓕 J = A.gradKineticTerm 𝓕 - A.gradFreeCurrentPotential J := + (lagrangian_hasVarGradientAt_eq_add_gradKineticTerm A hA J hJ).varGradient /-! diff --git a/Physlib/Electromagnetism/Kinematics/MagneticField.lean b/Physlib/Electromagnetism/Kinematics/MagneticField.lean index 1d88db0dd..214feeea6 100644 --- a/Physlib/Electromagnetism/Kinematics/MagneticField.lean +++ b/Physlib/Electromagnetism/Kinematics/MagneticField.lean @@ -319,18 +319,18 @@ lemma magneticFieldMatrix_eq_vectorPotential {c : SpeedOfLight} (A : Electromagn lemma magneticFieldMatrix_contDiff {n} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ (n + 1) A) (ij) : - ContDiff ℝ n ↿(fun t x => A.magneticFieldMatrix c t x ij) := by - exact (fieldStrengthMatrix_contDiff hA).comp (toTimeAndSpace c).symm.contDiff + ContDiff ℝ n ↿(fun t x => A.magneticFieldMatrix c t x ij) := + (fieldStrengthMatrix_contDiff hA).comp (toTimeAndSpace c).symm.contDiff lemma magneticFieldMatrix_space_contDiff {n} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ (n + 1) A) (t : Time) (ij) : - ContDiff ℝ n (fun x => A.magneticFieldMatrix c t x ij) := by - exact (magneticFieldMatrix_contDiff A hA ij).comp (f := fun x => (t, x)) (by fun_prop) + ContDiff ℝ n (fun x => A.magneticFieldMatrix c t x ij) := + (magneticFieldMatrix_contDiff A hA ij).comp (f := fun x => (t, x)) (by fun_prop) lemma magneticFieldMatrix_time_contDiff {n} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ (n + 1) A) (x : Space d) (ij) : - ContDiff ℝ n (fun t => A.magneticFieldMatrix c t x ij) := by - exact (magneticFieldMatrix_contDiff A hA ij).comp (f := fun t => (t, x)) (by fun_prop) + ContDiff ℝ n (fun t => A.magneticFieldMatrix c t x ij) := + (magneticFieldMatrix_contDiff A hA ij).comp (f := fun t => (t, x)) (by fun_prop) /-! @@ -339,18 +339,18 @@ lemma magneticFieldMatrix_time_contDiff {n} {c : SpeedOfLight} (A : Electromagne -/ lemma magneticFieldMatrix_differentiable {c : SpeedOfLight} (A : ElectromagneticPotential d) - (hA : ContDiff ℝ 2 A) (ij) : Differentiable ℝ ↿(fun t x => A.magneticFieldMatrix c t x ij) := by - exact (fieldStrengthMatrix_differentiable hA).comp (toTimeAndSpace c).symm.differentiable + (hA : ContDiff ℝ 2 A) (ij) : Differentiable ℝ ↿(fun t x => A.magneticFieldMatrix c t x ij) := + (fieldStrengthMatrix_differentiable hA).comp (toTimeAndSpace c).symm.differentiable lemma magneticFieldMatrix_differentiable_space {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ 2 A) (t : Time) (ij) : - Differentiable ℝ (fun x => A.magneticFieldMatrix c t x ij) := by - exact (magneticFieldMatrix_differentiable A hA ij).comp (f := fun x => (t, x)) (by fun_prop) + Differentiable ℝ (fun x => A.magneticFieldMatrix c t x ij) := + (magneticFieldMatrix_differentiable A hA ij).comp (f := fun x => (t, x)) (by fun_prop) lemma magneticFieldMatrix_differentiable_time {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ 2 A) (x : Space d) (ij) : - Differentiable ℝ (fun t => A.magneticFieldMatrix c t x ij) := by - exact (magneticFieldMatrix_differentiable A hA ij).comp (f := fun t => (t, x)) (by fun_prop) + Differentiable ℝ (fun t => A.magneticFieldMatrix c t x ij) := + (magneticFieldMatrix_differentiable A hA ij).comp (f := fun t => (t, x)) (by fun_prop) /-! From 189d96b7c74a128ceb3a3a5791e5ed48ae3fef4a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:09:28 -0700 Subject: [PATCH 022/498] refactor(space-time): golf exact wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/Module.lean | 8 ++++---- Physlib/SpaceAndTime/Time/Basic.lean | 8 ++++---- Physlib/SpaceAndTime/Time/TimeUnit.lean | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Module.lean b/Physlib/SpaceAndTime/Space/Module.lean index 629148a99..482d37a64 100644 --- a/Physlib/SpaceAndTime/Space/Module.lean +++ b/Physlib/SpaceAndTime/Space/Module.lean @@ -149,8 +149,8 @@ lemma norm_sq_eq {d} (p : Space d) : refine Real.sq_sqrt ?_ positivity -lemma point_dim_zero_eq (p : Space 0) : p = 0 := by - exact eq_of_apply fun i => by fin_cases i +lemma point_dim_zero_eq (p : Space 0) : p = 0 := + eq_of_apply fun i => by fin_cases i @[simp] lemma norm_vadd_zero {d} (v : EuclideanSpace ℝ (Fin d)) : @@ -366,8 +366,8 @@ lemma basis_inner {d} (i : Fin d) (p : Space d) : open InnerProductSpace lemma basis_repr_inner_eq {d} (p : Space d) (v : EuclideanSpace ℝ (Fin d)) : - ⟪basis.repr p, v⟫_ℝ = ⟪p, basis.repr.symm v⟫_ℝ := by - exact LinearIsometryEquiv.inner_map_eq_flip basis.repr p v + ⟪basis.repr p, v⟫_ℝ = ⟪p, basis.repr.symm v⟫_ℝ := + LinearIsometryEquiv.inner_map_eq_flip basis.repr p v instance {d : ℕ} : FiniteDimensional ℝ (Space d) := Module.Basis.finiteDimensional_of_finite (h := basis.toBasis) diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index dcce44b93..9d954e6d0 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -422,12 +422,12 @@ lemma finRank_eq_one : Module.finrank ℝ Time = 1 := by ext simp [one_val] -instance : FiniteDimensional ℝ Time := by - exact Module.finite_of_rank_eq_one rank_eq_one +instance : FiniteDimensional ℝ Time := + Module.finite_of_rank_eq_one rank_eq_one lemma volume_eq_basis_addHaar : - (volume (α := Time)) = basis.toBasis.addHaar := by - exact (OrthonormalBasis.addHaar_eq_volume _).symm + (volume (α := Time)) = basis.toBasis.addHaar := + (OrthonormalBasis.addHaar_eq_volume _).symm /-! diff --git a/Physlib/SpaceAndTime/Time/TimeUnit.lean b/Physlib/SpaceAndTime/Time/TimeUnit.lean index 91d53d9c8..6e3d7ef55 100644 --- a/Physlib/SpaceAndTime/Time/TimeUnit.lean +++ b/Physlib/SpaceAndTime/Time/TimeUnit.lean @@ -41,8 +41,8 @@ structure TimeUnit : Type where namespace TimeUnit @[simp] -lemma val_ne_zero (x : TimeUnit) : x.val ≠ 0 := by - exact Ne.symm (ne_of_lt x.property) +lemma val_ne_zero (x : TimeUnit) : x.val ≠ 0 := + Ne.symm (ne_of_lt x.property) lemma val_pos (x : TimeUnit) : 0 < x.val := x.property From 42873327e666dc62e4d27398b0cdb3a81af7ff72 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:11:04 -0700 Subject: [PATCH 023/498] refactor(spacetime): golf coordinate map proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/SpaceTime/Basic.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index 3852a03a7..457032945 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -101,25 +101,20 @@ open TensorSpecies This is denoted `𝔁 μ p`, where `𝔁` is typed with `\MCx`. -/ def coord {d : ℕ} (μ : Fin (1 + d)) : SpaceTime d →ₗ[ℝ] ℝ where toFun x := x (finSumFinEquiv.symm μ) - map_add' x1 x2 := by - simp - map_smul' c x := by - simp + map_add' _ _ := rfl + map_smul' _ _ := rfl @[inherit_doc coord] scoped notation "𝔁" => coord lemma coord_apply {d : ℕ} (μ : Fin (1 + d)) (y : SpaceTime d) : - 𝔁 μ y = y (finSumFinEquiv.symm μ) := by - rfl + 𝔁 μ y = y (finSumFinEquiv.symm μ) := rfl /-- The continuous linear map from a point in space time to one of its coordinates. -/ def coordCLM (μ : Fin 1 ⊕ Fin d) : SpaceTime d →L[ℝ] ℝ where toFun x := x μ - map_add' x1 x2 := by - simp - map_smul' c x := by - simp + map_add' _ _ := rfl + map_smul' _ _ := rfl cont := by fun_prop From 8efcd5701b9a8acbfe2948a8b73eefcab19d6ac9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:13:03 -0700 Subject: [PATCH 024/498] refactor(time-space): golf distribution derivative proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/TimeAndSpace/Basic.lean | 25 +++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean index 480e656a9..35b3e70ee 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean @@ -373,15 +373,14 @@ noncomputable def distTimeDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] toFun f := let ev : ((Time × Space d) →L[ℝ] M) →L[ℝ] M := { toFun v := v (1, 0) - map_add' v1 v2 := by - simp only [_root_.add_apply] - map_smul' a v := by - simp + map_add' _ _ := rfl + map_smul' _ _ := rfl } ev.comp (Distribution.fderivD ℝ f) - map_add' f1 f2 := by + map_add' _ _ := by + simp + map_smul' _ _ := by simp - map_smul' a f := by simp lemma distTimeDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : @@ -425,15 +424,14 @@ noncomputable def distSpaceDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M toFun f := let ev : (Time × Space d →L[ℝ] M) →L[ℝ] M := { toFun v := v (0, basis i) - map_add' v1 v2 := by - simp only [_root_.add_apply] - map_smul' a v := by - simp + map_add' _ _ := rfl + map_smul' _ _ := rfl } ev.comp (Distribution.fderivD ℝ f) - map_add' f1 f2 := by + map_add' _ _ := by + simp + map_smul' _ _ := by simp - map_smul' a f := by simp lemma distSpaceDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (i : Fin d) (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : @@ -537,8 +535,7 @@ noncomputable def distSpaceGrad {d} : simp lemma distSpaceGrad_apply {d} (f : (Time × Space d) →d[ℝ] ℝ) (ε : 𝓢(Time × Space d, ℝ)) : - distSpaceGrad f ε = fun i => distSpaceDeriv i f ε := by - rfl + distSpaceGrad f ε = fun i => distSpaceDeriv i f ε := rfl /-! From dea2438a78c7419dece356dcd0383d969c122a6d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:14:32 -0700 Subject: [PATCH 025/498] refactor(spacetime): golf distribution map proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/SpaceTime/Derivatives.lean | 14 ++++++-------- Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean | 5 ++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean b/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean index d7de1137f..fa13be9a6 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean @@ -88,8 +88,7 @@ scoped notation "∂_" => deriv lemma deriv_eq {M : Type} [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] {d : ℕ} (μ : Fin 1 ⊕ Fin d) (f : SpaceTime d → M) (y : SpaceTime d) : ∂_ μ f y = - fderiv ℝ f y (Lorentz.Vector.basis μ) := by - rfl + fderiv ℝ f y (Lorentz.Vector.basis μ) := rfl /-- The derivative of a function from `SpaceTime d` to a manifold along the `μ` coordinate, as a tangent vector at the value of the function. -/ @@ -374,15 +373,14 @@ noncomputable def distDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] toFun f := let ev : (SpaceTime d →L[ℝ] M) →L[ℝ] M := { toFun v := v (Lorentz.Vector.basis μ) - map_add' v1 v2 := by - simp only [_root_.add_apply] - map_smul' a v := by - simp + map_add' _ _ := rfl + map_smul' _ _ := rfl } ev.comp (Distribution.fderivD ℝ f) - map_add' f1 f2 := by + map_add' _ _ := by + simp + map_smul' _ _ := by simp - map_smul' a f := by simp lemma distDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (μ : Fin 1 ⊕ Fin d) (f : (SpaceTime d) →d[ℝ] M) (ε : 𝓢(SpaceTime d, ℝ)) : diff --git a/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean b/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean index 077a59bc5..12cb5999d 100644 --- a/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean +++ b/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean @@ -135,9 +135,8 @@ noncomputable def distTimeSlice {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] congr ext x simp - map_add' f1 f2 := by - simp - map_smul' a f := by simp + map_add' _ _ := rfl + map_smul' _ _ := rfl continuous_toFun := ((compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c)).precomp M).continuous continuous_invFun := ((compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c).symm).precomp M).continuous From 0d4c7016dc8028721a997b07b7d0d205e1838d2c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:16:36 -0700 Subject: [PATCH 026/498] refactor(electromagnetism): golf field strength wrappers Co-authored-by: Claude Opus 4.8 --- .../Distributional/FieldStrength.lean | 12 ++++++------ .../Kinematics/FieldStrength.lean | 19 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/FieldStrength.lean b/Physlib/Electromagnetism/Distributional/FieldStrength.lean index f03e5adb4..33e162212 100644 --- a/Physlib/Electromagnetism/Distributional/FieldStrength.lean +++ b/Physlib/Electromagnetism/Distributional/FieldStrength.lean @@ -244,16 +244,16 @@ lemma fieldStrength_eq_basis {d} (A : DistElectromagneticPotential d) (ε : 𝓢(SpaceTime d, ℝ)) : A.fieldStrength ε = ∑ μ, ∑ ν, ((η μ μ * distDeriv μ A ε ν) - η ν ν * distDeriv ν A ε μ) - • Lorentz.Vector.basis μ ⊗ₜ[ℝ] Lorentz.Vector.basis ν := by - rw [fieldStrength] - exact fieldStrengthAux_eq_basis A ε + • Lorentz.Vector.basis μ ⊗ₜ[ℝ] Lorentz.Vector.basis ν := + (fieldStrength_eq_fieldStrengthAux A ε).trans (fieldStrengthAux_eq_basis A ε) lemma fieldStrength_basis_repr_eq_single {d} {μν : (Fin 1 ⊕ Fin d) × (Fin 1 ⊕ Fin d)} (A : DistElectromagneticPotential d) (ε : 𝓢(SpaceTime d, ℝ)) : (Lorentz.Vector.basis.tensorProduct Lorentz.Vector.basis).repr (A.fieldStrength ε) μν = - ((η μν.1 μν.1 * distDeriv μν.1 A ε μν.2) - η μν.2 μν.2 * distDeriv μν.2 A ε μν.1) := by - rw [fieldStrength] - exact fieldStrengthAux_basis_repr_apply_eq_single A ε + ((η μν.1 μν.1 * distDeriv μν.1 A ε μν.2) - η μν.2 μν.2 * distDeriv μν.2 A ε μν.1) := + (congrArg (fun F => (Lorentz.Vector.basis.tensorProduct Lorentz.Vector.basis).repr F μν) + (fieldStrength_eq_fieldStrengthAux A ε)).trans + (fieldStrengthAux_basis_repr_apply_eq_single A ε) @[simp] lemma fieldStrength_diag_zero {d} (A : DistElectromagneticPotential d) diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index be1d8a4c5..0ae6f7b34 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -151,10 +151,9 @@ tensor in. the components extracted via `toField`. -/ lemma toFieldStrength_eq_sum_basis_eval {d} {A : ElectromagneticPotential d} : A.toFieldStrength = fun x => ∑ μ, ∑ ν, toField {A.toFieldStrength x| [μ] [ν]}ᵀ • - Vector.basis μ ⊗ₜ[ℝ] Vector.basis ν := by - ext x - exact prod_eq_sum_eval Vector.basis_eq_map_tensor_basis - Vector.basis_eq_map_tensor_basis (A.toFieldStrength x) + Vector.basis μ ⊗ₜ[ℝ] Vector.basis ν := + funext fun x => prod_eq_sum_eval Vector.basis_eq_map_tensor_basis + Vector.basis_eq_map_tensor_basis (A.toFieldStrength x) /-- The statement that `F = F^{μν} eᵤ ⊗ eᵥ` written explicitly, with the components given by `∑ κ, (η μ κ * ∂_ κ A x ν - η ν κ * ∂_ κ A x μ)`. -/ @@ -393,18 +392,18 @@ electromagnetic potential. -/ lemma toFieldStrength_eval_apply {d} (A : ElectromagneticPotential d) (x : SpaceTime d) (μ ν : Fin 1 ⊕ Fin d) : toField {A.toFieldStrength x | [μ] [ν]}ᵀ = - ∑ κ, (η μ κ * ∂_ κ A x ν - η ν κ * ∂_ κ A x μ) := by - rw [toFieldStrength_eval_eq_basis_repr] - exact toFieldStrength_basis_repr_apply (μν := (μ, ν)) A x + ∑ κ, (η μ κ * ∂_ κ A x ν - η ν κ * ∂_ κ A x μ) := + (toFieldStrength_eval_eq_basis_repr A x μ ν).trans + (toFieldStrength_basis_repr_apply (μν := (μ, ν)) A x) /-- The evaluated components of the field strength tensor after using diagonal form of the Minkowski metric. -/ lemma toFieldStrength_eval_apply_eq_single {d} (A : ElectromagneticPotential d) (x : SpaceTime d) (μ ν : Fin 1 ⊕ Fin d) : toField {A.toFieldStrength x | [μ] [ν]}ᵀ = - η μ μ * ∂_ μ A x ν - η ν ν * ∂_ ν A x μ := by - rw [toFieldStrength_eval_eq_basis_repr] - exact toFieldStrength_basis_repr_apply_eq_single (μν := (μ, ν)) A x + η μ μ * ∂_ μ A x ν - η ν ν * ∂_ ν A x μ := + (toFieldStrength_eval_eq_basis_repr A x μ ν).trans + (toFieldStrength_basis_repr_apply_eq_single (μν := (μ, ν)) A x) /-! From 6ce4a37d3a1f3312b3dfc4bedf08a13c708f5c45 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:18:39 -0700 Subject: [PATCH 027/498] refactor(electromagnetism): golf potential smoothness proofs Co-authored-by: Claude Opus 4.8 --- .../Dynamics/CurrentDensity.lean | 6 ++---- .../Kinematics/EMPotential.lean | 21 +++++++------------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Distributional/Dynamics/CurrentDensity.lean index 38e1ce7e7..66130cea2 100644 --- a/Physlib/Electromagnetism/Distributional/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Distributional/Dynamics/CurrentDensity.lean @@ -83,10 +83,8 @@ noncomputable def chargeDensity {d : ℕ} (c : SpeedOfLight) : noncomputable def currentDensity (c : SpeedOfLight) : DistLorentzCurrentDensity d →ₗ[ℝ] (Time × Space d) →d[ℝ] EuclideanSpace ℝ (Fin d) where toFun J := Lorentz.Vector.spatialCLM d ∘L distTimeSlice c J - map_add' J1 J2 := by - simp - map_smul' r J := by - simp + map_add' _ _ := rfl + map_smul' _ _ := rfl end DistLorentzCurrentDensity end Electromagnetism diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index f15200014..fd62adf31 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -281,7 +281,7 @@ noncomputable instance {d} : simp smul_add Λ A B := by ext x μ - simp [Lorentz.Vector.smul_add] + simp /-! @@ -295,10 +295,8 @@ open ContDiff @[fun_prop] lemma differentiable_component {d : ℕ} (A : ElectromagneticPotential d) (hA : Differentiable ℝ A) (μ : Fin 1 ⊕ Fin d) : - Differentiable ℝ (fun x => A x μ) := by - revert μ - rw [SpaceTime.differentiable_vector] - exact hA + Differentiable ℝ (fun x => A x μ) := + (SpaceTime.differentiable_vector A).mpr hA μ @[fun_prop] lemma differentiable_action {d} (Λ : LorentzGroup d) (A : ElectromagneticPotential d) @@ -321,18 +319,15 @@ lemma contDiff_action {d} (Λ : LorentzGroup d) (A : ElectromagneticPotential d) @[fun_prop] lemma differentiable_deriv {d} {A : ElectromagneticPotential d} (hA : ContDiff ℝ 2 A) (μ ν : Fin 1 ⊕ Fin d) : - Differentiable ℝ (fun x => ∂_ μ A x ν) := by - have diff_partial (μ) : - ∀ ν, Differentiable ℝ fun x => (fderiv ℝ A x) (Lorentz.Vector.basis μ) ν := by - rw [SpaceTime.differentiable_vector] - fun_prop - exact diff_partial μ ν + Differentiable ℝ (fun x => ∂_ μ A x ν) := + (SpaceTime.differentiable_vector (fun x => (fderiv ℝ A x) (Lorentz.Vector.basis μ))).mpr + (by fun_prop) ν @[fun_prop] lemma differentiable_deriv_of_smooth {d} {A : ElectromagneticPotential d} (hA : ContDiff ℝ ∞ A) (μ ν : Fin 1 ⊕ Fin d) : - Differentiable ℝ (fun x => ∂_ μ A x ν) := by - apply differentiable_deriv (hA.of_le (ENat.LEInfty.out)) μ ν + Differentiable ℝ (fun x => ∂_ μ A x ν) := + differentiable_deriv (hA.of_le (ENat.LEInfty.out)) μ ν @[fun_prop] lemma contDiff_deriv {n} {d} {A : ElectromagneticPotential d} From b95baa1176aa7e3254117195a356397728c8da78 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:19:58 -0700 Subject: [PATCH 028/498] refactor(electromagnetism): golf scalar potential wrappers Co-authored-by: Claude Opus 4.8 --- .../Kinematics/ScalarPotential.lean | 43 ++++++------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean index ba274ba3d..df3b3be98 100644 --- a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean @@ -144,37 +144,27 @@ lemma scalarPotential_contDiff {n} {d} (c : SpeedOfLight) (A : ElectromagneticPo (hA : ContDiff ℝ n A) : ContDiff ℝ n ↿(A.scalarPotential c) := by simp [scalarPotential] apply timeSlice_contDiff - have h1 : ∀ i, ContDiff ℝ n (fun x => A x i) := by - rw [SpaceTime.contDiff_vector] - exact hA apply ContDiff.mul · fun_prop - exact h1 (Sum.inl 0) + exact (SpaceTime.contDiff_vector A).mpr hA (Sum.inl 0) @[fun_prop] lemma scalarPotential_contDiff_space {n} {d} (c : SpeedOfLight) (A : ElectromagneticPotential d) - (hA : ContDiff ℝ n A) (t : Time) : ContDiff ℝ n (A.scalarPotential c t) := by - change ContDiff ℝ n (↿(A.scalarPotential c) ∘ fun x => (t, x)) - refine ContDiff.comp ?_ ?_ - · exact scalarPotential_contDiff c A hA - · fun_prop + (hA : ContDiff ℝ n A) (t : Time) : ContDiff ℝ n (A.scalarPotential c t) := + (scalarPotential_contDiff c A hA).comp (f := fun x => (t, x)) (by fun_prop) open ContDiff @[fun_prop] lemma scalarPotential_contDiff_space_of_smooth {n : ℕ} {d} (c : SpeedOfLight) (A : ElectromagneticPotential d) - (hA : ContDiff ℝ ∞ A) (t : Time) : ContDiff ℝ n (A.scalarPotential c t) := by - apply scalarPotential_contDiff_space - exact hA.of_le (ENat.LEInfty.out) + (hA : ContDiff ℝ ∞ A) (t : Time) : ContDiff ℝ n (A.scalarPotential c t) := + scalarPotential_contDiff_space c A (hA.of_le (ENat.LEInfty.out)) t lemma scalarPotential_contDiff_time {n} {d} (c : SpeedOfLight) (A : ElectromagneticPotential d) - (hA : ContDiff ℝ n A) (x : Space d) : ContDiff ℝ n (A.scalarPotential c · x) := by - change ContDiff ℝ n (↿(A.scalarPotential c) ∘ fun t => (t, x)) - refine ContDiff.comp ?_ ?_ - · exact scalarPotential_contDiff c A hA - · fun_prop + (hA : ContDiff ℝ n A) (x : Space d) : ContDiff ℝ n (A.scalarPotential c · x) := + (scalarPotential_contDiff c A hA).comp (f := fun t => (t, x)) (by fun_prop) /-! @@ -188,26 +178,17 @@ lemma scalarPotential_differentiable {d} (c : SpeedOfLight) (A : Electromagnetic (hA : Differentiable ℝ A) : Differentiable ℝ ↿(A.scalarPotential c) := by simp [scalarPotential] apply timeSlice_differentiable - have h1 : ∀ i, Differentiable ℝ (fun x => A x i) := by - rw [SpaceTime.differentiable_vector] - exact hA apply Differentiable.mul · fun_prop - exact h1 (Sum.inl 0) + exact (SpaceTime.differentiable_vector A).mpr hA (Sum.inl 0) lemma scalarPotential_differentiable_space {d} (c : SpeedOfLight) (A : ElectromagneticPotential d) - (hA : Differentiable ℝ A) (t : Time) : Differentiable ℝ (A.scalarPotential c t) := by - change Differentiable ℝ (↿(A.scalarPotential c) ∘ fun x => (t, x)) - refine Differentiable.comp ?_ ?_ - · exact scalarPotential_differentiable c A hA - · fun_prop + (hA : Differentiable ℝ A) (t : Time) : Differentiable ℝ (A.scalarPotential c t) := + (scalarPotential_differentiable c A hA).comp (f := fun x => (t, x)) (by fun_prop) lemma scalarPotential_differentiable_time {d} (c : SpeedOfLight) (A : ElectromagneticPotential d) - (hA : Differentiable ℝ A) (x : Space d) : Differentiable ℝ (A.scalarPotential c · x) := by - change Differentiable ℝ (↿(A.scalarPotential c) ∘ fun t => (t, x)) - refine Differentiable.comp ?_ ?_ - · exact scalarPotential_differentiable c A hA - · fun_prop + (hA : Differentiable ℝ A) (x : Space d) : Differentiable ℝ (A.scalarPotential c · x) := + (scalarPotential_differentiable c A hA).comp (f := fun t => (t, x)) (by fun_prop) end ElectromagneticPotential From d2f425da8cbf34784cd81f72eb615eedf8e4bf64 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:21:15 -0700 Subject: [PATCH 029/498] refactor(electromagnetism): golf vector potential wrappers Co-authored-by: Claude Opus 4.8 --- .../Kinematics/VectorPotential.lean | 60 ++++++------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index b5edd33d0..99c44f020 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -240,55 +240,39 @@ lemma vectorPotential_contDiff {n} {d} {c : SpeedOfLight} (A : ElectromagneticPo simp [vectorPotential] apply timeSlice_contDiff refine contDiff_euclidean.mpr ?_ - have h1 : ∀ i, ContDiff ℝ n (fun x => A x i) := by - rw [SpaceTime.contDiff_vector] - exact hA - exact fun i => h1 (Sum.inr i) + exact fun i => (SpaceTime.contDiff_vector A).mpr hA (Sum.inr i) open ContDiff @[fun_prop] lemma vectorPotential_contDiff_of_smooth {n : ℕ} {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ ∞ A) : - ContDiff ℝ n ↿(A.vectorPotential c) := by - apply vectorPotential_contDiff - exact hA.of_le (ENat.LEInfty.out) + ContDiff ℝ n ↿(A.vectorPotential c) := + vectorPotential_contDiff A (hA.of_le (ENat.LEInfty.out)) lemma vectorPotential_apply_contDiff {n} {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) - (hA : ContDiff ℝ n A) (i : Fin d) : ContDiff ℝ n ↿(fun t x => A.vectorPotential c t x i) := by - change ContDiff ℝ n (EuclideanSpace.proj i ∘ ↿(A.vectorPotential c)) - refine ContDiff.comp ?_ ?_ - · exact ContinuousLinearMap.contDiff (𝕜 := ℝ) (n := n) (EuclideanSpace.proj i) - · exact vectorPotential_contDiff A hA + (hA : ContDiff ℝ n A) (i : Fin d) : ContDiff ℝ n ↿(fun t x => A.vectorPotential c t x i) := + (ContinuousLinearMap.contDiff (𝕜 := ℝ) (n := n) (EuclideanSpace.proj i)).comp + (vectorPotential_contDiff A hA) lemma vectorPotential_comp_contDiff {n} {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) - (hA : ContDiff ℝ n A) (i : Fin d) : ContDiff ℝ n ↿(fun t x => A.vectorPotential c t x i) := by - change ContDiff ℝ n (EuclideanSpace.proj i ∘ ↿(A.vectorPotential c)) - refine ContDiff.comp ?_ ?_ - · exact ContinuousLinearMap.contDiff (𝕜 := ℝ) (n := n) (EuclideanSpace.proj i) - · exact vectorPotential_contDiff A hA + (hA : ContDiff ℝ n A) (i : Fin d) : ContDiff ℝ n ↿(fun t x => A.vectorPotential c t x i) := + (ContinuousLinearMap.contDiff (𝕜 := ℝ) (n := n) (EuclideanSpace.proj i)).comp + (vectorPotential_contDiff A hA) lemma vectorPotential_contDiff_space {n} {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) - (hA : ContDiff ℝ n A) (t : Time) : ContDiff ℝ n (A.vectorPotential c t) := by - change ContDiff ℝ n (↿(A.vectorPotential c) ∘ fun x => (t, x)) - refine ContDiff.comp ?_ ?_ - · exact vectorPotential_contDiff A hA - · fun_prop + (hA : ContDiff ℝ n A) (t : Time) : ContDiff ℝ n (A.vectorPotential c t) := + (vectorPotential_contDiff A hA).comp (f := fun x => (t, x)) (by fun_prop) lemma vectorPotential_apply_contDiff_space {n} {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ n A) (t : Time) (i : Fin d) : - ContDiff ℝ n (fun x => A.vectorPotential c t x i) := by - change ContDiff ℝ n (EuclideanSpace.proj i ∘ (↿(A.vectorPotential c) ∘ fun x => (t, x))) - refine ContDiff.comp ?_ ?_ - · exact ContinuousLinearMap.contDiff (𝕜 := ℝ) (n := n) (EuclideanSpace.proj i) - · exact vectorPotential_contDiff_space A hA t + ContDiff ℝ n (fun x => A.vectorPotential c t x i) := + (ContinuousLinearMap.contDiff (𝕜 := ℝ) (n := n) (EuclideanSpace.proj i)).comp + (vectorPotential_contDiff_space A hA t) lemma vectorPotential_contDiff_time {n} {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) - (hA : ContDiff ℝ n A) (x : Space d) : ContDiff ℝ n (A.vectorPotential c · x) := by - change ContDiff ℝ n (↿(A.vectorPotential c) ∘ fun t => (t, x)) - refine ContDiff.comp ?_ ?_ - · exact vectorPotential_contDiff A hA - · fun_prop + (hA : ContDiff ℝ n A) (x : Space d) : ContDiff ℝ n (A.vectorPotential c · x) := + (vectorPotential_contDiff A hA).comp (f := fun t => (t, x)) (by fun_prop) /-! @@ -304,17 +288,11 @@ lemma vectorPotential_differentiable {d} {c : SpeedOfLight} (A : Electromagnetic simp [vectorPotential] apply timeSlice_differentiable refine differentiable_euclidean.mpr ?_ - have h1 : ∀ i, Differentiable ℝ (fun x => A x i) := by - rw [SpaceTime.differentiable_vector] - exact hA - exact fun i => h1 (Sum.inr i) + exact fun i => (SpaceTime.differentiable_vector A).mpr hA (Sum.inr i) lemma vectorPotential_differentiable_time {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) - (hA : Differentiable ℝ A) (x : Space d) : Differentiable ℝ (A.vectorPotential c · x) := by - change Differentiable ℝ (↿(A.vectorPotential c) ∘ fun t => (t, x)) - refine Differentiable.comp ?_ ?_ - · exact vectorPotential_differentiable A hA - · fun_prop + (hA : Differentiable ℝ A) (x : Space d) : Differentiable ℝ (A.vectorPotential c · x) := + (vectorPotential_differentiable A hA).comp (f := fun t => (t, x)) (by fun_prop) end ElectromagneticPotential From 942672e30bb089b47ae7a2ac53dcda970e335102 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:22:47 -0700 Subject: [PATCH 030/498] refactor(electromagnetism): golf current density wrappers Co-authored-by: Claude Opus 4.8 --- .../Dynamics/CurrentDensity.lean | 69 +++++-------------- 1 file changed, 19 insertions(+), 50 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean index 3869cfc86..6c615db9f 100644 --- a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean @@ -103,19 +103,13 @@ lemma chargeDensity_differentiable {d : ℕ} {c : SpeedOfLight} {J : LorentzCurr (hJ : Differentiable ℝ J) : Differentiable ℝ ↿(J.chargeDensity c) := by rw [chargeDensity_eq_timeSlice] apply timeSlice_differentiable - have h1 : ∀ i, Differentiable ℝ (fun x => J x i) := by - rw [SpaceTime.differentiable_vector] - exact hJ apply Differentiable.fun_const_smul - exact h1 (Sum.inl 0) + exact (SpaceTime.differentiable_vector J).mpr hJ (Sum.inl 0) lemma chargeDensity_differentiable_space {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (t : Time) : - Differentiable ℝ (fun x => J.chargeDensity c t x) := by - change Differentiable ℝ (↿(J.chargeDensity c) ∘ fun x => (t, x)) - refine Differentiable.comp ?_ ?_ - · exact chargeDensity_differentiable hJ - · fun_prop + Differentiable ℝ (fun x => J.chargeDensity c t x) := + (chargeDensity_differentiable hJ).comp (f := fun x => (t, x)) (by fun_prop) /-! @@ -127,11 +121,8 @@ lemma chargeDensity_contDiff {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDen (hJ : ContDiff ℝ n J) : ContDiff ℝ n ↿(J.chargeDensity c) := by rw [chargeDensity_eq_timeSlice] apply timeSlice_contDiff - have h1 : ∀ i, ContDiff ℝ n (fun x => J x i) := by - rw [SpaceTime.contDiff_vector] - exact hJ apply ContDiff.const_smul - exact h1 (Sum.inl 0) + exact (SpaceTime.contDiff_vector J).mpr hJ (Sum.inl 0) /-! @@ -169,56 +160,37 @@ lemma currentDensity_differentiable {d : ℕ} {c : SpeedOfLight} {J : LorentzCur (hJ : Differentiable ℝ J) : Differentiable ℝ ↿(J.currentDensity c) := by rw [currentDensity_eq_timeSlice] apply timeSlice_differentiable - have h1 : ∀ i, Differentiable ℝ (fun x => J x i) := by - rw [SpaceTime.differentiable_vector] - exact hJ - exact differentiable_euclidean.mpr fun i => h1 (Sum.inr i) + exact differentiable_euclidean.mpr fun i => (SpaceTime.differentiable_vector J).mpr hJ (Sum.inr i) lemma currentDensity_apply_differentiable {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (i : Fin d) : - Differentiable ℝ ↿(fun t x => J.currentDensity c t x i) := by - change Differentiable ℝ (EuclideanSpace.proj i ∘ ↿(J.currentDensity c)) - refine Differentiable.comp ?_ ?_ - · exact ContinuousLinearMap.differentiable (𝕜 := ℝ) (EuclideanSpace.proj i) - · exact currentDensity_differentiable hJ + Differentiable ℝ ↿(fun t x => J.currentDensity c t x i) := + (ContinuousLinearMap.differentiable (𝕜 := ℝ) (EuclideanSpace.proj i)).comp + (currentDensity_differentiable hJ) lemma currentDensity_differentiable_space {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (t : Time) : - Differentiable ℝ (fun x => J.currentDensity c t x) := by - change Differentiable ℝ (↿(J.currentDensity c) ∘ fun x => (t, x)) - refine Differentiable.comp ?_ ?_ - · exact currentDensity_differentiable hJ - · fun_prop + Differentiable ℝ (fun x => J.currentDensity c t x) := + (currentDensity_differentiable hJ).comp (f := fun x => (t, x)) (by fun_prop) lemma currentDensity_apply_differentiable_space {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (t : Time) (i : Fin d) : - Differentiable ℝ (fun x => J.currentDensity c t x i) := by - change Differentiable ℝ (EuclideanSpace.proj i ∘ (↿(J.currentDensity c) ∘ fun x => (t, x))) - refine Differentiable.comp ?_ ?_ - · exact ContinuousLinearMap.differentiable (𝕜 := ℝ) _ - · apply Differentiable.comp ?_ ?_ - · exact currentDensity_differentiable hJ - · fun_prop + Differentiable ℝ (fun x => J.currentDensity c t x i) := + (ContinuousLinearMap.differentiable (𝕜 := ℝ) (EuclideanSpace.proj i)).comp + (currentDensity_differentiable_space hJ t) lemma currentDensity_differentiable_time {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (x : Space d) : - Differentiable ℝ (fun t => J.currentDensity c t x) := by - change Differentiable ℝ (↿(J.currentDensity c) ∘ fun t => (t, x)) - refine Differentiable.comp ?_ ?_ - · exact currentDensity_differentiable hJ - · fun_prop + Differentiable ℝ (fun t => J.currentDensity c t x) := + (currentDensity_differentiable hJ).comp (f := fun t => (t, x)) (by fun_prop) lemma currentDensity_apply_differentiable_time {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (x : Space d) (i : Fin d) : - Differentiable ℝ (fun t => J.currentDensity c t x i) := by - change Differentiable ℝ (EuclideanSpace.proj i ∘ (↿(J.currentDensity c) ∘ fun t => (t, x))) - refine Differentiable.comp ?_ ?_ - · exact ContinuousLinearMap.differentiable (𝕜 := ℝ) _ - · apply Differentiable.comp ?_ ?_ - · exact currentDensity_differentiable hJ - · fun_prop + Differentiable ℝ (fun t => J.currentDensity c t x i) := + (ContinuousLinearMap.differentiable (𝕜 := ℝ) (EuclideanSpace.proj i)).comp + (currentDensity_differentiable_time hJ x) /-! @@ -230,10 +202,7 @@ lemma currentDensity_ContDiff {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDe (hJ : ContDiff ℝ n J) : ContDiff ℝ n ↿(J.currentDensity c) := by rw [currentDensity_eq_timeSlice] apply timeSlice_contDiff - have h1 : ∀ i, ContDiff ℝ n (fun x => J x i) := by - rw [SpaceTime.contDiff_vector] - exact hJ - exact contDiff_euclidean.mpr fun i => h1 (Sum.inr i) + exact contDiff_euclidean.mpr fun i => (SpaceTime.contDiff_vector J).mpr hJ (Sum.inr i) end LorentzCurrentDensity From f629a3913025348a1e6a17b4840ac014b68c8167 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:24:49 -0700 Subject: [PATCH 031/498] refactor(electromagnetism): golf potential constructor proofs Co-authored-by: Claude Opus 4.8 --- .../Kinematics/EMPotential.lean | 87 +++++++++---------- 1 file changed, 39 insertions(+), 48 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index fd62adf31..8d50989a4 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -300,21 +300,15 @@ lemma differentiable_component {d : ℕ} @[fun_prop] lemma differentiable_action {d} (Λ : LorentzGroup d) (A : ElectromagneticPotential d) - (hA : Differentiable ℝ A) : Differentiable ℝ (fun x => Λ • A (Λ⁻¹ • x)) := by - apply Differentiable.comp - · exact ContinuousLinearMap.differentiable (Lorentz.Vector.actionCLM Λ) - · apply Differentiable.comp - · exact hA - · exact ContinuousLinearMap.differentiable (Lorentz.Vector.actionCLM Λ⁻¹) + (hA : Differentiable ℝ A) : Differentiable ℝ (fun x => Λ • A (Λ⁻¹ • x)) := + (ContinuousLinearMap.differentiable (Lorentz.Vector.actionCLM Λ)).comp + (hA.comp (ContinuousLinearMap.differentiable (Lorentz.Vector.actionCLM Λ⁻¹))) @[fun_prop] lemma contDiff_action {d} (Λ : LorentzGroup d) (A : ElectromagneticPotential d) - (hA : ContDiff ℝ n A) : ContDiff ℝ n (fun x => Λ • A (Λ⁻¹ • x)) := by - apply ContDiff.comp - · exact ContinuousLinearMap.contDiff (Lorentz.Vector.actionCLM Λ) - · apply ContDiff.comp - · exact hA - · exact ContinuousLinearMap.contDiff (Lorentz.Vector.actionCLM Λ⁻¹) + (hA : ContDiff ℝ n A) : ContDiff ℝ n (fun x => Λ • A (Λ⁻¹ • x)) := + (ContinuousLinearMap.contDiff (Lorentz.Vector.actionCLM Λ)).comp + (hA.comp (ContinuousLinearMap.contDiff (Lorentz.Vector.actionCLM Λ⁻¹))) @[fun_prop] lemma differentiable_deriv {d} {A : ElectromagneticPotential d} @@ -332,12 +326,9 @@ lemma differentiable_deriv_of_smooth {d} {A : ElectromagneticPotential d} @[fun_prop] lemma contDiff_deriv {n} {d} {A : ElectromagneticPotential d} (hA : ContDiff ℝ (n + 1) A) (μ ν : Fin 1 ⊕ Fin d) : - ContDiff ℝ n (fun x => ∂_ μ A x ν) := by - have diff_partial (μ) : - ∀ ν, ContDiff ℝ n fun x => (fderiv ℝ A x) (Lorentz.Vector.basis μ) ν := by - rw [SpaceTime.contDiff_vector] - fun_prop - exact diff_partial μ ν + ContDiff ℝ n (fun x => ∂_ μ A x ν) := + (SpaceTime.contDiff_vector (fun x => (fderiv ℝ A x) (Lorentz.Vector.basis μ))).mpr + (by fun_prop) ν TODO "Add results related to the differentiability of the derivative of the Electromagnetic potential." @@ -351,60 +342,60 @@ TODO "Add results related to the differentiability of the lemma differentiable_ofScalarPotential {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (hϕ : Differentiable ℝ ↿φ) : Differentiable ℝ (ofScalarPotential c φ) := by simp [ofScalarPotential] - rw [← SpaceTime.differentiable_vector] - intro μ - match μ with - | Sum.inl 0 => fun_prop - | Sum.inr _ => fun_prop + exact (SpaceTime.differentiable_vector _).mp fun μ => by + rcases μ with μ | i + · fin_cases μ + fun_prop + · fun_prop lemma contDiff_ofScalarPotential {n} {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (hϕ : ContDiff ℝ n ↿φ) : ContDiff ℝ n (ofScalarPotential c φ) := by simp [ofScalarPotential] - rw [← SpaceTime.contDiff_vector] - intro μ - match μ with - | Sum.inl 0 => fun_prop - | Sum.inr _ => fun_prop + exact (SpaceTime.contDiff_vector _).mp fun μ => by + rcases μ with μ | i + · fin_cases μ + fun_prop + · fun_prop lemma differentiable_ofVectorPotential {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hA : Differentiable ℝ ↿A) : Differentiable ℝ (ofVectorPotential c A) := by simp [ofVectorPotential] - rw [← SpaceTime.differentiable_vector] - intro μ - match μ with - | Sum.inl 0 => fun_prop - | Sum.inr i => fun_prop + exact (SpaceTime.differentiable_vector _).mp fun μ => by + rcases μ with μ | i + · fin_cases μ + fun_prop + · fun_prop lemma contDiff_ofVectorPotential {n} {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hA : ContDiff ℝ n ↿A) : ContDiff ℝ n (ofVectorPotential c A) := by simp [ofVectorPotential] - rw [← SpaceTime.contDiff_vector] - intro μ - match μ with - | Sum.inl 0 => fun_prop - | Sum.inr i => fun_prop + exact (SpaceTime.contDiff_vector _).mp fun μ => by + rcases μ with μ | i + · fin_cases μ + fun_prop + · fun_prop lemma differentiable_ofPotentials {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hϕ : Differentiable ℝ ↿φ) (hA : Differentiable ℝ ↿A) : Differentiable ℝ (ofPotentials c φ A) := by simp [ofPotentials] - rw [← SpaceTime.differentiable_vector] - intro μ - match μ with - | Sum.inl 0 => fun_prop - | Sum.inr i => fun_prop + exact (SpaceTime.differentiable_vector _).mp fun μ => by + rcases μ with μ | i + · fin_cases μ + fun_prop + · fun_prop lemma contDiff_ofPotentials {n} {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hϕ : ContDiff ℝ n ↿φ) (hA : ContDiff ℝ n ↿A) : ContDiff ℝ n (ofPotentials c φ A) := by simp [ofPotentials] - rw [← SpaceTime.contDiff_vector] - intro μ - match μ with - | Sum.inl 0 => fun_prop - | Sum.inr i => fun_prop + exact (SpaceTime.contDiff_vector _).mp fun μ => by + rcases μ with μ | i + · fin_cases μ + fun_prop + · fun_prop open MeasureTheory Matrix Space InnerProductSpace Time in lemma contDiff_ofElectromagneticField {n : ℕ} (c : SpeedOfLight) From 2c3aeb4e930f4a1ecb86634fd5f2fa47bc814b17 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:27:36 -0700 Subject: [PATCH 032/498] refactor(electromagnetism): golf field strength smoothness proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Dynamics/Basic.lean | 4 ++-- .../Kinematics/EMPotential.lean | 5 ++--- .../Kinematics/FieldStrength.lean | 21 +++++++------------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/Basic.lean b/Physlib/Electromagnetism/Dynamics/Basic.lean index 513934f8d..2cf4ca05f 100644 --- a/Physlib/Electromagnetism/Dynamics/Basic.lean +++ b/Physlib/Electromagnetism/Dynamics/Basic.lean @@ -102,8 +102,8 @@ lemma c_sq : (𝓕.c : ℝ) ^ 2 = 1 / (𝓕.ε₀ * 𝓕.μ₀) := by · positivity @[simp] -lemma c_abs : abs (𝓕.c : ℝ) = 𝓕.c := by - rw [abs_of_pos (SpeedOfLight.val_pos 𝓕.c)] +lemma c_abs : abs (𝓕.c : ℝ) = 𝓕.c := + abs_of_pos (SpeedOfLight.val_pos 𝓕.c) end FreeSpace diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index 8d50989a4..855271a5c 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -231,9 +231,8 @@ noncomputable def ofStaticPotentials {d} (c : SpeedOfLight) (ϕ : Space d → lemma ofStaticPotentials_eq_ofPotentials {d} (c : SpeedOfLight) (ϕ : Space d → ℝ) (A : Space d → EuclideanSpace ℝ (Fin d)) : - ofStaticPotentials c ϕ A = ofPotentials c (fun _ => ϕ) (fun _ => A) := by - rw [ofPotentials_eq_add] - rfl + ofStaticPotentials c ϕ A = ofPotentials c (fun _ => ϕ) (fun _ => A) := + (ofPotentials_eq_add c (fun _ => ϕ) (fun _ => A)).symm open MeasureTheory Matrix Space InnerProductSpace Time in /-- The electromagnetic potential from an electric and a magnetic field. diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index 0ae6f7b34..f12cbc95f 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -477,19 +477,15 @@ lemma fieldStrengthMatrix_differentiable {d} {A : ElectromagneticPotential d} lemma fieldStrengthMatrix_differentiable_space {d} {A : ElectromagneticPotential d} {μν} (hA : ContDiff ℝ 2 A) (t : Time) {c : SpeedOfLight} : - Differentiable ℝ (fun x => A.fieldStrengthMatrix ((toTimeAndSpace c).symm (t, x)) μν) := by - change Differentiable ℝ ((A.fieldStrengthMatrix · μν) ∘ fun x => (toTimeAndSpace c).symm (t, x)) - refine Differentiable.comp ?_ ?_ - · exact fieldStrengthMatrix_differentiable hA - · fun_prop + Differentiable ℝ (fun x => A.fieldStrengthMatrix ((toTimeAndSpace c).symm (t, x)) μν) := + (fieldStrengthMatrix_differentiable hA).comp (f := fun x => (toTimeAndSpace c).symm (t, x)) + (by fun_prop) lemma fieldStrengthMatrix_differentiable_time {d} {A : ElectromagneticPotential d} {μν} (hA : ContDiff ℝ 2 A) (x : Space d) {c : SpeedOfLight} : - Differentiable ℝ (fun t => A.fieldStrengthMatrix ((toTimeAndSpace c).symm (t, x)) μν) := by - change Differentiable ℝ ((A.fieldStrengthMatrix · μν) ∘ fun t => (toTimeAndSpace c).symm (t, x)) - refine Differentiable.comp ?_ ?_ - · exact fieldStrengthMatrix_differentiable hA - · fun_prop + Differentiable ℝ (fun t => A.fieldStrengthMatrix ((toTimeAndSpace c).symm (t, x)) μν) := + (fieldStrengthMatrix_differentiable hA).comp (f := fun t => (toTimeAndSpace c).symm (t, x)) + (by fun_prop) lemma fieldStrengthMatrix_contDiff {d} {n : WithTop ℕ∞} {A : ElectromagneticPotential d} {μν} (hA : ContDiff ℝ (n + 1) A) : @@ -520,9 +516,8 @@ lemma fieldStrengthMatrix_contDiff {d} {n : WithTop ℕ∞} {A : Electromagnetic lemma fieldStrengthMatrix_smooth {d} {A : ElectromagneticPotential d} (hA : ContDiff ℝ ∞ A) (μν) : - ContDiff ℝ ∞ (A.fieldStrengthMatrix · μν) := by - apply fieldStrengthMatrix_contDiff - simpa using hA + ContDiff ℝ ∞ (A.fieldStrengthMatrix · μν) := + fieldStrengthMatrix_contDiff (μν := μν) (by simpa using hA) /-! From f064c9742513ae327f2b43f88b07901d1d185812 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:33:55 -0700 Subject: [PATCH 033/498] refactor(electromagnetism): golf vacuum wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Vacuum/Constant.lean | 5 ++--- Physlib/Electromagnetism/Vacuum/HarmonicWave.lean | 10 ++++------ Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean | 10 ++++------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Physlib/Electromagnetism/Vacuum/Constant.lean b/Physlib/Electromagnetism/Vacuum/Constant.lean index 4bbfd58b1..cd33bc31a 100644 --- a/Physlib/Electromagnetism/Vacuum/Constant.lean +++ b/Physlib/Electromagnetism/Vacuum/Constant.lean @@ -86,9 +86,8 @@ lemma constantEB_smooth {c : SpeedOfLight} {E₀ : EuclideanSpace ℝ (Fin d)} {B₀ : Fin d × Fin d → ℝ} {B₀_antisymm : ∀ i j, B₀ (i, j) = - B₀ (j, i)} : ContDiff ℝ ∞ (constantEB c E₀ B₀ B₀_antisymm) := by - rw [← Lorentz.Vector.contDiff_apply] - intro μ - match μ with + exact (Lorentz.Vector.contDiff_apply _).mp fun μ => by + match μ with | Sum.inl _ => simp [constantEB] apply ContDiff.neg diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index bc4fbe15d..73164e01d 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -105,9 +105,8 @@ lemma harmonicWaveX_inr_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → lemma harmonicWaveX_differentiable {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) : Differentiable ℝ (harmonicWaveX 𝓕 k E₀ φ) := by - rw [← Lorentz.Vector.differentiable_apply] - intro μ - match μ with + exact (Lorentz.Vector.differentiable_apply _).mp fun μ => by + match μ with | Sum.inl 0 => simp | Sum.inr ⟨0, h⟩ => simp | Sum.inr ⟨Nat.succ i, h⟩ => @@ -124,9 +123,8 @@ lemma harmonicWaveX_differentiable {d} (𝓕 : FreeSpace) (k : ℝ) lemma harmonicWaveX_contDiff {d} (n : WithTop ℕ∞) (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) : ContDiff ℝ n (harmonicWaveX 𝓕 k E₀ φ) := by - rw [← Lorentz.Vector.contDiff_apply] - intro μ - match μ with + exact (Lorentz.Vector.contDiff_apply _).mp fun μ => by + match μ with | Sum.inl 0 => simp [harmonicWaveX]; fun_prop | Sum.inr ⟨0, h⟩ => simp [harmonicWaveX]; fun_prop | Sum.inr ⟨Nat.succ i, h⟩ => diff --git a/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean b/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean index eb0811902..0101d269d 100644 --- a/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean +++ b/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean @@ -93,9 +93,8 @@ lemma electricField_eq_electricFunction {d : ℕ} {𝓕 : FreeSpace} {A : ElectromagneticPotential d} {s : Direction d} (P : IsPlaneWave 𝓕 A s) (t : Time) (x : Space d) : A.electricField 𝓕.c t x = - P.electricFunction (⟪x, s.unit⟫_ℝ - 𝓕.c * t) := by - rw [Classical.choose_spec P.1] - rfl + P.electricFunction (⟪x, s.unit⟫_ℝ - 𝓕.c * t) := + congrFun (congrFun (Classical.choose_spec P.1) t) x /-- The corresponding magnetic field function from `ℝ` to `Fin d × Fin d → ℝ` of a plane wave. -/ @@ -108,9 +107,8 @@ lemma magneticFieldMatrix_eq_magneticFunction {d : ℕ} {𝓕 : FreeSpace} {A : ElectromagneticPotential d} {s : Direction d} (P : IsPlaneWave 𝓕 A s) (t : Time) (x : Space d) : A.magneticFieldMatrix 𝓕.c t x = - P.magneticFunction (⟪x, s.unit⟫_ℝ - 𝓕.c * t) := by - rw [Classical.choose_spec P.2 t x] - rfl + P.magneticFunction (⟪x, s.unit⟫_ℝ - 𝓕.c * t) := + Classical.choose_spec P.2 t x /-! From 3d1e6d54c8e04a3169e6a2fae279654c872ef273 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:40:24 -0700 Subject: [PATCH 034/498] refactor(relativity): golf exact wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Proper.lean | 4 ++-- Physlib/Relativity/SL2C/Basic.lean | 4 ++-- .../Tensors/ComplexTensor/Metrics/Lemmas.lean | 24 +++++++++---------- .../Tensors/RealTensor/CoVector/Basic.lean | 4 ++-- .../Tensors/RealTensor/Vector/Basic.lean | 4 ++-- .../Tensors/RealTensor/Vector/Pre/Basic.lean | 4 ++-- .../RealTensor/Vector/Pre/Modules.lean | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Proper.lean b/Physlib/Relativity/LorentzGroup/Proper.lean index 98bbc1201..ced833d3d 100644 --- a/Physlib/Relativity/LorentzGroup/Proper.lean +++ b/Physlib/Relativity/LorentzGroup/Proper.lean @@ -43,8 +43,8 @@ local notation "ℤ₂" => Multiplicative (ZMod 2) instance : TopologicalSpace ℤ₂ := instTopologicalSpaceFin /-- The topological space defined by `ℤ₂` is discrete. -/ -instance : DiscreteTopology ℤ₂ := by - exact discreteTopology_iff_forall_isOpen.mpr fun _ => trivial +instance : DiscreteTopology ℤ₂ := + discreteTopology_iff_forall_isOpen.mpr fun _ => trivial /-- The instance of a topological group on `ℤ₂` defined via the discrete topology. -/ instance : IsTopologicalGroup ℤ₂ := IsTopologicalGroup.mk diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index 3f7ba29f2..fdf549625 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -241,8 +241,8 @@ lemma toLorentzGroup_fst_col (M : SL(2, ℂ)) : /-- The first element of the image of `SL(2, ℂ)` in the Lorentz group. -/ lemma toLorentzGroup_inl_inl (M : SL(2, ℂ)) : (toLorentzGroup M).1 (Sum.inl 0) (Sum.inl 0) = - ((‖M.1 0 0‖ ^ 2 + ‖M.1 0 1‖ ^ 2 + ‖M.1 1 0‖ ^ 2 + ‖M.1 1 1‖ ^ 2) / 2) := by - exact congrFun (toLorentzGroup_fst_col M) (Sum.inl 0) + ((‖M.1 0 0‖ ^ 2 + ‖M.1 0 1‖ ^ 2 + ‖M.1 1 0‖ ^ 2 + ‖M.1 1 1‖ ^ 2) / 2) := + congrFun (toLorentzGroup_fst_col M) (Sum.inl 0) /-- The image of `SL(2, ℂ)` in the Lorentz group is orthochronous. -/ lemma toLorentzGroup_isOrthochronous (M : SL(2, ℂ)) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Lemmas.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Lemmas.lean index 0f6fa5fe7..8944c699b 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Lemmas.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Lemmas.lean @@ -105,38 +105,38 @@ lemma dualRightMetric_antisymm : {εR' | α α' = - (εR' | α' α)}ᵀ := by /-- The contraction of the covariant metric with the contravariant metric is the unit `{η' | μ ρ ⊗ η | ρ ν = δ' | μ ν}ᵀ`. -/ -lemma coMetric_contr_contrMetric : {η' | μ ρ ⊗ η | ρ ν = δ' | μ ν}ᵀ := by - exact contrT_metricTensor_metricTensor_eq_dual_unit +lemma coMetric_contr_contrMetric : {η' | μ ρ ⊗ η | ρ ν = δ' | μ ν}ᵀ := + contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the contravariant metric with the covariant metric is the unit `{η | μ ρ ⊗ η' | ρ ν = δ | μ ν}ᵀ`. -/ -lemma contrMetric_contr_coMetric : {η | μ ρ ⊗ η' | ρ ν = δ | μ ν}ᵀ := by - exact contrT_metricTensor_metricTensor_eq_dual_unit +lemma contrMetric_contr_coMetric : {η | μ ρ ⊗ η' | ρ ν = δ | μ ν}ᵀ := + contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the left metric with the dual-left metric is the unit `{εL | α β ⊗ εL' | β γ = δL | α γ}ᵀ`. -/ -lemma leftMetric_contr_dualLeftMetric : {εL | α β ⊗ εL' | β γ = δL | α γ}ᵀ := by - exact contrT_metricTensor_metricTensor_eq_dual_unit +lemma leftMetric_contr_dualLeftMetric : {εL | α β ⊗ εL' | β γ = δL | α γ}ᵀ := + contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the right metric with the dual-right metric is the unit `{εR | α β ⊗ εR' | β γ = δR | α γ}ᵀ`. -/ -lemma rightMetric_contr_dualRightMetric : {εR | α β ⊗ εR' | β γ = δR | α γ}ᵀ := by - exact contrT_metricTensor_metricTensor_eq_dual_unit +lemma rightMetric_contr_dualRightMetric : {εR | α β ⊗ εR' | β γ = δR | α γ}ᵀ := + contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the dual-left metric with the left metric is the unit `{εL' | α β ⊗ εL | β γ = δL' | α γ}ᵀ`. -/ -lemma dualLeftMetric_contr_leftMetric : {εL' | α β ⊗ εL | β γ = δL' | α γ}ᵀ := by - exact contrT_metricTensor_metricTensor_eq_dual_unit +lemma dualLeftMetric_contr_leftMetric : {εL' | α β ⊗ εL | β γ = δL' | α γ}ᵀ := + contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the dual-right metric with the right metric is the unit `{εR' | α β ⊗ εR | β γ = δR' | α γ}ᵀ`. -/ -lemma dualRightMetric_contr_rightMetric : {εR' | α β ⊗ εR | β γ = δR' | α γ}ᵀ := by - exact contrT_metricTensor_metricTensor_eq_dual_unit +lemma dualRightMetric_contr_rightMetric : {εR' | α β ⊗ εR | β γ = δR' | α γ}ᵀ := + contrT_metricTensor_metricTensor_eq_dual_unit /-! diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean index e9636635c..41945c016 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean @@ -158,8 +158,8 @@ lemma basis_repr_apply {d : ℕ} (p : CoVector d) (μ : Fin 1 ⊕ Fin d) : erw [Pi.basisFun_repr] lemma map_apply_eq_basis_mulVec {d : ℕ} (f : CoVector d →ₗ[ℝ] CoVector d) (p : CoVector d) : - (f p) = (LinearMap.toMatrix basis basis) f *ᵥ p := by - exact Eq.symm (LinearMap.toMatrix_mulVec_repr basis basis f p) + (f p) = (LinearMap.toMatrix basis basis) f *ᵥ p := + Eq.symm (LinearMap.toMatrix_mulVec_repr basis basis f p) end CoVector diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean index 529398ff4..b0a78d9ec 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean @@ -288,8 +288,8 @@ lemma basis_repr_apply {d : ℕ} (p : Vector d) (μ : Fin 1 ⊕ Fin d) : erw [Pi.basisFun_repr] lemma map_apply_eq_basis_mulVec {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) (p : Vector d) : - (f p) = (LinearMap.toMatrix basis basis) f *ᵥ p := by - exact Eq.symm (LinearMap.toMatrix_mulVec_repr basis basis f p) + (f p) = (LinearMap.toMatrix basis basis) f *ᵥ p := + Eq.symm (LinearMap.toMatrix_mulVec_repr basis basis f p) lemma sum_basis_eq_zero_iff {d : ℕ} (f : Fin 1 ⊕ Fin d → ℝ) : (∑ μ, f μ • basis μ) = 0 ↔ ∀ μ, f μ = 0 := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index 182087ea6..f22216f2c 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -72,8 +72,8 @@ instance : TopologicalSpace (Contr d) := TopologicalSpace.induced ContrMod.toFin1dℝEquiv (Pi.topologicalSpace) lemma continuous_contr {T : Type} [TopologicalSpace T] (f : T → Contr d) - (h : Continuous (fun i => (f i).toFin1dℝ)) : Continuous f := by - exact continuous_induced_rng.mpr h + (h : Continuous (fun i => (f i).toFin1dℝ)) : Continuous f := + continuous_induced_rng.mpr h set_option backward.isDefEq.respectTransparency false in lemma contr_continuous {T : Type} [TopologicalSpace T] (f : Contr d → T) diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index 72d7b7d89..f7f6390e4 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -290,8 +290,8 @@ instance : TopologicalSpace (ContrMod d) := TopologicalSpace.induced open Topology -lemma toFin1dℝEquiv_isInducing : IsInducing (@ContrMod.toFin1dℝEquiv d) := by - exact { eq_induced := rfl } +lemma toFin1dℝEquiv_isInducing : IsInducing (@ContrMod.toFin1dℝEquiv d) := + { eq_induced := rfl } lemma toFin1dℝEquiv_symm_isInducing : IsInducing ((@ContrMod.toFin1dℝEquiv d).symm) := by let x := Equiv.toHomeomorphOfIsInducing (@ContrMod.toFin1dℝEquiv d).toEquiv From 81d6f5624234ae82ad2b6a7c7043226b6b673222 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:45:19 -0700 Subject: [PATCH 035/498] refactor(relativity): golf definitional wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Basic.lean | 4 ++-- Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean | 3 ++- Physlib/Relativity/MinkowskiMatrix.lean | 2 +- Physlib/Relativity/SL2C/Basic.lean | 2 +- .../Tensors/ComplexTensor/Vector/Pre/Contraction.lean | 4 ++-- .../Tensors/ComplexTensor/Weyl/Contraction.lean | 8 ++++---- Physlib/Relativity/Tensors/Constructors.lean | 2 +- .../Tensors/RealTensor/CoVector/Representation.lean | 3 ++- Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean | 4 ++-- .../Tensors/RealTensor/Vector/MinkowskiProduct.lean | 4 ++-- .../Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean | 3 ++- .../Tensors/RealTensor/Vector/Representation.lean | 3 ++- Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean | 8 ++++---- 13 files changed, 27 insertions(+), 23 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index a4794c27d..6c9644448 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -59,8 +59,8 @@ variable {Λ Λ' : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ} -/ -lemma mem_iff_self_mul_dual : Λ ∈ LorentzGroup d ↔ Λ * dual Λ = 1 := by - rfl +lemma mem_iff_self_mul_dual : Λ ∈ LorentzGroup d ↔ Λ * dual Λ = 1 := + Iff.rfl lemma mem_iff_dual_mul_self : Λ ∈ LorentzGroup d ↔ dual Λ * Λ = 1 := by rw [mem_iff_self_mul_dual] diff --git a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean index 1a9a3add9..37a336150 100644 --- a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean @@ -42,7 +42,8 @@ lemma isOrthochronous_iff_toVector_timeComponet_nonneg : /-- A Lorentz transformation is orthochronous if and only if its transpose is orthochronous. -/ lemma isOrthochronous_iff_transpose : - IsOrthochronous Λ ↔ IsOrthochronous (transpose Λ) := by rfl + IsOrthochronous Λ ↔ IsOrthochronous (transpose Λ) := + Iff.rfl @[simp] lemma isOrthochronous_inv_iff {Λ : LorentzGroup d} : diff --git a/Physlib/Relativity/MinkowskiMatrix.lean b/Physlib/Relativity/MinkowskiMatrix.lean index d06f5350e..13d8a485a 100644 --- a/Physlib/Relativity/MinkowskiMatrix.lean +++ b/Physlib/Relativity/MinkowskiMatrix.lean @@ -113,7 +113,7 @@ We prove some simple properties related to the components of the Minkowski matri /-- The `time-time` component of the Minkowski matrix is `1`. -/ @[simp] -lemma inl_0_inl_0 : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := by +lemma inl_0_inl_0 : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := rfl /-- The space diagonal components of the Minkowski matrix are `-1`. -/ diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index fdf549625..94d9c9f37 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -176,7 +176,7 @@ def toLorentzGroup : SL(2, ℂ) →* LorentzGroup 3 where lemma toLorentzGroup_eq_pauliBasis' (M : SL(2, ℂ)) : toLorentzGroup M = LinearMap.toMatrix - PauliMatrix.pauliBasis' PauliMatrix.pauliBasis' (toSelfAdjointMap M) := by + PauliMatrix.pauliBasis' PauliMatrix.pauliBasis' (toSelfAdjointMap M) := rfl lemma toSelfAdjointMap_basis (i : Fin 1 ⊕ Fin 3) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean index ed154264d..62f8a2258 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean @@ -89,7 +89,7 @@ def contrCoContraction : (ContrℂModule.SL2CRep.tprod CoℂModule.SL2CRep).Inte simp lemma contrCoContraction_hom_tmul (ψ : ContrℂModule) (φ : CoℂModule) : - contrCoContraction (ψ ⊗ₜ φ) = ψ.toFin13ℂ ⬝ᵥ φ.toFin13ℂ := by + contrCoContraction (ψ ⊗ₜ φ) = ψ.toFin13ℂ ⬝ᵥ φ.toFin13ℂ := rfl lemma contrCoContraction_basis (i j : Fin 4) : @@ -128,7 +128,7 @@ def coContrContraction : (CoℂModule.SL2CRep.tprod ContrℂModule.SL2CRep).Inte simp lemma coContrContraction_hom_tmul (φ : CoℂModule) (ψ : ContrℂModule) : - coContrContraction (φ ⊗ₜ ψ) = φ.toFin13ℂ ⬝ᵥ ψ.toFin13ℂ := by + coContrContraction (φ ⊗ₜ ψ) = φ.toFin13ℂ ⬝ᵥ ψ.toFin13ℂ := rfl lemma coContrContraction_basis (i j : Fin 4) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean index 4748e2992..3b57afdd3 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean @@ -140,7 +140,7 @@ def leftDualContraction : (leftHandedRep.tprod dualLeftHandedRep).IntertwiningMa lemma leftDualContraction_hom_tmul (ψ : LeftHandedWeyl) (φ : DualLeftHandedWeyl) : - leftDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := by + leftDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := rfl lemma leftDualContraction_basis (i j : Fin 2) : @@ -166,7 +166,7 @@ def dualLeftContraction : (dualLeftHandedRep.tprod leftHandedRep).IntertwiningMa simp lemma dualLeftContraction_hom_tmul (φ : DualLeftHandedWeyl) (ψ : LeftHandedWeyl) : - dualLeftContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := by + dualLeftContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := rfl lemma dualLeftContraction_basis (i j : Fin 2) : @@ -206,7 +206,7 @@ def rightDualContraction : (rightHandedRep.tprod dualRightHandedRep).Intertwinin lemma rightDualContraction_hom_tmul (ψ : RightHandedWeyl) (φ : DualRightHandedWeyl) : - rightDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := by + rightDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := rfl lemma rightDualContraction_basis (i j : Fin 2) : @@ -247,7 +247,7 @@ def dualRightContraction : (dualRightHandedRep.tprod rightHandedRep).Intertwinin lemma dualRightContraction_hom_tmul (φ : DualRightHandedWeyl) (ψ : RightHandedWeyl) : - dualRightContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := by + dualRightContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := rfl lemma dualRightContraction_basis (i j : Fin 2) : diff --git a/Physlib/Relativity/Tensors/Constructors.lean b/Physlib/Relativity/Tensors/Constructors.lean index b37d9ddf6..041224ec4 100644 --- a/Physlib/Relativity/Tensors/Constructors.lean +++ b/Physlib/Relativity/Tensors/Constructors.lean @@ -46,7 +46,7 @@ noncomputable def Pure.fromSingleP {c : C} : V c ≃ₗ[k] Pure S ![c] where ext i fin_cases i rfl - left_inv x := by rfl + left_inv x := rfl right_inv x := by ext i fin_cases i diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean index a79c5cbc6..f1400cf1a 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean @@ -46,7 +46,8 @@ def rep {d : ℕ} : Representation ℝ (LorentzGroup d) (CoVector d) where -/ lemma rep_apply_eq_mulVec (d : ℕ) (Λ : LorentzGroup d) (v : CoVector d) : - rep Λ v = (LorentzGroup.transpose Λ⁻¹) *ᵥ v := by rfl + rep Λ v = (LorentzGroup.transpose Λ⁻¹) *ᵥ v := + rfl lemma rep_apply_eq_sum (d : ℕ) (Λ : LorentzGroup d) (v : CoVector d) (k : Fin 1 ⊕ Fin d) : rep Λ v k = ∑ j, (Λ⁻¹).1 j k • v j := rfl diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean index b0a78d9ec..2cefa6522 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean @@ -340,8 +340,8 @@ lemma spatialPart_basis_sum_inl {d : ℕ} (i : Fin d) : /-- The spatial part of a Lorentz vector as a continuous linear map. -/ def spatialCLM (d : ℕ) : Vector d →L[ℝ] EuclideanSpace ℝ (Fin d) where toFun v := WithLp.toLp 2 fun i => v (Sum.inr i) - map_add' v1 v2 := by rfl - map_smul' c v := by rfl + map_add' v1 v2 := rfl + map_smul' c v := rfl cont := by fun_prop lemma spatialCLM_apply_eq_spatialPart {d : ℕ} (v : Vector d) (i : Fin d) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean index 2dbe8d943..ed5224500 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean @@ -255,8 +255,8 @@ def IsLorentz {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : Prop := ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ lemma isLorentz_iff {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : - IsLorentz f ↔ ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ := by - rfl + IsLorentz f ↔ ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ := + Iff.rfl lemma isLorentz_iff_basis {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : IsLorentz f ↔ ∀ μ ν : Fin 1 ⊕ Fin d, ⟪f (basis μ), f (basis ν)⟫ₘ = ⟪basis μ, basis ν⟫ₘ := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index f7f6390e4..612a09eeb 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -72,7 +72,8 @@ def toFin1dℝEquiv : ContrMod d ≃ₗ[ℝ] (Fin 1 ⊕ Fin d → ℝ) := through the linear equivalence `toFin1dℝEquiv`. -/ abbrev toFin1dℝ (ψ : ContrMod d) := toFin1dℝEquiv ψ -lemma toFin1dℝ_eq_val (ψ : ContrMod d) : ψ.toFin1dℝ = ψ.val := by rfl +lemma toFin1dℝ_eq_val (ψ : ContrMod d) : ψ.toFin1dℝ = ψ.val := + rfl /-! ## The standard basis. diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean index d0a2d609b..4e00521f8 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean @@ -43,7 +43,8 @@ def rep {d : ℕ} : Representation ℝ (LorentzGroup d) (Vector d) where -/ lemma rep_apply_eq_mulVec (d : ℕ) (Λ : LorentzGroup d) (v : Vector d) : - rep Λ v = Λ *ᵥ v := by rfl + rep Λ v = Λ *ᵥ v := + rfl lemma rep_apply_eq_sum (d : ℕ) (Λ : LorentzGroup d) (v : Vector d) (k : Fin 1 ⊕ Fin d) : rep Λ v k = ∑ j, Λ.1 k j • v j := rfl diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index 0720cd529..215fb4b2a 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -35,11 +35,11 @@ variable {d : ℕ} noncomputable instance : TopologicalSpace (Velocity d) := instTopologicalSpaceSubtype @[ext] -lemma ext {v w : Velocity d} (h : v.1 = w.1) : v = w := by - exact SetCoe.ext h +lemma ext {v w : Velocity d} (h : v.1 = w.1) : v = w := + SetCoe.ext h -lemma mem_iff {v : Vector d} : v ∈ Velocity d ↔ ⟪v, v⟫ₘ = (1 : ℝ) ∧ 0 < v.timeComponent := by - rfl +lemma mem_iff {v : Vector d} : v ∈ Velocity d ↔ ⟪v, v⟫ₘ = (1 : ℝ) ∧ 0 < v.timeComponent := + Iff.rfl @[simp] lemma minkowskiProduct_self_eq_one (v : Velocity d) : ⟪v.1, v.1⟫ₘ = (1 : ℝ) := v.2.1 From e9d830e7ac98c816f938dc8d6ebd42f1b4a31747 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:49:09 -0700 Subject: [PATCH 036/498] refactor(relativity): golf local wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../Relativity/LorentzAlgebra/ExponentialMap.lean | 4 ++-- .../Relativity/LorentzGroup/Boosts/Generalized.lean | 12 ++++++------ .../Relativity/LorentzGroup/Restricted/Basic.lean | 6 +++--- Physlib/Relativity/PauliMatrices/Basic.lean | 3 ++- Physlib/Relativity/Tensors/Basic.lean | 3 ++- .../Tensors/ComplexTensor/Weyl/Contraction.lean | 4 ++-- .../Tensors/RealTensor/CoVector/Basic.lean | 3 ++- .../Relativity/Tensors/RealTensor/Vector/Basic.lean | 3 ++- .../RealTensor/Vector/Causality/TimeLike.lean | 12 ++++++------ .../Tensors/RealTensor/Vector/Pre/Basic.lean | 6 ++++-- .../Tensors/RealTensor/Vector/Pre/Contraction.lean | 7 ++++--- 11 files changed, 35 insertions(+), 28 deletions(-) diff --git a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean index a906c0aab..66ce46b51 100644 --- a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean +++ b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean @@ -177,5 +177,5 @@ theorem exp_isOrthochronous (A : lorentzAlgebra) : restricted Lorentz group. -/ theorem exp_mem_restricted_lorentzGroup (A : lorentzAlgebra) : (⟨NormedSpace.exp A.1, exp_mem_lorentzGroup A⟩ : LorentzGroup 3) ∈ - LorentzGroup.restricted 3 := by - exact ⟨exp_isProper A, exp_isOrthochronous A⟩ + LorentzGroup.restricted 3 := + ⟨exp_isProper A, exp_isOrthochronous A⟩ diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean index 55c9e9457..df444f58d 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean @@ -112,8 +112,8 @@ lemma genBoostAux₂_basis_minkowskiProduct (u v : Velocity d) (μ ν : Fin 1 rw [minkowskiProduct_symm] ring dsimp - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by - exact Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := + Velocity.one_add_minkowskiProduct_ne_zero u v field_simp [h2] have h2 : (minkowskiProduct ↑v) u.1 = ⟪u.1, v.1⟫ₘ := by rw [minkowskiProduct_symm] simp only [map_add, _root_.smul_add, _root_.neg_smul, add_apply, _root_.neg_apply, smul_apply, @@ -132,8 +132,8 @@ lemma genBoostAux₁_basis_genBoostAux₂_minkowskiProduct (u v : Velocity d) ( ring simp only [smul_apply, map_add, Velocity.minkowskiProduct_self_eq_one, smul_eq_mul, neg_mul, neg_inj] - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by - exact Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := + Velocity.one_add_minkowskiProduct_ne_zero u v field_simp [h2] rw [minkowskiProduct_symm] ring @@ -174,8 +174,8 @@ lemma basis_minkowskiProduct_genBoostAux₁_add_genBoostAux₂ (u v : Velocity d rw [genBoostAux₁_apply_basis, genBoostAux₂_apply_basis] rw [map_smul, map_smul] simp - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by - exact Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := + Velocity.one_add_minkowskiProduct_ne_zero u v field_simp ring diff --git a/Physlib/Relativity/LorentzGroup/Restricted/Basic.lean b/Physlib/Relativity/LorentzGroup/Restricted/Basic.lean index f42a69c9a..4baebe772 100644 --- a/Physlib/Relativity/LorentzGroup/Restricted/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Restricted/Basic.lean @@ -34,12 +34,12 @@ def restricted (d : ℕ) : Subgroup (LorentzGroup d) where mul_mem' := by rintro Λ₁ Λ₂ ⟨Λ₁_proper, Λ₁_ortho⟩ ⟨Λ₂_proper, Λ₂_ortho⟩ exact ⟨ - by exact isProper_mul Λ₁_proper Λ₂_proper, - by exact isOrthochronous_mul Λ₁_ortho Λ₂_ortho⟩ + isProper_mul Λ₁_proper Λ₂_proper, + isOrthochronous_mul Λ₁_ortho Λ₂_ortho⟩ inv_mem' := by rintro Λ ⟨Λ_proper, Λ_ortho⟩ - have h_η₀₀ : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := by rfl + have h_η₀₀ : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := rfl have h_dual : (dual Λ.1) (Sum.inl 0) (Sum.inl 0) = Λ.1 (Sum.inl 0) (Sum.inl 0) := by rw [dual_apply, h_η₀₀, one_mul, mul_one] diff --git a/Physlib/Relativity/PauliMatrices/Basic.lean b/Physlib/Relativity/PauliMatrices/Basic.lean index 471937671..13ba8fa2b 100644 --- a/Physlib/Relativity/PauliMatrices/Basic.lean +++ b/Physlib/Relativity/PauliMatrices/Basic.lean @@ -101,7 +101,8 @@ instance pauliMatrixInvertiable (μ : Fin 1 ⊕ Fin 3) : Invertible (σ μ) := b · simp lemma pauliMatrix_inv (μ : Fin 1 ⊕ Fin 3) : - ⅟ (σ μ) = σ μ := by rfl + ⅟ (σ μ) = σ μ := + rfl /-! ### Products diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index 8c8ab9ce1..6a771f202 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -212,7 +212,8 @@ noncomputable def component {n : ℕ} {c : Fin n → C} (p : Pure S c) ∏ i, (b (c i)).repr (p i) (φ i) lemma component_eq {n : ℕ} {c : Fin n → C} (p : Pure S c) (φ : ComponentIdx c) : - p.component φ = ∏ i, (b (c i)).repr (p i) (φ i) := by rfl + p.component φ = ∏ i, (b (c i)).repr (p i) (φ i) := + rfl lemma component_eq_drop {n : ℕ} {c : Fin (n + 1) → C} (p : Pure S c) (i : Fin (n + 1)) (φ : ComponentIdx c) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean index 3b57afdd3..d5a79fe54 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean @@ -191,7 +191,7 @@ def rightDualContraction : (rightHandedRep.tprod dualRightHandedRep).Intertwinin isIntertwining' M := TensorProduct.ext' fun ψ φ => by change (M.1.map star *ᵥ ψ.toFin2ℂ) ⬝ᵥ (M.1⁻¹.conjTranspose *ᵥ φ.toFin2ℂ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ - have h1 : (M.1)⁻¹ᴴ = ((M.1)⁻¹.map star)ᵀ := by rfl + have h1 : (M.1)⁻¹ᴴ = ((M.1)⁻¹.map star)ᵀ := rfl rw [dotProduct_mulVec, h1, vecMul_transpose, mulVec_mulVec] have h2 : ((M.1)⁻¹.map star * (M.1).map star) = 1 := by refine transpose_inj.mp ?_ @@ -232,7 +232,7 @@ def dualRightContraction : (dualRightHandedRep.tprod rightHandedRep).Intertwinin isIntertwining' M := TensorProduct.ext' fun φ ψ => by change (M.1⁻¹.conjTranspose *ᵥ φ.toFin2ℂ) ⬝ᵥ (M.1.map star *ᵥ ψ.toFin2ℂ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ - have h1 : (M.1)⁻¹ᴴ = ((M.1)⁻¹.map star)ᵀ := by rfl + have h1 : (M.1)⁻¹ᴴ = ((M.1)⁻¹.map star)ᵀ := rfl rw [dotProduct_mulVec, h1, mulVec_transpose, vecMul_vecMul] have h2 : ((M.1)⁻¹.map star * (M.1).map star) = 1 := by refine transpose_inj.mp ?_ diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean index 41945c016..94fb4021d 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean @@ -120,7 +120,8 @@ lemma apply_add {d : ℕ} (v w : CoVector d) (i : Fin 1 ⊕ Fin d) : @[simp] lemma apply_sub {d : ℕ} (v w : CoVector d) (i : Fin 1 ⊕ Fin d) : - (v - w) i = v i - w i := by rfl + (v - w) i = v i - w i := + rfl @[simp] lemma apply_sum {d : ℕ} {ι : Type} [Fintype ι] (f : ι → CoVector d) (i : Fin 1 ⊕ Fin d) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean index 2cefa6522..f698ec9ed 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean @@ -137,7 +137,8 @@ lemma apply_add {d : ℕ} (v w : Vector d) (i : Fin 1 ⊕ Fin d) : @[simp] lemma apply_sub {d : ℕ} (v w : Vector d) (i : Fin 1 ⊕ Fin d) : - (v - w) i = v i - w i := by rfl + (v - w) i = v i - w i := + rfl lemma apply_sum {d : ℕ} {ι : Type} [Fintype ι] (f : ι → Vector d) (i : Fin 1 ⊕ Fin d) : (∑ j, f j) i = ∑ j, f j i := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean index 1febf830f..9d55500cd 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean @@ -27,8 +27,8 @@ namespace Vector @[simp] lemma timelike_neg_time_component_product {d : ℕ} (v w : Vector d) (hv_neg : v (Sum.inl 0) < 0) (hw_neg : w (Sum.inl 0) < 0) : - v (Sum.inl 0) * w (Sum.inl 0) > 0 := by - exact mul_pos_of_neg_of_neg hv_neg hw_neg + v (Sum.inl 0) * w (Sum.inl 0) > 0 := + mul_pos_of_neg_of_neg hv_neg hw_neg /-- For timelike vectors, the Minkowski inner product is positive -/ lemma timeLike_iff_norm_sq_pos {d : ℕ} (p : Vector d) : @@ -60,8 +60,8 @@ lemma timelike_time_dominates_space {d : ℕ} {v : Vector d} ∑ i, v (Sum.inr i) * v (Sum.inr i) := hv -- Rearrange the inequality have h : ∑ i, v (Sum.inr i) * v (Sum.inr i) < - v (Sum.inl 0) * v (Sum.inl 0) := by - exact lt_of_sub_pos h_norm_pos + v (Sum.inl 0) * v (Sum.inl 0) := + lt_of_sub_pos h_norm_pos exact h /-- For nonzero timelike vectors, the time component is nonzero -/ @@ -102,8 +102,8 @@ lemma timeLike_iff_time_lt_space {d : ℕ} {v : Vector d} : @[simp] lemma timeComponent_squared_pos_of_timelike {d : ℕ} {v : Vector d} (hv : causalCharacter v = .timeLike) : - 0 < (timeComponent v)^2 := by - exact pow_two_pos_of_ne_zero (time_component_ne_zero_of_timelike hv) + 0 < (timeComponent v)^2 := + pow_two_pos_of_ne_zero (time_component_ne_zero_of_timelike hv) /-- For timelike vectors, the spatial norm squared is strictly less than the time component squared -/ diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index f22216f2c..3f807fa42 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -64,7 +64,8 @@ lemma contrBasisFin_toFin1dℝ {d : ℕ} (i : Fin (1 + d)) : simp only [contrBasisFin, Basis.reindex_apply, contrBasis_toFin1dℝ] lemma contrBasisFin_repr_apply {d : ℕ} (p : ContrMod d) (i : Fin (1 + d)) : - (contrBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := by rfl + (contrBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := + rfl /-- The representation of contravariant Lorentz vectors forms a topological space, induced by its equivalence to `Fin 1 ⊕ Fin d → ℝ`. -/ @@ -121,7 +122,8 @@ lemma coBasisFin_toFin1dℝ {d : ℕ} (i : Fin (1 + d)) : simp only [coBasisFin, Basis.reindex_apply, coBasis_toFin1dℝ] lemma coBasisFin_repr_apply {d : ℕ} (p : Co d) (i : Fin (1 + d)) : - (coBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := by rfl + (coBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := + rfl open CategoryTheory.MonoidalCategory diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 48354dbc7..829c1578a 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -97,7 +97,7 @@ def contrCoContract : ((ContrMod.rep).tprod (CoMod.rep)).IntertwiningMap /-- Notation for `contrCoContract` acting on a tmul. -/ local notation "⟪" ψ "," φ "⟫ₘ" => contrCoContract (ψ ⊗ₜ φ) -lemma contrCoContract_hom_tmul (ψ : Contr d) (φ : Co d) : ⟪ψ, φ⟫ₘ = ψ.toFin1dℝ ⬝ᵥ φ.toFin1dℝ := by +lemma contrCoContract_hom_tmul (ψ : Contr d) (φ : Co d) : ⟪ψ, φ⟫ₘ = ψ.toFin1dℝ ⬝ᵥ φ.toFin1dℝ := rfl /-- The linear map from Co d ⊗ Contr d to ℝ given by @@ -119,7 +119,7 @@ def coContrContract : ((CoMod.rep (d := d)).tprod (ContrMod.rep (d := d))).Inter /-- Notation for `coContrContract` acting on a tmul. -/ local notation "⟪" φ "," ψ "⟫ₘ" => coContrContract (φ ⊗ₜ ψ) -lemma coContrContract_hom_tmul (φ : Co d) (ψ : Contr d) : ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ ψ.toFin1dℝ := by +lemma coContrContract_hom_tmul (φ : Co d) (ψ : Contr d) : ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ ψ.toFin1dℝ := rfl /-! @@ -172,7 +172,8 @@ def coCoContract : ((CoMod.rep (d := d)).tprod (CoMod.rep (d := d))).Intertwinin local notation "⟪" ψ "," φ "⟫ₘ" => coCoContract (ψ ⊗ₜ φ) lemma coCoContract_hom_tmul (φ : Co d) (ψ : Co d) : - ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ := by rfl + ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ := + rfl /-! From f7f794aef01ba83ad7dbf75f5d61f769c5361b53 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:51:23 -0700 Subject: [PATCH 037/498] refactor(relativity): golf remaining wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Boosts/Basic.lean | 4 ++-- Physlib/Relativity/Tensors/Contraction/Pure.lean | 2 +- Physlib/Relativity/Tensors/RealTensor/ToComplex.lean | 2 +- Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean index a45850ad4..b8ebdf947 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean @@ -95,8 +95,8 @@ where ring · simp only [hk', ↓reduceIte, Fin.isValue] rw [one_apply_ne fun a => hk (id (Eq.symm a))] - rw [if_neg (by exact fun a => hk (id (Eq.symm a)))] - rw [if_neg (by exact fun a => hk' (id (Eq.symm a)))] + rw [if_neg fun a => hk (id (Eq.symm a))] + rw [if_neg fun a => hk' (id (Eq.symm a))] simp · intro b _ hb simp [hb] diff --git a/Physlib/Relativity/Tensors/Contraction/Pure.lean b/Physlib/Relativity/Tensors/Contraction/Pure.lean index 87e256b57..36c18b868 100644 --- a/Physlib/Relativity/Tensors/Contraction/Pure.lean +++ b/Physlib/Relativity/Tensors/Contraction/Pure.lean @@ -224,7 +224,7 @@ lemma contrPCoeff_dropPair {n : ℕ} {c : Fin (n + 1 + 1) → C} (i j : Fin n) (hij : i ≠ j ∧ S.τ (c (succSuccAbove a b i)) = (c (succSuccAbove a b j))) (p : Pure S c) : (p.dropPair a b hab).contrPCoeff i j hij = p.contrPCoeff (succSuccAbove a b i) (succSuccAbove a b j) - (by simpa using hij) := by rfl + (by simpa using hij) := rfl lemma contrPCoeff_symm {n : ℕ} {c : Fin n → C} {i j : Fin n} {hij : i ≠ j ∧ S.τ (c i) = c j} {p : Pure S c} : diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index 3a1dfb51d..d89d3be5b 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -411,7 +411,7 @@ lemma toComplexPure_component {c : Fin n → Color} (p : Pure realLorentzTensor ↑(((b' c).repr px) φx) - suffices h : P (c x) px φx h2 by exact h + suffices h : P (c x) px φx h2 from h generalize c x = c at * fin_cases c · simp only [colorToComplex, toComplexVector, Nat.reduceAdd, Fin.cast_eq_self, P, b, b'] diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index 215fb4b2a..c5c6984b0 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -130,7 +130,7 @@ noncomputable def pathFromZero (u : Velocity d) : Path zero u where apply And.intro · let x := (√(1 + t ^ 2 * ‖u.1.spatialPart‖ ^ 2) - u.1 (Sum.inl 0) * t) calc _ - _ = ⟪x • zero.1 + (t : ℝ) • u.1, x • zero.1 + (t : ℝ) • u.1⟫ₘ := by rfl + _ = ⟪x • zero.1 + (t : ℝ) • u.1, x • zero.1 + (t : ℝ) • u.1⟫ₘ := rfl _ = x ^ 2 + (t : ℝ) ^ 2 + 2 * x * (t : ℝ) * u.1 (Sum.inl 0) := by simp only [zero, Fin.isValue, map_add, map_smul, _root_.add_apply, FunLike.coe_smul, Pi.smul_apply, minkowskiProduct_basis_right, From 7d3a15e4549087d4a9b3723e2c4bde94ad4a98ba Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:53:57 -0700 Subject: [PATCH 038/498] refactor(relativity): golf tensor conversion proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Metrics/Basic.lean | 30 ++++++++----------- .../Tensors/ComplexTensor/Units/Basic.lean | 30 ++++++++----------- .../Tensors/RealTensor/ToComplex.lean | 16 +++++----- 3 files changed, 32 insertions(+), 44 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean index d9f832f19..3ff818d0e 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean @@ -109,34 +109,28 @@ lemma dualRightMetric_eq_fromConstPair : εR' = fromConstPair Fermion.dualRightM -/ lemma coMetric_eq_fromPairT : η' = fromPairT (Lorentz.coMetricVal) := by - rw [coMetric_eq_fromConstPair, fromConstPair] - congr 1 - exact Lorentz.coMetric_apply_one + simpa only [coMetric_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Lorentz.coMetric_apply_one lemma contrMetric_eq_fromPairT : η = fromPairT (Lorentz.contrMetricVal) := by - rw [contrMetric_eq_fromConstPair, fromConstPair] - congr 1 - exact Lorentz.contrMetric_apply_one + simpa only [contrMetric_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Lorentz.contrMetric_apply_one lemma leftMetric_eq_fromPairT : εL = fromPairT (Fermion.leftMetricVal) := by - rw [leftMetric_eq_fromConstPair, fromConstPair] - congr 1 - exact Fermion.leftMetric_apply_one + simpa only [leftMetric_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Fermion.leftMetric_apply_one lemma rightMetric_eq_fromPairT : εR = fromPairT (Fermion.rightMetricVal) := by - rw [rightMetric_eq_fromConstPair, fromConstPair] - congr 1 - exact Fermion.rightMetric_apply_one + simpa only [rightMetric_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Fermion.rightMetric_apply_one lemma dualLeftMetric_eq_fromPairT : εL' = fromPairT (Fermion.dualLeftMetricVal) := by - rw [dualLeftMetric_eq_fromConstPair, fromConstPair] - congr 1 - exact Fermion.dualLeftMetric_apply_one + simpa only [dualLeftMetric_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Fermion.dualLeftMetric_apply_one lemma dualRightMetric_eq_fromPairT : εR' = fromPairT (Fermion.dualRightMetricVal) := by - rw [dualRightMetric_eq_fromConstPair, fromConstPair] - congr 1 - exact Fermion.dualRightMetric_apply_one + simpa only [dualRightMetric_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Fermion.dualRightMetric_apply_one /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index 947062b86..d91c2b6b1 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -115,34 +115,28 @@ lemma rightDualRightUnit_eq_fromConstPair : δR = fromConstPair Fermion.rightDua -/ lemma coContrUnit_eq_fromPairT : δ' = fromPairT (Lorentz.coContrUnitVal) := by - rw [coContrUnit_eq_fromConstPair, fromConstPair] - congr 1 - exact Lorentz.coContrUnit_apply_one + simpa only [coContrUnit_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Lorentz.coContrUnit_apply_one lemma contrCoUnit_eq_fromPairT : δ = fromPairT (Lorentz.contrCoUnitVal) := by - rw [contrCoUnit_eq_fromConstPair, fromConstPair] - congr 1 - exact Lorentz.contrCoUnit_apply_one + simpa only [contrCoUnit_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Lorentz.contrCoUnit_apply_one lemma dualLeftLeftUnit_eq_fromPairT : δL' = fromPairT (Fermion.dualLeftLeftUnitVal) := by - rw [dualLeftLeftUnit_eq_fromConstPair, fromConstPair] - congr 1 - exact Fermion.dualLeftLeftUnit_apply_one + simpa only [dualLeftLeftUnit_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Fermion.dualLeftLeftUnit_apply_one lemma leftDualLeftUnit_eq_fromPairT : δL = fromPairT (Fermion.leftDualLeftUnitVal) := by - rw [leftDualLeftUnit_eq_fromConstPair, fromConstPair] - congr 1 - exact Fermion.leftDualLeftUnit_apply_one + simpa only [leftDualLeftUnit_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Fermion.leftDualLeftUnit_apply_one lemma dualRightRightUnit_eq_fromPairT : δR' = fromPairT (Fermion.dualRightRightUnitVal) := by - rw [dualRightRightUnit_eq_fromConstPair, fromConstPair] - congr 1 - exact Fermion.dualRightRightUnit_apply_one + simpa only [dualRightRightUnit_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Fermion.dualRightRightUnit_apply_one lemma rightDualRightUnit_eq_fromPairT : δR = fromPairT (Fermion.rightDualRightUnitVal) := by - rw [rightDualRightUnit_eq_fromConstPair, fromConstPair] - congr 1 - exact Fermion.rightDualRightUnit_apply_one + simpa only [rightDualRightUnit_eq_fromConstPair, fromConstPair] using + congrArg fromPairT Fermion.rightDualRightUnit_apply_one /-! diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index d89d3be5b..069d1bb2c 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -469,24 +469,24 @@ lemma actionP_toComplexPure {n : ℕ} (c : Fin n → Color) (p : Pure realLorent · simp_all [P, b, b', colorToComplex] calc (Lorentz.ContrℂModule.SL2CRep Λ) ((toComplexVector Color.up) p) - = (Lorentz.ContrℂModule.SL2CRep Λ) (Lorentz.inclCongrRealLorentz p) := by - exact congrArg (Lorentz.ContrℂModule.SL2CRep Λ) + = (Lorentz.ContrℂModule.SL2CRep Λ) (Lorentz.inclCongrRealLorentz p) := + congrArg (Lorentz.ContrℂModule.SL2CRep Λ) (toComplexVector_up_eq_inclCongrRealLorentz p) _ = Lorentz.inclCongrRealLorentz ((Lorentz.Contr 3).ρ (toLorentzGroup Λ) p) := by rw [Lorentz.inclCongrRealLorentz_ρ] - _ = (toComplexVector Color.up) ((Lorentz.ContrMod.rep (toLorentzGroup Λ)) p) := by - exact (toComplexVector_up_eq_inclCongrRealLorentz + _ = (toComplexVector Color.up) ((Lorentz.ContrMod.rep (toLorentzGroup Λ)) p) := + (toComplexVector_up_eq_inclCongrRealLorentz ((Lorentz.ContrMod.rep (toLorentzGroup Λ)) p)).symm · simp_all [P, b, b', colorToComplex] calc (Lorentz.CoℂModule.SL2CRep Λ) ((toComplexVector Color.down) p) - = (Lorentz.CoℂModule.SL2CRep Λ) (Lorentz.inclCoRealLorentz p) := by - exact congrArg (Lorentz.CoℂModule.SL2CRep Λ) + = (Lorentz.CoℂModule.SL2CRep Λ) (Lorentz.inclCoRealLorentz p) := + congrArg (Lorentz.CoℂModule.SL2CRep Λ) (toComplexVector_down_eq_inclCoRealLorentz p) _ = Lorentz.inclCoRealLorentz ((Lorentz.Co 3).ρ (toLorentzGroup Λ) p) := by rw [Lorentz.inclCoRealLorentz_ρ] - _ = (toComplexVector Color.down) ((Lorentz.CoMod.rep (toLorentzGroup Λ)) p) := by - exact (toComplexVector_down_eq_inclCoRealLorentz + _ = (toComplexVector Color.down) ((Lorentz.CoMod.rep (toLorentzGroup Λ)) p) := + (toComplexVector_down_eq_inclCoRealLorentz ((Lorentz.CoMod.rep (toLorentzGroup Λ)) p)).symm lemma toComplex_pure {n : ℕ} (c : Fin n → Color) (p : Pure realLorentzTensor c) : From a1e9bb76ff4a80d555542ac366f1d64e2a0763a0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 10:58:43 -0700 Subject: [PATCH 039/498] refactor(particles): golf definitional wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../StandardModel/AnomalyCancellation/Basic.lean | 7 ++++--- .../NoGrav/One/LinearParameterization.lean | 2 +- .../StandardModel/HiggsBoson/Potential.lean | 6 ++++-- .../MSSMNu/AnomalyCancellation/Basic.lean | 12 ++++++------ .../SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean | 3 ++- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index bfddec06f..6220cac81 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -49,11 +49,12 @@ def toSpeciesEquiv : (SMCharges n).Charges ≃ (Fin 5 → Fin (SMSpecies n).numb @[simps!] def toSpecies (i : Fin 5) : (SMCharges n).Charges →ₗ[ℚ] (SMSpecies n).Charges where toFun S := toSpeciesEquiv S i - map_add' _ _ := by rfl - map_smul' _ _ := by rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl lemma toSpecies_apply_eq (i : Fin 5) (S : (SMCharges n).Charges) : - toSpecies i S = fun j => toSpeciesEquiv S i j := by rfl + toSpecies i S = fun j => toSpeciesEquiv S i j := + rfl lemma charges_eq_toSpecies_eq (S T : (SMCharges n).Charges) : S = T ↔ ∀ i, toSpecies i S = toSpecies i T := by diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean index efb447d2f..7657971ae 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean @@ -304,7 +304,7 @@ lemma cubic (S : linearParametersQENeqZero) : lemma cubic_v_or_w_zero (S : linearParametersQENeqZero) (h : accCube (bijection S).1.val = 0) : S.v = 0 ∨ S.w = 0 := by rw [S.cubic] at h - have h1 : (-1)^3 = (-1 : ℚ) := by rfl + have h1 : (-1)^3 = (-1 : ℚ) := rfl rw [← h1] at h by_contra hn rw [not_or] at hn diff --git a/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean b/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean index d0dc88789..437aebe98 100644 --- a/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean +++ b/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean @@ -77,10 +77,12 @@ lemma toFun_neg (φ : HiggsField) (x : SpaceTime) : P.neg.toFun φ x = - P.toFun ring @[simp] -lemma μ2_neg : P.neg.μ2 = - P.μ2 := by rfl +lemma μ2_neg : P.neg.μ2 = - P.μ2 := + rfl @[simp] -lemma 𝓵_neg : P.neg.𝓵 = - P.𝓵 := by rfl +lemma 𝓵_neg : P.neg.𝓵 = - P.𝓵 := + rfl /-! diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean index 340c8f26d..3a290e729 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean @@ -75,8 +75,8 @@ corresponding SM species of charges. -/ @[simps!] def toSMSpecies (i : Fin 6) : MSSMCharges.Charges →ₗ[ℚ] MSSMSpecies.Charges where toFun S := (Prod.fst ∘ toSpecies) S i - map_add' _ _ := by rfl - map_smul' _ _ := by rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl lemma toSMSpecies_toSpecies_inv (i : Fin 6) (f : (Fin 6 → Fin 3 → ℚ) × (Fin 2 → ℚ)) : (toSMSpecies i) (toSpecies.symm f) = f.1 i := by @@ -100,15 +100,15 @@ abbrev N := toSMSpecies 5 @[simps!] def Hd : MSSMCharges.Charges →ₗ[ℚ] ℚ where toFun S := S ⟨18, Nat.lt_of_sub_eq_succ rfl⟩ - map_add' _ _ := by rfl - map_smul' _ _ := by rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl /-- The charge `Hu`. -/ @[simps!] def Hu : MSSMCharges.Charges →ₗ[ℚ] ℚ where toFun S := S ⟨19, Nat.lt_of_sub_eq_succ rfl⟩ - map_add' _ _ := by rfl - map_smul' _ _ := by rfl + map_add' _ _ := rfl + map_smul' _ _ := rfl lemma charges_eq_toSpecies_eq (S T : MSSMCharges.Charges) : S = T ↔ (∀ i, toSMSpecies i S = toSMSpecies i T) ∧ Hd S = Hd T ∧ Hu S = Hu T := by diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean index 030ae5816..b71d45960 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean @@ -169,7 +169,8 @@ instance (x : ChargeSpectrum 𝓩) (n : ℕ) : Decidable (YukawaGeneratesDangero lemma YukawaGeneratesDangerousAtLevel_iff_inter {x : ChargeSpectrum 𝓩} {n : ℕ} : YukawaGeneratesDangerousAtLevel x n ↔ - (x.ofYukawaTermsNSum n) ∩ x.phenoConstrainingChargesSP ≠ ∅ := by rfl + (x.ofYukawaTermsNSum n) ∩ x.phenoConstrainingChargesSP ≠ ∅ := + Iff.rfl lemma yukawaGeneratesDangerousAtLevel_iff_toFinset (x : ChargeSpectrum 𝓩) (n : ℕ) : x.YukawaGeneratesDangerousAtLevel n ↔ From 3332be6861649b3a04995f80c42867a9b71a5a0a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:01:40 -0700 Subject: [PATCH 040/498] refactor(qft): golf definitional wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean | 6 ++++-- .../QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean | 3 ++- Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean | 5 +++-- .../QFT/PerturbationTheory/WickAlgebra/Universality.lean | 6 ++++-- .../PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean | 4 ++-- Physlib/QFT/QED/AnomalyCancellation/Permutations.lean | 4 ++-- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 34ced8b47..21265d3be 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -70,10 +70,12 @@ noncomputable def superCommuteRight (a : 𝓕.FieldOpFreeAlgebra) : simp lemma superCommuteRight_apply_ι (a b : 𝓕.FieldOpFreeAlgebra) : - superCommuteRight a (ι b) = ι [a, b]ₛF := by rfl + superCommuteRight a (ι b) = ι [a, b]ₛF := + rfl lemma superCommuteRight_apply_quot (a b : 𝓕.FieldOpFreeAlgebra) : - superCommuteRight a ⟦b⟧= ι [a, b]ₛF := by rfl + superCommuteRight a ⟦b⟧= ι [a, b]ₛF := + rfl lemma superCommuteRight_eq_of_equiv (a1 a2 : 𝓕.FieldOpFreeAlgebra) (h : a1 ≈ a2) : superCommuteRight a1 = superCommuteRight a2 := by diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean index 091fa274b..f5bf701c0 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean @@ -33,7 +33,8 @@ def timeContract (φ ψ : 𝓕.FieldOp) : 𝓕.WickAlgebra := 𝓣(ofFieldOp φ * ofFieldOp ψ) - 𝓝(ofFieldOp φ * ofFieldOp ψ) lemma timeContract_eq_smul (φ ψ : 𝓕.FieldOp) : timeContract φ ψ = - 𝓣(ofFieldOp φ * ofFieldOp ψ) + (-1 : ℂ) • 𝓝(ofFieldOp φ * ofFieldOp ψ) := by rfl + 𝓣(ofFieldOp φ * ofFieldOp ψ) + (-1 : ℂ) • 𝓝(ofFieldOp φ * ofFieldOp ψ) := + rfl /-- For a field specification `𝓕`, and `φ` and `ψ` elements of `𝓕.FieldOp`, if `φ` and `ψ` are time-ordered then diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 06137c996..559ce6c75 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -183,7 +183,8 @@ lemma ι_timeOrderF_superCommuteF_superCommuteF {φ1 φ2 φ3 : 𝓕.CrAnFieldOp} simp_all [pb] example (c1 c2 : ℂ) (a : 𝓕.WickAlgebra) : c1 • c2 • a = - c2 • c1 • a := by exact smul_comm c1 c2 a + c2 • c1 • a := + smul_comm c1 c2 a lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp} (hφψ : crAnTimeOrderRel φ ψ) (hψφ : crAnTimeOrderRel ψ φ) (a b : 𝓕.FieldOpFreeAlgebra) : ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * b) = @@ -228,7 +229,7 @@ lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp} trans crAnTimeOrderSign (φs' ++ [φ, ψ] ++ φs) simp only [List.append_assoc, List.cons_append, List.nil_append] rw [crAnTimeOrderSign] - have hp : List.Perm [φ,ψ] [ψ,φ] := by exact List.Perm.swap ψ φ [] + have hp : List.Perm [φ,ψ] [ψ,φ] := List.Perm.swap ψ φ [] rw [Wick.koszulSign_perm_eq _ _ φ _ _ _ _ _ hp] simp only [List.append_assoc, List.cons_append] rfl diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean index 85ef247f5..ae5847347 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean @@ -40,7 +40,8 @@ def universalLiftMap {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnField @[simp] lemma universalLiftMap_ι {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp → A) (h1 : ∀ a ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet, FreeAlgebra.lift ℂ f a = 0) : - universalLiftMap f h1 (ι a) = FreeAlgebra.lift ℂ f a := by rfl + universalLiftMap f h1 (ι a) = FreeAlgebra.lift ℂ f a := + rfl /-- For a field specification, `𝓕`, given an algebra `A` and a function `f : 𝓕.CrAnFieldOp → A` such that the lift of `f` to `FreeAlgebra.lift ℂ f : FreeAlgebra ℂ 𝓕.CrAnFieldOp → A` is @@ -74,7 +75,8 @@ def universalLift {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp @[simp] lemma universalLift_ι {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp → A) (h1 : ∀ a ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet, FreeAlgebra.lift ℂ f a = 0) : - universalLift f h1 (ι a) = FreeAlgebra.lift ℂ f a := by rfl + universalLift f h1 (ι a) = FreeAlgebra.lift ℂ f a := + rfl /-- For a field specification, `𝓕`, the algebra `𝓕.WickAlgebra` satisfies the following universal diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean index 3ffe501b8..cee58d9d5 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean @@ -90,7 +90,7 @@ lemma timeOrder_ofFieldOpList_eq_eqTimeOnly_empty (φs : List 𝓕.FieldOp) : · let e2 : { φsΛ : {φsΛ : WickContraction φs.length // φsΛ.EqTimeOnly} // ¬ φsΛ.1 = empty } ≃ {φsΛ // φsΛ.EqTimeOnly ∧ φsΛ ≠ empty} := { toFun := fun x => ⟨x, ⟨x.1.2, x.2⟩⟩, invFun := fun x => ⟨⟨x.1, x.2.1⟩, x.2.2⟩, - left_inv a := by rfl, right_inv a := by rfl } + left_inv a := rfl, right_inv a := rfl } rw [← e2.symm.sum_comp] rfl @@ -211,7 +211,7 @@ lemma wicks_theorem_normal_order_empty : 𝓣(𝓝(ofFieldOpList [])) = simp only [Finset.univ_unique, PUnit.default_eq_unit, List.length_nil, Equiv.coe_fn_symm_mk, sign_empty, timeContract_empty, OneMemClass.coe_one, one_smul, uncontractedListGet_empty, one_mul, Finset.sum_const, Finset.card_singleton, e2] - have h1' : ofFieldOpList (𝓕 := 𝓕) [] = ofCrAnList [] := by rfl + have h1' : ofFieldOpList (𝓕 := 𝓕) [] = ofCrAnList [] := rfl rw [h1'] rw [normalOrder_ofCrAnList] simp only [normalOrderSign_nil, normalOrderList_nil, one_smul] diff --git a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean index 221f1e0bc..379ab30c5 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean @@ -43,8 +43,8 @@ def chargeMap {n : ℕ} (f : PermGroup n) : @[simp] def permCharges {n : ℕ} : Representation ℚ (PermGroup n) (PureU1 n).Charges where toFun f := chargeMap f⁻¹ - map_mul' f g := by rfl - map_one' := by rfl + map_mul' _ _ := rfl + map_one' := rfl lemma accGrav_invariant {n : ℕ} (f : (PermGroup n)) (S : (PureU1 n).Charges) : PureU1.accGrav n (permCharges f S) = accGrav n S := by From f70a2b8982bb9b6d830966c35607cfead05f7b94 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:04:18 -0700 Subject: [PATCH 041/498] refactor(quantum): golf wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/Uncertainty.lean | 12 ++++++------ .../OneDimension/HarmonicOscillator/Basic.lean | 8 ++++---- .../OneDimension/HilbertSpace/Basic.lean | 4 ++-- .../OneDimension/ReflectionlessPotential/Basic.lean | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean index 01f7556fb..9cd23cb97 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean @@ -115,11 +115,11 @@ lemma raw_commutator_eq_of_symmetric (h_raw : ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩ - B ⟨A ψ, hBA⟩⟫_ℂ = Complex.I * c) : ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = Complex.I * c := by have ha_pairing : - ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ := by - exact hA ψ ⟨B ⟨ψ, hψB⟩, hAB⟩ + ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ := + hA ψ ⟨B ⟨ψ, hψB⟩, hAB⟩ have hb_pairing : - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), B ⟨A ψ, hBA⟩⟫_ℂ := by - exact hB ⟨ψ, hψB⟩ ⟨A ψ, hBA⟩ + ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), B ⟨A ψ, hBA⟩⟫_ℂ := + hB ⟨ψ, hψB⟩ ⟨A ψ, hBA⟩ calc ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ - @@ -145,7 +145,7 @@ def rawCommutatorExpectation (A B : H →ₗ.[ℂ] H) lemma commutator_half_sq_le_mul_norm_sq {u v : H} {c : ℝ} (h_comm : ⟪u, v⟫_ℂ - ⟪v, u⟫_ℂ = Complex.I * c) : (|c| / 2) ^ 2 ≤ (‖u‖ * ‖v‖) ^ 2 := by - suffices (|c| / 2) ^ 2 ≤ (‖u‖ * ‖v‖) ^ 2 by exact this + suffices (|c| / 2) ^ 2 ≤ (‖u‖ * ‖v‖) ^ 2 from this have h_sq : |c / 2| ^ 2 ≤ (‖u‖ * ‖v‖) ^ 2 := by have h_bound : |c / 2| ≤ ‖u‖ * ‖v‖ := by have h_im : |(⟪u, v⟫_ℂ).im| ≤ ‖u‖ * ‖v‖ := @@ -158,7 +158,7 @@ lemma commutator_half_sq_le_mul_norm_sq {u v : H} {c : ℝ} private lemma sqrt_mul_le_of_sq_le {x y z : ℝ} (hx : 0 ≤ x) (hz : 0 ≤ z) (hxy : z ^ 2 ≤ x * y) : z ≤ Real.sqrt x * Real.sqrt y := by - suffices z ≤ Real.sqrt x * Real.sqrt y by exact this + suffices z ≤ Real.sqrt x * Real.sqrt y from this have hs : Real.sqrt (z ^ 2) ≤ Real.sqrt (x * y) := Real.sqrt_le_sqrt hxy rw [Real.sqrt_sq hz, Real.sqrt_mul hx] at hs simpa [mul_comm] using hs diff --git a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean index 26f3c20e4..96d5f644a 100644 --- a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean @@ -42,12 +42,12 @@ lemma Complex.ofReal_hasDerivAt : HasDerivAt Complex.ofReal 1 x := by exact hasDerivAt_id _ @[simp] -lemma Complex.deriv_ofReal : deriv Complex.ofReal x = 1 := by - exact HasDerivAt.deriv Complex.ofReal_hasDerivAt +lemma Complex.deriv_ofReal : deriv Complex.ofReal x = 1 := + HasDerivAt.deriv Complex.ofReal_hasDerivAt @[fun_prop] -lemma Complex.differentiableAt_ofReal : DifferentiableAt ℝ Complex.ofReal x := by - exact HasFDerivAt.differentiableAt Complex.ofReal_hasDerivAt +lemma Complex.differentiableAt_ofReal : DifferentiableAt ℝ Complex.ofReal x := + HasFDerivAt.differentiableAt Complex.ofReal_hasDerivAt /-! diff --git a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean index 67623e9d4..8ff5cea18 100644 --- a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean @@ -156,8 +156,8 @@ lemma mk_eq_iff {f g : ℝ → ℂ} {hf : MemHS f} {hg : MemHS g} : simp [mk] lemma ext_iff {f g : HilbertSpace} : - f = g ↔ (f : ℝ → ℂ) =ᶠ[ae volume] (g : ℝ → ℂ) := by - exact Lp.ext_iff + f = g ↔ (f : ℝ → ℂ) =ᶠ[ae volume] (g : ℝ → ℂ) := + Lp.ext_iff end HilbertSpace end diff --git a/Physlib/QuantumMechanics/OneDimension/ReflectionlessPotential/Basic.lean b/Physlib/QuantumMechanics/OneDimension/ReflectionlessPotential/Basic.lean index 9151f8a44..9bc48f59a 100644 --- a/Physlib/QuantumMechanics/OneDimension/ReflectionlessPotential/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/ReflectionlessPotential/Basic.lean @@ -77,8 +77,8 @@ noncomputable def mulByTemperateGrowth {g : ℝ → ℂ} (hg : g.HasTemperateGro -- First, you need a theorem that the scaled tanh has temperate growth lemma scaled_tanh_hasTemperateGrowth (κ : ℝ) : - Function.HasTemperateGrowth (fun x => (Real.tanh (κ * x))) := by - exact tanh_const_mul_hasTemperateGrowth κ + Function.HasTemperateGrowth (fun x => (Real.tanh (κ * x))) := + tanh_const_mul_hasTemperateGrowth κ /-- This is a helper lemma to show that the embedding of a real function with temperate growth in ℂ also has temperate growth -/ From c0476fd48221f1112f4e04e8dbf5f40d549b79e6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:08:20 -0700 Subject: [PATCH 042/498] refactor(classical): golf wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../DampedHarmonicOscillator/Basic.lean | 4 ++-- Physlib/ClassicalMechanics/EulerLagrange.lean | 3 ++- .../HarmonicOscillator/Basic.lean | 22 +++++++++++-------- .../HarmonicOscillator/Solution.lean | 12 +++++----- .../TotalDerivativeEquivalence.lean | 8 +++---- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 897b98f92..20c1b745e 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -298,8 +298,8 @@ lemma isCriticallyDamped_decayRate (hS : S.IsCriticallyDamped) : S.ω = S.decayR nlinarith exact ne_of_gt hm_sq_pos have hsq : S.decayRate^2 = S.ω^2 := by - have hsub : S.decayRate^2 - S.ω^2 = 0 := by - exact (mul_eq_zero.mp hS).resolve_left hm_sq_ne_zero + have hsub : S.decayRate^2 - S.ω^2 = 0 := + (mul_eq_zero.mp hS).resolve_left hm_sq_ne_zero linarith nlinarith [S.decayRate_nonneg, S.ω_pos] diff --git a/Physlib/ClassicalMechanics/EulerLagrange.lean b/Physlib/ClassicalMechanics/EulerLagrange.lean index fe0086452..5e597bd7b 100644 --- a/Physlib/ClassicalMechanics/EulerLagrange.lean +++ b/Physlib/ClassicalMechanics/EulerLagrange.lean @@ -33,7 +33,8 @@ noncomputable def eulerLagrangeOp (L : Time → X → X → ℝ) (q : Time → X lemma eulerLagrangeOp_eq (L : Time → X → X → ℝ) (q : Time → X) : eulerLagrangeOp L q = fun t => gradient (L t · (∂ₜ q t)) (q t) - - ∂ₜ (fun t' => gradient (L t' (q t') ·) (∂ₜ q t')) t := by rfl + - ∂ₜ (fun t' => gradient (L t' (q t') ·) (∂ₜ q t')) t := + rfl lemma eulerLagrangeOp_zero (q : Time → X) : eulerLagrangeOp (fun _ _ _ => 0) q = fun _ => 0 := by diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index 347e2bc7e..147fb079b 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -209,13 +209,16 @@ noncomputable def energy (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : Time → -/ lemma kineticEnergy_eq (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - kineticEnergy S xₜ = fun t => (1 / (2 : ℝ)) * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ:= by rfl + kineticEnergy S xₜ = fun t => (1 / (2 : ℝ)) * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ := + rfl lemma potentialEnergy_eq (x : EuclideanSpace ℝ (Fin 1)) : - potentialEnergy S x = (1 / (2 : ℝ)) • S.k • ⟪x, x⟫_ℝ:= by rfl + potentialEnergy S x = (1 / (2 : ℝ)) • S.k • ⟪x, x⟫_ℝ := + rfl lemma energy_eq (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - energy S xₜ = fun t => kineticEnergy S xₜ t + potentialEnergy S (xₜ t) := by rfl + energy S xₜ = fun t => kineticEnergy S xₜ t + potentialEnergy S (xₜ t) := + rfl /-! ### C.3. Differentiability of the energies @@ -513,7 +516,8 @@ We write a simple iff statement for the definition of the equation of motions. -/ lemma equationOfMotion_iff_gradLagrangian_zero (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - S.EquationOfMotion xₜ ↔ S.gradLagrangian xₜ = 0 := by rfl + S.EquationOfMotion xₜ ↔ S.gradLagrangian xₜ = 0 := + Iff.rfl /-! @@ -588,8 +592,8 @@ lemma gradLagrangian_eq_force (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : calc ∂ₜ (fun t' => S.m • ∂ₜ xₜ t') t = fderiv ℝ (fun t' => S.m • ∂ₜ xₜ t') t 1 := rfl - _ = S.m • (fderiv ℝ (∂ₜ xₜ) t 1) := by - exact congrArg (fun L => L 1) (fderiv_const_smul (c := S.m) (f := ∂ₜ xₜ) hd) + _ = S.m • (fderiv ℝ (∂ₜ xₜ) t 1) := + congrArg (fun L => L 1) (fderiv_const_smul (c := S.m) (f := ∂ₜ xₜ) hd) _ = S.m • ∂ₜ (∂ₜ xₜ) t := rfl /-! @@ -743,7 +747,7 @@ lemma hamiltonian_eq : funext t x p simp only [hamiltonian, toCanonicalMomentum, lagrangian_eq, one_div, LinearEquiv.coe_symm_mk', inner_smul_right, inner_smul_left, map_inv₀, ringHom_apply] - have hm : S.m ≠ 0 := by exact m_ne_zero S + have hm : S.m ≠ 0 := m_ne_zero S field_simp ring @@ -875,8 +879,8 @@ lemma equationOfMotion_iff_hamiltonEqOp_eq_zero (xₜ : Time → EuclideanSpace calc ∂ₜ (fun t' => S.m • ∂ₜ xₜ t') t = fderiv ℝ (fun t' => S.m • ∂ₜ xₜ t') t 1 := rfl - _ = S.m • (fderiv ℝ (∂ₜ xₜ) t 1) := by - exact congrArg (fun L => L 1) (fderiv_const_smul (c := S.m) (f := ∂ₜ xₜ) hd) + _ = S.m • (fderiv ℝ (∂ₜ xₜ) t 1) := + congrArg (fun L => L 1) (fderiv_const_smul (c := S.m) (f := ∂ₜ xₜ) hd) _ = S.m • ∂ₜ (∂ₜ xₜ) t := rfl simp [hderiv_smul, force_eq_linear] diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index 459ab748c..a582a03bb 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -1224,7 +1224,7 @@ lemma return_time (IC : InitialConditions) (non_trivial : IC.x₀ ≠ 0 ∨ IC.v 0 < xx * S.ω^2 := by bound _ ≤ ‖IC.v₀‖^2 + xx * S.ω^2 := by bound _ = vv + xx * S.ω^2 := by rw [← real_inner_self_eq_norm_sq IC.v₀] - _ = det := by rfl + _ = det := rfl | inr hv => have vv_gt_zero : 0 < vv := by apply real_inner_self_pos.mpr @@ -1233,7 +1233,7 @@ lemma return_time (IC : InitialConditions) (non_trivial : IC.x₀ ≠ 0 ∨ IC.v 0 < vv := vv_gt_zero _ ≤ vv + ‖IC.x₀‖^2 * S.ω^2 := by bound _ = vv + xx * S.ω^2 := by rw [← real_inner_self_eq_norm_sq IC.x₀] - _ = det := by rfl + _ = det := rfl have det_ne_zero : det ≠ 0 := by bound have hxx : c * xx + (s / S.ω) * xv = xx := by calc @@ -1259,20 +1259,20 @@ lemma return_time (IC : InitialConditions) (non_trivial : IC.x₀ ≠ 0 ∨ IC.v have hcos : 1 = cos (S.ω * t) := by calc 1 = det / det := by simp only [ne_eq, det_ne_zero, not_false_eq_true, div_self] - _ = (vv + xx * S.ω^2 ) / det := by rfl + _ = (vv + xx * S.ω^2 ) / det := rfl _ = c * ((vv + xx * S.ω^2) / det) + s * xv *S.ω* (S.ω/S.ω-1 ) / det := by nth_rewrite 1 [← hvv, ← hxx] ring_nf _ = c * ((vv + xx * S.ω^2) / det ) := by simp only [ne_eq, S.ω_ne_zero, not_false_eq_true, div_self, sub_self, mul_zero, zero_div, add_zero] - _ = c * (det / det) := by rfl + _ = c * (det / det) := rfl _ = c := by simp only [ne_eq, det_ne_zero, not_false_eq_true, div_self, mul_one] - _ = _ := by rfl + _ = _ := rfl let ⟨n, hn⟩ := (Real.cos_eq_one_iff (S.ω * t)).mp (Eq.symm hcos) use n calc - (n : ℝ) * (T S) = (n : ℝ) * (2 * π / S.ω) := by rfl + (n : ℝ) * (T S) = (n : ℝ) * (2 * π / S.ω) := rfl _ = ((n : ℝ) * (2 * π)) / S.ω := by ring_nf _ = (S.ω * t) / S.ω := by rw [hn] _ = t * (S.ω / S.ω) := by ring_nf diff --git a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean index 72764922c..8df6deb97 100644 --- a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean +++ b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean @@ -107,7 +107,7 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : calc (1 : Time) = fderiv ℝ (fun (t' : Time) => t') t 1 := by simp only [fderiv_fun_id, ContinuousLinearMap.coe_id', id_eq] - _ = fderiv ℝ (fun (t' : Time) => (tq q t').1) t 1 := by rfl + _ = fderiv ℝ (fun (t' : Time) => (tq q t').1) t 1 := rfl _ = (∂ₜ (tq q) t).1 := by rw [fderiv.fst] · simp @@ -119,7 +119,7 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : rcases this apply Eq.symm calc - (1, ∂ₜ q t).2 = fderiv ℝ (fun t' => (tq q t').2) t 1 := by rfl + (1, ∂ₜ q t).2 = fderiv ℝ (fun t' => (tq q t').2) t 1 := rfl _ = (∂ₜ (tq q) t).2 := by rw [fderiv.snd] · simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.coe_snd'] @@ -162,11 +162,11 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : fun_prop have h_qv_t : qv t = q₀ := by calc - qv t = (q₀ - t.val • v) + t.val • v := by rfl + qv t = (q₀ - t.val • v) + t.val • v := rfl _ = q₀ := by module have h_qv_der : ∂ₜ qv t = v := by calc - ∂ₜ qv t = fderiv ℝ (fun t' => (q₀ - t.val • v) + t'.val • v) t 1 := by rfl + ∂ₜ qv t = fderiv ℝ (fun t' => (q₀ - t.val • v) + t'.val • v) t 1 := rfl _ = v := by rw [fderiv_const_add,fderiv_smul_const] · simp only [ContinuousLinearMap.smulRight_apply, fderiv_val, one_smul] From 57c16dbc11587328b2d8fd087364c84091ee4989 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:13:20 -0700 Subject: [PATCH 043/498] refactor(mathematics): golf wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Distribution/Basic.lean | 2 +- Physlib/Mathematics/FDerivCurry.lean | 4 ++-- Physlib/Mathematics/Fin.lean | 2 +- .../Metric/PseudoRiemannian/Defs.lean | 2 +- .../Mathematics/InnerProductSpace/Basic.lean | 8 +++---- .../InnerProductSpace/Calculus.lean | 5 ++-- Physlib/Mathematics/LinearMaps.lean | 24 +++++++------------ 7 files changed, 19 insertions(+), 28 deletions(-) diff --git a/Physlib/Mathematics/Distribution/Basic.lean b/Physlib/Mathematics/Distribution/Basic.lean index cbcf8f4f1..8c9f487e7 100644 --- a/Physlib/Mathematics/Distribution/Basic.lean +++ b/Physlib/Mathematics/Distribution/Basic.lean @@ -351,7 +351,7 @@ def const [hμ : Measure.HasTemperateGrowth (volume (α := E))] (c : F) : E →d lemma const_apply [hμ : Measure.HasTemperateGrowth (volume (α := E))] (c : F) (η : 𝓢(E, 𝕜)) : - const 𝕜 E c η = ∫ x, η x • c ∂MeasureTheory.volume := by rfl + const 𝕜 E c η = ∫ x, η x • c ∂MeasureTheory.volume := rfl end section diff --git a/Physlib/Mathematics/FDerivCurry.lean b/Physlib/Mathematics/FDerivCurry.lean index 3dd64883e..e47082974 100644 --- a/Physlib/Mathematics/FDerivCurry.lean +++ b/Physlib/Mathematics/FDerivCurry.lean @@ -24,8 +24,8 @@ lemma fderiv_uncurry (f : X → Y → Z) (xy dxy : X × Y) fderiv 𝕜 ↿f xy dxy = fderiv 𝕜 (f · xy.2) xy.1 dxy.1 + fderiv 𝕜 (f xy.1 ·) xy.2 dxy.2 := by - have hx : (f · xy.2) = ↿f ∘ (fun x' => (x',xy.2)) := by rfl - have hy : (f xy.1 ·) = ↿f ∘ (fun y' => (xy.1,y')) := by rfl + have hx : (f · xy.2) = ↿f ∘ (fun x' => (x',xy.2)) := rfl + have hy : (f xy.1 ·) = ↿f ∘ (fun y' => (xy.1,y')) := rfl rw [hx,hy] repeat rw [fderiv_comp (hg := by fun_prop) (hf := by fun_prop)] dsimp diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index e89b8d3a5..a1c6f664c 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -220,7 +220,7 @@ lemma finExtractTwo_symm_inl_inr_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin @[simp] lemma finExtractTwo_symm_inl_inl_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : - (finExtractTwo i j).symm (Sum.inl (Sum.inl 0)) = i := by rfl + (finExtractTwo i j).symm (Sum.inl (Sum.inl 0)) = i := rfl @[simp] lemma finExtractTwo_apply_snd {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : diff --git a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean index a6bf51cf6..271c8c3de 100644 --- a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean @@ -345,7 +345,7 @@ def flat (g : PseudoRiemannianMetric E H M n I) (x : M) : @[simp] lemma flat_apply (g : PseudoRiemannianMetric E H M n I) (x : M) (v w : TangentSpace I x) : - (flat g x v) w = g.val x v w := by rfl + (flat g x v) w = g.val x v w := rfl /-- The musical isomorphism as a continuous linear map. -/ def flatL (g : PseudoRiemannianMetric E H M n I) (x : M) : diff --git a/Physlib/Mathematics/InnerProductSpace/Basic.lean b/Physlib/Mathematics/InnerProductSpace/Basic.lean index f6d0b35ec..cb7c5d000 100644 --- a/Physlib/Mathematics/InnerProductSpace/Basic.lean +++ b/Physlib/Mathematics/InnerProductSpace/Basic.lean @@ -220,13 +220,13 @@ def fromL2 : WithLp 2 E →L[𝕜] E where lemma fromL2_inner_left (x : WithLp 2 E) (y : E) : ⟪fromL2 𝕜 x, y⟫ = ⟪x, toL2 𝕜 y⟫ := rfl -lemma ofLp_inner_left (x : E) (y : WithLp 2 E) : ⟪WithLp.ofLp y, x⟫ = ⟪y, WithLp.toLp 2 x⟫ := by - exact fromL2_inner_left y x +lemma ofLp_inner_left (x : E) (y : WithLp 2 E) : ⟪WithLp.ofLp y, x⟫ = ⟪y, WithLp.toLp 2 x⟫ := + fromL2_inner_left y x lemma toL2_inner_left (x : E) (y : WithLp 2 E) : ⟪toL2 𝕜 x, y⟫ = ⟪x, fromL2 𝕜 y⟫ := rfl -lemma toLp_inner_left (x : WithLp 2 E) (y : E) : ⟪WithLp.toLp 2 y, x⟫ = ⟪y, WithLp.ofLp x⟫ := by - exact toL2_inner_left y x +lemma toLp_inner_left (x : WithLp 2 E) (y : E) : ⟪WithLp.toLp 2 y, x⟫ = ⟪y, WithLp.ofLp x⟫ := + toL2_inner_left y x @[simp] lemma toL2_fromL2 (x : WithLp 2 E) : toL2 𝕜 (fromL2 𝕜 x) = x := rfl diff --git a/Physlib/Mathematics/InnerProductSpace/Calculus.lean b/Physlib/Mathematics/InnerProductSpace/Calculus.lean index e5b79dc10..e90768127 100644 --- a/Physlib/Mathematics/InnerProductSpace/Calculus.lean +++ b/Physlib/Mathematics/InnerProductSpace/Calculus.lean @@ -49,6 +49,5 @@ lemma deriv_inner_apply' @[fun_prop] lemma DifferentiableAt.inner' {f g : E → F} {x} (hf : DifferentiableAt ℝ f x) (hg : DifferentiableAt ℝ g x) : - DifferentiableAt ℝ (fun x => ⟪f x, g x⟫) x := by - apply HasFDerivAt.differentiableAt - exact hf.hasFDerivAt.inner' hg.hasFDerivAt + DifferentiableAt ℝ (fun x => ⟪f x, g x⟫) x := + (hf.hasFDerivAt.inner' hg.hasFDerivAt).differentiableAt diff --git a/Physlib/Mathematics/LinearMaps.lean b/Physlib/Mathematics/LinearMaps.lean index 35fbdd5b8..4c4279a07 100644 --- a/Physlib/Mathematics/LinearMaps.lean +++ b/Physlib/Mathematics/LinearMaps.lean @@ -88,9 +88,7 @@ def mk₂ (f : V × V → ℚ) (map_smul : ∀ a S T, f (a • S, T) = a * f (S, swap' := swap lemma map_smul₁ (f : BiLinearSymm V) (a : ℚ) (S T : V) : f (a • S) T = a * f S T := by - have h : f (a • S) = a • (f S) := by - exact f.map_smul a S - simp [h] + exact (congrArg (fun g : V →ₗ[ℚ] ℚ => g T) (f.map_smul a S)).trans (by rfl) lemma swap (f : BiLinearSymm V) (S T : V) : f S T = f T S := f.swap' S T @@ -98,9 +96,7 @@ lemma map_smul₂ (f : BiLinearSymm V) (a : ℚ) (S : V) (T : V) : f S (a • T) rw [f.swap, f.map_smul₁, f.swap] lemma map_add₁ (f : BiLinearSymm V) (S1 S2 T : V) : f (S1 + S2) T = f S1 T + f S2 T := by - have h : f (S1 + S2) = f S1 + f S2 := by - exact f.map_add S1 S2 - simp [h] + exact (congrArg (fun g : V →ₗ[ℚ] ℚ => g T) (f.map_add S1 S2)).trans (by rfl) lemma map_add₂ (f : BiLinearSymm V) (S : V) (T1 T2 : V) : f S (T1 + T2) = f S T1 + f S T2 := by @@ -194,7 +190,7 @@ def mk₃ (f : V × V × V→ ℚ) (map_smul : ∀ a S T L, f (a • S, T, L) = (by intro S1 S2 T rw [swap₁, map_add, swap₁, swap₁ S2 S T]) - (by exact fun L T ↦ swap₂ S L T)).toLinearMap + (fun L T ↦ swap₂ S L T)).toLinearMap map_add' S1 S2 := LinearMap.ext fun T ↦ LinearMap.ext fun L => map_add S1 S2 T L map_smul' a S := LinearMap.ext fun T => LinearMap.ext fun L => map_smul a S T L @@ -212,9 +208,8 @@ lemma swap₃ (f : TriLinearSymm V) (S T L : V) : f S T L = f L T S := by lemma map_smul₁ (f : TriLinearSymm V) (a : ℚ) (S T L : V) : f (a • S) T L = a * f S T L := by - have h : f (a • S) = a • (f S) := by - exact f.map_smul a S - simp [h] + exact + (congrArg (fun g : V →ₗ[ℚ] V →ₗ[ℚ] ℚ => g T L) (f.map_smul a S)).trans (by rfl) lemma map_smul₂ (f : TriLinearSymm V) (S : V) (a : ℚ) (T L : V) : f S (a • T) L = a * f S T L := by @@ -226,9 +221,8 @@ lemma map_smul₃ (f : TriLinearSymm V) (S T : V) (a : ℚ) (L : V) : lemma map_add₁ (f : TriLinearSymm V) (S1 S2 T L : V) : f (S1 + S2) T L = f S1 T L + f S2 T L := by - have h : f (S1 + S2) = f S1 + f S2 := by - exact f.map_add S1 S2 - simp [h] + exact + (congrArg (fun g : V →ₗ[ℚ] V →ₗ[ℚ] ℚ => g T L) (f.map_add S1 S2)).trans (by rfl) lemma map_add₂ (f : TriLinearSymm V) (S T1 T2 L : V) : f S (T1 + T2) L = f S T1 L + f S T2 L := by @@ -242,9 +236,7 @@ lemma map_add₃ (f : TriLinearSymm V) (S T L1 L2 : V) : def toLinear₁ (f : TriLinearSymm V) (T L : V) : V →ₗ[ℚ] ℚ where toFun S := f S T L map_add' S1 S2 := map_add₁ f S1 S2 T L - map_smul' a S := by - simp only [f.map_smul₁] - rfl + map_smul' a S := by simp [f.map_smul₁] lemma toLinear₁_apply (f : TriLinearSymm V) (S T L : V) : f S T L = f.toLinear₁ T L S := rfl From a91f7a0c4ba768a3a84803aebc5dec01bd33d0a3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:18:08 -0700 Subject: [PATCH 044/498] refactor: golf remaining rfl proofs Co-authored-by: Claude Opus 4.8 --- .../Distributional/Dynamics/IsExtrema.lean | 2 +- .../Distributional/FieldStrength.lean | 2 +- .../Dynamics/CurrentDensity.lean | 4 ++-- .../Electromagnetism/Dynamics/IsExtrema.lean | 2 +- .../Dynamics/KineticTerm.lean | 2 +- .../Kinematics/FieldStrength.lean | 2 +- .../Kinematics/VectorPotential.lean | 2 +- .../WickContraction/TimeCond.lean | 2 +- .../SpaceAndTime/Space/ConstantSliceDist.lean | 2 +- .../SpaceAndTime/Space/Derivatives/Curl.lean | 4 ++-- .../SpaceAndTime/Space/Derivatives/Grad.lean | 2 +- Physlib/SpaceAndTime/SpaceTime/Basic.lean | 6 +++--- Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean | 4 ++-- Physlib/SpaceAndTime/TimeAndSpace/Basic.lean | 2 +- .../TimeAndSpace/ConstantTimeDist.lean | 8 ++++---- Physlib/Units/Dimension.lean | 20 +++++++++---------- 16 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Distributional/Dynamics/IsExtrema.lean index 1bb99344f..9ad1c4165 100644 --- a/Physlib/Electromagnetism/Distributional/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Distributional/Dynamics/IsExtrema.lean @@ -60,7 +60,7 @@ def IsExtrema {d} (𝓕 : FreeSpace) lemma isExtrema_iff_gradLagrangian {𝓕 : FreeSpace} (A : DistElectromagneticPotential d) (J : DistLorentzCurrentDensity d) : - IsExtrema 𝓕 A J ↔ A.gradLagrangian 𝓕 J = 0 := by rfl + IsExtrema 𝓕 A J ↔ A.gradLagrangian 𝓕 J = 0 := Iff.rfl lemma isExtrema_iff_components {𝓕 : FreeSpace} (A : DistElectromagneticPotential d) diff --git a/Physlib/Electromagnetism/Distributional/FieldStrength.lean b/Physlib/Electromagnetism/Distributional/FieldStrength.lean index 33e162212..5af7cfc75 100644 --- a/Physlib/Electromagnetism/Distributional/FieldStrength.lean +++ b/Physlib/Electromagnetism/Distributional/FieldStrength.lean @@ -233,7 +233,7 @@ noncomputable def fieldStrength {d} : lemma fieldStrength_eq_fieldStrengthAux {d} (A : DistElectromagneticPotential d) (ε : 𝓢(SpaceTime d, ℝ)) : - A.fieldStrength ε = A.fieldStrengthAux ε := by rfl + A.fieldStrength ε = A.fieldStrengthAux ε := rfl /-! ### A.3. Field strength written in terms of a basis diff --git a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean index 6c615db9f..ff8964147 100644 --- a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean @@ -80,7 +80,7 @@ noncomputable def chargeDensity (c : SpeedOfLight := 1) fun t x => (1 / (c : ℝ)) * J ((toTimeAndSpace c).symm (t, x)) (Sum.inl 0) lemma chargeDensity_eq_timeSlice {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} : - J.chargeDensity c = timeSlice c (fun x => (1 / (c : ℝ)) • J x (Sum.inl 0)) := by rfl + J.chargeDensity c = timeSlice c (fun x => (1 / (c : ℝ)) • J x (Sum.inl 0)) := rfl /-! @@ -137,7 +137,7 @@ noncomputable def currentDensity (c : SpeedOfLight := 1) (J : LorentzCurrentDens lemma currentDensity_eq_timeSlice {d : ℕ} {J : LorentzCurrentDensity d} : J.currentDensity c = timeSlice c (fun x => WithLp.toLp 2 - fun i => J x (Sum.inr i)) := by rfl + fun i => J x (Sum.inr i)) := rfl /-! diff --git a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean index 5c5cee879..e118d69a7 100644 --- a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean @@ -77,7 +77,7 @@ def IsExtrema {d} (𝓕 : FreeSpace) (A : ElectromagneticPotential d) lemma isExtrema_iff_gradLagrangian {𝓕 : FreeSpace} (A : ElectromagneticPotential d) (J : LorentzCurrentDensity d) : - IsExtrema 𝓕 A J ↔ A.gradLagrangian 𝓕 J = 0 := by rfl + IsExtrema 𝓕 A J ↔ A.gradLagrangian 𝓕 J = 0 := Iff.rfl /-! diff --git a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean index 8ccc89229..b168c38e7 100644 --- a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean @@ -341,7 +341,7 @@ lemma kineticTerm_eq_electricMatrix_magneticFieldMatrix_time_space {𝓕 : FreeS simp only [Fin.isValue, Finset.sum_neg_distrib] have h1 : ∑ i, ∑ j, magneticFieldMatrix 𝓕.c A t x (i, j) ^ 2 = ∑ i, ∑ j, (A.fieldStrengthMatrix ((toTimeAndSpace 𝓕.c).symm (t, x))) - (Sum.inr i, Sum.inr j) ^ 2 := by rfl + (Sum.inr i, Sum.inr j) ^ 2 := rfl rw [h1] ring_nf have h2 : ‖electricField 𝓕.c A t x‖ ^ 2 = 𝓕.c.val ^ 2 * diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index f12cbc95f..32cd59d00 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -422,7 +422,7 @@ noncomputable abbrev fieldStrengthMatrix {d} (A : ElectromagneticPotential d) (x lemma fieldStrengthMatrix_eq {d} (A : ElectromagneticPotential d) (x : SpaceTime d) : A.fieldStrengthMatrix x = - (Lorentz.CoVector.basis.tensorProduct Lorentz.Vector.basis).repr (A.toFieldStrength x) := by rfl + (Lorentz.CoVector.basis.tensorProduct Lorentz.Vector.basis).repr (A.toFieldStrength x) := rfl /-- Index evaluation of the field strength tensor agrees with the corresponding component of the field strength matrix. -/ diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index 99c44f020..538e3a29a 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -199,7 +199,7 @@ lemma vectorPotential_inner_radial_eq_zero_ofElectromagneticField ⟪(ofElectromagneticField c E B).vectorPotential c t (a • x), Space.basis.repr x⟫_ℝ = 0 := by rw [real_inner_comm] rw [PiLp.inner_apply] - have h1 (a b : ℝ) : ⟪a, b⟫_ℝ = b * a:= by rfl + have h1 (a b : ℝ) : ⟪a, b⟫_ℝ = b * a := rfl simp only [Space.basis_repr_apply, ofElectromagneticField_vectorPotential_apply_eq_expand hB, Fin.isValue, Space.smul_apply, h1, Fin.sum_univ_three, zero_add, Fin.reduceAdd] ring diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean index b50b356d8..dc4ee18ea 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean @@ -388,7 +388,7 @@ lemma join_eqTimeContractSet {φs : List 𝓕.FieldOp} (φsΛ : WickContraction · intro h' have h2 := h1.2 h1.1 have hj : ⟨(Finset.mapEmbedding uncontractedListEmd) b, h'⟩ - = joinLiftRight ⟨b, h1.1⟩ := by rfl + = joinLiftRight ⟨b, h1.1⟩ := rfl simp only [hj, join_fstFieldOfContract_joinLiftRight, getElem_uncontractedListEmd, join_sndFieldOfContract_joinLiftRight] simpa using h2 diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index acd0b4304..93ea4b605 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -616,7 +616,7 @@ lemma distDeriv_constantSliceDist_same {M : Type} [NormedAddCommGroup M] [Normed ext x simp [sliceSchwartz_apply] calc _ - _ = ∫ r, fderiv ℝ η ((slice i).symm (r, x)) (basis i) := by rfl + _ = ∫ r, fderiv ℝ η ((slice i).symm (r, x)) (basis i) := rfl _ = ∫ r, fderiv ℝ (fun r => η ((slice i).symm (r, x))) r 1 := by congr funext r diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean b/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean index fb3eedc74..964dba8b2 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean @@ -280,7 +280,7 @@ private noncomputable def homotopyOperatorIntegrand (f : Space → EuclideanSpac Space → ℝ → EuclideanSpace ℝ (Fin 3) := fun x t => (t • basis.repr x) ⨯ₑ₃ f (t • x) private lemma homotopyOperatorIntegrand_eq (f : Space → EuclideanSpace ℝ (Fin 3)) : - homotopyOperatorIntegrand f = fun x t => (t • basis.repr x) ⨯ₑ₃ f (t • x) := by rfl + homotopyOperatorIntegrand f = fun x t => (t • basis.repr x) ⨯ₑ₃ f (t • x) := rfl @[fun_prop] private lemma differentiable_homotopyOperatorIntegrand_space {f : Space → EuclideanSpace ℝ (Fin 3)} (hf : Differentiable ℝ f) (t : ℝ) : @@ -632,7 +632,7 @@ lemma exists_grad_of_curl_zero (f : Space → EuclideanSpace ℝ (Fin 3)) (hf : ⟪(basis.repr.symm (fderiv ℝ f a x)), y⟫_ℝ:= by calc _ _ = (fderiv ℝ (InnerProductSpace.toDual ℝ _ ∘ - fun a => (basis.repr.symm (f a))) a x) y := by rfl + fun a => (basis.repr.symm (f a))) a x) y := rfl rw [fderiv_comp _ (by exact (InnerProductSpace.toDual ℝ (Space)).differentiable.differentiableAt) (by fun_prop)] erw [(InnerProductSpace.toDual ℝ (Space)).fderiv] diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean index dd46d0b26..577f3ba79 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean @@ -275,7 +275,7 @@ lemma grad_inner_space_unit_vector {d} (x : Space d) (f : Space d → ℝ) (hd : simp symm calc _ - _ = fderiv ℝ (f ∘ (fun r => r • ‖x‖⁻¹ • x)) ‖x‖ 1 := by rfl + _ = fderiv ℝ (f ∘ (fun r => r • ‖x‖⁻¹ • x)) ‖x‖ 1 := rfl _ = (fderiv ℝ f (‖x‖ • ‖x‖⁻¹ • x)) (_root_.deriv (fun r => r • ‖x‖⁻¹ • x) ‖x‖) := by rw [fderiv_comp _ (by fun_prop) (by fun_prop)] simp diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index 457032945..5163e3e34 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -140,7 +140,7 @@ instance {d : ℕ} : MeasurableSpace (SpaceTime d) := borel (SpaceTime d) -/ instance {d : ℕ} : BorelSpace (SpaceTime d) where - measurable_eq := by rfl + measurable_eq := rfl /-! @@ -315,12 +315,12 @@ lemma time_toTimeAndSpace_symm {d : ℕ} {c : SpeedOfLight} (t : Time) (s : Spac @[simp] lemma toTimeAndSpace_symm_apply_inl {d : ℕ} {c : SpeedOfLight} (t : Time) (s : Space d) : - (toTimeAndSpace c).symm (t, s) (Sum.inl 0) = c * t := by rfl + (toTimeAndSpace c).symm (t, s) (Sum.inl 0) = c * t := rfl @[simp] lemma toTimeAndSpace_symm_apply_inr {d : ℕ} {c : SpeedOfLight} (t : Time) (x : Space d) (i : Fin d) : - (toTimeAndSpace c).symm (t, x) (Sum.inr i) = x i := by rfl + (toTimeAndSpace c).symm (t, x) (Sum.inr i) = x i := rfl /-! #### B.3.1. Derivative of `toTimeAndSpace` diff --git a/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean b/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean index 12cb5999d..40e286a5d 100644 --- a/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean +++ b/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean @@ -144,12 +144,12 @@ noncomputable def distTimeSlice {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] lemma distTimeSlice_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (c : SpeedOfLight) (f : (SpaceTime d) →d[ℝ] M) (κ : 𝓢(Time × Space d, ℝ)) : distTimeSlice c f κ = - f (compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c) κ) := by rfl + f (compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c) κ) := rfl lemma distTimeSlice_symm_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (c : SpeedOfLight) (f : (Time × (Space d)) →d[ℝ] M) (κ : 𝓢(SpaceTime d, ℝ)) : (distTimeSlice c).symm f κ = - f (compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c).symm κ) := by rfl + f (compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c).symm κ) := rfl /-! diff --git a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean index 35b3e70ee..a6a237617 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean @@ -560,7 +560,7 @@ noncomputable def distSpaceDiv {d} : lemma distSpaceDiv_apply_eq_sum_distSpaceDeriv {d} (f : (Time × Space d) →d[ℝ] EuclideanSpace ℝ (Fin d)) (η : 𝓢(Time ×Space d, ℝ)) : - distSpaceDiv f η = ∑ i, distSpaceDeriv i f η i := by rfl + distSpaceDiv f η = ∑ i, distSpaceDeriv i f η i := rfl /-! diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 3cb0daf08..a4d08a749 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -875,7 +875,7 @@ def timeIntegralSchwartz {d : ℕ} : rfl lemma timeIntegralSchwartz_apply {d : ℕ} (η : 𝓢(Time × Space d, ℝ)) (x : Space d) : - timeIntegralSchwartz η x = ∫ (t : Time), η (t, x) := by rfl + timeIntegralSchwartz η x = ∫ (t : Time), η (t, x) := rfl /-! @@ -898,7 +898,7 @@ def constantTime {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : ℕ} lemma constantTime_apply {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : ℕ} (f : (Space d) →d[ℝ] M) (η : 𝓢(Time × Space d, ℝ)) : - constantTime f η = f (timeIntegralSchwartz η) := by rfl + constantTime f η = f (timeIntegralSchwartz η) := rfl /-! @@ -918,7 +918,7 @@ lemma constantTime_distSpaceDeriv {M : Type} {d : ℕ} [NormedAddCommGroup M] [N symm change fderiv ℝ (timeIntegralSchwartz η) x (basis i) = _ calc _ - _ = fderiv ℝ (fun x => ∫ t, η (t, x) ∂volume) x (basis i) := by rfl + _ = fderiv ℝ (fun x => ∫ t, η (t, x) ∂volume) x (basis i) := rfl _ = (∫ t, fderiv ℝ (fun x => η (t, x)) x) (basis i) := by have h1 := time_integral_hasFDerivAt (η) x rw [h1.fderiv] @@ -1002,7 +1002,7 @@ lemma constantTime_distTimeDeriv {M : Type} [NormedAddCommGroup M] [NormedSpace ext x rw [timeIntegralSchwartz_apply] calc _ - _ = ∫ (t : Time), fderiv ℝ η (t, x) (1, 0) := by rfl + _ = ∫ (t : Time), fderiv ℝ η (t, x) (1, 0) := rfl _ = ∫ (t : Time), fderiv ℝ (fun t => η (t, x)) t 1 := by congr funext t diff --git a/Physlib/Units/Dimension.lean b/Physlib/Units/Dimension.lean index 4e5b4da29..042535620 100644 --- a/Physlib/Units/Dimension.lean +++ b/Physlib/Units/Dimension.lean @@ -190,37 +190,37 @@ instance : Pow Dimension ℚ where def L𝓭 : Dimension := ⟨1, 0, 0, 0, 0⟩ @[simp] -lemma L𝓭_length : L𝓭.length = 1 := by rfl +lemma L𝓭_length : L𝓭.length = 1 := rfl @[simp] -lemma L𝓭_time : L𝓭.time = 0 := by rfl +lemma L𝓭_time : L𝓭.time = 0 := rfl @[simp] -lemma L𝓭_mass : L𝓭.mass = 0 := by rfl +lemma L𝓭_mass : L𝓭.mass = 0 := rfl @[simp] -lemma L𝓭_charge : L𝓭.charge = 0 := by rfl +lemma L𝓭_charge : L𝓭.charge = 0 := rfl @[simp] -lemma L𝓭_temperature : L𝓭.temperature = 0 := by rfl +lemma L𝓭_temperature : L𝓭.temperature = 0 := rfl /-- The dimension corresponding to time. -/ def T𝓭 : Dimension := ⟨0, 1, 0, 0, 0⟩ @[simp] -lemma T𝓭_length : T𝓭.length = 0 := by rfl +lemma T𝓭_length : T𝓭.length = 0 := rfl @[simp] -lemma T𝓭_time : T𝓭.time = 1 := by rfl +lemma T𝓭_time : T𝓭.time = 1 := rfl @[simp] -lemma T𝓭_mass : T𝓭.mass = 0 := by rfl +lemma T𝓭_mass : T𝓭.mass = 0 := rfl @[simp] -lemma T𝓭_charge : T𝓭.charge = 0 := by rfl +lemma T𝓭_charge : T𝓭.charge = 0 := rfl @[simp] -lemma T𝓭_temperature : T𝓭.temperature = 0 := by rfl +lemma T𝓭_temperature : T𝓭.temperature = 0 := rfl /-- The dimension corresponding to mass. -/ def M𝓭 : Dimension := ⟨0, 0, 1, 0, 0⟩ From 7cb1bfc2f570d594c049d21d27363ebe3e02cbf1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:20:38 -0700 Subject: [PATCH 045/498] refactor: golf direct proof terms Co-authored-by: Claude Opus 4.8 --- Physlib/CondensedMatter/TightBindingChain/Basic.lean | 2 +- Physlib/Mathematics/List/InsertIdx.lean | 4 ++-- Physlib/Mathematics/List/InsertionSort.lean | 2 +- Physlib/SpaceAndTime/Space/ConstantSliceDist.lean | 2 +- Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 2 +- Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean | 4 ++-- Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Physlib/CondensedMatter/TightBindingChain/Basic.lean b/Physlib/CondensedMatter/TightBindingChain/Basic.lean index 60bd6a73d..a06b0885a 100644 --- a/Physlib/CondensedMatter/TightBindingChain/Basic.lean +++ b/Physlib/CondensedMatter/TightBindingChain/Basic.lean @@ -431,7 +431,7 @@ lemma quantaWaveNumber_exp_sub_one (n : Fin T.N) (k : T.QuantaWaveNumber) : lemma quantaWaveNumber_exp_add_one (n : Fin T.N) (k : T.QuantaWaveNumber) : Complex.exp (Complex.I * k * (n + 1).val * T.a) = Complex.exp (Complex.I * k * n * T.a) * Complex.exp (Complex.I * k * T.a) := by - have hn : n = (n + 1) - 1 := by exact Eq.symm (add_sub_cancel_right n 1) + have hn : n = (n + 1) - 1 := Eq.symm (add_sub_cancel_right n 1) conv_rhs => rw [hn, quantaWaveNumber_exp_sub_one, mul_assoc, ← Complex.exp_add] simp diff --git a/Physlib/Mathematics/List/InsertIdx.lean b/Physlib/Mathematics/List/InsertIdx.lean index b9f4ae4fc..81c86ae58 100644 --- a/Physlib/Mathematics/List/InsertIdx.lean +++ b/Physlib/Mathematics/List/InsertIdx.lean @@ -99,7 +99,7 @@ lemma insertIdx_length_fin {I : Type} (i : I) : lemma insertIdx_getElem_fin {I : Type} (i : I) : (r : List I) → (k : Fin r.length.succ) → (m : Fin r.length) → (List.insertIdx r k i)[(k.succAbove m).val] = r[m.val] - | [], 0, m => by exact Fin.elim0 m + | [], 0, m => Fin.elim0 m | a :: as, 0, m => by simp | a :: as, ⟨n + 1, h⟩, ⟨0, h0⟩ => by simp [Fin.succAbove, Fin.lt_def] @@ -117,7 +117,7 @@ lemma insertIdx_getElem_fin {I : Type} (i : I) : lemma insertIdx_eraseIdx_fin {I : Type} : (r : List I) → (k : Fin r.length) → (List.eraseIdx r k).insertIdx k r[k] = r - | [], k => by exact Fin.elim0 k + | [], k => Fin.elim0 k | a :: as, ⟨0, h⟩ => by simp | a :: as, ⟨n + 1, h⟩ => by simp only [List.length_cons, Fin.getElem_fin, List.getElem_cons_succ, List.eraseIdx_cons_succ, diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index 7d2b893f7..9a2b5d45d 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -512,7 +512,7 @@ lemma filter_rel_eq_insertionSort {α : Type} (r : α → α → Prop) [Decidabl simp only [List.insertionSort] by_cases h : r a b ∧ r b a · have hl := orderedInsert_filter_of_pos r b (fun c => r a c ∧ r c a) h - (List.insertionSort r l) (by exact List.pairwise_insertionSort r l) + (List.insertionSort r l) (List.pairwise_insertionSort r l) simp only [Bool.decide_and] at hl ⊢ erw [hl] rw [List.orderedInsert_eq_take_drop] diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index 93ea4b605..0c021e1d1 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -284,7 +284,7 @@ lemma schwartzMap_slice_integral_hasFDerivAt {d : ℕ} (η : 𝓢(Space d.succ, exact ((η.smooth'.differentiable (by simp)).comp (by fun_prop)).differentiableAt obtain ⟨rt, hrt⟩ := schwartzMap_slice_bound (m := 0) (n := 1) (d := d) i obtain ⟨k, hrt, hbound, k_eq⟩ := hrt η - suffices h1 : HasFDerivAt (fun x => ∫ (a : ℝ), F x a) (∫ (a : ℝ), F' x₀ a) x₀ by exact h1 + suffices HasFDerivAt (fun x => ∫ (a : ℝ), F x a) (∫ (a : ℝ), F' x₀ a) x₀ from this apply hasFDerivAt_integral_of_dominated_of_fderiv_le (bound := fun t => (k * ‖(slice i).symm.toContinuousLinearMap.comp (ContinuousLinearMap.prod (0 : Space d →L[ℝ] ℝ) (ContinuousLinearMap.id ℝ (Space d)))‖) diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index c19c5e7ca..af943841b 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -464,7 +464,7 @@ lemma deriv_differentiable {M} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : ℕ} {f : Space d → M} (hf : ContDiff ℝ 2 f) (i : Fin d) : Differentiable ℝ (deriv i f) := by - suffices h1 : Differentiable ℝ (fun x => fderiv ℝ f x (basis i)) by exact h1 + suffices Differentiable ℝ (fun x => fderiv ℝ f x (basis i)) from this fun_prop open ContDiff diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index a4d08a749..6b65456e1 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -663,13 +663,13 @@ lemma time_integral_iteratedFDeriv_apply {d : ℕ} (n : ℕ) (η : 𝓢(Time × intro m refine ContDiff.differentiable_iteratedFDeriv (n := (m + 1 : ℕ)) ?_ ?_ · exact Nat.cast_lt.mpr (by omega) - · exact η.smooth'.of_le (by exact ENat.LEInfty.out) + · exact η.smooth'.of_le ENat.LEInfty.out have hη_diff' : ∀ (m : ℕ) (t : Time), Differentiable ℝ (iteratedFDeriv ℝ m (fun x => η (t, x))) := by intro m t refine ContDiff.differentiable_iteratedFDeriv (n := (m + 1 : ℕ)) ?_ ?_ · exact Nat.cast_lt.mpr (by omega) - · exact (η.smooth'.of_le (by exact ENat.LEInfty.out)).comp (by fun_prop) + · exact (η.smooth'.of_le ENat.LEInfty.out).comp (by fun_prop) induction n with | zero => simp diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index ff8e5c1aa..652967d5e 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -938,7 +938,7 @@ lemma physicalProbability_nonneg (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] [NeZero 𝓒.μ] (i : ι) : 0 ≤ 𝓒.physicalProbability T i := by have hp := 𝓒.probability_nonneg (T:=T) i - exact mul_nonneg hp (by exact pow_nonneg (le_of_lt 𝓒.hPos) _) + exact mul_nonneg hp (pow_nonneg (le_of_lt 𝓒.hPos) _) lemma physicalProbability_pos (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] [NeZero 𝓒.μ] (i : ι) : From 4bdd97dec92acdbfd3a61fdfce03e340b4dadfb9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:26:16 -0700 Subject: [PATCH 046/498] refactor: golf multiline rfl proofs Co-authored-by: Claude Opus 4.8 --- .../ClassicalMechanics/HamiltonsEquations.lean | 3 +-- Physlib/Mathematics/Calculus/AdjFDeriv.lean | 4 ++-- Physlib/Mathematics/Distribution/Basic.lean | 7 +++---- Physlib/Mathematics/FDerivCurry.lean | 12 ++++-------- Physlib/Mathematics/List/InsertIdx.lean | 4 ++-- Physlib/Mathematics/List/InsertionSort.lean | 3 +-- .../NoGrav/One/LinearParameterization.lean | 3 +-- .../MSSMNu/AnomalyCancellation/B3.lean | 3 +-- .../MSSMNu/AnomalyCancellation/Basic.lean | 12 ++++-------- .../AnomalyCancellation/OrthogY3B3/Basic.lean | 3 +-- .../OrthogY3B3/PlaneWithY3B3.lean | 6 ++---- .../MSSMNu/AnomalyCancellation/Y3.lean | 3 +-- .../FieldStatistics/ExchangeSign.lean | 3 +-- .../QED/AnomalyCancellation/Odd/BasisLinear.lean | 6 ++---- .../QFT/QED/AnomalyCancellation/Permutations.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/Sorts.lean | 6 ++---- .../OneDimension/GeneralPotential/Basic.lean | 7 +++---- .../OneDimension/Operators/Momentum.lean | 3 +-- Physlib/Relativity/LorentzGroup/Basic.lean | 3 +-- Physlib/Relativity/LorentzGroup/Rotations.lean | 3 +-- Physlib/Relativity/PauliMatrices/AsTensor.lean | 3 +-- Physlib/Relativity/Tensors/Basic.lean | 3 +-- .../Tensors/ComplexTensor/Vector/Pre/Basic.lean | 6 ++---- Physlib/Relativity/Tensors/Constructors.lean | 6 ++---- Physlib/Relativity/Tensors/Dual.lean | 6 ++---- .../Tensors/RealTensor/Metrics/Basic.lean | 6 ++---- .../Tensors/RealTensor/Vector/Pre/Modules.lean | 15 +++++---------- .../CanonicalEnsemble/TwoState.lean | 6 ++---- 28 files changed, 53 insertions(+), 98 deletions(-) diff --git a/Physlib/ClassicalMechanics/HamiltonsEquations.lean b/Physlib/ClassicalMechanics/HamiltonsEquations.lean index 71d0ed6d0..f9309e0a9 100644 --- a/Physlib/ClassicalMechanics/HamiltonsEquations.lean +++ b/Physlib/ClassicalMechanics/HamiltonsEquations.lean @@ -43,8 +43,7 @@ noncomputable def hamiltonEqOp (H : Time → X → X → ℝ) (p : Time → X) ( lemma hamiltonEqOp_eq (H : Time → X → X → ℝ) (p : Time → X) (q : Time → X) : hamiltonEqOp H p q = fun t => (∂ₜ q t + -gradient (fun x => H t x (q t)) (p t), - - ∂ₜ p t + -gradient (fun x => H t (p t) x) (q t)) := by - rfl + - ∂ₜ p t + -gradient (fun x => H t (p t) x) (q t)) := rfl lemma hamiltonEqOp_eq_zero_iff_hamiltons_equations (H : Time → X → X → ℝ) (p : Time → X) (q : Time → X) : diff --git a/Physlib/Mathematics/Calculus/AdjFDeriv.lean b/Physlib/Mathematics/Calculus/AdjFDeriv.lean index 16130eb11..f4169ebaf 100644 --- a/Physlib/Mathematics/Calculus/AdjFDeriv.lean +++ b/Physlib/Mathematics/Calculus/AdjFDeriv.lean @@ -144,8 +144,8 @@ lemma adjFDeriv_id : adjFDeriv 𝕜 (fun x : E => x) = fun _ dx => dx := by funext x rw[HasAdjFDerivAt.adjFDeriv (hasAdjFDerivAt_id x)] -lemma adjFDeriv_id' : adjFDeriv 𝕜 (id : E → E) = fun _ dx => dx := by - exact adjFDeriv_id +lemma adjFDeriv_id' : adjFDeriv 𝕜 (id : E → E) = fun _ dx => dx := + adjFDeriv_id lemma hasAdjFDerivAt_const (x : E) (y : F) : HasAdjFDerivAt 𝕜 (fun _ : E => y) (fun _ => 0) x where diff --git a/Physlib/Mathematics/Distribution/Basic.lean b/Physlib/Mathematics/Distribution/Basic.lean index 8c9f487e7..a8d43d391 100644 --- a/Physlib/Mathematics/Distribution/Basic.lean +++ b/Physlib/Mathematics/Distribution/Basic.lean @@ -238,8 +238,8 @@ def fderivD [FiniteDimensional ℝ E] : (E →d[𝕜] F) →ₗ[𝕜] (E →d[ simp lemma fderivD_apply [FiniteDimensional ℝ E] (u : E →d[𝕜] F) (η : 𝓢(E, 𝕜)) (v : E) : - fderivD 𝕜 u η v = - u (SchwartzMap.evalCLM (𝕜 := 𝕜) E 𝕜 v (SchwartzMap.fderivCLM 𝕜 E 𝕜 η)) := by - rfl + fderivD 𝕜 u η v = + - u (SchwartzMap.evalCLM (𝕜 := 𝕜) E 𝕜 v (SchwartzMap.fderivCLM 𝕜 E 𝕜 η)) := rfl TODO "For distributions, prove that the derivative fderivD commutes with integrals and sums. This may require defining the integral of families of distributions @@ -473,8 +473,7 @@ def heavisideStep (d : ℕ) : (EuclideanSpace ℝ (Fin d.succ)) →d[ℝ] ℝ := lemma heavisideStep_apply (d : ℕ) (η : 𝓢(EuclideanSpace ℝ (Fin d.succ), ℝ)) : heavisideStep d η = ∫ x in {x : EuclideanSpace ℝ (Fin d.succ) | 0 < x (Fin.last d)}, - η x ∂MeasureTheory.volume := by - rfl + η x ∂MeasureTheory.volume := rfl end Distribution end Physlib diff --git a/Physlib/Mathematics/FDerivCurry.lean b/Physlib/Mathematics/FDerivCurry.lean index e47082974..42a416bc0 100644 --- a/Physlib/Mathematics/FDerivCurry.lean +++ b/Physlib/Mathematics/FDerivCurry.lean @@ -103,8 +103,7 @@ lemma fderiv_uncurry_comp_fst (f : X → Y → Z) (y : Y) (hf : Differentiable fderiv 𝕜 (fun x' => (↿f) (x', y)) = fun x => (fderiv 𝕜 (↿f) ((·, y) x)).comp (fderiv 𝕜 (·, y) x) := by - have hl (y : Y) : (fun x' => (↿f) (x', y)) = ↿f ∘ (·, y) := by - rfl + have hl (y : Y) : (fun x' => (↿f) (x', y)) = ↿f ∘ (·, y) := rfl rw [hl] funext x rw [fderiv_comp] @@ -115,8 +114,7 @@ lemma fderiv_uncurry_comp_snd (f : X → Y → Z) (x : X) (hf : Differentiable fderiv 𝕜 (fun y' => (↿f) (x, y')) = fun y => (fderiv 𝕜 (↿f) ((x, ·) y)).comp (fderiv 𝕜 (x, ·) y) := by - have hl (x : X) : (fun y' => (↿f) (x, y')) = ↿f ∘ (x, ·) := by - rfl + have hl (x : X) : (fun y' => (↿f) (x, y')) = ↿f ∘ (x, ·) := rfl rw [hl] funext y rw [fderiv_comp] @@ -128,8 +126,7 @@ lemma fderiv_curry_comp_fst (f : X → Y → Z) (x dx : X) (y : Y) (fderiv 𝕜 (fun x' => f x' y) x) dx = (fderiv 𝕜 (↿f) ((·, y) x)) ((fderiv 𝕜 (·, y) x) dx) := by - have hl (y : Y) : (fun x' => f x' y) = ↿f ∘ (·, y) := by - rfl + have hl (y : Y) : (fun x' => f x' y) = ↿f ∘ (·, y) := rfl rw [hl] rw [fderiv_comp] simp only [ContinuousLinearMap.coe_comp, Function.comp_apply] @@ -141,8 +138,7 @@ lemma fderiv_curry_comp_snd (f : X → Y → Z) (x : X) (y dy : Y) (fderiv 𝕜 (fun y' => f x y') y) dy = (fderiv 𝕜 (↿f) ((x, ·) y)) ((fderiv 𝕜 (x, ·) y) dy) := by - have hl (x : X) : (fun y' => f x y') = ↿f ∘ (x, ·) := by - rfl + have hl (x : X) : (fun y' => f x y') = ↿f ∘ (x, ·) := rfl rw [hl] rw [fderiv_comp] simp only [ContinuousLinearMap.coe_comp, Function.comp_apply] diff --git a/Physlib/Mathematics/List/InsertIdx.lean b/Physlib/Mathematics/List/InsertIdx.lean index 81c86ae58..e132bb919 100644 --- a/Physlib/Mathematics/List/InsertIdx.lean +++ b/Physlib/Mathematics/List/InsertIdx.lean @@ -187,8 +187,8 @@ lemma take_insert_let {I : Type} (i : I) : simp at hm | n + 1, m + 1, h, a::as, hm => by simp only [List.insertIdx_succ_cons, List.take_succ_cons] - have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := by - exact List.Perm.swap a i (List.take n as) + have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := + List.Perm.swap a i (List.take n as) refine List.Perm.trans ?_ hp.symm refine List.Perm.cons a ?_ exact take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm) diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index 9a2b5d45d..2df755cb4 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -84,8 +84,7 @@ lemma insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt {α : Type} (r : α apply lt_of_eq_of_lt (insertionSortMinPos_insertionSortEquiv r a l) apply insertionSortEquiv_gt_zero_of_ne_insertionSortMinPos r a l simp only [List.length_cons, ne_eq, Fin.ext_iff, Fin.val_cast] - have hl : (insertionSortMinPos r a l).val = (insertionSortMinPosFin r a l).val := by - rfl + have hl : (insertionSortMinPos r a l).val = (insertionSortMinPosFin r a l).val := rfl simp only [hl, Nat.succ_eq_add_one, Fin.val_eq_val, ne_eq] exact Fin.succAbove_ne (insertionSortMinPosFin r a l) i diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean index 7657971ae..3201fe0b4 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean @@ -82,8 +82,7 @@ def asLinear (S : linearParameters) : (SMNoGrav 1).LinSols := LinearMap.coe_mk, AddHom.coe_mk, speciesVal, asCharges, neg_add_rev] ring) -lemma asLinear_val (S : linearParameters) : S.asLinear.val = S.asCharges := by - rfl +lemma asLinear_val (S : linearParameters) : S.asLinear.val = S.asCharges := rfl set_option backward.isDefEq.respectTransparency false in lemma cubic (S : linearParameters) : diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/B3.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/B3.lean index 2cba2d097..407e88b8e 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/B3.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/B3.lean @@ -61,8 +61,7 @@ def B₃ : MSSMACC.Sols := (by with_unfolding_all rfl) (by with_unfolding_all rfl) (by with_unfolding_all rfl) (by with_unfolding_all rfl) (by with_unfolding_all rfl) -lemma B₃_val : B₃.val = B₃AsCharge := by - rfl +lemma B₃_val : B₃.val = B₃AsCharge := rfl set_option backward.isDefEq.respectTransparency false in lemma doublePoint_B₃_B₃ (R : MSSMACC.LinSols) : cubeTriLin B₃.val B₃.val R.val = 0 := by diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean index 3a290e729..b53ac86ae 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean @@ -125,12 +125,10 @@ lemma charges_eq_toSpecies_eq (S T : MSSMCharges.Charges) : | 1 => exact h.2.2 lemma Hd_toSpecies_inv (f : (Fin 6 → Fin 3 → ℚ) × (Fin 2 → ℚ)) : - Hd (toSpecies.symm f) = f.2 0 := by - rfl + Hd (toSpecies.symm f) = f.2 0 := rfl lemma Hu_toSpecies_inv (f : (Fin 6 → Fin 3 → ℚ) × (Fin 2 → ℚ)) : - Hu (toSpecies.symm f) = f.2 1 := by - rfl + Hu (toSpecies.symm f) = f.2 1 := rfl end MSSMCharges @@ -455,8 +453,7 @@ def AnomalyFreeMk (S : MSSMACC.Charges) (hg : accGrav S = 0) lemma AnomalyFreeMk_val (S : MSSMACC.Charges) (hg : accGrav S = 0) (hsu2 : accSU2 S = 0) (hsu3 : accSU3 S = 0) (hyy : accYY S = 0) (hquad : accQuad S = 0) (hcube : accCube S = 0) : - (AnomalyFreeMk S hg hsu2 hsu3 hyy hquad hcube).val = S := by - rfl + (AnomalyFreeMk S hg hsu2 hsu3 hyy hquad hcube).val = S := rfl /-- A `QuadSol` from a `LinSol` satisfying the quadratic ACC. -/ @[simp] @@ -483,8 +480,7 @@ def AnomalyFreeMk'' (S : MSSMACC.QuadSols) (hcube : accCube S.val = 0) : MSSMACC lemma AnomalyFreeMk''_val (S : MSSMACC.QuadSols) (hcube : accCube S.val = 0) : - (AnomalyFreeMk'' S hcube).val = S.val := by - rfl + (AnomalyFreeMk'' S hcube).val = S.val := rfl set_option backward.isDefEq.respectTransparency false in /-- The dot product on the vector space of charges. -/ diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean index 2c038fff9..1a74d38e3 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean @@ -58,8 +58,7 @@ def proj (T : MSSMACC.LinSols) : MSSMACC.AnomalyFreePerp := lemma proj_val (T : MSSMACC.LinSols) : (proj T).val = (dot B₃.val T.val - dot Y₃.val T.val) • Y₃.val + (dot Y₃.val T.val - 2 * dot B₃.val T.val) • B₃.val + - dot Y₃.val B₃.val • T.val := by - rfl + dot Y₃.val B₃.val • T.val := rfl lemma Y₃_plus_B₃_plus_proj (T : MSSMACC.LinSols) (a b c : ℚ) : a • Y₃.val + b • B₃.val + c • (proj T).val = diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean index dae9178f8..f546a7a66 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean @@ -30,8 +30,7 @@ def planeY₃B₃ (R : MSSMACC.AnomalyFreePerp) (a b c : ℚ) : MSSMACC.LinSols a • Y₃.1.1 + b • B₃.1.1 + c • R.1 lemma planeY₃B₃_val (R : MSSMACC.AnomalyFreePerp) (a b c : ℚ) : - (planeY₃B₃ R a b c).val = a • Y₃.val + b • B₃.val + c • R.val := by - rfl + (planeY₃B₃ R a b c).val = a • Y₃.val + b • B₃.val + c • R.val := rfl lemma planeY₃B₃_smul (R : MSSMACC.AnomalyFreePerp) (a b c d : ℚ) : planeY₃B₃ R (d * a) (d * b) (d * c) = d • planeY₃B₃ R a b c := by @@ -118,8 +117,7 @@ lemma lineQuad_val (R : MSSMACC.AnomalyFreePerp) (c1 c2 c3 : ℚ) : (lineQuad R c1 c2 c3).val = (planeY₃B₃ R (c2 * quadBiLin R.val R.val - 2 * c3 * quadBiLin B₃.val R.val) (2 * c3 * quadBiLin Y₃.val R.val - c1 * quadBiLin R.val R.val) - (2 * c1 * quadBiLin B₃.val R.val - 2 * c2 * quadBiLin Y₃.val R.val)).val := by - rfl + (2 * c1 * quadBiLin B₃.val R.val - 2 * c2 * quadBiLin Y₃.val R.val)).val := rfl lemma lineQuad_smul (R : MSSMACC.AnomalyFreePerp) (a b c d : ℚ) : lineQuad R (d * a) (d * b) (d * c) = d • lineQuad R a b c := by diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Y3.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Y3.lean index 87a0f57c4..b3b6b522e 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Y3.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Y3.lean @@ -61,8 +61,7 @@ def Y₃ : MSSMACC.Sols := (by with_unfolding_all rfl) (by with_unfolding_all rfl) (by with_unfolding_all rfl) (by with_unfolding_all rfl) (by with_unfolding_all rfl) (by with_unfolding_all rfl) -lemma Y₃_val : Y₃.val = Y₃AsCharge := by - rfl +lemma Y₃_val : Y₃.val = Y₃AsCharge := rfl set_option backward.isDefEq.respectTransparency false in lemma doublePoint_Y₃_Y₃ (R : MSSMACC.LinSols) : diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean index 025ffab39..64be719ac 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean @@ -81,8 +81,7 @@ lemma bosonic_exchangeSign (a : FieldStatistic) : 𝓢(bosonic, a) = 1 := by rw [exchangeSign_symm, exchangeSign_bosonic] @[simp] -lemma fermionic_exchangeSign_fermionic : 𝓢(fermionic, fermionic) = - 1 := by - rfl +lemma fermionic_exchangeSign_fermionic : 𝓢(fermionic, fermionic) = - 1 := rfl lemma exchangeSign_eq_if (a b : FieldStatistic) : 𝓢(a, b) = if a = fermionic ∧ b = fermionic then - 1 else 1 := by diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index b1e743abf..d2f7cb754 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -219,8 +219,7 @@ lemma oddShiftShiftFst_eq_oddFst_succ (j : Fin n) : exact Nat.add_comm 1 ↑j lemma oddShiftShiftFst_eq_oddShiftFst_castSucc (j : Fin n) : - oddShiftShiftFst j = oddShiftFst j.castSucc := by - rfl + oddShiftShiftFst j = oddShiftFst j.castSucc := rfl lemma oddShiftShiftMid_eq_oddMid : @oddShiftShiftMid n = oddMid := by rw [Fin.ext_iff] @@ -228,8 +227,7 @@ lemma oddShiftShiftMid_eq_oddMid : @oddShiftShiftMid n = oddMid := by Fin.val_natAdd, Fin.val_eq_zero, add_zero, oddMid] exact Nat.add_comm 1 n -lemma oddShiftShiftMid_eq_oddShiftFst_last : oddShiftShiftMid = oddShiftFst (Fin.last n) := by - rfl +lemma oddShiftShiftMid_eq_oddShiftFst_last : oddShiftShiftMid = oddShiftFst (Fin.last n) := rfl lemma oddShiftShiftSnd_eq_oddSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddSnd j := by rw [Fin.ext_iff] diff --git a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean index 379ab30c5..ce1e1e8d4 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean @@ -80,13 +80,11 @@ def FamilyPermutations (n : ℕ) : ACCSystemGroupAction (PureU1 n) where lemma FamilyPermutations_charges_apply (S : (PureU1 n).Charges) (i : Fin n) (f : (FamilyPermutations n).group) : - ((FamilyPermutations n).rep f S) i = S (f.invFun i) := by - rfl + ((FamilyPermutations n).rep f S) i = S (f.invFun i) := rfl lemma FamilyPermutations_anomalyFreeLinear_apply (S : (PureU1 n).LinSols) (i : Fin n) (f : (FamilyPermutations n).group) : - ((FamilyPermutations n).linSolRep f S).val i = S.val (f.invFun i) := by - rfl + ((FamilyPermutations n).linSolRep f S).val i = S.val (f.invFun i) := rfl /-- A permutation of fermions which takes one ordered subset into another. -/ noncomputable def permOfInjection (f g : Fin m ↪ Fin n) : (FamilyPermutations n).group := diff --git a/Physlib/QFT/QED/AnomalyCancellation/Sorts.lean b/Physlib/QFT/QED/AnomalyCancellation/Sorts.lean index e28cd3136..581a3e31e 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Sorts.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Sorts.lean @@ -43,8 +43,7 @@ lemma sort_perm {n : ℕ} (S : (PureU1 n).Charges) (M :(FamilyPermutations n).gr @Tuple.comp_perm_comp_sort_eq_comp_sort n ℚ _ S M⁻¹ lemma sort_apply {n : ℕ} (S : (PureU1 n).Charges) (j : Fin n) : - sort S j = S ((Tuple.sort S) j) := by - rfl + sort S j = S ((Tuple.sort S) j) := rfl lemma sort_zero {n : ℕ} (S : (PureU1 n).Charges) (hS : sort S = 0) : S = 0 := by funext i @@ -65,8 +64,7 @@ lemma sort_projection {n : ℕ} (S : (PureU1 n).Charges) : sort (sort S) = sort def sortAFL {n : ℕ} (S : (PureU1 n).LinSols) : (PureU1 n).LinSols := ((FamilyPermutations n).linSolRep (Tuple.sort S.val).symm S) -lemma sortAFL_val {n : ℕ} (S : (PureU1 n).LinSols) : (sortAFL S).val = sort S.val := by - rfl +lemma sortAFL_val {n : ℕ} (S : (PureU1 n).LinSols) : (sortAFL S).val = sort S.val := rfl lemma sortAFL_zero {n : ℕ} (S : (PureU1 n).LinSols) (hS : sortAFL S = 0) : S = 0 := by apply ACCSystemLinear.LinSols.ext diff --git a/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean b/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean index 6c2b716a9..1a4ebb4d4 100644 --- a/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean @@ -22,11 +22,10 @@ namespace OneDimension open HilbertSpace Constants private lemma fun_add {α : Type*} (f g : α → ℂ) : - (fun x ↦ f x) + (fun x ↦ g x) = fun x ↦ f x + g x := by - rfl + (fun x ↦ f x) + (fun x ↦ g x) = fun x ↦ f x + g x := rfl -private lemma fun_smul (a1: ℂ) (f : ℝ → ℂ) : (a1 • fun x ↦ f x) = (fun x ↦ a1*(f x)) := by - rfl +private lemma fun_smul (a1: ℂ) (f : ℝ → ℂ) : (a1 • fun x ↦ f x) = (fun x ↦ a1*(f x)) := + rfl lemma momentumOperator_linear (a1 a2 : ℂ) (ψ1 ψ2 : ℝ → ℂ) (hψ1_x: Differentiable ℝ ψ1) (hψ2_x: Differentiable ℝ ψ2) : diff --git a/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean b/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean index 448334e5c..8395ca4e4 100644 --- a/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean +++ b/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean @@ -42,8 +42,7 @@ open HilbertSpace SchwartzMap def momentumOperator (ψ : ℝ → ℂ) : ℝ → ℂ := fun x ↦ - Complex.I * ℏ * deriv ψ x lemma momentumOperator_eq_smul (ψ : ℝ → ℂ) : - momentumOperator ψ = fun x => (- Complex.I * ℏ) • deriv ψ x := by - rfl + momentumOperator ψ = fun x => (- Complex.I * ℏ) • deriv ψ x := rfl @[fun_prop] lemma continuous_momentumOperator (ψ : ℝ → ℂ) (hψ : ContDiff ℝ 1 ψ) : diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 6c9644448..8f37ffdb9 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -175,8 +175,7 @@ lemma isClosedEmbedding_val {d : ℕ} : -/ lemma inv_eq_dual (Λ : LorentzGroup d) : - (Λ⁻¹ : LorentzGroup d) = ⟨minkowskiMatrix.dual Λ.1, LorentzGroup.dual_mem Λ.2⟩ := by - rfl + (Λ⁻¹ : LorentzGroup d) = ⟨minkowskiMatrix.dual Λ.1, LorentzGroup.dual_mem Λ.2⟩ := rfl lemma coe_inv : (Λ⁻¹).1 = Λ.1⁻¹:= (inv_eq_left_inv (mem_iff_dual_mul_self.mp Λ.2)).symm diff --git a/Physlib/Relativity/LorentzGroup/Rotations.lean b/Physlib/Relativity/LorentzGroup/Rotations.lean index f476e2c64..45842ce4a 100644 --- a/Physlib/Relativity/LorentzGroup/Rotations.lean +++ b/Physlib/Relativity/LorentzGroup/Rotations.lean @@ -46,8 +46,7 @@ def Rotations (d) : Subgroup (LorentzGroup d) where · simpa [inv_eq_dual, IsProper] using h.2 lemma mem_rotations_iff {d} (Λ : LorentzGroup d) : - Λ ∈ Rotations d ↔ Λ.1 (Sum.inl 0) (Sum.inl 0) = 1 ∧ IsProper Λ := by - rfl + Λ ∈ Rotations d ↔ Λ.1 (Sum.inl 0) (Sum.inl 0) = 1 ∧ IsProper Λ := Iff.rfl @[simp] lemma transpose_mem_rotations {d} (Λ : LorentzGroup d) : diff --git a/Physlib/Relativity/PauliMatrices/AsTensor.lean b/Physlib/Relativity/PauliMatrices/AsTensor.lean index d1fcdbb6f..ab34afa10 100644 --- a/Physlib/Relativity/PauliMatrices/AsTensor.lean +++ b/Physlib/Relativity/PauliMatrices/AsTensor.lean @@ -42,8 +42,7 @@ lemma asTensor_expand_complexContrBasis : asTensor = complexContrBasis (Sum.inl 0) ⊗ₜ leftRightToMatrix.symm (pauliBasis (Sum.inl 0)) + complexContrBasis (Sum.inr 0) ⊗ₜ leftRightToMatrix.symm (pauliBasis (Sum.inr 0)) + complexContrBasis (Sum.inr 1) ⊗ₜ leftRightToMatrix.symm (pauliBasis (Sum.inr 1)) - + complexContrBasis (Sum.inr 2) ⊗ₜ leftRightToMatrix.symm (pauliBasis (Sum.inr 2)) := by - rfl + + complexContrBasis (Sum.inr 2) ⊗ₜ leftRightToMatrix.symm (pauliBasis (Sum.inr 2)) := rfl /-- The expansion of the pauli matrix `σ₀` in terms of a basis of tensor product vectors. -/ lemma leftRightToMatrix_σSA_inl_0_expand : leftRightToMatrix.symm (pauliBasis (Sum.inl 0)) = diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index 6a771f202..de0885783 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -264,8 +264,7 @@ noncomputable def componentMap {n : ℕ} (c : Fin n → C) : @[simp] lemma componentMap_apply {n : ℕ} (c : Fin n → C) - (p : Pure S c) : componentMap c p = p.component := by - rfl + (p : Pure S c) : componentMap c p = p.component := rfl /-- Given an component idx `b` in `ComponentIdx c`, `basisVector c b` is the pure tensor formed by `S.basis (c i) (b i)`. -/ diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index ad4a97ace..4555daac9 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -46,8 +46,7 @@ lemma complexContrBasis_ρ_apply (M : SL(2,ℂ)) (i j : Fin 1 ⊕ Fin 3) : lemma complexContrBasis_ρ_val (M : SL(2,ℂ)) (v : ContrℂModule) : ((ContrℂModule.SL2CRep M) v).val = - LorentzGroup.toComplex (SL2C.toLorentzGroup M) *ᵥ v.val := by - rfl + LorentzGroup.toComplex (SL2C.toLorentzGroup M) *ᵥ v.val := rfl /-- The standard basis of complex contravariant Lorentz vectors indexed by `Fin 4`. -/ def complexContrBasisFin4 : Basis (Fin 4) ℂ ContrℂModule := @@ -112,8 +111,7 @@ lemma complexCoBasis_ρ_apply (M : SL(2,ℂ)) (i j : Fin 1 ⊕ Fin 3) : lemma CoℂModule.SL2CRep_val (M : SL(2,ℂ)) (v : CoℂModule) : ((CoℂModule.SL2CRep M) v).val = - (LorentzGroup.toComplex (SL2C.toLorentzGroup M))⁻¹ᵀ *ᵥ v.val := by - rfl + (LorentzGroup.toComplex (SL2C.toLorentzGroup M))⁻¹ᵀ *ᵥ v.val := rfl /-- The standard basis of complex covariant Lorentz vectors indexed by `Fin 4`. -/ def complexCoBasisFin4 : Basis (Fin 4) ℂ CoℂModule := diff --git a/Physlib/Relativity/Tensors/Constructors.lean b/Physlib/Relativity/Tensors/Constructors.lean index 041224ec4..f305510e0 100644 --- a/Physlib/Relativity/Tensors/Constructors.lean +++ b/Physlib/Relativity/Tensors/Constructors.lean @@ -126,8 +126,7 @@ noncomputable def fromPairT {c1 c2 : C} : lemma fromPairT_tmul {c1 c2 : C} (x : V c1) (y : V c2) : fromPairT (x ⊗ₜ[k] y) = permT id (And.intro Function.bijective_id (fun i => by fin_cases i <;> rfl)) - (prodT (fromSingleT (S := S) x) (fromSingleT y)) := by - rfl + (prodT (fromSingleT (S := S) x) (fromSingleT y)) := rfl lemma fromPairT_eq_pure {c1 c2 : C} (x : V c1) (y : V c2) : fromPairT (S := S) (x ⊗ₜ[k] y) = Pure.toTensor (fun | 0 => x | 1 => y) := by @@ -485,8 +484,7 @@ lemma fromTripleT_tmul {c1 c2 c3 : C} (x : V c1) (y : V c2) (z : V c3) : fromTripleT (x ⊗ₜ[k] (y ⊗ₜ[k] z)) = permT id (And.intro Function.bijective_id (fun i => by fin_cases i <;> rfl)) - (prodT (fromSingleT (S := S) x) (prodT (fromSingleT y) (fromSingleT z))) := by - rfl + (prodT (fromSingleT (S := S) x) (prodT (fromSingleT y) (fromSingleT z))) := rfl lemma actionT_fromTripleT {c1 c2 c3 : C} (x : V c1 ⊗[k] (V c2 ⊗[k] V c3)) (g : G) : diff --git a/Physlib/Relativity/Tensors/Dual.lean b/Physlib/Relativity/Tensors/Dual.lean index eecf2559b..0bef5962e 100644 --- a/Physlib/Relativity/Tensors/Dual.lean +++ b/Physlib/Relativity/Tensors/Dual.lean @@ -37,8 +37,7 @@ noncomputable def fromDualMap {c : C} : S.Tensor ![S.τ c] →ₗ[k] S.Tensor ![ lemma fromDualMap_apply {c : C} (t : S.Tensor ![S.τ c]) : fromDualMap t = permT id (by simp; rfl) - (contrT 1 1 2 (by simp; rfl) (prodT (metricTensor c) t)) := by - rfl + (contrT 1 1 2 (by simp; rfl) (prodT (metricTensor c) t)) := rfl /-- The linear map taking a tensor based on the color `c` to a tensor based on the color `S.τ c`, defined by contraction with the metric tensor. -/ @@ -56,8 +55,7 @@ lemma toDualMap_apply {c : C} (t : S.Tensor ![c]) : toDualMap t = permT id (by simp; rfl) (contrT 1 1 2 (by change _ ∧ S.τ (S.τ c) = c - simp) (prodT (metricTensor (S.τ c)) t)) := by - rfl + simp) (prodT (metricTensor (S.τ c)) t)) := rfl set_option backward.isDefEq.respectTransparency false in @[simp] diff --git a/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean index 61061f0d7..c3f4e031a 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean @@ -60,13 +60,11 @@ open Tensor lemma coMetric_eq_fromConstPair {d : ℕ} : η' d = fromConstPair (S := realLorentzTensor d) (c1 := .down) (c2 := .down) - (Lorentz.preCoMetric d) := by - rfl + (Lorentz.preCoMetric d) := rfl lemma contrMetric_eq_fromConstPair {d : ℕ} : η d = fromConstPair (S := realLorentzTensor d) - (c1 := .up) (c2 := .up) (Lorentz.preContrMetric d) := by - rfl + (c1 := .up) (c2 := .up) (Lorentz.preContrMetric d) := rfl lemma coMetric_eq_fromPairT {d : ℕ} : η' d = fromPairT (S := realLorentzTensor d) (c1 := .down) (c2 := .down) diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index 612a09eeb..e67a8a186 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -142,13 +142,11 @@ scoped[Lorentz] infixr:73 " *ᵥ " => ContrMod.mulVec @[simp] lemma mulVec_toFin1dℝ (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v : ContrMod d) : - (M *ᵥ v).toFin1dℝ = M *ᵥ v.toFin1dℝ := by - rfl + (M *ᵥ v).toFin1dℝ = M *ᵥ v.toFin1dℝ := rfl @[simp] lemma mulVec_val (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v : ContrMod d) : - (M *ᵥ v).val = M *ᵥ v.val := by - rfl + (M *ᵥ v).val = M *ᵥ v.val := rfl lemma mulVec_sub (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v w : ContrMod d) : M *ᵥ (v - w) = M *ᵥ v - M *ᵥ w := by @@ -206,8 +204,7 @@ def rep : Representation ℝ (LorentzGroup d) (ContrMod d) where simp only [lorentzGroupIsGroup_mul_coe, _root_.map_mul] lemma rep_apply_toFin1dℝ (g : LorentzGroup d) (ψ : ContrMod d) : - (rep g ψ).toFin1dℝ = g.1 *ᵥ ψ.toFin1dℝ := by - rfl + (rep g ψ).toFin1dℝ = g.1 *ᵥ ψ.toFin1dℝ := rfl /-! @@ -403,13 +400,11 @@ scoped[Lorentz] infixr:73 " *ᵥ " => CoMod.mulVec @[simp] lemma mulVec_toFin1dℝ (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v : CoMod d) : - (M *ᵥ v).toFin1dℝ = M *ᵥ v.toFin1dℝ := by - rfl + (M *ᵥ v).toFin1dℝ = M *ᵥ v.toFin1dℝ := rfl @[simp] lemma mulVec_val (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v : CoMod d) : - (M *ᵥ v).val = M *ᵥ v.val := by - rfl + (M *ᵥ v).val = M *ᵥ v.val := rfl /-! ## The representation diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/TwoState.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/TwoState.lean index b67dc0c5b..e249ba004 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/TwoState.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/TwoState.lean @@ -50,12 +50,10 @@ lemma twoState_partitionFunction_apply_eq_cosh (E₀ E₁ : ℝ) (T : Temperatur ring_nf @[simp] -lemma twoState_energy_fst (E₀ E₁ : ℝ) : (twoState E₀ E₁).energy 0 = E₀ := by - rfl +lemma twoState_energy_fst (E₀ E₁ : ℝ) : (twoState E₀ E₁).energy 0 = E₀ := rfl @[simp] -lemma twoState_energy_snd (E₀ E₁ : ℝ) : (twoState E₀ E₁).energy 1 = E₁ := by - rfl +lemma twoState_energy_snd (E₀ E₁ : ℝ) : (twoState E₀ E₁).energy 1 = E₁ := rfl /-- Probability of the first state (energy `E₀`) in closed form. -/ lemma twoState_probability_fst (E₀ E₁ : ℝ) (T : Temperature) : From b55f189d95be0c4e1a477c4222c333f184e28eec Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:29:15 -0700 Subject: [PATCH 047/498] refactor: golf residual rfl proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Fin.lean | 3 +-- .../Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean | 3 +-- .../WickContraction/UncontractedList.lean | 3 +-- .../QuantumMechanics/DDimensions/Operators/Uncertainty.lean | 6 ++---- Physlib/Relativity/Tensors/RealTensor/Basic.lean | 3 +-- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 6 ++---- Physlib/Thermodynamics/Temperature/Basic.lean | 3 +-- 7 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index a1c6f664c..8d4fb4752 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -140,8 +140,7 @@ lemma finExtractOne_symm_inr_apply {n : ℕ} (i : Fin n.succ) (x : Fin n) : @[simp] lemma finExtractOne_symm_inl_apply {n : ℕ} (i : Fin n.succ) : - (finExtractOne i).symm (Sum.inl 0) = i := by - rfl + (finExtractOne i).symm (Sum.inl 0) = i := rfl lemma finExtractOne_apply_neq {n : ℕ} (i j : Fin (n + 1 + 1)) (hij : i ≠ j) : finExtractOne i j = Sum.inr (predAboveI i j) := by diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean index 7241858a8..cbe11a7fb 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean @@ -176,8 +176,7 @@ instance subsetDecidable [DecidableEq 𝓩] (x y : ChargeSpectrum 𝓩) : Decida instDecidableAnd lemma subset_def {x y : ChargeSpectrum 𝓩} : x ⊆ y ↔ x.qHd.toFinset ⊆ y.qHd.toFinset ∧ - x.qHu.toFinset ⊆ y.qHu.toFinset ∧ x.Q5 ⊆ y.Q5 ∧ x.Q10 ⊆ y.Q10 := by - rfl + x.qHu.toFinset ⊆ y.qHu.toFinset ∧ x.Q5 ⊆ y.Q5 ∧ x.Q10 ⊆ y.Q10 := Iff.rfl @[simp, refl] lemma subset_refl (x : ChargeSpectrum 𝓩) : x ⊆ x := ⟨by rfl, by rfl, by rfl, by rfl⟩ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index 732cf0dfe..e33ad8e6f 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -380,8 +380,7 @@ lemma uncontractedListEmd_congr {φs : List 𝓕.FieldOp} {φsΛ φsΛ' : WickCo lemma uncontractedListEmd_toFun_eq_get (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) : (uncontractedListEmd (φsΛ := φsΛ)).toFun = - φsΛ.uncontractedList.get ∘ (finCongr (by simp [uncontractedListGet])) := by - rfl + φsΛ.uncontractedList.get ∘ (finCongr (by simp [uncontractedListGet])) := rfl lemma uncontractedListEmd_strictMono {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length} {i j : Fin [φsΛ]ᵘᶜ.length} (h : i < j) : uncontractedListEmd i < uncontractedListEmd j := by diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean index 9cd23cb97..637e9bdcc 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean @@ -260,12 +260,10 @@ lemma inner_centered_commutator_of_raw_commutator : calc centeredCommutatorExpectation A B ψ hψB = ⟪centered A ψ, centered B ⟨ψ, hψB⟩⟫_ℂ - - ⟪centered B ⟨ψ, hψB⟩, centered A ψ⟫_ℂ := by - rfl + ⟪centered B ⟨ψ, hψB⟩, centered A ψ⟫_ℂ := rfl _ = ⟪a - (μa : ℂ) • (ψ : H), b - (μb : ℂ) • (ψ : H)⟫_ℂ - - ⟪b - (μb : ℂ) • (ψ : H), a - (μa : ℂ) • (ψ : H)⟫_ℂ := by - rfl + ⟪b - (μb : ℂ) • (ψ : H), a - (μa : ℂ) • (ψ : H)⟫_ℂ := rfl _ = ⟪a, b⟫_ℂ - ⟪b, a⟫_ℂ := sub_expectation_commutator_eq_raw (ψ : H) a b μa μb hμa_right hμa_left hμb_right hμb_left hψ_norm diff --git a/Physlib/Relativity/Tensors/RealTensor/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Basic.lean index 42a195154..7626eac14 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Basic.lean @@ -136,8 +136,7 @@ These re-express fields of `realLorentzTensor d` in terms of `Lorentz` data. @[simp] lemma basisIdxCongr_eq_refl {d : ℕ} {c1 c2 : realLorentzTensor.Color} (h : c1 = c2) : - TensorSpecies.basisIdxCongr (basisIdx := fun _ => Fin 1 ⊕ Fin d) h = Equiv.refl _ := by - rfl + TensorSpecies.basisIdxCongr (basisIdx := fun _ => Fin 1 ⊕ Fin d) h = Equiv.refl _ := rfl lemma basisIdxCongr_apply {d : ℕ} {c1 c2 : realLorentzTensor.Color} (h : c1 = c2) (i : Fin 1 ⊕ Fin d) : diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index 99f6cb005..d5352859f 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -510,8 +510,7 @@ lemma gradient_dist_normPowerSeries_zpow {d : ℕ} {n : ℕ} (m : ℤ) : simp [distGrad_inner_eq] rw [Distribution.fderivD_apply, distOfFunction_apply, distOfFunction_inner] calc _ - _ = - ∫ (x : Space d), fderiv ℝ η x (basis.repr.symm y) * normPowerSeries n x ^ m := by - rfl + _ = - ∫ (x : Space d), fderiv ℝ η x (basis.repr.symm y) * normPowerSeries n x ^ m := rfl _ = ∫ (x : Space d), η x * fderiv ℝ (normPowerSeries n · ^ m) x (basis.repr.symm y) := by rw [integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable] · fun_prop @@ -736,8 +735,7 @@ lemma gradient_dist_normPowerSeries_log {d : ℕ} {n : ℕ} : simp [distGrad_inner_eq] rw [Distribution.fderivD_apply, distOfFunction_apply, distOfFunction_inner] calc _ - _ = - ∫ (x : Space d), fderiv ℝ η x (basis.repr.symm y) * Real.log (normPowerSeries n x) := by - rfl + _ = - ∫ (x : Space d), fderiv ℝ η x (basis.repr.symm y) * Real.log (normPowerSeries n x) := rfl _ = ∫ (x : Space d), η x * fderiv ℝ (fun x => Real.log (normPowerSeries n x)) x (basis.repr.symm y) := by rw [integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable] diff --git a/Physlib/Thermodynamics/Temperature/Basic.lean b/Physlib/Thermodynamics/Temperature/Basic.lean index 4cf0db442..3f9f3ba22 100644 --- a/Physlib/Thermodynamics/Temperature/Basic.lean +++ b/Physlib/Thermodynamics/Temperature/Basic.lean @@ -69,8 +69,7 @@ lemma ofβ_eq : ofβ = fun β => ⟨⟨1 / (kB * β), by · exact zero_le_one · apply mul_nonneg · exact kB_nonneg - · exact β.2⟩⟩ := by - rfl + · exact β.2⟩⟩ := rfl @[simp] lemma β_ofβ (β' : ℝ≥0) : β (ofβ β') = β' := by From e7711ed5d30520f27e5a9a75a66bb7e343ae056a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:32:02 -0700 Subject: [PATCH 048/498] refactor: golf direct exact proofs Co-authored-by: Claude Opus 4.8 --- .../Mathematics/DataStructures/Matrix/LieTrace.lean | 11 +++++------ .../VariationalCalculus/HasVarAdjoint.lean | 4 ++-- .../RHN/AnomalyCancellation/PlusU1/Basic.lean | 4 ++-- .../PerturbationTheory/FieldStatistics/OfFinset.lean | 3 +-- Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean | 3 +-- .../QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean | 4 ++-- .../QFT/PerturbationTheory/WickContraction/Join.lean | 7 +++---- .../WickContraction/Sign/InsertNone.lean | 3 +-- .../PerturbationTheory/WickContraction/Sign/Join.lean | 4 ++-- .../QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 4 ++-- .../QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 4 ++-- Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/Curl.lean | 4 ++-- Physlib/SpaceAndTime/Space/Integrals/Basic.lean | 3 +-- Physlib/SpaceAndTime/SpaceTime/Basic.lean | 6 ++---- Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean | 4 ++-- 16 files changed, 31 insertions(+), 40 deletions(-) diff --git a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean index 5abed796b..b82dda7f5 100644 --- a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean +++ b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean @@ -59,10 +59,9 @@ lemma matrix_tsum_apply have h_row_summable : Summable (fun n ↦ (f n) i) := by have h := Pi.summable.1 hf exact h i - have h₁ : ((∑' n, f n) : Matrix m m 𝕂) i = (∑' n, (f n) i) := by - exact tsum_apply hf - have h₂ : ((∑' n, (f n) i) : m → 𝕂) j = (∑' n, (f n) i j) := by - exact tsum_apply h_row_summable + have h₁ : ((∑' n, f n) : Matrix m m 𝕂) i = (∑' n, (f n) i) := tsum_apply hf + have h₂ : ((∑' n, (f n) i) : m → 𝕂) j = (∑' n, (f n) i j) := + tsum_apply h_row_summable rw [h₁, h₂] variable [Fintype m] [LinearOrder m] @@ -242,8 +241,8 @@ lemma exp_map_algebraMap {n : Type*} [Fintype n] [DecidableEq n] letI : NormedAlgebra ℂ (Matrix n n ℂ) := Matrix.linftyOpNormedAlgebra letI : CompleteSpace (Matrix n n ℂ) := inferInstance simp only [exp_eq_tsum ℝ] - have hs : Summable (fun k => (k.factorial : ℝ)⁻¹ • A ^ k) := by - exact NormedSpace.expSeries_summable' A + have hs : Summable (fun k => (k.factorial : ℝ)⁻¹ • A ^ k) := + NormedSpace.expSeries_summable' A erw [Matrix.map_tsum (algebraMap ℝ ℂ).toAddMonoidHom RCLike.continuous_ofReal hs] apply tsum_congr intro k diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean index dabe8bf76..e2f94e512 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean @@ -522,8 +522,8 @@ lemma adjFDeriv_apply rw [(DifferentiableAt.hasAdjFDerivAt (hφ.differentiable y)).hasAdjoint_fderiv.adjoint_inner_left] _ = ∑ i, ∫ (y : X), bX.repr (ψ y) i * fderiv ℝ (fun y' => ⟪dy, φ y' ⟫_ℝ) y (bX i) := by - have h (y : X) : ψ y = ∑ i, bX.repr (ψ y) i • bX i := by - exact Eq.symm (Basis.sum_equivFun bX (ψ y)) + have h (y : X) : ψ y = ∑ i, bX.repr (ψ y) i • bX i := + Eq.symm (Basis.sum_equivFun bX (ψ y)) conv_lhs => enter [2, y] rw [h] diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean index 8fb0b8bcd..0f0acdf23 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean @@ -66,8 +66,8 @@ lemma quadSol (S : (PlusU1 n).QuadSols) : accQuad S.val = 0 := by simp only [PlusU1_quadraticACCs] at hS exact hS ⟨0, by simp⟩ -lemma cubeSol (S : (PlusU1 n).Sols) : accCube S.val = 0 := by - exact S.cubicSol +lemma cubeSol (S : (PlusU1 n).Sols) : accCube S.val = 0 := + S.cubicSol /-- An element of `charges` which satisfies the linear ACCs gives us a element of `LinSols`. -/ diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean index b86ef25e3..76d572ecd 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean @@ -74,8 +74,7 @@ lemma ofFinset_insert (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a : Finse lemma ofFinset_erase (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a : Finset (Fin φs.length)) (i : Fin φs.length) (h : i ∈ a) : ofFinset q φs.get (a.erase i) = (q φs[i]) * ofFinset q φs.get a := by - have ha : a = Insert.insert i (a.erase i) := by - exact Eq.symm (Finset.insert_erase h) + have ha : a = Insert.insert i (a.erase i) := Eq.symm (Finset.insert_erase h) conv_rhs => rw [ha] rw [ofFinset_insert] rw [← mul_assoc] diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index 5de3325d7..a778efcd4 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -210,8 +210,7 @@ lemma koszulSign_eraseIdx [Std.Total le] [IsTrans 𝓕 le] (φs : List 𝓕) (n 𝓢(q (φs.get n), ofList q (List.take (↑(insertionSortEquiv le φs n)) (List.insertionSort le φs))) := by let φs' := φs.eraseIdx ↑n - have hφs : List.insertIdx φs' n (φs.get n) = φs := by - exact insertIdx_eraseIdx n.1 φs n.prop + have hφs : List.insertIdx φs' n (φs.get n) = φs := insertIdx_eraseIdx n.1 φs n.prop conv_rhs => lhs lhs diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 559ce6c75..1b3a5c176 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -332,8 +332,8 @@ lemma ι_timeOrderF_superCommuteF_ne_time {φ ψ : 𝓕.CrAnFieldOp} (hφψ : ¬ (crAnTimeOrderRel φ ψ ∧ crAnTimeOrderRel ψ φ)) (a b : 𝓕.FieldOpFreeAlgebra) : ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * b) = 0 := by rw [timeOrderF_timeOrderF_mid] - have hφψ : ¬ (crAnTimeOrderRel φ ψ) ∨ ¬ (crAnTimeOrderRel ψ φ) := by - exact Decidable.not_and_iff_or_not.mp hφψ + have hφψ : ¬ (crAnTimeOrderRel φ ψ) ∨ ¬ (crAnTimeOrderRel ψ φ) := + Decidable.not_and_iff_or_not.mp hφψ rcases hφψ with hφψ | hφψ · rw [timeOrderF_superCommuteF_ofCrAnOpF_ofCrAnOpF_not_crAnTimeOrderRel] simp_all only [false_and, not_false_eq_true, mul_zero, zero_mul, map_zero] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean index 5540142ca..07f8aa54f 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean @@ -273,8 +273,8 @@ lemma join_card {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length} simp only [Finset.mem_map, RelEmbedding.coe_toEmbedding, not_exists, not_and] intro x hx by_contra hn - have hdis : Disjoint (Finset.map uncontractedListEmd x) a := by - exact uncontractedListEmd_finset_disjoint_left x a ha + have hdis : Disjoint (Finset.map uncontractedListEmd x) a := + uncontractedListEmd_finset_disjoint_left x a ha rw [Finset.mapEmbedding_apply] at hn rw [hn] at hdis simp only [disjoint_self, Finset.bot_eq_empty] at hdis @@ -347,8 +347,7 @@ lemma mem_join_uncontracted_of_mem_right_uncontracted {φs : List 𝓕.FieldOp} simp only [join, Finset.le_eq_subset, Finset.mem_union, Finset.mem_map, RelEmbedding.coe_toEmbedding] at hp rcases hp with hp | hp - · have hi : uncontractedListEmd i ∈ φsΛ.uncontracted := by - exact uncontractedListEmd_mem_uncontracted i + · have hi : uncontractedListEmd i ∈ φsΛ.uncontracted := uncontractedListEmd_mem_uncontracted i rw [mem_uncontracted_iff_not_contracted] at hi exact hi p hp · obtain ⟨p, hp, rfl⟩ := hp diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean index 4bf3e5334..250239991 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean @@ -58,8 +58,7 @@ lemma signFinset_insertAndContract_none (φ : 𝓕.FieldOp) (φs : List 𝓕.Fie · simp only [Nat.succ_eq_add_one, finCongr_apply, Finset.mem_insert, Fin.ext_iff, Fin.val_cast, or_iff_right_iff_imp] intro h - have h1 : i.succAbove k ≠ i := by - exact Fin.succAbove_ne i k + have h1 : i.succAbove k ≠ i := Fin.succAbove_ne i k omega · simp rw [h1] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean index bb834f7b1..5d544a689 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean @@ -131,8 +131,8 @@ lemma join_singleton_signFinset_eq_filter {φs : List 𝓕.FieldOp} · intro h1 h2 rcases h1 with h1 | h1 · simp only [h1, Option.isSome_none, Bool.false_eq_true, IsEmpty.exists_iff] - have h2' : ¬ (((singleton h).join φsucΛ).getDual? a).isSome := by - exact Option.not_isSome_iff_eq_none.mpr h1 + have h2' : ¬ (((singleton h).join φsucΛ).getDual? a).isSome := + Option.not_isSome_iff_eq_none.mpr h1 exact h2' h2 use h2 have h1 := h1 h2 diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index aed41de11..fe04ec596 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -960,8 +960,8 @@ lemma Pa'_eq (f f' : (Fin n.succ) ⊕ (Fin n) → ℚ) : Pa' f = Pa' f' ↔ f = rw [h] rw [← Finset.sum_add_distrib] simp - have h2 : ∀ i, (f i + (- f' i)) = 0 := by - exact Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) + have h2 : ∀ i, (f i + (- f' i)) = 0 := + Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) (fun i => f i + -f' i) h1 have h2i := h2 i linarith diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index d2f7cb754..13dd61bd3 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -921,8 +921,8 @@ lemma Pa'_eq (f f' : (Fin n.succ) ⊕ (Fin n.succ) → ℚ) : Pa' f = Pa' f' ↔ rw [h] rw [← Finset.sum_add_distrib] simp - have h2 : ∀ i, (f i + (- f' i)) = 0 := by - exact Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) + have h2 : ∀ i, (f i + (- f' i)) = 0 := + Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) (fun i => f i + -f' i) h1 have h2i := h2 i linarith diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index af943841b..35539c4d4 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -93,8 +93,7 @@ lemma deriv_eq_fderiv_basis [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] lemma fderiv_eq_sum_deriv {M d} [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (f : Space d → M) (x y : Space d) : fderiv ℝ f x y = ∑ i : Fin d, y i • ∂[i] f x := by - have h1 : y = ∑ i, y i • basis i := by - exact Eq.symm (OrthonormalBasis.sum_repr basis y) + have h1 : y = ∑ i, y i • basis i := Eq.symm (OrthonormalBasis.sum_repr basis y) conv_lhs => rw [h1] simp [deriv_eq_fderiv_basis] diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean b/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean index 964dba8b2..86b89156b 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean @@ -451,8 +451,8 @@ private lemma deriv_intervalIntegral_homotopyOperatorIntegrand_sub fderiv ℝ (homotopyOperatorIntegrand f · t) x₀ (basis j) m) ∂(volume) := by let F : Space → ℝ → EuclideanSpace ℝ (Fin 3) := homotopyOperatorIntegrand f let F' : Space → ℝ → Space →L[ℝ] EuclideanSpace ℝ (Fin 3) := fun x t => fderiv ℝ (F · t) x - have F'_continuous : Continuous (Function.uncurry F') := by - exact continuous_uncurry_fderiv_homotopyOperatorIntegrand (hf) + have F'_continuous : Continuous (Function.uncurry F') := + continuous_uncurry_fderiv_homotopyOperatorIntegrand (hf) have hfderiv (x₀ : Space) : HasFDerivAt (fun (x : Space) => ∫ (t : ℝ) in 0..1, F x t ∂(volume)) (∫ (t : ℝ) in 0..1, F' x₀ t ∂(volume)) x₀ := by exact hasFDerivAt_intervalIntegral_homotopyOperatorIntegrand (hf) x₀ diff --git a/Physlib/SpaceAndTime/Space/Integrals/Basic.lean b/Physlib/SpaceAndTime/Space/Integrals/Basic.lean index addda4ca7..974453ab8 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/Basic.lean @@ -109,8 +109,7 @@ lemma integral_volume_eq_spherical (d : ℕ) [NeZero d] (f : Space d → F) rw [MeasureTheory.integral_subtype_comap (by simp), ← setIntegral_univ] simp [f'] refine integral_congr_ae ?_ - have h1 : ∀ᵐ x ∂(volume (α := Space d)), x ≠ 0 := by - exact Measure.ae_ne volume 0 + have h1 : ∀ᵐ x ∂(volume (α := Space d)), x ≠ 0 := Measure.ae_ne volume 0 filter_upwards [Measure.ae_ne volume 0] with x hx congr simp [smul_smul] diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index 5163e3e34..639898e7e 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -599,10 +599,8 @@ lemma spaceTime_integral_eq_time_space_integral {M} [NormedAddCommGroup M] apply MeasureTheory.MeasurePreserving.integral_comp · refine { measurable := ?_, map_eq := ?_ } · fun_prop - have hs : volume (α := Space d) = Space.basis.toBasis.addHaar := by - exact Space.volume_eq_addHaar - have ht : volume (α := Time) = Time.basis.toBasis.addHaar := by - exact Time.volume_eq_basis_addHaar + have hs : volume (α := Space d) = Space.basis.toBasis.addHaar := Space.volume_eq_addHaar + have ht : volume (α := Time) = Time.basis.toBasis.addHaar := Time.volume_eq_basis_addHaar rw [hs, ht] rw [← Module.Basis.prod_addHaar] rw [Module.Basis.map_addHaar] diff --git a/Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean b/Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean index b9a90ad86..1220ec901 100644 --- a/Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean +++ b/Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean @@ -595,8 +595,8 @@ lemma mem_viableCharges_iff' {I} {x : ChargeSpectrum} : ¬ IsPhenoConstrained x ∧ ¬ YukawaGeneratesDangerousAtLevel x 1 ∧ IsComplete x := by constructor · intro h - have h1 : x ∈ ofFinset I.allowedBarFiveCharges I.allowedTenCharges := by - exact viableCharges_mem_ofFinset I x h + have h1 : x ∈ ofFinset I.allowedBarFiveCharges I.allowedTenCharges := + viableCharges_mem_ofFinset I x h rw [mem_viableCharges_iff h1] at h exact ⟨h1, h⟩ · rintro ⟨h1, h⟩ From b6217966e3b16f3a9288284f78514ca4af3319a6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:34:52 -0700 Subject: [PATCH 049/498] refactor(calculus): golf adjoint derivative proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/AdjFDeriv.lean | 34 ++++++--------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/Physlib/Mathematics/Calculus/AdjFDeriv.lean b/Physlib/Mathematics/Calculus/AdjFDeriv.lean index f4169ebaf..dd1b6861a 100644 --- a/Physlib/Mathematics/Calculus/AdjFDeriv.lean +++ b/Physlib/Mathematics/Calculus/AdjFDeriv.lean @@ -170,10 +170,7 @@ lemma adjFDeriv_comp [CompleteSpace E] [CompleteSpace F] [CompleteSpace G] {f : F → G} {g : E → F} {x : E} (hf : DifferentiableAt 𝕜 f (g x)) (hg : DifferentiableAt 𝕜 g x) : adjFDeriv 𝕜 (fun x => f (g x)) x = fun dy => adjFDeriv 𝕜 g x (adjFDeriv 𝕜 f (g x) dy) := by - apply HasAdjFDerivAt.adjFDeriv - apply HasAdjFDerivAt.comp - apply hf.hasAdjFDerivAt - apply hg.hasAdjFDerivAt + exact (HasAdjFDerivAt.comp hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv lemma HasAdjFDerivAt.prodMk {f : E → F} {g : E → G} {f' g'} {x : E} (hf : HasAdjFDerivAt 𝕜 f f' x) (hg : HasAdjFDerivAt 𝕜 g g' x) : @@ -195,8 +192,7 @@ lemma HasAjdFDerivAt.fst {f : E → F×G} {f'} {x : E} (hf : HasAdjFDerivAt 𝕜 lemma adjFDeriv_fst [CompleteSpace E] [CompleteSpace F] [CompleteSpace G] {f : E → F×G} {x : E} (hf : DifferentiableAt 𝕜 f x) : adjFDeriv 𝕜 (fun x => (f x).fst) x = fun dy => adjFDeriv 𝕜 f x (dy, 0) := by - apply HasAdjFDerivAt.adjFDeriv - apply HasAjdFDerivAt.fst hf.hasAdjFDerivAt + exact (HasAjdFDerivAt.fst hf.hasAdjFDerivAt).adjFDeriv @[simp] lemma adjFDeriv_prod_fst [CompleteSpace E] [CompleteSpace F] {x : F × E} : @@ -217,8 +213,7 @@ lemma HasAjdFDerivAt.snd {f : E → F×G} {f'} {x : E} (hf : HasAdjFDerivAt 𝕜 lemma adjFDeriv_snd [CompleteSpace E] [CompleteSpace F] [CompleteSpace G] {f : E → F×G} {x : E} (hf : DifferentiableAt 𝕜 f x) : adjFDeriv 𝕜 (fun x => (f x).snd) x = fun dy => adjFDeriv 𝕜 f x (0, dy) := by - apply HasAdjFDerivAt.adjFDeriv - apply HasAjdFDerivAt.snd hf.hasAdjFDerivAt + exact (HasAjdFDerivAt.snd hf.hasAdjFDerivAt).adjFDeriv @[simp] lemma adjFDeriv_prod_snd [CompleteSpace E] [CompleteSpace F] {x : F × E} : @@ -263,8 +258,7 @@ lemma HasAdjFDerivAt.neg {f : E → F} {f'} {x : E} (hf : HasAdjFDerivAt 𝕜 f lemma adjFDeriv_neg [CompleteSpace E] [CompleteSpace F] {f : E → F} {x : E} (hf : DifferentiableAt 𝕜 f x) : adjFDeriv 𝕜 (fun x => - f x) x = fun dy => - adjFDeriv 𝕜 f x dy := by - apply HasAdjFDerivAt.adjFDeriv - apply HasAdjFDerivAt.neg hf.hasAdjFDerivAt + exact (HasAdjFDerivAt.neg hf.hasAdjFDerivAt).adjFDeriv lemma HasAjdFDerivAt.add {f g : E → F} {f' g'} {x : E} (hf : HasAdjFDerivAt 𝕜 f f' x) (hg : HasAdjFDerivAt 𝕜 g g' x) : @@ -278,10 +272,7 @@ lemma adjFDeriv_add [CompleteSpace E] [CompleteSpace F] {f g : E → F} {x : E} (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : adjFDeriv 𝕜 (fun x => f x + g x) x = fun dy => adjFDeriv 𝕜 f x dy + adjFDeriv 𝕜 g x dy := by - apply HasAdjFDerivAt.adjFDeriv - apply HasAjdFDerivAt.add - apply hf.hasAdjFDerivAt - apply hg.hasAdjFDerivAt + exact (HasAjdFDerivAt.add hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv lemma HasAdjFDerivAt.sub {f g : E → F} {f' g'} {x : E} @@ -295,10 +286,7 @@ lemma HasAdjFDerivAt.sub lemma adjFDeriv_sub [CompleteSpace E] [CompleteSpace F] {f g : E → F} {x : E} (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : adjFDeriv 𝕜 (fun x => f x - g x) x = fun dy => adjFDeriv 𝕜 f x dy - adjFDeriv 𝕜 g x dy := by - apply HasAdjFDerivAt.adjFDeriv - apply HasAdjFDerivAt.sub - apply hf.hasAdjFDerivAt - apply hg.hasAdjFDerivAt + exact (HasAdjFDerivAt.sub hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv open ComplexConjugate in lemma HasAdjFDerivAt.smul {f : E → F} {g : E → 𝕜} {f' g'} @@ -318,10 +306,7 @@ lemma adjFDeriv_smul [CompleteSpace E] [CompleteSpace F] (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : adjFDeriv 𝕜 (fun x => g x • f x) x = fun dy => conj (g x) • adjFDeriv 𝕜 f x dy + adjFDeriv 𝕜 g x (conj (inner 𝕜 dy (f x))) := by - apply HasAdjFDerivAt.adjFDeriv - apply HasAdjFDerivAt.smul - apply hf.hasAdjFDerivAt - apply hg.hasAdjFDerivAt + exact (HasAdjFDerivAt.smul hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv set_option backward.isDefEq.respectTransparency false in open InnerProductSpace in @@ -348,6 +333,5 @@ open InnerProductSpace in lemma adjFDeriv_inner {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [InnerProductSpace' ℝ E] (x : E × E) : adjFDeriv ℝ (fun (x : E × E) => ⟪x.1, x.2⟫_ℝ) x = - fun y => y • (x.2, x.1) := by - apply HasAdjFDerivAt.adjFDeriv - apply HasAdjFDerivAt.inner + fun y => y • (x.2, x.1) := + (HasAdjFDerivAt.inner x).adjFDeriv From ff3b31d0f2f46990c559fa11b3ed0c0cf6751e9c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:38:37 -0700 Subject: [PATCH 050/498] refactor(mathematics): golf curry and list proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/FDerivCurry.lean | 22 ++++++--------------- Physlib/Mathematics/List/InsertionSort.lean | 6 ++---- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Physlib/Mathematics/FDerivCurry.lean b/Physlib/Mathematics/FDerivCurry.lean index 42a416bc0..203a669d3 100644 --- a/Physlib/Mathematics/FDerivCurry.lean +++ b/Physlib/Mathematics/FDerivCurry.lean @@ -37,9 +37,7 @@ lemma fderiv_uncurry (f : X → Y → Z) (xy dxy : X × Y) lemma fderiv_curry_fst (f : X × Y → Z) (x : X) (y : Y) (h : DifferentiableAt 𝕜 f (x,y)) (dx : X) : fderiv 𝕜 (fun x' => Function.curry f x' y) x dx = fderiv 𝕜 f (x,y) (dx, 0) := by - have h1 : f = ↿(Function.curry f) := by - ext x - rfl + have h1 : f = ↿(Function.curry f) := rfl conv_rhs => rw [h1] rw [fderiv_uncurry] @@ -49,9 +47,7 @@ lemma fderiv_curry_fst (f : X × Y → Z) (x : X) (y : Y) lemma fderiv_curry_snd (f : X × Y → Z) (x : X) (y : Y) (h : DifferentiableAt 𝕜 f (x,y)) (dy : Y) : fderiv 𝕜 (Function.curry f x) y dy = fderiv 𝕜 (f) (x,y) (0, dy) := by - have h1 : f = ↿(Function.curry f) := by - ext x - rfl + have h1 : f = ↿(Function.curry f) := rfl conv_rhs => rw [h1] rw [fderiv_uncurry] @@ -157,21 +153,15 @@ lemma fderiv_inl_snd_clm (x : X) (y : Y) : lemma function_differentiableAt_fst (f : X → Y → Z) (x : X) (y : Y) (hf : Differentiable 𝕜 (↿f)) : DifferentiableAt 𝕜 (fun x' => f x' y) x := by - have hl : (fun x' => f x' y) = ↿f ∘ (·, y) := by - funext x' - rfl + have hl : (fun x' => f x' y) = ↿f ∘ (·, y) := rfl rw [hl] - apply Differentiable.differentiableAt - apply Differentiable.comp <;> fun_prop + exact (Differentiable.comp (by fun_prop) (by fun_prop)).differentiableAt lemma function_differentiableAt_snd (f : X → Y → Z) (x : X) (y : Y) (hf : Differentiable 𝕜 (↿f)) : DifferentiableAt 𝕜 (fun y' => f x y') y := by - have hl : (fun y' => f x y') = ↿f ∘ (x, ·) := by - funext y' - rfl + have hl : (fun y' => f x y') = ↿f ∘ (x, ·) := rfl rw [hl] - apply Differentiable.differentiableAt - apply Differentiable.comp <;> fun_prop + exact (Differentiable.comp (by fun_prop) (by fun_prop)).differentiableAt @[fun_prop] lemma fderiv_uncurry_differentiable_fst (f : X → Y → Z) (y : Y) (hf : ContDiff 𝕜 2 ↿f) : diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index 2df755cb4..a3ab4cc9d 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -91,8 +91,7 @@ lemma insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt {α : Type} (r : α lemma insertionSort_insertionSort {α : Type} (r : α → α → Prop) [DecidableRel r] [Std.Total r] [IsTrans α r] (l1 : List α) : List.insertionSort r (List.insertionSort r l1) = List.insertionSort r l1 := by - apply List.Pairwise.insertionSort_eq - exact List.pairwise_insertionSort r l1 + exact List.Pairwise.insertionSort_eq (List.pairwise_insertionSort r l1) lemma orderedInsert_commute {α : Type} (r : α → α → Prop) [DecidableRel r] [Std.Total r] [IsTrans α r] (a b : α) (hr : ¬ r a b) : (l : List α) → @@ -154,8 +153,7 @@ lemma insertionSort_append_insertionSort_append {α : Type} (r : α → α → P @[simp] lemma orderedInsert_length {α : Type} (r : α → α → Prop) [DecidableRel r] (a : α) (l : List α) : (List.orderedInsert r a l).length = (a :: l).length := by - apply List.Perm.length_eq - exact List.perm_orderedInsert r a l + exact List.Perm.length_eq (List.perm_orderedInsert r a l) lemma takeWhile_orderedInsert {α : Type} (r : α → α → Prop) [DecidableRel r] [Std.Total r] [IsTrans α r] From c213518168d55fc79ec82ecf2c6bf608c2b30b8a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:41:19 -0700 Subject: [PATCH 051/498] refactor(qft): golf uncontracted-list proofs Co-authored-by: Claude Opus 4.8 --- .../WickContraction/UncontractedList.lean | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index e33ad8e6f..e0df2a909 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -45,18 +45,13 @@ lemma fin_list_sorted_monotone_sorted {n m : ℕ} (l: List (Fin n)) (hl : l.Pair lemma fin_list_sorted_succAboveEmb_sorted (l: List (Fin n)) (hl : l.Pairwise (· ≤ ·)) (i : Fin n.succ) : ((List.map i.succAboveEmb l)).Pairwise (· ≤ ·) := by - apply fin_list_sorted_monotone_sorted - exact hl - simp only [Fin.coe_succAboveEmb] - exact Fin.strictMono_succAbove i + exact fin_list_sorted_monotone_sorted l hl i.succAboveEmb (Fin.strictMono_succAbove i) lemma fin_finset_sort_map_monotone {n m : ℕ} (a : Finset (Fin n)) (f : Fin n ↪ Fin m) (hf : StrictMono f) : (a.sort (· ≤ ·)).map f = ((a.map f).sort (· ≤ ·)) := by have h1 : ((a.sort (· ≤ ·)).map f).Pairwise (· ≤ ·) := by - apply fin_list_sorted_monotone_sorted - exact a.pairwise_sort (fun x1 x2 => x1 ≤ x2) - exact hf + exact fin_list_sorted_monotone_sorted _ (a.pairwise_sort (fun x1 x2 => x1 ≤ x2)) f hf have h2 : ((a.sort (· ≤ ·)).map f).Nodup := by refine (List.nodup_map_iff_inj_on ?_).mpr ?_ exact a.sort_nodup (fun x1 x2 => x1 ≤ x2) @@ -254,8 +249,7 @@ lemma uncontractedList_length_eq_card (c : WickContraction n) : lemma filter_uncontractedList (c : WickContraction n) (p : Fin n → Prop) [DecidablePred p] : (c.uncontractedList.filter p) = (c.uncontracted.filter p).sort (· ≤ ·) := by have h1 : (c.uncontractedList.filter p).Pairwise (· ≤ ·) := by - apply List.Pairwise.filter - exact uncontractedList_sorted c + exact List.Pairwise.filter _ (uncontractedList_sorted c) have h2 : (c.uncontractedList.filter p).Nodup := by refine List.Nodup.filter _ ?_ exact uncontractedList_nodup c @@ -387,9 +381,7 @@ lemma uncontractedListEmd_strictMono {φs : List 𝓕.FieldOp} {φsΛ : WickCont 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] - apply List.SortedLT.strictMono_get - exact φsΛ.uncontractedList_sorted_lt.sortedLT - exact h + exact List.SortedLT.strictMono_get φsΛ.uncontractedList_sorted_lt.sortedLT h lemma uncontractedListEmd_mem_uncontracted {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length} (i : Fin [φsΛ]ᵘᶜ.length) : uncontractedListEmd i ∈ φsΛ.uncontracted := by @@ -400,8 +392,8 @@ lemma uncontractedListEmd_surjective_mem_uncontracted {φs : List 𝓕.FieldOp} ∃ j, φsΛ.uncontractedListEmd j = i := by simp only [uncontractedListEmd, Equiv.trans_toEmbedding, Function.Embedding.trans_apply, Equiv.coe_toEmbedding, finCongr_apply, Function.Embedding.coe_subtype] - have hj : ∃ j, φsΛ.uncontractedIndexEquiv j = ⟨i, hi⟩ := by - exact φsΛ.uncontractedIndexEquiv.surjective ⟨i, hi⟩ + have hj : ∃ j, φsΛ.uncontractedIndexEquiv j = ⟨i, hi⟩ := + φsΛ.uncontractedIndexEquiv.surjective ⟨i, hi⟩ generalize_proofs h1 obtain ⟨j, hj⟩ := hj have hj' : ∃ j', Fin.cast h1 j' = j := (finCongr h1).surjective j @@ -452,8 +444,7 @@ lemma uncontractedListEmd_empty {φs : List 𝓕.FieldOp} : lemma uncontractedList_succAboveEmb_sorted (c : WickContraction n) (i : Fin n.succ) : ((List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := by - apply fin_list_sorted_succAboveEmb_sorted - exact uncontractedList_sorted c + exact fin_list_sorted_succAboveEmb_sorted c.uncontractedList (uncontractedList_sorted c) i lemma uncontractedList_succAboveEmb_nodup (c : WickContraction n) (i : Fin n.succ) : ((List.map i.succAboveEmb c.uncontractedList)).Nodup := by @@ -464,8 +455,8 @@ lemma uncontractedList_succAboveEmb_nodup (c : WickContraction n) (i : Fin n.suc lemma uncontractedList_succAbove_orderedInsert_nodup (c : WickContraction n) (i : Fin n.succ) : (List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).Nodup := by have h1 : (List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).Perm - (i :: List.map i.succAboveEmb c.uncontractedList) := by - exact List.perm_orderedInsert (fun x1 x2 => x1 ≤ x2) i _ + (i :: List.map i.succAboveEmb c.uncontractedList) := + List.perm_orderedInsert (fun x1 x2 => x1 ≤ x2) i _ apply List.Perm.nodup h1.symm simp only [Nat.succ_eq_add_one, List.nodup_cons, List.mem_map, not_exists, not_and] @@ -540,8 +531,7 @@ lemma uncontractedList_succAboveEmb_eraseIdx_toFinset (c : WickContraction n) (i lemma uncontractedList_succAboveEmb_eraseIdx_sorted (c : WickContraction n) (i : Fin n.succ) (k: ℕ) : ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Pairwise (· ≤ ·) := by - apply Physlib.List.eraseIdx_sorted - exact uncontractedList_succAboveEmb_sorted c i + exact Physlib.List.eraseIdx_sorted (· ≤ ·) _ k (uncontractedList_succAboveEmb_sorted c i) lemma uncontractedList_succAboveEmb_eraseIdx_nodup (c : WickContraction n) (i : Fin n.succ) (k: ℕ) : ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Nodup := by @@ -614,8 +604,7 @@ lemma take_uncontractedListOrderPos_eq_filter_sort (c : WickContraction n) (i : (c.uncontracted.filter (fun x => x.1 < i.1)).sort (· ≤ ·) := by rw [take_uncontractedListOrderPos_eq_filter] have h1 : (c.uncontractedList.filter (fun x => x.1 < i.1)).Pairwise (· ≤ ·) := by - apply List.Pairwise.filter - exact uncontractedList_sorted c + exact List.Pairwise.filter _ (uncontractedList_sorted c) have h2 : (c.uncontractedList.filter (fun x => x.1 < i.1)).Nodup := by refine List.Nodup.filter _ ?_ exact uncontractedList_nodup c From f1c527c6e7e1918c7f8a71300b2ad6f193388bb9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:43:33 -0700 Subject: [PATCH 052/498] refactor(qft): golf contraction sign proofs Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/WickContraction/Join.lean | 9 +++------ .../WickContraction/Sign/InsertNone.lean | 4 ++-- .../WickContraction/Sign/InsertSome.lean | 8 ++++---- .../PerturbationTheory/WickContraction/Sign/Join.lean | 10 ++++------ 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean index 07f8aa54f..9837d3343 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean @@ -52,13 +52,11 @@ def join {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) right symm rw [Finset.mapEmbedding_apply] - apply uncontractedListEmd_finset_disjoint_left - exact ha + exact uncontractedListEmd_finset_disjoint_left b a ha · obtain ⟨a, ha, rfl⟩ := ha right rw [Finset.mapEmbedding_apply] - apply uncontractedListEmd_finset_disjoint_left - exact hb + exact uncontractedListEmd_finset_disjoint_left a b hb · obtain ⟨a, ha, rfl⟩ := ha obtain ⟨b, hb, rfl⟩ := hb simp only [EmbeddingLike.apply_eq_iff_eq] @@ -113,8 +111,7 @@ lemma jointLiftLeft_disjoint_joinLiftRight {φs : List 𝓕.FieldOp} {φsΛ : Wi Disjoint (@joinLiftLeft _ _ _ φsucΛ a).1 (joinLiftRight b).1 := by simp only [joinLiftLeft, joinLiftRight] symm - apply uncontractedListEmd_finset_disjoint_left - exact a.2 + exact uncontractedListEmd_finset_disjoint_left b.1 a.1 a.2 lemma jointLiftLeft_ne_joinLiftRight {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length} {φsucΛ : WickContraction [φsΛ]ᵘᶜ.length} (a : φsΛ.1) (b : φsucΛ.1) : diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean index 250239991..cad815331 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean @@ -171,8 +171,8 @@ lemma signInsertNone_eq_prod_getDual?_Some (φ : 𝓕.FieldOp) (φs : List 𝓕. · rw [Finset.prod_sigma'] rfl rw [← φsΛ.sigmaContractedEquiv.symm.prod_comp] - let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := by - exact (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm + let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := + (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm rw [← e2.symm.prod_comp] simp only [Fin.getElem_fin, Fintype.prod_sum_type] conv_rhs => diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean index c819bae03..7cf174f70 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean @@ -38,8 +38,8 @@ lemma stat_ofFinset_eq_one_of_gradingCompliant (φs : List 𝓕.FieldOp) (hsom : ∀ i, (h : (φsΛ.getDual? i).isSome) → i ∈ a → (φsΛ.getDual? i).get h ∈ a) : (𝓕 |>ₛ ⟨φs.get, a⟩) = 1 := by rw [ofFinset_eq_prod] - let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := by - exact (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm + let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := + (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm rw [← e2.symm.prod_comp] simp only [Fin.getElem_fin, Fintype.prod_sum_type] conv_lhs => @@ -368,8 +368,8 @@ lemma signInsertSomeProd_eq_prod_fin (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldO rw [signInsertSomeProd_eq_prod_prod] rw [Finset.prod_sigma'] erw [← φsΛ.sigmaContractedEquiv.symm.prod_comp] - let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := by - exact (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm + let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := + (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm rw [← e2.symm.prod_comp] simp only [Fin.getElem_fin, Fintype.prod_sum_type] conv_rhs => diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean index 5d544a689..c71d2c0a2 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean @@ -306,8 +306,8 @@ lemma joinSignLeftExtra_eq_joinSignRightExtra {φs : List 𝓕.FieldOp} joinSignLeftExtra h φsucΛ = joinSignRightExtra h φsucΛ := by /- Simplifying joinSignLeftExtra. -/ let e2 : Fin φs.length ≃ {x // (((singleton h).join φsucΛ).getDual? x).isSome} ⊕ - {x // ¬ (((singleton h).join φsucΛ).getDual? x).isSome} := by - exact (Equiv.sumCompl fun a => (((singleton h).join φsucΛ).getDual? a).isSome = true).symm + {x // ¬ (((singleton h).join φsucΛ).getDual? x).isSome} := + (Equiv.sumCompl fun a => (((singleton h).join φsucΛ).getDual? a).isSome = true).symm rw [joinSignLeftExtra, ofFinset_eq_prod, map_prod, ← e2.symm.prod_comp] simp only [Fin.getElem_fin, Fintype.prod_sum_type] conv_lhs => @@ -339,8 +339,7 @@ lemma joinSignLeftExtra_eq_joinSignRightExtra {φs : List 𝓕.FieldOp} have hjneqsnd := singleton_uncontractedEmd_ne_right h (φsucΛ.sndFieldOfContract a) have hl : uncontractedListEmd (φsucΛ.fstFieldOfContract a) < uncontractedListEmd (φsucΛ.sndFieldOfContract a) := by - apply uncontractedListEmd_strictMono - exact fstFieldOfContract_lt_sndFieldOfContract φsucΛ a + exact uncontractedListEmd_strictMono (fstFieldOfContract_lt_sndFieldOfContract φsucΛ a) by_cases hj1 : ¬ uncontractedListEmd (φsucΛ.fstFieldOfContract a) < j · have hi1 : ¬ uncontractedListEmd (φsucΛ.fstFieldOfContract a) < i := by omega simp [hj1, hi1] @@ -418,8 +417,7 @@ lemma join_sign_induction {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs simp only [mul_eq_mul_left_iff] left left - apply sign_congr - exact join_uncontractedListGet (singleton hij) φsucΛ' + exact sign_congr (join_uncontractedListGet (singleton hij) φsucΛ') φsucΛ /-- For a list `φs` of `𝓕.FieldOp`, a grading compliant Wick contraction `φsΛ` of `φs`, and a Wick contraction `φsucΛ` of `[φsΛ]ᵘᶜ`, the following relation holds From 39f4ec83b5974bd671fa07f8fba336f837638302 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:46:01 -0700 Subject: [PATCH 053/498] refactor(qft): golf koszul permutation proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean | 11 +++++------ .../PerturbationTheory/Koszul/KoszulSignInsert.lean | 9 +++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index a778efcd4..b478016ea 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -277,8 +277,8 @@ lemma koszulSign_swap_eq_rel {ψ φ : 𝓕} (h1 : le φ ψ) (h2 : le ψ φ) : ( simp only [List.cons_append, koszulSign] rw [koszulSign_swap_eq_rel h1 h2] congr 1 - apply Wick.koszulSignInsert_eq_perm - exact List.Perm.append_left φs (List.Perm.swap ψ φ φs') + exact Wick.koszulSignInsert_eq_perm q le _ _ _ + (List.Perm.append_left φs (List.Perm.swap ψ φ φs')) lemma koszulSign_eq_rel_eq_stat_append {ψ φ : 𝓕} [IsTrans 𝓕 le] (h1 : le φ ψ) (h2 : le ψ φ) (hq : q ψ = q φ) : (φs : List 𝓕) → @@ -324,8 +324,7 @@ lemma koszulSign_of_sorted : (φs : List 𝓕) @[simp] lemma koszulSign_of_insertionSort [Std.Total le] [IsTrans 𝓕 le] (φs : List 𝓕) : koszulSign q le (List.insertionSort le φs) = 1 := by - apply koszulSign_of_sorted - exact List.pairwise_insertionSort le φs + exact koszulSign_of_sorted q le _ (List.pairwise_insertionSort le φs) lemma koszulSign_of_append_eq_insertionSort_left [Std.Total le] [IsTrans 𝓕 le] : (φs φs' : List 𝓕) → koszulSign q le (φs ++ φs') = @@ -403,8 +402,8 @@ lemma koszulSign_perm_eq_append [IsTrans 𝓕 le] (φ : 𝓕) (φs φs' φs2 : L forall_eq_or_imp, List.cons_append, motive] simp only [koszulSign, ih, mul_eq_mul_right_iff] left - apply koszulSignInsert_eq_perm - exact (List.perm_append_right_iff φs2).mpr h + exact koszulSignInsert_eq_perm q le _ _ _ + ((List.perm_append_right_iff φs2).mpr h) · intro x y l h simp_all only [List.mem_cons, forall_eq_or_imp, List.cons_append] apply Wick.koszulSign_swap_eq_rel_cons diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean index 96add368d..52841c33f 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean @@ -149,14 +149,12 @@ lemma koszulSignInsert_eq_perm (φs φs' : List 𝓕) (φ : 𝓕) (h : φs.Perm intro h' have hg : ofList q (List.filter (fun i => !decide (le φ i)) φs) = ofList q (List.filter (fun i => !decide (le φ i)) φs') := by - apply ofList_perm - exact List.Perm.filter (fun i => !decide (le φ i)) h + exact ofList_perm q (List.Perm.filter (fun i => !decide (le φ i)) h) rw [hg] lemma koszulSignInsert_eq_sort (φs : List 𝓕) (φ : 𝓕) : koszulSignInsert q le φ φs = koszulSignInsert q le φ (List.insertionSort le φs) := by - apply koszulSignInsert_eq_perm - exact List.Perm.symm (List.perm_insertionSort le φs) + exact koszulSignInsert_eq_perm q le _ _ _ (List.Perm.symm (List.perm_insertionSort le φs)) lemma koszulSignInsert_eq_exchangeSign_take [Std.Total le] [IsTrans 𝓕 le] (φ : 𝓕) (φs : List 𝓕) : koszulSignInsert q le φ φs = 𝓢(q φ, ofList q @@ -210,8 +208,7 @@ lemma koszulSignInsert_eq_exchangeSign_take [Std.Total le] [IsTrans 𝓕 le] (φ lemma koszulSignInsert_insertIdx (i j : 𝓕) (r : List 𝓕) (n : ℕ) (hn : n ≤ r.length) : koszulSignInsert q le j (List.insertIdx r n i) = koszulSignInsert q le j (i :: r) := by - apply koszulSignInsert_eq_perm - exact List.perm_insertIdx i r hn + exact koszulSignInsert_eq_perm q le _ _ _ (List.perm_insertIdx i r hn) /-- The difference in `koszulSignInsert` on inserting `r0` into `r` compared to into `r1 :: r` for any `r`. -/ From fbefbc59d07905aa8f9bb2f235ee32c515946b85 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:47:26 -0700 Subject: [PATCH 054/498] refactor(qft): golf field-specification wrappers Co-authored-by: Claude Opus 4.8 --- .../FieldSpecification/CrAnSection.lean | 3 +-- .../FieldSpecification/NormalOrder.lean | 4 ++-- .../FieldSpecification/TimeOrder.lean | 23 +++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 6067efcf6..46cd2534f 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -140,8 +140,7 @@ def consEquiv {φ : 𝓕.FieldOp} {φs : List 𝓕.FieldOp} : CrAnSection (φ :: match ψψs with | (ψ, ψs) => cons ψ ψs left_inv ψs := by - apply Subtype.ext - exact Eq.symm eq_head_cons_tail + exact Subtype.ext (Eq.symm eq_head_cons_tail) right_inv ψψs := by match ψψs with | (ψ, ψs) => rfl diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index 7ad2e23e2..b0f10b2e8 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -180,8 +180,8 @@ lemma normalOrderSign_swap_create_create (φc φc' : 𝓕.CrAnFieldOp) dsimp only [normalOrderSign, Wick.koszulSign] rw [← normalOrderSign] simp only [mul_eq_mul_right_iff] - apply Or.inl (Wick.koszulSignInsert_eq_perm _ _ _ _ _ _) - exact List.Perm.append_left φs (List.Perm.swap φc' φc φs') + exact Or.inl (Wick.koszulSignInsert_eq_perm _ _ _ _ _ + (List.Perm.append_left φs (List.Perm.swap φc' φc φs'))) lemma normalOrderSign_swap_annihilate_annihilate_fst (φa φa' : 𝓕.CrAnFieldOp) (hφa : 𝓕 |>ᶜ φa = CreateAnnihilate.annihilate) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean index 96b35b211..0c7f31bbe 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean @@ -120,13 +120,13 @@ def maxTimeFieldPosFin (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : lemma lt_maxTimeFieldPosFin_not_timeOrder (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) (i : Fin (eraseMaxTimeField φ φs).length) (hi : (maxTimeFieldPosFin φ φs).succAbove i < maxTimeFieldPosFin φ φs) : - ¬ timeOrderRel ((eraseMaxTimeField φ φs)[i.val]) (maxTimeField φ φs) := by - exact insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt timeOrderRel φ φs i hi + ¬ timeOrderRel ((eraseMaxTimeField φ φs)[i.val]) (maxTimeField φ φs) := + insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt timeOrderRel φ φs i hi lemma timeOrder_maxTimeField (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) (i : Fin (eraseMaxTimeField φ φs).length) : - timeOrderRel (maxTimeField φ φs) ((eraseMaxTimeField φ φs)[i.val]) := by - exact insertionSortMin_lt_mem_insertionSortDropMinPos timeOrderRel φ φs _ + timeOrderRel (maxTimeField φ φs) ((eraseMaxTimeField φ φs)[i.val]) := + insertionSortMin_lt_mem_insertionSortDropMinPos timeOrderRel φ φs _ /-- The sign associated with putting a list of states into time order (with the state of greatest time to the left). @@ -182,8 +182,8 @@ lemma timeOrderList_nil : timeOrderList (𝓕 := 𝓕) [] = [] := by simp [timeOrderList] lemma timeOrderList_eq_maxTimeField_timeOrderList (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : - timeOrderList (φ :: φs) = maxTimeField φ φs :: timeOrderList (eraseMaxTimeField φ φs) := by - exact insertionSort_eq_insertionSortMin_cons timeOrderRel φ φs + timeOrderList (φ :: φs) = maxTimeField φ φs :: timeOrderList (eraseMaxTimeField φ φs) := + insertionSort_eq_insertionSortMin_cons timeOrderRel φ φs /-! @@ -226,8 +226,8 @@ instance : IsTrans 𝓕.CrAnFieldOp 𝓕.crAnTimeOrderRel where trans a b c := IsTrans.trans (r := 𝓕.timeOrderRel) a.1 b.1 c.1 @[simp] -lemma crAnTimeOrderRel_refl (φ : 𝓕.CrAnFieldOp) : crAnTimeOrderRel φ φ := by - exact (Std.Total.to_refl (r := 𝓕.crAnTimeOrderRel)).refl φ +lemma crAnTimeOrderRel_refl (φ : 𝓕.CrAnFieldOp) : crAnTimeOrderRel φ φ := + (Std.Total.to_refl (r := 𝓕.crAnTimeOrderRel)).refl φ /-- For a field specification `𝓕`, and a list `φs` of `𝓕.CrAnFieldOp`, `𝓕.crAnTimeOrderSign φs` is the sign corresponding to the number of `ferimionic`-`fermionic` @@ -255,8 +255,8 @@ lemma crAnTimeOrderSign_pair_not_ordered {φ ψ : 𝓕.CrAnFieldOp} (h : ¬ crAn lemma crAnTimeOrderSign_swap_eq_time {φ ψ : 𝓕.CrAnFieldOp} (h1 : crAnTimeOrderRel φ ψ) (h2 : crAnTimeOrderRel ψ φ) (φs φs' : List 𝓕.CrAnFieldOp) : - crAnTimeOrderSign (φs ++ φ :: ψ :: φs') = crAnTimeOrderSign (φs ++ ψ :: φ :: φs') := by - exact Wick.koszulSign_swap_eq_rel _ _ h1 h2 _ _ + crAnTimeOrderSign (φs ++ φ :: ψ :: φs') = crAnTimeOrderSign (φs ++ ψ :: φ :: φs') := + Wick.koszulSign_swap_eq_rel _ _ h1 h2 _ _ /-- For a field specification `𝓕`, and a list `φs` of `𝓕.CrAnFieldOp`, `𝓕.crAnTimeOrderList φs` is the list `φs` time-ordered using the insertion sort algorithm. -/ @@ -416,8 +416,7 @@ lemma orderedInsert_crAnTimeOrderRel_crAnSection {φ : 𝓕.FieldOp} {ψ : 𝓕. rw [← h1.1] at hr simp only [crAnFieldOpToFieldOp] at hr simp only [hr, ↓reduceIte, List.map_cons, List.cons.injEq] - apply And.intro h1.1 - exact orderedInsert_crAnTimeOrderRel_crAnSection h ⟨ψs, h1.2⟩ + exact And.intro h1.1 (orderedInsert_crAnTimeOrderRel_crAnSection h ⟨ψs, h1.2⟩) lemma crAnTimeOrderList_crAnSection_is_crAnSection : {φs : List 𝓕.FieldOp} → (ψs : CrAnSection φs) → (crAnTimeOrderList ψs.1).map 𝓕.crAnFieldOpToFieldOp = timeOrderList φs From 759cf5346121cc38a5a4cdf101e1a86dc4c373b7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:50:01 -0700 Subject: [PATCH 055/498] refactor(qft): golf grading wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/Grading.lean | 6 ++---- .../FieldOpFreeAlgebra/TimeOrder.lean | 6 ++---- .../WickAlgebra/Grading.lean | 18 ++++++------------ .../WickAlgebra/SuperCommute.lean | 7 +++---- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean index 40f76ac7d..3a45616a1 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean @@ -105,8 +105,7 @@ lemma bosonicProjF_of_bonosic_part lemma bosonicProjF_of_fermionic_part (a : DirectSum FieldStatistic (fun i => (statisticSubmodule (𝓕 := 𝓕) i))) : bosonicProjF (a fermionic).1 = 0 := by - apply bosonicProjF_of_mem_fermionic - exact Submodule.coe_mem (a.toFun fermionic) + exact bosonicProjF_of_mem_fermionic (a.toFun fermionic).1 (Submodule.coe_mem (a.toFun fermionic)) /-- The projection of an element of `FieldOpFreeAlgebra` onto it's fermionic part. -/ def fermionicProjF : 𝓕.FieldOpFreeAlgebra →ₗ[ℂ] statisticSubmodule (𝓕 := 𝓕) fermionic := @@ -172,8 +171,7 @@ lemma fermionicProjF_of_mem_bosonic (a : 𝓕.FieldOpFreeAlgebra) lemma fermionicProjF_of_bosonic_part (a : DirectSum FieldStatistic (fun i => (statisticSubmodule (𝓕 := 𝓕) i))) : fermionicProjF (a bosonic).1 = 0 := by - apply fermionicProjF_of_mem_bosonic - exact Submodule.coe_mem (a.toFun bosonic) + exact fermionicProjF_of_mem_bosonic (a.toFun bosonic).1 (Submodule.coe_mem (a.toFun bosonic)) @[simp] lemma fermionicProjF_of_fermionic_part diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean index 8f07abd3c..609add0c7 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean @@ -277,8 +277,7 @@ lemma timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_all_not_crAnTimeOrderRel by_cases h12 : ¬ crAnTimeOrderRel φ1 φ2 · have h13 : ¬ crAnTimeOrderRel φ1 φ3 := by intro h13 - apply h12 - exact IsTrans.trans φ1 φ3 φ2 h13 h32 + exact h12 (IsTrans.trans φ1 φ3 φ2 h13 h32) rw [timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_not_crAnTimeOrderRel h12 h13] simp_all only [Decidable.not_not, forall_const] have h13 : crAnTimeOrderRel φ1 φ3 := IsTrans.trans φ1 φ2 φ3 h12 h23 @@ -287,8 +286,7 @@ lemma timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_all_not_crAnTimeOrderRel · simp_all only [IsEmpty.forall_iff] have h31 : ¬ crAnTimeOrderRel φ3 φ1 := by intro h31 - apply h21 - exact IsTrans.trans φ2 φ3 φ1 h23 h31 + exact h21 (IsTrans.trans φ2 φ3 φ1 h23 h31) rw [timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_not_crAnTimeOrderRel' h21 h31] simp_all only [Decidable.not_not, forall_const] refine False.elim (h ?_) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean index 077cdd961..5c3512d32 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean @@ -44,8 +44,7 @@ lemma mem_bosonic_of_mem_free_bosonic (a : 𝓕.FieldOpFreeAlgebra) simp only [Set.mem_setOf_eq] at hx obtain ⟨φs, rfl, h⟩ := hx simp [p] - apply ofCrAnList_mem_statSubmodule_of_eq - exact h + exact ofCrAnList_mem_statSubmodule_of_eq φs bosonic h · simp only [map_zero, p] exact Submodule.zero_mem (statSubmodule bosonic) · intro x y hx hy hpx hpy @@ -65,8 +64,7 @@ lemma mem_fermionic_of_mem_free_fermionic (a : 𝓕.FieldOpFreeAlgebra) simp only [Set.mem_setOf_eq] at hx obtain ⟨φs, rfl, h⟩ := hx simp [p] - apply ofCrAnList_mem_statSubmodule_of_eq - exact h + exact ofCrAnList_mem_statSubmodule_of_eq φs fermionic h · simp only [map_zero, p] exact Submodule.zero_mem (statSubmodule fermionic) · intro x y hx hy hpx hpy @@ -292,14 +290,12 @@ lemma eq_zero_of_bosonic_and_fermionic {a : 𝓕.WickAlgebra} @[simp] lemma bosonicProj_fermionicProj_eq_zero (a : 𝓕.WickAlgebra) : bosonicProj (fermionicProj a).1 = 0 := by - apply bosonicProj_mem_fermionic - exact Submodule.coe_mem (fermionicProj a) + exact bosonicProj_mem_fermionic (fermionicProj a).1 (Submodule.coe_mem (fermionicProj a)) @[simp] lemma fermionicProj_bosonicProj_eq_zero (a : 𝓕.WickAlgebra) : fermionicProj (bosonicProj a).1 = 0 := by - apply fermionicProj_mem_bosonic - exact Submodule.coe_mem (bosonicProj a) + exact fermionicProj_mem_bosonic (bosonicProj a).1 (Submodule.coe_mem (bosonicProj a)) @[simp] lemma bosonicProj_bosonicProj_eq_bosonicProj (a : 𝓕.WickAlgebra) : @@ -321,15 +317,13 @@ lemma bosonicProj_of_bosonic_part lemma bosonicProj_of_fermionic_part (a : DirectSum FieldStatistic (fun i => (statSubmodule (𝓕 := 𝓕) i))) : bosonicProj (a fermionic).1 = 0 := by - apply bosonicProj_mem_fermionic - exact Submodule.coe_mem (a.toFun fermionic) + exact bosonicProj_mem_fermionic (a.toFun fermionic).1 (Submodule.coe_mem (a.toFun fermionic)) @[simp] lemma fermionicProj_of_bosonic_part (a : DirectSum FieldStatistic (fun i => (statSubmodule (𝓕 := 𝓕) i))) : fermionicProj (a bosonic).1 = 0 := by - apply fermionicProj_mem_bosonic - exact Submodule.coe_mem (a.toFun bosonic) + exact fermionicProj_mem_bosonic (a.toFun bosonic).1 (Submodule.coe_mem (a.toFun bosonic)) @[simp] lemma fermionicProj_of_fermionic_part diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 21265d3be..b972bd48d 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -42,8 +42,7 @@ lemma ι_superCommuteF_eq_zero_of_ι_left_zero (a b : 𝓕.FieldOpFreeAlgebra) ( lemma ι_superCommuteF_right_zero_of_mem_ideal (a b : 𝓕.FieldOpFreeAlgebra) (h : b ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet) : ι [a, b]ₛF = 0 := by - apply ι_superCommuteF_eq_zero_of_ι_right_zero - exact (ι_eq_zero_iff_mem_ideal b).mpr h + exact ι_superCommuteF_eq_zero_of_ι_right_zero a b ((ι_eq_zero_iff_mem_ideal b).mpr h) lemma ι_superCommuteF_eq_of_equiv_right (a b1 b2 : 𝓕.FieldOpFreeAlgebra) (h : b1 ≈ b2) : ι [a, b1]ₛF = ι [a, b2]ₛF := by @@ -84,8 +83,8 @@ lemma superCommuteRight_eq_of_equiv (a1 a2 : 𝓕.FieldOpFreeAlgebra) (h : a1 obtain ⟨b, rfl⟩ := ι_surjective b have ha1b1 : (superCommuteRight (a1 - a2)) (ι b) = 0 := by rw [superCommuteRight_apply_ι] - apply ι_superCommuteF_eq_zero_of_ι_left_zero - exact (ι_eq_zero_iff_mem_ideal (a1 - a2)).mpr h + exact ι_superCommuteF_eq_zero_of_ι_left_zero (a1 - a2) b + ((ι_eq_zero_iff_mem_ideal (a1 - a2)).mpr h) simp_all only [superCommuteRight_apply_ι, map_sub, LinearMap.sub_apply] trans ι ((superCommuteF a2) b) + 0 rw [← ha1b1] From b1a897d885e91cb695e46f232f71ca05377943d7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:52:41 -0700 Subject: [PATCH 056/498] refactor(qft): golf qed anomaly wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/AnomalyCancellation/Basic.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean | 7 ++----- .../QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 11 ++++------- .../AnomalyCancellation/Even/Parameterization.lean | 4 ++-- .../QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 11 ++++------- .../QED/AnomalyCancellation/Odd/Parameterization.lean | 4 ++-- 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/Physlib/QFT/AnomalyCancellation/Basic.lean b/Physlib/QFT/AnomalyCancellation/Basic.lean index d9b158e81..dcd68a49c 100644 --- a/Physlib/QFT/AnomalyCancellation/Basic.lean +++ b/Physlib/QFT/AnomalyCancellation/Basic.lean @@ -384,8 +384,7 @@ lemma quadSolsIncl_injective (χ : ACCSystemQuad) : Function.Injective χ.quadSolsIncl := by intro S T h have h' : χ.quadSolsInclLinSols S = χ.quadSolsInclLinSols T := by - apply ACCSystemLinear.linSolsIncl_injective (χ := χ.toACCSystemLinear) - exact h + exact ACCSystemLinear.linSolsIncl_injective (χ := χ.toACCSystemLinear) h exact quadSolsInclLinSols_injective χ h' end ACCSystemQuad diff --git a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean index 13008404c..0e306e47b 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean @@ -64,9 +64,7 @@ lemma lt_eq {k i : Fin n.succ} (hk : S k ≤ 0) (hik : i ≤ k) : S i = S k := b include hS in lemma val_le_zero {i : Fin n.succ} (hi : S i ≤ 0) : S i = S (0 : Fin n.succ) := by - symm - apply lt_eq hS hi - exact Fin.zero_le i + exact (lt_eq hS hi (Fin.zero_le i)).symm include hS in lemma gt_eq {k i: Fin n.succ} (hk : 0 ≤ S k) (hik : k ≤ i) : S i = S k := by @@ -208,8 +206,7 @@ lemma AFL_odd_zero {A : (PureU1 (2 * n + 1)).LinSols} (h : ConstAbsSorted A.val) theorem AFL_odd (A : (PureU1 (2 * n + 1)).LinSols) (h : ConstAbsSorted A.val) : A = 0 := by - apply ACCSystemLinear.LinSols.ext - exact is_zero h (AFL_odd_zero h) + exact ACCSystemLinear.LinSols.ext (is_zero h (AFL_odd_zero h)) lemma AFL_even_Boundary {A : (PureU1 (2 * n.succ)).LinSols} (h : ConstAbsSorted A.val) (hA : A.val (0 : Fin (2 * n.succ)) ≠ 0) {k : Fin (2 * n + 1)} (hk : Boundary A.val k) : diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index fe04ec596..adfe2a8ee 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -917,8 +917,8 @@ def Pa' (f : (Fin n.succ) ⊕ (Fin n) → ℚ) : (PureU1 (2 * n.succ)).LinSols : ∑ i, f i • basisa i lemma Pa'_P'_P!' (f : (Fin n.succ) ⊕ (Fin n) → ℚ) : - Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := by - exact Fintype.sum_sum_type _ + Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := + Fintype.sum_sum_type _ /-! @@ -1037,9 +1037,7 @@ lemma span_basis_swap! {S : (PureU1 (2 * n.succ)).LinSols} (j : Fin n) (S.val (evenShiftSnd j) - S.val (evenShiftFst j)) • basis!AsCharges j ∧ g' = g := by let X := P! f + (S.val (evenShiftSnd j) - S.val (evenShiftFst j)) • basis!AsCharges j have hX : X ∈ Submodule.span ℚ (Set.range (basis!AsCharges)) := by - apply Submodule.add_mem - exact (P!_in_span f) - exact (smul_basis!AsCharges_in_span S j) + exact Submodule.add_mem _ (P!_in_span f) (smul_basis!AsCharges_in_span S j) have hXsum := (Submodule.mem_span_range_iff_exists_fun ℚ).mp hX obtain ⟨f', hf'⟩ := hXsum use g @@ -1048,8 +1046,7 @@ lemma span_basis_swap! {S : (PureU1 (2 * n.succ)).LinSols} (j : Fin n) erw [hf'] simp only [and_self, and_true, X] rw [← add_assoc, ← h] - apply swap!_as_add at hS - exact hS + exact swap!_as_add j hS end VectorLikeEvenPlane diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean index 5c469ac08..62cbbaf6f 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean @@ -108,8 +108,8 @@ lemma generic_or_special (S : (PureU1 (2 * n.succ)).Sols) : GenericCase S ∨ SpecialCase S := by obtain ⟨g, f, h⟩ := span_basis S.1.1 have h1 : accCubeTriLinSymm (P g) (P g) (P! f) ≠ 0 ∨ - accCubeTriLinSymm (P g) (P g) (P! f) = 0 := by - exact ne_or_eq _ _ + accCubeTriLinSymm (P g) (P g) (P! f) = 0 := + ne_or_eq _ _ rcases h1 with h1 | h1 · exact Or.inl (genericCase_exists S ⟨g, f, h, h1⟩) · exact Or.inr (specialCase_exists S ⟨g, f, h, h1⟩) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 13dd61bd3..4f2853631 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -876,8 +876,8 @@ def Pa' (f : (Fin n) ⊕ (Fin n) → ℚ) : (PureU1 (2 * n + 1)).LinSols := ∑ i, f i • basisa i lemma Pa'_P'_P!' (f : (Fin n) ⊕ (Fin n) → ℚ) : - Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := by - exact Fintype.sum_sum_type _ + Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := + Fintype.sum_sum_type _ /-! @@ -1010,9 +1010,7 @@ lemma span_basis_swap! {S : (PureU1 (2 * n.succ + 1)).LinSols} (j : Fin n.succ) apply Submodule.subset_span simp_all only [Set.mem_range, exists_apply_eq_apply] have hX : X ∈ Submodule.span ℚ (Set.range (basis!AsCharges)) := by - apply Submodule.add_mem - exact hf - exact hP + exact Submodule.add_mem _ hf hP have hXsum := (Submodule.mem_span_range_iff_exists_fun ℚ).mp hX obtain ⟨f', hf'⟩ := hXsum use g @@ -1021,8 +1019,7 @@ lemma span_basis_swap! {S : (PureU1 (2 * n.succ + 1)).LinSols} (j : Fin n.succ) erw [hf'] simp only [and_self, and_true, X] rw [← add_assoc, ← hS1] - apply swap!_as_add at hS - exact hS + exact swap!_as_add j hS end VectorLikeOddPlane diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean index 567fbb4a6..8a502f6df 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean @@ -110,8 +110,8 @@ lemma generic_or_special (S : (PureU1 (2 * n.succ + 1)).Sols) : GenericCase S ∨ SpecialCase S := by obtain ⟨g, f, h⟩ := span_basis S.1.1 have h1 : accCubeTriLinSymm (P g) (P g) (P! f) ≠ 0 ∨ - accCubeTriLinSymm (P g) (P g) (P! f) = 0 := by - exact ne_or_eq _ _ + accCubeTriLinSymm (P g) (P g) (P! f) = 0 := + ne_or_eq _ _ cases h1 <;> rename_i h1 · exact Or.inl (genericCase_exists S ⟨g, f, h, h1⟩) · exact Or.inr (specialCase_exists S ⟨g, f, h, h1⟩) From 62333d1f291d3be08af8a3925c65fcb78f9ec613 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:54:41 -0700 Subject: [PATCH 057/498] refactor(particles): golf charge-spectrum wrappers Co-authored-by: Claude Opus 4.8 --- .../StandardModel/AnomalyCancellation/Basic.lean | 4 ++-- .../SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean | 3 +-- .../SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean | 6 +++--- .../SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean | 9 +++------ Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean | 3 +-- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index 6220cac81..15d743d35 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -59,8 +59,8 @@ lemma toSpecies_apply_eq (i : Fin 5) (S : (SMCharges n).Charges) : lemma charges_eq_toSpecies_eq (S T : (SMCharges n).Charges) : S = T ↔ ∀ i, toSpecies i S = toSpecies i T := by refine Iff.intro (fun a i => congrArg (⇑(toSpecies i)) a) (fun h => ?_) - apply toSpeciesEquiv.injective - exact (Set.eqOn_univ (toSpeciesEquiv S) (toSpeciesEquiv T)).mp fun ⦃x⦄ _ => h x + exact toSpeciesEquiv.injective + ((Set.eqOn_univ (toSpeciesEquiv S) (toSpeciesEquiv T)).mp fun ⦃x⦄ _ => h x) lemma toSMSpecies_toSpecies_inv (i : Fin 5) (f : Fin 5 → Fin n → ℚ) : (toSpecies i) (toSpeciesEquiv.symm f) = f i := by diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean index b615cfc72..6769f8402 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean @@ -114,8 +114,7 @@ lemma allowsTerm_of_has_minimallyAllowsTerm_subset (hx : ∃ y ∈ powerset x, y.MinimallyAllowsTerm T) : x.AllowsTerm T := by obtain ⟨y, hy⟩ := hx simp only [mem_powerset_iff_subset] at hy - apply allowsTerm_mono hy.1 - exact allowsTerm_of_minimallyAllowsTerm hy.2 + exact allowsTerm_mono hy.1 (allowsTerm_of_minimallyAllowsTerm hy.2) /-! diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean index 50135936b..f3efe403a 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean @@ -230,9 +230,9 @@ def completeMinSubset (S5 S10 : Finset 𝓩) : Multiset (ChargeSpectrum 𝓩) := lemma completeMinSubset_nodup {S5 S10 : Finset 𝓩} : (completeMinSubset S5 S10).Nodup := by simp [completeMinSubset] - apply Multiset.Nodup.filter - exact Multiset.nodup_dedup - ((minimallyAllowsTermsOfFinset S5 S10 topYukawa).bind (completionsTopYukawa S5)) + exact Multiset.Nodup.filter _ + (Multiset.nodup_dedup + ((minimallyAllowsTermsOfFinset S5 S10 topYukawa).bind (completionsTopYukawa S5))) /-! diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean index b71d45960..705a9039a 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean @@ -84,11 +84,9 @@ lemma ofYukawaTerms_subset_of_subset [DecidableEq 𝓩] {x y : ChargeSpectrum intro hr rcases hr with hr | hr · left - apply ofPotentialTerm'_mono h - exact hr + exact ofPotentialTerm'_mono h topYukawa hr · right - apply ofPotentialTerm'_mono h - exact hr + exact ofPotentialTerm'_mono h bottomYukawa hr /-! @@ -131,8 +129,7 @@ lemma ofYukawaTermsNSum_subset_of_subset [DecidableEq 𝓩] {x y : ChargeSpectru · exact ih hz1 use z2 simp_all only [and_true] - apply ofYukawaTerms_subset_of_subset h - exact hz2 + exact ofYukawaTerms_subset_of_subset h hz2 /-! diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean index c0b4841c6..89ba6a9f8 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean @@ -953,8 +953,7 @@ lemma mem_liftCharge_of_exists_toCharges_toFluxesTen (c : Finset 𝓩) {x : TenQ refine (Multiset.cons_le_of_notMem ?_).mpr ⟨?_, ?_⟩ · simp · rw [← hp2_2] - apply Multiset.erase_subset p1 x - exact hp2 + exact Multiset.erase_subset p1 x hp2 simp only [Multiset.singleton_le] rw [← hp3_2] apply Multiset.erase_subset p1 x From bc9e4293d38bb08632efedfa93be4dafd2ec3e20 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:56:57 -0700 Subject: [PATCH 058/498] refactor(variational): golf adjoint wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean | 6 +++--- Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean | 6 ++---- Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean | 6 +++--- Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean | 6 ++---- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index 0bcaef70b..9304ac6a1 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -587,9 +587,9 @@ lemma sum {ι : Type} [Fintype ι] fun_prop · intro i ι' hp F F' u hu ih simp only [Fintype.sum_option] - apply HasVarAdjDerivAt.add - exact ih none - exact hp (fun i_1 => F (some i_1)) (fun i_1 => F' (some i_1)) u hu fun i_1 => ih (some i_1) + exact HasVarAdjDerivAt.add _ _ _ _ _ (ih none) + (hp (fun i_1 => F (some i_1)) (fun i_1 => F' (some i_1)) u hu fun i_1 => + ih (some i_1)) exact hp F F' u hu hF lemma mul diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean index e2f94e512..9be1a202f 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean @@ -696,8 +696,7 @@ lemma fst {F'} {F : (X → U) → (X → W×V)} (fun φ x => (F φ x).1) (fun φ x => F' (fun x' => (φ x', 0)) x) where test_fun_preserving _ hφ := by - apply IsTestFunction.prod_fst - exact hF.test_fun_preserving _ hφ + exact IsTestFunction.prod_fst (hF.test_fun_preserving _ hφ) test_fun_preserving' y hφ := by apply hF.test_fun_preserving' fun_prop @@ -722,8 +721,7 @@ lemma snd {F'} {F : (X → U) → (X → W×V)} (fun φ x => (F φ x).2) (fun φ x => F' (fun x' => (0, φ x')) x) where test_fun_preserving _ hφ := by - apply IsTestFunction.prod_snd - exact hF.test_fun_preserving _ hφ + exact IsTestFunction.prod_snd (hF.test_fun_preserving _ hφ) test_fun_preserving' y hφ := by apply hF.test_fun_preserving' _ fun_prop diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean b/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean index 4698332a5..d26795542 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean @@ -103,9 +103,9 @@ lemma HasVarGradientAt.sum {ι : Type} [Fintype ι] (F : ι → (X → U) → (X rfl · intro i ι' hp F F' u hu ih simp only [Fintype.sum_option] - apply HasVarGradientAt.add - exact ih none - exact hp (fun i_1 => F (some i_1)) (fun i_1 => F' (some i_1)) u hu fun i_1 => ih (some i_1) + exact HasVarGradientAt.add _ _ (ih none) + (hp (fun i_1 => F (some i_1)) (fun i_1 => F' (some i_1)) u hu fun i_1 => + ih (some i_1)) exact hp F grad u hu h lemma HasVarGradientAt.neg {F : (X → U) → (X → ℝ)} diff --git a/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean b/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean index dd3e9fbcb..8cde56080 100644 --- a/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean +++ b/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean @@ -233,8 +233,7 @@ lemma IsTestFunction.of_fderiv {f : X → U} (hf : IsTestFunction f) : · fun_prop · exact Preorder.le_refl (∞ + 1) supp := by - apply HasCompactSupport.fderiv - exact hf.supp + exact HasCompactSupport.fderiv ℝ hf.supp @[fun_prop] lemma IsTestFunction.fderiv_apply {f : X → U} (hf : IsTestFunction f) (δx : X) : @@ -246,8 +245,7 @@ lemma IsTestFunction.fderiv_apply {f : X → U} (hf : IsTestFunction f) (δx : X · fun_prop · exact Preorder.le_refl (∞ + 1) supp := by - apply HasCompactSupport.fderiv_apply - exact hf.supp + exact HasCompactSupport.fderiv_apply ℝ hf.supp δx open InnerProductSpace' in @[fun_prop] From 5899726edb2bf70c6374e56008bf9b90f28ba156 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 11:59:03 -0700 Subject: [PATCH 059/498] refactor: golf miscellaneous wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../HarmonicOscillator/ConfigurationSpace.lean | 3 +-- .../ClassicalMechanics/HarmonicOscillator/Solution.lean | 8 ++------ Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean | 3 +-- Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean | 3 +-- Physlib/Units/UnitDependent.lean | 3 +-- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean index 7465a6b57..f9207401c 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean @@ -119,8 +119,7 @@ def valHomeomorphism : ConfigurationSpace ≃ₜ EuclideanSpace ℝ (Fin 1) wher toEquiv := valEquiv continuous_toFun := continuous_induced_dom continuous_invFun := by - apply continuous_induced_rng.mpr - exact continuous_id + exact continuous_induced_rng.mpr continuous_id /-- Configuration space is Hausdorff, transported from `EuclideanSpace ℝ (Fin 1)` across the coordinate homeomorphism. -/ diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index a582a03bb..d561c700d 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -1217,18 +1217,14 @@ lemma return_time (IC : InitialConditions) (non_trivial : IC.x₀ ≠ 0 ∨ IC.v have zero_lt_det : 0 < det := by cases non_trivial with | inl hx => - have xx_gt_zero : 0 < xx := by - apply real_inner_self_pos.mpr - exact hx + have xx_gt_zero : 0 < xx := real_inner_self_pos.mpr hx calc 0 < xx * S.ω^2 := by bound _ ≤ ‖IC.v₀‖^2 + xx * S.ω^2 := by bound _ = vv + xx * S.ω^2 := by rw [← real_inner_self_eq_norm_sq IC.v₀] _ = det := rfl | inr hv => - have vv_gt_zero : 0 < vv := by - apply real_inner_self_pos.mpr - exact hv + have vv_gt_zero : 0 < vv := real_inner_self_pos.mpr hv calc 0 < vv := vv_gt_zero _ ≤ vv + ‖IC.x₀‖^2 * S.ω^2 := by bound diff --git a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean index 0e46651d2..98cf01af9 100644 --- a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean @@ -93,8 +93,7 @@ lemma toQuadraticForm_posDef (g : RiemannianMetric I n M) (x : M) : lemma riemannian_metric_negDim_zero (g : RiemannianMetric I n M) (x : M) : (g.toQuadraticForm x).negDim = 0 := by - apply QuadraticForm.rankNeg_eq_zero - exact g.toQuadraticForm_posDef x + exact QuadraticForm.rankNeg_eq_zero (g.toQuadraticForm_posDef x) /-! ## InnerProductSpace structure from RiemannianMetric -/ diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 652967d5e..0b9b97e02 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -381,8 +381,7 @@ lemma μBolt_ne_zero_of_μ_ne_zero (T : Temperature) (h : 𝓒.μ ≠ 0) : instance (T : Temperature) [NeZero 𝓒.μ] : NeZero (𝓒.μBolt T) := by refine { out := ?_ } - apply μBolt_ne_zero_of_μ_ne_zero - exact Ne.symm (NeZero.ne' 𝓒.μ) + exact μBolt_ne_zero_of_μ_ne_zero 𝓒 T (Ne.symm (NeZero.ne' 𝓒.μ)) instance (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] [IsFiniteMeasure (𝓒1.μBolt T)] : IsFiniteMeasure ((𝓒 + 𝓒1).μBolt T) := by diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 1c9157018..b8b35c3bb 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -279,8 +279,7 @@ noncomputable instance {M : Type} [AddCommMonoid M] [Module ℝ M] enter [1, m] rw [toDimensionful_apply_apply] change Continuous fun m => (u1.dimScale u2 (dim M)).1 • m - apply Continuous.const_smul - exact continuous_id' + exact Continuous.const_smul continuous_id' _ /-! From f0445d19e4b9f99906e8661c5ac3da176f3f06c2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:01:12 -0700 Subject: [PATCH 060/498] refactor(electromagnetism): golf current-density wrappers Co-authored-by: Claude Opus 4.8 --- .../Electromagnetism/Dynamics/CurrentDensity.lean | 14 ++++++-------- Physlib/Electromagnetism/Dynamics/IsExtrema.lean | 5 ++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean index ff8964147..7987e2646 100644 --- a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean @@ -103,8 +103,7 @@ lemma chargeDensity_differentiable {d : ℕ} {c : SpeedOfLight} {J : LorentzCurr (hJ : Differentiable ℝ J) : Differentiable ℝ ↿(J.chargeDensity c) := by rw [chargeDensity_eq_timeSlice] apply timeSlice_differentiable - apply Differentiable.fun_const_smul - exact (SpaceTime.differentiable_vector J).mpr hJ (Sum.inl 0) + exact Differentiable.fun_const_smul ((SpaceTime.differentiable_vector J).mpr hJ (Sum.inl 0)) _ lemma chargeDensity_differentiable_space {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (t : Time) : @@ -121,8 +120,7 @@ lemma chargeDensity_contDiff {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDen (hJ : ContDiff ℝ n J) : ContDiff ℝ n ↿(J.chargeDensity c) := by rw [chargeDensity_eq_timeSlice] apply timeSlice_contDiff - apply ContDiff.const_smul - exact (SpaceTime.contDiff_vector J).mpr hJ (Sum.inl 0) + exact ContDiff.const_smul _ ((SpaceTime.contDiff_vector J).mpr hJ (Sum.inl 0)) /-! @@ -159,8 +157,8 @@ lemma currentDensity_zero {d : ℕ} {c : SpeedOfLight}: lemma currentDensity_differentiable {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) : Differentiable ℝ ↿(J.currentDensity c) := by rw [currentDensity_eq_timeSlice] - apply timeSlice_differentiable - exact differentiable_euclidean.mpr fun i => (SpaceTime.differentiable_vector J).mpr hJ (Sum.inr i) + exact timeSlice_differentiable c _ + (differentiable_euclidean.mpr fun i => (SpaceTime.differentiable_vector J).mpr hJ (Sum.inr i)) lemma currentDensity_apply_differentiable {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (i : Fin d) : @@ -201,8 +199,8 @@ lemma currentDensity_apply_differentiable_time {d : ℕ} {c : SpeedOfLight} lemma currentDensity_ContDiff {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : ContDiff ℝ n J) : ContDiff ℝ n ↿(J.currentDensity c) := by rw [currentDensity_eq_timeSlice] - apply timeSlice_contDiff - exact contDiff_euclidean.mpr fun i => (SpaceTime.contDiff_vector J).mpr hJ (Sum.inr i) + exact timeSlice_contDiff c _ + (contDiff_euclidean.mpr fun i => (SpaceTime.contDiff_vector J).mpr hJ (Sum.inr i)) end LorentzCurrentDensity diff --git a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean index e118d69a7..9e2502a51 100644 --- a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean @@ -489,9 +489,8 @@ lemma time_deriv_time_deriv_electricField_of_isExtrema {A : ElectromagneticPoten rw [fderiv_const_mul] simp [← Space.deriv_eq_fderiv_basis] field_simp - apply Differentiable.differentiableAt - apply LorentzCurrentDensity.chargeDensity_differentiable_space - exact hJ.differentiable (by simp) + exact (LorentzCurrentDensity.chargeDensity_differentiable_space + (hJ.differentiable (by simp)) _).differentiableAt · exact hA · exact hJ _ = 𝓕.c ^ 2 * ∑ j, (∂[j] (∂[j] (A.electricField 𝓕.c t · i)) x) - From 53c23b3fc6abec73342aa770683e53bec7fd9b8b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:02:26 -0700 Subject: [PATCH 061/498] refactor(qft): golf qed permutation proofs Co-authored-by: Claude Opus 4.8 --- .../QED/AnomalyCancellation/Permutations.lean | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean index ce1e1e8d4..40ef5f38f 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean @@ -108,8 +108,8 @@ lemma permTwoInj_fst : i ∈ Set.range ⇑(permTwoInj hij) := by rfl lemma permTwoInj_fst_apply : - (Function.Embedding.toEquivRange (permTwoInj hij)).symm ⟨i, permTwoInj_fst hij⟩ = 0 := by - exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permTwoInj hij))).mpr rfl + (Function.Embedding.toEquivRange (permTwoInj hij)).symm ⟨i, permTwoInj_fst hij⟩ = 0 := + (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permTwoInj hij))).mpr rfl lemma permTwoInj_snd : j ∈ Set.range ⇑(permTwoInj hij) := by simp only [Set.mem_range] @@ -118,8 +118,8 @@ lemma permTwoInj_snd : j ∈ Set.range ⇑(permTwoInj hij) := by lemma permTwoInj_snd_apply : (Function.Embedding.toEquivRange (permTwoInj hij)).symm - ⟨j, permTwoInj_snd hij⟩ = 1 := by - exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permTwoInj hij))).mpr rfl + ⟨j, permTwoInj_snd hij⟩ = 1 := + (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permTwoInj hij))).mpr rfl /-- A permutation which swaps `i` with `i'` and `j` with `j'`. -/ noncomputable def permTwo : (FamilyPermutations n).group := @@ -166,8 +166,8 @@ lemma permThreeInj_fst : i ∈ Set.range ⇑(permThreeInj hij hjk hik) := by lemma permThreeInj_fst_apply : (Function.Embedding.toEquivRange (permThreeInj hij hjk hik)).symm - ⟨i, permThreeInj_fst hij hjk hik⟩ = 0 := by - exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl + ⟨i, permThreeInj_fst hij hjk hik⟩ = 0 := + (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl lemma permThreeInj_snd : j ∈ Set.range ⇑(permThreeInj hij hjk hik) := by simp only [Set.mem_range] @@ -176,8 +176,8 @@ lemma permThreeInj_snd : j ∈ Set.range ⇑(permThreeInj hij hjk hik) := by lemma permThreeInj_snd_apply : (Function.Embedding.toEquivRange (permThreeInj hij hjk hik)).symm - ⟨j, permThreeInj_snd hij hjk hik⟩ = 1 := by - exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl + ⟨j, permThreeInj_snd hij hjk hik⟩ = 1 := + (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl lemma permThreeInj_thd : k ∈ Set.range ⇑(permThreeInj hij hjk hik) := by simp only [Set.mem_range] @@ -186,8 +186,8 @@ lemma permThreeInj_thd : k ∈ Set.range ⇑(permThreeInj hij hjk hik) := by lemma permThreeInj_thd_apply : (Function.Embedding.toEquivRange (permThreeInj hij hjk hik)).symm - ⟨k, permThreeInj_thd hij hjk hik⟩ = 2 := by - exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl + ⟨k, permThreeInj_thd hij hjk hik⟩ = 2 := + (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl /-- A permutation which swaps three distinct elements with another three. -/ noncomputable def permThree : (FamilyPermutations n).group := From 2ca7c7e885b2f3048941b090b12dd5b6bfd46dc5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:04:15 -0700 Subject: [PATCH 062/498] refactor(qft): golf contraction direct proofs Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/NormalOrder/WickContractions.lean | 8 ++++---- .../WickAlgebra/WicksTheoremNormal.lean | 4 ++-- Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean | 4 ++-- .../PerturbationTheory/WickContraction/ExtractEquiv.lean | 4 ++-- .../WickContraction/InsertAndContractNat.lean | 4 ++-- .../WickContraction/SubContraction.lean | 4 ++-- .../QFT/PerturbationTheory/WickContraction/TimeCond.lean | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/WickContractions.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/WickContractions.lean index 6fe714d63..6d9017141 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/WickContractions.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/WickContractions.lean @@ -59,11 +59,11 @@ lemma normalOrder_uncontracted_none (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp congr rw [uncontractedList_eq_sort] have hdup : (List.filter (fun x => decide (x.1 < i.1)) - (φsΛ.uncontracted.sort (fun x1 x2 => x1 ≤ x2))).Nodup := by - exact List.Nodup.filter _ (φsΛ.uncontracted.sort_nodup (fun x1 x2 => x1 ≤ x2)) + (φsΛ.uncontracted.sort (fun x1 x2 => x1 ≤ x2))).Nodup := + List.Nodup.filter _ (φsΛ.uncontracted.sort_nodup (fun x1 x2 => x1 ≤ x2)) have hsort : (List.filter (fun x => decide (x.1 < i.1)) - (φsΛ.uncontracted.sort (fun x1 x2 => x1 ≤ x2))).Pairwise (· ≤ ·) := by - exact List.Pairwise.filter _ (φsΛ.uncontracted.pairwise_sort (fun x1 x2 => x1 ≤ x2)) + (φsΛ.uncontracted.sort (fun x1 x2 => x1 ≤ x2))).Pairwise (· ≤ ·) := + List.Pairwise.filter _ (φsΛ.uncontracted.pairwise_sort (fun x1 x2 => x1 ≤ x2)) rw [← (List.toFinset_sort (· ≤ ·) hdup).mpr hsort] congr ext a diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean index cee58d9d5..5d2dec371 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean @@ -140,8 +140,8 @@ lemma timeOrder_haveEqTime_split (φs : List 𝓕.FieldOp) : φssucΛ.1.wickTerm) := by rw [wicks_theorem] simp only [wickTerm] - let e1 : WickContraction φs.length ≃ {φsΛ // HaveEqTime φsΛ} ⊕ {φsΛ // ¬ HaveEqTime φsΛ} := by - exact (Equiv.sumCompl HaveEqTime).symm + let e1 : WickContraction φs.length ≃ {φsΛ // HaveEqTime φsΛ} ⊕ {φsΛ // ¬ HaveEqTime φsΛ} := + (Equiv.sumCompl HaveEqTime).symm rw [← e1.symm.sum_comp] simp only [Equiv.symm_symm, Algebra.smul_mul_assoc, Fintype.sum_sum_type, Equiv.sumCompl_apply_inl, Equiv.sumCompl_apply_inr, ne_eq, e1] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean index e9ae5dd39..eb5b2d6b5 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean @@ -129,8 +129,8 @@ lemma congrLift_surjective {n m : ℕ} {c : WickContraction n} (h : n = m) : simp [Function.surjective_id] lemma congrLift_bijective {n m : ℕ} {c : WickContraction n} (h : n = m) : - Function.Bijective (c.congrLift h) := by - exact ⟨c.congrLift_injective h, c.congrLift_surjective h⟩ + Function.Bijective (c.congrLift h) := + ⟨c.congrLift_injective h, c.congrLift_surjective h⟩ /-- Given a contracted pair in `c : WickContraction n` the contracted pair in `congr h c`. -/ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean b/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean index 7b8c3db81..987530659 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean @@ -58,8 +58,8 @@ def extractEquiv (i : Fin n.succ) : WickContraction n.succ ≃ 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 - exact insertAndContractNat_none_uncontracted c i + (Insert.insert i (c.uncontracted.map i.succAboveEmb)) := + insertAndContractNat_none_uncontracted c i @[simp] lemma extractEquiv_apply_congr_symm_apply {n m : ℕ} (k : ℕ) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean index bc4cf4f25..40d148f92 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean @@ -651,8 +651,8 @@ lemma insertLift_none_surjective {c : WickContraction n} (i : Fin n.succ) : exact Subtype.ext ha'' lemma insertLift_none_bijective {c : WickContraction n} (i : Fin n.succ) : - Function.Bijective (c.insertLift i none) := by - exact ⟨insertLift_injective i none, insertLift_none_surjective i⟩ + Function.Bijective (c.insertLift i none) := + ⟨insertLift_injective i none, insertLift_none_surjective i⟩ @[simp] lemma insertAndContractNat_fstFieldOfContract (c : WickContraction n) (i : Fin n.succ) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean index e0b2db5cd..f81bf4fea 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean @@ -33,8 +33,8 @@ def subContraction (S : Finset (Finset (Fin φs.length))) (ha : S ⊆ φsΛ.1) : exact φsΛ.2.2 i (ha hi) j (ha hj)⟩ lemma mem_of_mem_subContraction {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} - {a : Finset (Fin φs.length)} (ha : a ∈ (φsΛ.subContraction S hs).1) : a ∈ φsΛ.1 := by - exact hs ha + {a : Finset (Fin φs.length)} (ha : a ∈ (φsΛ.subContraction S hs).1) : a ∈ φsΛ.1 := + hs ha /-- Given a Wick contraction `φsΛ`, and a subset `S` of `φsΛ.1`, the Wick contraction on the uncontracted list `[φsΛ.subContraction S ha]ᵘᶜ` diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean index dc4ee18ea..12c3ca4f0 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean @@ -192,8 +192,8 @@ lemma timeOrder_timeContract_mul_of_eqTimeOnly_mid_induction {φs : List 𝓕.Fi lemma timeOrder_timeContract_mul_of_eqTimeOnly_mid {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) (hl : φsΛ.EqTimeOnly) (a b : 𝓕.WickAlgebra) : - 𝓣(a * φsΛ.timeContract.1 * b) = φsΛ.timeContract.1 * 𝓣(a * b) := by - exact timeOrder_timeContract_mul_of_eqTimeOnly_mid_induction φsΛ hl a b φsΛ.1.card rfl + 𝓣(a * φsΛ.timeContract.1 * b) = φsΛ.timeContract.1 * 𝓣(a * b) := + timeOrder_timeContract_mul_of_eqTimeOnly_mid_induction φsΛ hl a b φsΛ.1.card rfl /-- Let `φs` be a list of `𝓕.FieldOp`, `φsΛ` a `WickContraction` of `φs` within which every contraction involves two `𝓕.FieldOp`s that have the same time and @@ -476,8 +476,8 @@ lemma quotContraction_eqTimeContractSet_not_haveEqTime {φs : List 𝓕.FieldOp} quotContraction_sndFieldOfContract_uncontractedListEmd] simp only [quotContraction, Finset.mem_filter, Finset.mem_univ, true_and] at ha have hn' : Finset.map uncontractedListEmd a ∉ - (φsΛ.subContraction (eqTimeContractSet φsΛ) (eqTimeContractSet_subset φsΛ)).1 := by - exact uncontractedListEmd_finset_not_mem a + (φsΛ.subContraction (eqTimeContractSet φsΛ) (eqTimeContractSet_subset φsΛ)).1 := + uncontractedListEmd_finset_not_mem a simp only [subContraction, eqTimeContractSet, Fin.getElem_fin, Finset.mem_filter, Finset.mem_univ, true_and, not_and, not_forall] at hn' have hn'' := hn' ha From 569f2660fbc1939572577dddf43a4e764fb4726c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:07:43 -0700 Subject: [PATCH 063/498] refactor(space-time): golf distribution integrability proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/ConstantSliceDist.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/Grad.lean | 3 +-- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 3 +-- Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index 0c021e1d1..9ad5f94c2 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -210,8 +210,7 @@ lemma schwartzMap_fderiv_left_integrable_slice_symm {d : ℕ} (η : 𝓢(Space d simp only [Nat.succ_eq_add_one, one_mul] change fderiv ℝ (η ∘ fun r => ((slice i).symm (r, x))) r 1 rw [fderiv_comp _ (by - apply Differentiable.differentiableAt - exact η.smooth'.differentiable (by simp)) + exact (η.smooth'.differentiable (by simp)).differentiableAt) (by fun_prop)] simp only [Nat.succ_eq_add_one, ContinuousLinearMap.coe_comp, Function.comp_apply, fderiv_slice_symm_left_apply] diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean index 577f3ba79..31343c32b 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean @@ -445,8 +445,7 @@ lemma integrable_isDistBounded_inner_grad_schwartzMap_spherical {d : ℕ} change Integrable ((fun x => ⟪f x, Space.grad η x⟫_ℝ) ∘ Subtype.val) (.comap (Subtype.val (p := fun x => x ∈ ({0}ᶜ : Set _))) volume) rw [← MeasureTheory.integrableOn_iff_comap_subtypeVal] - apply Integrable.integrableOn - exact integrable_isDistBounded_inner_grad_schwartzMap hf η + exact Integrable.integrableOn (integrable_isDistBounded_inner_grad_schwartzMap hf η) simp have he := (MeasureTheory.Measure.measurePreserving_homeomorphUnitSphereProd (volume (α := Space d))) diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index 1e171ceaa..8f24c772c 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -204,8 +204,7 @@ lemma integrable_space {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) by_cases hp' : p = 0 · subst hp' simp only [zpow_zero, mul_one] - apply Integrable.norm - exact η.integrable + exact Integrable.norm η.integrable suffices h1 : Integrable (fun x => ‖η x‖ * ‖x‖ ^ (p + d)) (radialAngularMeasure (d := (d + 1))) by rw [integrable_radialAngularMeasure_iff] at h1 convert h1 using 1 diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 6b65456e1..d7ac9f42b 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -210,8 +210,7 @@ lemma time_integral_hasFDerivAt {d : ℕ} (η : 𝓢(Time × Space d, ℝ)) (x · filter_upwards with x fun_prop · simp [F] - have hf : Integrable η (volume.prod volume) := by - exact η.integrable + have hf : Integrable η (volume.prod volume) := η.integrable apply MeasureTheory.Integrable.comp_measurable · haveI : (Measure.map (fun t => (t, x₀)) (volume (α := Time))).HasTemperateGrowth := by refine { exists_integrable := ?_ } @@ -1025,8 +1024,7 @@ lemma constantTime_distTimeDeriv {M : Type} [NormedAddCommGroup M] [NormedSpace simp only [one_mul] change (fderiv ℝ (η ∘ fun t => (t, x)) t) 1 rw [fderiv_comp _ (by - apply Differentiable.differentiableAt - exact η.smooth'.differentiable (by simp)) + exact (η.smooth'.differentiable (by simp)).differentiableAt) (by fun_prop), DifferentiableAt.fderiv_prodMk (by fun_prop) (by fun_prop)] simp only [fderiv_fun_id, fderiv_fun_const, Pi.ofNat_apply, ContinuousLinearMap.comp_apply, ContinuousLinearMap.prod_apply, From 8a59f7f535f8753b35be05a617b3ccd704a52860 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:10:46 -0700 Subject: [PATCH 064/498] refactor: golf relativity and ensemble proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Basic.lean | 3 +-- Physlib/Relativity/SL2C/Basic.lean | 3 +-- Physlib/Relativity/Tensors/Basic.lean | 3 +-- .../StatisticalMechanics/CanonicalEnsemble/Lemmas.lean | 8 ++++---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 8f37ffdb9..33e29c8e7 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -416,7 +416,6 @@ def parity : LorentzGroup d := ⟨minkowskiMatrix, by lemma eq_of_mulVec_eq {Λ Λ' : LorentzGroup d} (h : ∀ (x : Fin 1 ⊕ Fin d → ℝ), Λ.1 *ᵥ x = Λ'.1 *ᵥ x) : Λ = Λ' := by - apply Subtype.ext - exact ext_of_mulVec_single fun i => h (Pi.single i 1) + exact Subtype.ext (ext_of_mulVec_single fun i => h (Pi.single i 1)) end LorentzGroup diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index 94d9c9f37..801b9de0c 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -200,8 +200,7 @@ lemma toSelfAdjointMap_pauliBasis (i : Fin 1 ⊕ Fin 3) : funext j rw [smul_smul, PauliMatrix.pauliBasis_minkowskiMetric_pauliBasis', smul_smul] apply congrFun - apply congrArg - exact Eq.symm (minkowskiMatrix.dual_apply_minkowskiMatrix ((toLorentzGroup M).1) i j) + exact congrArg _ (Eq.symm (minkowskiMatrix.dual_apply_minkowskiMatrix ((toLorentzGroup M).1) i j)) /-- The first column of the Lorentz matrix formed from an element of `SL(2, ℂ)`. -/ lemma toLorentzGroup_fst_col (M : SL(2, ℂ)) : diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index de0885783..422df53d5 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -102,8 +102,7 @@ lemma congr_mid {n : ℕ} {c : Fin n → C} (c' : C) (p : Pure S c) subst hi simp only [LinearEquiv.cast_apply, cast_eq] symm - apply congr_right - exact h + exact congr_right p i j h lemma map_mid_move_left {n n1 : ℕ} {c : Fin n → C} {c1 : Fin n1 → C} (p : Pure S c) (p' : Pure S c1) {c' : C} diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index f08cee5bf..1afd0491a 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -408,8 +408,8 @@ to the energy observable. -/ lemma integral_energy_bolt {ι} [MeasurableSpace ι] (𝓒 : CanonicalEnsemble ι) (T : Temperature) : ∫ x, 𝓒.energy x ∂ 𝓒.μBolt T - = ∫ x, 𝓒.energy x * Real.exp (-T.β * 𝓒.energy x) ∂ 𝓒.μ := by - exact integral_bolt_eq_integral_mul_exp 𝓒 T 𝓒.energy + = ∫ x, 𝓒.energy x * Real.exp (-T.β * 𝓒.energy x) ∂ 𝓒.μ := + integral_bolt_eq_integral_mul_exp 𝓒 T 𝓒.energy /-- The mean energy can be expressed as a ratio of integrals. -/ lemma meanEnergy_eq_ratio_of_integrals @@ -426,8 +426,8 @@ lemma meanEnergy_eq_ratio_of_integrals integral_energy_bolt (𝓒:=𝓒) (T:=T) have h_den : (𝓒.μBolt T Set.univ).toReal - = ∫ x, Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ := by - exact (mathematicalPartitionFunction_eq_integral (𝓒:=𝓒) (T:=T)) + = ∫ x, Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ := + mathematicalPartitionFunction_eq_integral (𝓒:=𝓒) (T:=T) have h_inv_toReal : ((𝓒.μBolt T Set.univ)⁻¹).toReal = 1 / (𝓒.μBolt T Set.univ).toReal := by From 5e64e5d12ca44e140f71852e7f7d02d10d8fb90d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:12:43 -0700 Subject: [PATCH 065/498] refactor(quantum): golf integrability wrappers Co-authored-by: Claude Opus 4.8 --- .../QuantumMechanics/DDimensions/Operators/Momentum.lean | 4 ++-- .../DDimensions/Operators/SpectralTheory/Symmetric.lean | 8 ++++---- .../OneDimension/HarmonicOscillator/Completeness.lean | 3 +-- .../OneDimension/HilbertSpace/Gaussians.lean | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean index e1b95f4c4..33c7a709f 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean @@ -118,8 +118,8 @@ lemma momentumOperator_isSymmetric : (𝓟 i).IsSymmetric := by have hI₃ : Integrable fun x ↦ g x * fderiv ℝ (star ∘ f) x (basis i) := by simp_rw [heq] refine Integrable.mul_of_top_right ?_ g.memLp_top - apply (starL' ℝ).integrable_comp_iff.mpr - exact ((f.fderivCLM ℂ _ _).evalCLM ℂ _ _ _).integrable + exact (starL' ℝ).integrable_comp_iff.mpr + ((f.fderivCLM ℂ _ _).evalCLM ℂ _ _ _).integrable have hI₄ : Integrable fun x ↦ g x * star (f x) := hI₁.mul_of_top_right g.memLp_top trans I * ℏ * ∫ x, g x * fderiv ℝ (star ∘ f) x (basis i) · simp_rw [← integral_const_mul_of_integrable hI₃, heq] diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Symmetric.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Symmetric.lean index 75725cab5..ac855bc56 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Symmetric.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Symmetric.lean @@ -186,15 +186,15 @@ lemma regularityDomain_isConnected_iff : lemma regularityDomain_isConnected_of_bddBelow (h : BddBelow (Θᵣₑ T)) : IsConnected T.regularityDomain := by obtain ⟨m, hm⟩ := h - apply hT.regularityDomain_isConnected_iff.mpr - exact ⟨m - 1, hT.Iio_subset_regularityDomain hm ⟨m - 1, by simp⟩⟩ + exact hT.regularityDomain_isConnected_iff.mpr + ⟨m - 1, hT.Iio_subset_regularityDomain hm ⟨m - 1, by simp⟩⟩ /-- The regularity domain of an upper semibounded symmetric operator is connected. -/ lemma regularityDomain_isConnected_of_bddAbove (h : BddAbove (Θᵣₑ T)) : IsConnected T.regularityDomain := by obtain ⟨m, hm⟩ := h - apply hT.regularityDomain_isConnected_iff.mpr - exact ⟨m + 1, hT.Ioi_subset_regularityDomain hm ⟨m + 1, by simp⟩⟩ + exact hT.regularityDomain_isConnected_iff.mpr + ⟨m + 1, hT.Ioi_subset_regularityDomain hm ⟨m + 1, by simp⟩⟩ /-! ## C. Point spectrum diff --git a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean index 8d2e465d2..4501e523e 100644 --- a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean +++ b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean @@ -109,8 +109,7 @@ lemma mul_polynomial_integrable (f : ℝ → ℂ) (hf : MemHS f) (P : Polynomial simp only [Complex.ofReal_exp, Complex.ofReal_div, Complex.ofReal_neg, Complex.ofReal_pow, Complex.ofReal_mul, Complex.ofReal_ofNat, Complex.real_smul] rw [hf'] - apply MeasureTheory.Integrable.fun_smul - exact Q.mul_physHermite_integrable f hf i + exact (Q.mul_physHermite_integrable f hf i).fun_smul (a i) lemma mul_power_integrable (f : ℝ → ℂ) (hf : MemHS f) (r : ℕ) : MeasureTheory.Integrable (fun x => x ^ r * (f x * Real.exp (- x^2 / (2 * Q.ξ^2)))) volume := by diff --git a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Gaussians.lean b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Gaussians.lean index e855bf752..0d9ac2c39 100644 --- a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Gaussians.lean +++ b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Gaussians.lean @@ -73,8 +73,8 @@ lemma exp_mul_gaussian_integrable (b c : ℝ) (hb : 0 < b) : ring rw [h1] apply MeasureTheory.Integrable.const_mul - apply Integrable.comp_sub_right (f := (fun x => Real.exp (- b * x ^ 2))) - exact integrable_exp_neg_mul_sq hb + exact Integrable.comp_sub_right (f := (fun x => Real.exp (- b * x ^ 2))) + (integrable_exp_neg_mul_sq hb) (c / (2 * b)) lemma exp_abs_mul_gaussian_integrable (b c : ℝ) (hb : 0 < b) : MeasureTheory.Integrable (fun x => Real.exp (|c * x|) * Real.exp (- b * x ^ 2)) := by From e98859a547eda573afc8d8b129b56c961cd2dffa Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:14:03 -0700 Subject: [PATCH 066/498] refactor: golf direct wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../HarmonicOscillator/ConfigurationSpace.lean | 3 +-- Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean | 4 ++-- Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean | 4 ++-- Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean | 6 ++---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean index f9207401c..18c3779d0 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean @@ -118,8 +118,7 @@ homeomorphism underlies the single global chart used for the smooth-manifold str def valHomeomorphism : ConfigurationSpace ≃ₜ EuclideanSpace ℝ (Fin 1) where toEquiv := valEquiv continuous_toFun := continuous_induced_dom - continuous_invFun := by - exact continuous_induced_rng.mpr continuous_id + continuous_invFun := continuous_induced_rng.mpr continuous_id /-- Configuration space is Hausdorff, transported from `EuclideanSpace ℝ (Fin 1)` across the coordinate homeomorphism. -/ diff --git a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean index b82dda7f5..400f8e7f9 100644 --- a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean +++ b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean @@ -133,8 +133,8 @@ lemma exp_series_diag_term_eq {A : Matrix m m 𝕂} (hA : BlockTriangular A id) /-- The diagonal of the matrix exponential series equals the scalar exponential series -/ lemma matrix_exp_series_diag_eq_scalar_series {A : Matrix m m 𝕂} (hA : BlockTriangular A id) (i : m) : - (∑' n, ((n.factorial : 𝕂)⁻¹ • (A ^ n)) i i) = ∑' n, (n.factorial : 𝕂)⁻¹ • (A i i) ^ n := by - exact tsum_congr (exp_series_diag_term_eq hA · i) + (∑' n, ((n.factorial : 𝕂)⁻¹ • (A ^ n)) i i) = ∑' n, (n.factorial : 𝕂)⁻¹ • (A i i) ^ n := + tsum_congr (exp_series_diag_term_eq hA · i) /-- The diagonal of the exponential of an upper-triangular matrix `A` consists of the exponentials of the diagonal entries of `A`. -/ diff --git a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean index 98cf01af9..1b14565bd 100644 --- a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean @@ -92,8 +92,8 @@ lemma toQuadraticForm_posDef (g : RiemannianMetric I n M) (x : M) : λ v hv => g.pos_def x v hv lemma riemannian_metric_negDim_zero (g : RiemannianMetric I n M) (x : M) : - (g.toQuadraticForm x).negDim = 0 := by - exact QuadraticForm.rankNeg_eq_zero (g.toQuadraticForm_posDef x) + (g.toQuadraticForm x).negDim = 0 := + QuadraticForm.rankNeg_eq_zero (g.toQuadraticForm_posDef x) /-! ## InnerProductSpace structure from RiemannianMetric -/ diff --git a/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean b/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean index 8cde56080..8261d64fb 100644 --- a/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean +++ b/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean @@ -232,8 +232,7 @@ lemma IsTestFunction.of_fderiv {f : X → U} (hf : IsTestFunction f) : · fun_prop · fun_prop · exact Preorder.le_refl (∞ + 1) - supp := by - exact HasCompactSupport.fderiv ℝ hf.supp + supp := HasCompactSupport.fderiv ℝ hf.supp @[fun_prop] lemma IsTestFunction.fderiv_apply {f : X → U} (hf : IsTestFunction f) (δx : X) : @@ -244,8 +243,7 @@ lemma IsTestFunction.fderiv_apply {f : X → U} (hf : IsTestFunction f) (δx : X · fun_prop · fun_prop · exact Preorder.le_refl (∞ + 1) - supp := by - exact HasCompactSupport.fderiv_apply ℝ hf.supp δx + supp := HasCompactSupport.fderiv_apply ℝ hf.supp δx open InnerProductSpace' in @[fun_prop] From 3a4fd624c1e09b3cff5a5f6b816c2b57d0e5a094 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:15:10 -0700 Subject: [PATCH 067/498] refactor(qft): golf grading projection proofs Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/Grading.lean | 8 ++++---- .../FieldSpecification/CrAnSection.lean | 3 +-- .../PerturbationTheory/WickAlgebra/Grading.lean | 16 ++++++++-------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean index 3a45616a1..229a9cd29 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean @@ -104,8 +104,8 @@ lemma bosonicProjF_of_bonosic_part @[simp] lemma bosonicProjF_of_fermionic_part (a : DirectSum FieldStatistic (fun i => (statisticSubmodule (𝓕 := 𝓕) i))) : - bosonicProjF (a fermionic).1 = 0 := by - exact bosonicProjF_of_mem_fermionic (a.toFun fermionic).1 (Submodule.coe_mem (a.toFun fermionic)) + bosonicProjF (a fermionic).1 = 0 := + bosonicProjF_of_mem_fermionic (a.toFun fermionic).1 (Submodule.coe_mem (a.toFun fermionic)) /-- The projection of an element of `FieldOpFreeAlgebra` onto it's fermionic part. -/ def fermionicProjF : 𝓕.FieldOpFreeAlgebra →ₗ[ℂ] statisticSubmodule (𝓕 := 𝓕) fermionic := @@ -170,8 +170,8 @@ lemma fermionicProjF_of_mem_bosonic (a : 𝓕.FieldOpFreeAlgebra) @[simp] lemma fermionicProjF_of_bosonic_part (a : DirectSum FieldStatistic (fun i => (statisticSubmodule (𝓕 := 𝓕) i))) : - fermionicProjF (a bosonic).1 = 0 := by - exact fermionicProjF_of_mem_bosonic (a.toFun bosonic).1 (Submodule.coe_mem (a.toFun bosonic)) + fermionicProjF (a bosonic).1 = 0 := + fermionicProjF_of_mem_bosonic (a.toFun bosonic).1 (Submodule.coe_mem (a.toFun bosonic)) @[simp] lemma fermionicProjF_of_fermionic_part diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 46cd2534f..fc0f4d208 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -139,8 +139,7 @@ def consEquiv {φ : 𝓕.FieldOp} {φs : List 𝓕.FieldOp} : CrAnSection (φ :: invFun ψψs := match ψψs with | (ψ, ψs) => cons ψ ψs - left_inv ψs := by - exact Subtype.ext (Eq.symm eq_head_cons_tail) + left_inv ψs := Subtype.ext (Eq.symm eq_head_cons_tail) right_inv ψψs := by match ψψs with | (ψ, ψs) => rfl diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean index 5c3512d32..3d9fcf200 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean @@ -289,13 +289,13 @@ lemma eq_zero_of_bosonic_and_fermionic {a : 𝓕.WickAlgebra} @[simp] lemma bosonicProj_fermionicProj_eq_zero (a : 𝓕.WickAlgebra) : - bosonicProj (fermionicProj a).1 = 0 := by - exact bosonicProj_mem_fermionic (fermionicProj a).1 (Submodule.coe_mem (fermionicProj a)) + bosonicProj (fermionicProj a).1 = 0 := + bosonicProj_mem_fermionic (fermionicProj a).1 (Submodule.coe_mem (fermionicProj a)) @[simp] lemma fermionicProj_bosonicProj_eq_zero (a : 𝓕.WickAlgebra) : - fermionicProj (bosonicProj a).1 = 0 := by - exact fermionicProj_mem_bosonic (bosonicProj a).1 (Submodule.coe_mem (bosonicProj a)) + fermionicProj (bosonicProj a).1 = 0 := + fermionicProj_mem_bosonic (bosonicProj a).1 (Submodule.coe_mem (bosonicProj a)) @[simp] lemma bosonicProj_bosonicProj_eq_bosonicProj (a : 𝓕.WickAlgebra) : @@ -316,14 +316,14 @@ lemma bosonicProj_of_bosonic_part @[simp] lemma bosonicProj_of_fermionic_part (a : DirectSum FieldStatistic (fun i => (statSubmodule (𝓕 := 𝓕) i))) : - bosonicProj (a fermionic).1 = 0 := by - exact bosonicProj_mem_fermionic (a.toFun fermionic).1 (Submodule.coe_mem (a.toFun fermionic)) + bosonicProj (a fermionic).1 = 0 := + bosonicProj_mem_fermionic (a.toFun fermionic).1 (Submodule.coe_mem (a.toFun fermionic)) @[simp] lemma fermionicProj_of_bosonic_part (a : DirectSum FieldStatistic (fun i => (statSubmodule (𝓕 := 𝓕) i))) : - fermionicProj (a bosonic).1 = 0 := by - exact fermionicProj_mem_bosonic (a.toFun bosonic).1 (Submodule.coe_mem (a.toFun bosonic)) + fermionicProj (a bosonic).1 = 0 := + fermionicProj_mem_bosonic (a.toFun bosonic).1 (Submodule.coe_mem (a.toFun bosonic)) @[simp] lemma fermionicProj_of_fermionic_part From a2a5a9e9d429310cb2740f253cc4baf42517a464 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:16:12 -0700 Subject: [PATCH 068/498] refactor(list): golf insertion sort wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List/InsertionSort.lean | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index a3ab4cc9d..02feb815d 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -90,8 +90,8 @@ lemma insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt {α : Type} (r : α lemma insertionSort_insertionSort {α : Type} (r : α → α → Prop) [DecidableRel r] [Std.Total r] [IsTrans α r] (l1 : List α) : - List.insertionSort r (List.insertionSort r l1) = List.insertionSort r l1 := by - exact List.Pairwise.insertionSort_eq (List.pairwise_insertionSort r l1) + List.insertionSort r (List.insertionSort r l1) = List.insertionSort r l1 := + List.Pairwise.insertionSort_eq (List.pairwise_insertionSort r l1) lemma orderedInsert_commute {α : Type} (r : α → α → Prop) [DecidableRel r] [Std.Total r] [IsTrans α r] (a b : α) (hr : ¬ r a b) : (l : List α) → @@ -152,8 +152,8 @@ lemma insertionSort_append_insertionSort_append {α : Type} (r : α → α → P @[simp] lemma orderedInsert_length {α : Type} (r : α → α → Prop) [DecidableRel r] (a : α) (l : List α) : - (List.orderedInsert r a l).length = (a :: l).length := by - exact List.Perm.length_eq (List.perm_orderedInsert r a l) + (List.orderedInsert r a l).length = (a :: l).length := + List.Perm.length_eq (List.perm_orderedInsert r a l) lemma takeWhile_orderedInsert {α : Type} (r : α → α → Prop) [DecidableRel r] [Std.Total r] [IsTrans α r] @@ -295,8 +295,8 @@ lemma insertionSortEquiv_orderedInsert_append {α : Type} (r : α → α → Pro conv_lhs => simp [insertionSortEquiv] rw [insertionSortEquiv_orderedInsert_append r a] have hl : (List.insertionSort r (List.orderedInsert r a l1 ++ a2 :: l2)) = - List.insertionSort r (a :: l1 ++ a2 :: l2) := by - exact insertionSort_orderedInsert_append r a l1 (a2 :: l2) + List.insertionSort r (a :: l1 ++ a2 :: l2) := + insertionSort_orderedInsert_append r a l1 (a2 :: l2) rw [orderedInsertEquiv_congr _ _ _ hl] conv_lhs => enter [2, 1, 2, 1] @@ -332,8 +332,8 @@ lemma insertionSortEquiv_insertionSort_append {α : Type} (r : α → α → Pro equivCons_succ] erw [ih] have hl : (List.insertionSort r (List.insertionSort r l1 ++ a :: l2)) = - (List.insertionSort r (l1 ++ a :: l2)) := by - exact insertionSort_insertionSort_append r l1 (a :: l2) + (List.insertionSort r (l1 ++ a :: l2)) := + insertionSort_insertionSort_append r l1 (a :: l2) erw [orderedInsertEquiv_congr _ _ _ hl] simp only [List.foldr_cons, finCongr_apply] rfl @@ -380,8 +380,8 @@ lemma orderedInsert_filter_of_pos {α : Type} (r : α → α → Prop) [Decidabl simp only [List.pairwise_cons] at hl apply hl.1 have hlf : (List.filter (fun b => decide (p b)) l)[0] ∈ - (List.filter (fun b => decide (p b)) l) := by - exact List.getElem_mem c + (List.filter (fun b => decide (p b)) l) := + List.getElem_mem c simp only [List.mem_filter, decide_eq_true_eq] at hlf exact hlf.1 rw [hl] From 7c9ff9a0c47ba2674f368f08a098552c2326c9a6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:17:22 -0700 Subject: [PATCH 069/498] refactor(qft): golf uncontracted-list sortedness proofs Co-authored-by: Claude Opus 4.8 --- .../WickContraction/UncontractedList.lean | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index e0df2a909..1a568a140 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -44,8 +44,8 @@ lemma fin_list_sorted_monotone_sorted {n m : ℕ} (l: List (Fin n)) (hl : l.Pair exact ih hl.2 lemma fin_list_sorted_succAboveEmb_sorted (l: List (Fin n)) (hl : l.Pairwise (· ≤ ·)) - (i : Fin n.succ) : ((List.map i.succAboveEmb l)).Pairwise (· ≤ ·) := by - exact fin_list_sorted_monotone_sorted l hl i.succAboveEmb (Fin.strictMono_succAbove i) + (i : Fin n.succ) : ((List.map i.succAboveEmb l)).Pairwise (· ≤ ·) := + fin_list_sorted_monotone_sorted l hl i.succAboveEmb (Fin.strictMono_succAbove i) lemma fin_finset_sort_map_monotone {n m : ℕ} (a : Finset (Fin n)) (f : Fin n ↪ Fin m) (hf : StrictMono f) : (a.sort (· ≤ ·)).map f = @@ -248,11 +248,10 @@ lemma uncontractedList_length_eq_card (c : WickContraction n) : lemma filter_uncontractedList (c : WickContraction n) (p : Fin n → Prop) [DecidablePred p] : (c.uncontractedList.filter p) = (c.uncontracted.filter p).sort (· ≤ ·) := by - have h1 : (c.uncontractedList.filter p).Pairwise (· ≤ ·) := by - exact List.Pairwise.filter _ (uncontractedList_sorted c) - have h2 : (c.uncontractedList.filter p).Nodup := by - refine List.Nodup.filter _ ?_ - exact uncontractedList_nodup c + have h1 : (c.uncontractedList.filter p).Pairwise (· ≤ ·) := + List.Pairwise.filter _ (uncontractedList_sorted c) + have h2 : (c.uncontractedList.filter p).Nodup := + List.Nodup.filter _ (uncontractedList_nodup c) have h3 : (c.uncontractedList.filter p).toFinset = (c.uncontracted.filter p) := by ext a simp only [List.toFinset_filter, decide_eq_true_eq, Finset.mem_filter, List.mem_toFinset, @@ -443,8 +442,8 @@ lemma uncontractedListEmd_empty {φs : List 𝓕.FieldOp} : -/ lemma uncontractedList_succAboveEmb_sorted (c : WickContraction n) (i : Fin n.succ) : - ((List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := by - exact fin_list_sorted_succAboveEmb_sorted c.uncontractedList (uncontractedList_sorted c) i + ((List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := + fin_list_sorted_succAboveEmb_sorted c.uncontractedList (uncontractedList_sorted c) i lemma uncontractedList_succAboveEmb_nodup (c : WickContraction n) (i : Fin n.succ) : ((List.map i.succAboveEmb c.uncontractedList)).Nodup := by @@ -530,8 +529,8 @@ lemma uncontractedList_succAboveEmb_eraseIdx_toFinset (c : WickContraction n) (i exact uncontractedList_succAboveEmb_nodup c i lemma uncontractedList_succAboveEmb_eraseIdx_sorted (c : WickContraction n) (i : Fin n.succ) - (k: ℕ) : ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Pairwise (· ≤ ·) := by - exact Physlib.List.eraseIdx_sorted (· ≤ ·) _ k (uncontractedList_succAboveEmb_sorted c i) + (k: ℕ) : ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Pairwise (· ≤ ·) := + Physlib.List.eraseIdx_sorted (· ≤ ·) _ k (uncontractedList_succAboveEmb_sorted c i) lemma uncontractedList_succAboveEmb_eraseIdx_nodup (c : WickContraction n) (i : Fin n.succ) (k: ℕ) : ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Nodup := by @@ -603,11 +602,10 @@ lemma take_uncontractedListOrderPos_eq_filter_sort (c : WickContraction n) (i : (c.uncontractedList.take (c.uncontractedListOrderPos i)) = (c.uncontracted.filter (fun x => x.1 < i.1)).sort (· ≤ ·) := by rw [take_uncontractedListOrderPos_eq_filter] - have h1 : (c.uncontractedList.filter (fun x => x.1 < i.1)).Pairwise (· ≤ ·) := by - exact List.Pairwise.filter _ (uncontractedList_sorted c) - have h2 : (c.uncontractedList.filter (fun x => x.1 < i.1)).Nodup := by - refine List.Nodup.filter _ ?_ - exact uncontractedList_nodup c + have h1 : (c.uncontractedList.filter (fun x => x.1 < i.1)).Pairwise (· ≤ ·) := + List.Pairwise.filter _ (uncontractedList_sorted c) + have h2 : (c.uncontractedList.filter (fun x => x.1 < i.1)).Nodup := + List.Nodup.filter _ (uncontractedList_nodup c) have h3 : (c.uncontractedList.filter (fun x => x.1 < i.1)).toFinset = (c.uncontracted.filter (fun x => x.1 < i.1)) := by rw [uncontractedList_eq_sort] From 5fe39f701c5129f31020daaa0d8ccaa740cf8fc2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:18:32 -0700 Subject: [PATCH 070/498] refactor(calculus): golf adjoint derivative wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/AdjFDeriv.lean | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Physlib/Mathematics/Calculus/AdjFDeriv.lean b/Physlib/Mathematics/Calculus/AdjFDeriv.lean index dd1b6861a..dc4311ba5 100644 --- a/Physlib/Mathematics/Calculus/AdjFDeriv.lean +++ b/Physlib/Mathematics/Calculus/AdjFDeriv.lean @@ -169,8 +169,8 @@ lemma HasAdjFDerivAt.comp {f : F → G} {g : E → F} {f' g'} {x : E} lemma adjFDeriv_comp [CompleteSpace E] [CompleteSpace F] [CompleteSpace G] {f : F → G} {g : E → F} {x : E} (hf : DifferentiableAt 𝕜 f (g x)) (hg : DifferentiableAt 𝕜 g x) : - adjFDeriv 𝕜 (fun x => f (g x)) x = fun dy => adjFDeriv 𝕜 g x (adjFDeriv 𝕜 f (g x) dy) := by - exact (HasAdjFDerivAt.comp hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv + adjFDeriv 𝕜 (fun x => f (g x)) x = fun dy => adjFDeriv 𝕜 g x (adjFDeriv 𝕜 f (g x) dy) := + (HasAdjFDerivAt.comp hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv lemma HasAdjFDerivAt.prodMk {f : E → F} {g : E → G} {f' g'} {x : E} (hf : HasAdjFDerivAt 𝕜 f f' x) (hg : HasAdjFDerivAt 𝕜 g g' x) : @@ -191,8 +191,8 @@ lemma HasAjdFDerivAt.fst {f : E → F×G} {f'} {x : E} (hf : HasAdjFDerivAt 𝕜 lemma adjFDeriv_fst [CompleteSpace E] [CompleteSpace F] [CompleteSpace G] {f : E → F×G} {x : E} (hf : DifferentiableAt 𝕜 f x) : - adjFDeriv 𝕜 (fun x => (f x).fst) x = fun dy => adjFDeriv 𝕜 f x (dy, 0) := by - exact (HasAjdFDerivAt.fst hf.hasAdjFDerivAt).adjFDeriv + adjFDeriv 𝕜 (fun x => (f x).fst) x = fun dy => adjFDeriv 𝕜 f x (dy, 0) := + (HasAjdFDerivAt.fst hf.hasAdjFDerivAt).adjFDeriv @[simp] lemma adjFDeriv_prod_fst [CompleteSpace E] [CompleteSpace F] {x : F × E} : @@ -212,8 +212,8 @@ lemma HasAjdFDerivAt.snd {f : E → F×G} {f'} {x : E} (hf : HasAdjFDerivAt 𝕜 lemma adjFDeriv_snd [CompleteSpace E] [CompleteSpace F] [CompleteSpace G] {f : E → F×G} {x : E} (hf : DifferentiableAt 𝕜 f x) : - adjFDeriv 𝕜 (fun x => (f x).snd) x = fun dy => adjFDeriv 𝕜 f x (0, dy) := by - exact (HasAjdFDerivAt.snd hf.hasAdjFDerivAt).adjFDeriv + adjFDeriv 𝕜 (fun x => (f x).snd) x = fun dy => adjFDeriv 𝕜 f x (0, dy) := + (HasAjdFDerivAt.snd hf.hasAdjFDerivAt).adjFDeriv @[simp] lemma adjFDeriv_prod_snd [CompleteSpace E] [CompleteSpace F] {x : F × E} : @@ -257,8 +257,8 @@ lemma HasAdjFDerivAt.neg {f : E → F} {f'} {x : E} (hf : HasAdjFDerivAt 𝕜 f lemma adjFDeriv_neg [CompleteSpace E] [CompleteSpace F] {f : E → F} {x : E} (hf : DifferentiableAt 𝕜 f x) : - adjFDeriv 𝕜 (fun x => - f x) x = fun dy => - adjFDeriv 𝕜 f x dy := by - exact (HasAdjFDerivAt.neg hf.hasAdjFDerivAt).adjFDeriv + adjFDeriv 𝕜 (fun x => - f x) x = fun dy => - adjFDeriv 𝕜 f x dy := + (HasAdjFDerivAt.neg hf.hasAdjFDerivAt).adjFDeriv lemma HasAjdFDerivAt.add {f g : E → F} {f' g'} {x : E} (hf : HasAdjFDerivAt 𝕜 f f' x) (hg : HasAdjFDerivAt 𝕜 g g' x) : @@ -271,8 +271,8 @@ lemma HasAjdFDerivAt.add {f g : E → F} {f' g'} {x : E} lemma adjFDeriv_add [CompleteSpace E] [CompleteSpace F] {f g : E → F} {x : E} (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : - adjFDeriv 𝕜 (fun x => f x + g x) x = fun dy => adjFDeriv 𝕜 f x dy + adjFDeriv 𝕜 g x dy := by - exact (HasAjdFDerivAt.add hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv + adjFDeriv 𝕜 (fun x => f x + g x) x = fun dy => adjFDeriv 𝕜 f x dy + adjFDeriv 𝕜 g x dy := + (HasAjdFDerivAt.add hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv lemma HasAdjFDerivAt.sub {f g : E → F} {f' g'} {x : E} @@ -285,8 +285,8 @@ lemma HasAdjFDerivAt.sub lemma adjFDeriv_sub [CompleteSpace E] [CompleteSpace F] {f g : E → F} {x : E} (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : - adjFDeriv 𝕜 (fun x => f x - g x) x = fun dy => adjFDeriv 𝕜 f x dy - adjFDeriv 𝕜 g x dy := by - exact (HasAdjFDerivAt.sub hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv + adjFDeriv 𝕜 (fun x => f x - g x) x = fun dy => adjFDeriv 𝕜 f x dy - adjFDeriv 𝕜 g x dy := + (HasAdjFDerivAt.sub hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv open ComplexConjugate in lemma HasAdjFDerivAt.smul {f : E → F} {g : E → 𝕜} {f' g'} @@ -305,8 +305,8 @@ lemma adjFDeriv_smul [CompleteSpace E] [CompleteSpace F] {f : E → F} {g : E → 𝕜} {x : E} (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : adjFDeriv 𝕜 (fun x => g x • f x) x = fun dy => conj (g x) • adjFDeriv 𝕜 f x dy + - adjFDeriv 𝕜 g x (conj (inner 𝕜 dy (f x))) := by - exact (HasAdjFDerivAt.smul hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv + adjFDeriv 𝕜 g x (conj (inner 𝕜 dy (f x))) := + (HasAdjFDerivAt.smul hf.hasAdjFDerivAt hg.hasAdjFDerivAt).adjFDeriv set_option backward.isDefEq.respectTransparency false in open InnerProductSpace in From 9e5a34dafa91eb7835bdd7f9b26c0b1f6d5902c8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:19:42 -0700 Subject: [PATCH 071/498] refactor: golf variational and qft wrappers Co-authored-by: Claude Opus 4.8 --- .../Mathematics/VariationalCalculus/HasVarAdjDeriv.lean | 8 ++++---- .../Mathematics/VariationalCalculus/HasVarAdjoint.lean | 6 ++---- Physlib/QFT/AnomalyCancellation/Basic.lean | 4 ++-- .../QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index 9304ac6a1..744e68a8c 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -66,8 +66,8 @@ lemma apply_smooth_of_smooth {F : (X → U) → (X → V)} {F' : (X → V) → ( fun_prop lemma apply_smooth_self {F : (X → U) → (X → V)} {F' : (X → V) → (X → U)} {u : X → U} - (h : HasVarAdjDerivAt F F' u) : ContDiff ℝ ∞ (F u) := by - exact h.apply_smooth_of_smooth (h.smooth_at) + (h : HasVarAdjDerivAt F F' u) : ContDiff ℝ ∞ (F u) := + h.apply_smooth_of_smooth (h.smooth_at) lemma smooth_R {F : (X → U) → (X → V)} {F' : (X → V) → (X → U)} {u : X → U} (h : HasVarAdjDerivAt F F' u) {φ : ℝ → X → U} (hφ : ContDiff ℝ ∞ ↿φ) (x : X) : @@ -96,8 +96,8 @@ lemma smooth_adjoint {F : (X → U) → (X → V)} {F' : (X → V) → (X → U) lemma differentiable_linear {F : (X → U) → (X → V)} {F' : (X → V) → (X → U)} {u : X → U} (h : HasVarAdjDerivAt F F' u) {φ : ℝ → X → U} (hφ : ContDiff ℝ ∞ ↿φ) (x : X) : - Differentiable ℝ (fun s' : ℝ => F (fun x => φ 0 x + s' • deriv (φ · x) 0) x) := by - exact fun x => (h.smooth_linear hφ).differentiable (by simp) x + Differentiable ℝ (fun s' : ℝ => F (fun x => φ 0 x + s' • deriv (φ · x) 0) x) := + fun x => (h.smooth_linear hφ).differentiable (by simp) x omit [MeasureSpace X] [InnerProductSpace' ℝ U] [InnerProductSpace' ℝ V] in lemma linearize_of_linear {F : (X → U) → (X → V)} diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean index 9be1a202f..6d48dd71f 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean @@ -695,8 +695,7 @@ lemma fst {F'} {F : (X → U) → (X → W×V)} HasVarAdjoint (fun φ x => (F φ x).1) (fun φ x => F' (fun x' => (φ x', 0)) x) where - test_fun_preserving _ hφ := by - exact IsTestFunction.prod_fst (hF.test_fun_preserving _ hφ) + test_fun_preserving _ hφ := IsTestFunction.prod_fst (hF.test_fun_preserving _ hφ) test_fun_preserving' y hφ := by apply hF.test_fun_preserving' fun_prop @@ -720,8 +719,7 @@ lemma snd {F'} {F : (X → U) → (X → W×V)} HasVarAdjoint (fun φ x => (F φ x).2) (fun φ x => F' (fun x' => (0, φ x')) x) where - test_fun_preserving _ hφ := by - exact IsTestFunction.prod_snd (hF.test_fun_preserving _ hφ) + test_fun_preserving _ hφ := IsTestFunction.prod_snd (hF.test_fun_preserving _ hφ) test_fun_preserving' y hφ := by apply hF.test_fun_preserving' _ fun_prop diff --git a/Physlib/QFT/AnomalyCancellation/Basic.lean b/Physlib/QFT/AnomalyCancellation/Basic.lean index dcd68a49c..98957f780 100644 --- a/Physlib/QFT/AnomalyCancellation/Basic.lean +++ b/Physlib/QFT/AnomalyCancellation/Basic.lean @@ -383,8 +383,8 @@ def quadSolsIncl (χ : ACCSystemQuad) : χ.QuadSols →[ℚ] χ.Charges := lemma quadSolsIncl_injective (χ : ACCSystemQuad) : Function.Injective χ.quadSolsIncl := by intro S T h - have h' : χ.quadSolsInclLinSols S = χ.quadSolsInclLinSols T := by - exact ACCSystemLinear.linSolsIncl_injective (χ := χ.toACCSystemLinear) h + have h' : χ.quadSolsInclLinSols S = χ.quadSolsInclLinSols T := + ACCSystemLinear.linSolsIncl_injective (χ := χ.toACCSystemLinear) h exact quadSolsInclLinSols_injective χ h' end ACCSystemQuad diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index b972bd48d..2c26bca6b 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -41,8 +41,8 @@ lemma ι_superCommuteF_eq_zero_of_ι_left_zero (a b : 𝓕.FieldOpFreeAlgebra) ( -/ lemma ι_superCommuteF_right_zero_of_mem_ideal (a b : 𝓕.FieldOpFreeAlgebra) - (h : b ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet) : ι [a, b]ₛF = 0 := by - exact ι_superCommuteF_eq_zero_of_ι_right_zero a b ((ι_eq_zero_iff_mem_ideal b).mpr h) + (h : b ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet) : ι [a, b]ₛF = 0 := + ι_superCommuteF_eq_zero_of_ι_right_zero a b ((ι_eq_zero_iff_mem_ideal b).mpr h) lemma ι_superCommuteF_eq_of_equiv_right (a b1 b2 : 𝓕.FieldOpFreeAlgebra) (h : b1 ≈ b2) : ι [a, b1]ₛF = ι [a, b2]ₛF := by From 8775a8603b137ad990dc42d4e0254a7849092f14 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:20:49 -0700 Subject: [PATCH 072/498] refactor(qed): golf basis and const-abs wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/SpecialFunctions/PhysHermite.lean | 4 ++-- Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean | 8 ++++---- Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 4 ++-- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean index 68d76cc46..7661d8600 100644 --- a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean +++ b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean @@ -482,8 +482,8 @@ lemma cos_mem_physHermite_span_topologicalClosure (c : ℝ) : simp only [HasSum] at h1 have h1 : Filter.Tendsto (fun s => fun y => ∑ x ∈ s, (-1) ^ x * (c * y) ^ (2 * x) / ((2 * x)! : ℝ)) - Filter.atTop (nhds (fun x => Real.cos (c * x))) := by - exact tendsto_pi_nhds.mpr fun x => h1 (c * x) + Filter.atTop (nhds (fun x => Real.cos (c * x))) := + tendsto_pi_nhds.mpr fun x => h1 (c * x) have h2 (z : Finset ℕ) : (fun y => ∑ x ∈ z, (-1) ^ x * (c * y) ^ (2 * x) / ↑(2 * x)!) ∈ ↑(Submodule.span ℝ (Set.range (fun n => (physHermite n : ℝ → ℝ)))) := by have h0 : (fun y => ∑ x ∈ z, (-1) ^ x * (c * y) ^ (2 * x) / ↑(2 * x)!) = diff --git a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean index 0e306e47b..25be0d979 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean @@ -63,8 +63,8 @@ lemma lt_eq {k i : Fin n.succ} (hk : S k ≤ 0) (hik : i ≤ k) : S i = S k := b · linarith include hS in -lemma val_le_zero {i : Fin n.succ} (hi : S i ≤ 0) : S i = S (0 : Fin n.succ) := by - exact (lt_eq hS hi (Fin.zero_le i)).symm +lemma val_le_zero {i : Fin n.succ} (hi : S i ≤ 0) : S i = S (0 : Fin n.succ) := + (lt_eq hS hi (Fin.zero_le i)).symm include hS in lemma gt_eq {k i: Fin n.succ} (hk : 0 ≤ S k) (hik : k ≤ i) : S i = S k := by @@ -205,8 +205,8 @@ lemma AFL_odd_zero {A : (PureU1 (2 * n + 1)).LinSols} (h : ConstAbsSorted A.val) exact (AFL_odd_noBoundary h hn) (AFL_hasBoundary h hn) theorem AFL_odd (A : (PureU1 (2 * n + 1)).LinSols) (h : ConstAbsSorted A.val) : - A = 0 := by - exact ACCSystemLinear.LinSols.ext (is_zero h (AFL_odd_zero h)) + A = 0 := + ACCSystemLinear.LinSols.ext (is_zero h (AFL_odd_zero h)) lemma AFL_even_Boundary {A : (PureU1 (2 * n.succ)).LinSols} (h : ConstAbsSorted A.val) (hA : A.val (0 : Fin (2 * n.succ)) ≠ 0) {k : Fin (2 * n + 1)} (hk : Boundary A.val k) : diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index adfe2a8ee..938c956ce 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -1036,8 +1036,8 @@ lemma span_basis_swap! {S : (PureU1 (2 * n.succ)).LinSols} (j : Fin n) S'.val = P g' + P! f' ∧ P! f' = P! f + (S.val (evenShiftSnd j) - S.val (evenShiftFst j)) • basis!AsCharges j ∧ g' = g := by let X := P! f + (S.val (evenShiftSnd j) - S.val (evenShiftFst j)) • basis!AsCharges j - have hX : X ∈ Submodule.span ℚ (Set.range (basis!AsCharges)) := by - exact Submodule.add_mem _ (P!_in_span f) (smul_basis!AsCharges_in_span S j) + have hX : X ∈ Submodule.span ℚ (Set.range (basis!AsCharges)) := + Submodule.add_mem _ (P!_in_span f) (smul_basis!AsCharges_in_span S j) have hXsum := (Submodule.mem_span_range_iff_exists_fun ℚ).mp hX obtain ⟨f', hf'⟩ := hXsum use g diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 4f2853631..7464fe53e 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -1009,8 +1009,8 @@ lemma span_basis_swap! {S : (PureU1 (2 * n.succ + 1)).LinSols} (j : Fin n.succ) apply SetLike.mem_of_subset apply Submodule.subset_span simp_all only [Set.mem_range, exists_apply_eq_apply] - have hX : X ∈ Submodule.span ℚ (Set.range (basis!AsCharges)) := by - exact Submodule.add_mem _ hf hP + have hX : X ∈ Submodule.span ℚ (Set.range (basis!AsCharges)) := + Submodule.add_mem _ hf hP have hXsum := (Submodule.mem_span_range_iff_exists_fun ℚ).mp hX obtain ⟨f', hf'⟩ := hXsum use g From ea148c8f14ffa7e470bcd80ea5c3deaf5c6c5660 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:22:06 -0700 Subject: [PATCH 073/498] refactor(qft): golf koszul wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List.lean | 4 ++-- .../QFT/PerturbationTheory/Koszul/KoszulSign.lean | 4 ++-- .../PerturbationTheory/Koszul/KoszulSignInsert.lean | 12 ++++++------ .../WickContraction/Sign/Join.lean | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Physlib/Mathematics/List.lean b/Physlib/Mathematics/List.lean index d2c0fa4e4..abc26fb7d 100644 --- a/Physlib/Mathematics/List.lean +++ b/Physlib/Mathematics/List.lean @@ -187,8 +187,8 @@ lemma orderedInsertPos_drop_eq_orderedInsert {I : Type} (le1 : I → I → Prop) List.drop (orderedInsertPos le1 r r0).succ (List.orderedInsert le1 r0 r) := by conv_rhs => simp [orderedInsertPos, List.orderedInsert_eq_take_drop] have hr : r = List.takeWhile (fun b => !decide (le1 r0 b)) r ++ - List.dropWhile (fun b => !decide (le1 r0 b)) r := by - exact Eq.symm (List.takeWhile_append_dropWhile) + List.dropWhile (fun b => !decide (le1 r0 b)) r := + Eq.symm (List.takeWhile_append_dropWhile) conv_lhs => rhs rw [hr] diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index b478016ea..d51d42c8f 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -323,8 +323,8 @@ lemma koszulSign_of_sorted : (φs : List 𝓕) @[simp] lemma koszulSign_of_insertionSort [Std.Total le] [IsTrans 𝓕 le] (φs : List 𝓕) : - koszulSign q le (List.insertionSort le φs) = 1 := by - exact koszulSign_of_sorted q le _ (List.pairwise_insertionSort le φs) + koszulSign q le (List.insertionSort le φs) = 1 := + koszulSign_of_sorted q le _ (List.pairwise_insertionSort le φs) lemma koszulSign_of_append_eq_insertionSort_left [Std.Total le] [IsTrans 𝓕 le] : (φs φs' : List 𝓕) → koszulSign q le (φs ++ φs') = diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean index 52841c33f..5dbed34d4 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean @@ -148,13 +148,13 @@ lemma koszulSignInsert_eq_perm (φs φs' : List 𝓕) (φ : 𝓕) (h : φs.Perm simp only [decide_not, eq_iff_iff, and_congr_right_iff] intro h' have hg : ofList q (List.filter (fun i => !decide (le φ i)) φs) = - ofList q (List.filter (fun i => !decide (le φ i)) φs') := by - exact ofList_perm q (List.Perm.filter (fun i => !decide (le φ i)) h) + ofList q (List.filter (fun i => !decide (le φ i)) φs') := + ofList_perm q (List.Perm.filter (fun i => !decide (le φ i)) h) rw [hg] lemma koszulSignInsert_eq_sort (φs : List 𝓕) (φ : 𝓕) : - koszulSignInsert q le φ φs = koszulSignInsert q le φ (List.insertionSort le φs) := by - exact koszulSignInsert_eq_perm q le _ _ _ (List.Perm.symm (List.perm_insertionSort le φs)) + koszulSignInsert q le φ φs = koszulSignInsert q le φ (List.insertionSort le φs) := + koszulSignInsert_eq_perm q le _ _ _ (List.Perm.symm (List.perm_insertionSort le φs)) lemma koszulSignInsert_eq_exchangeSign_take [Std.Total le] [IsTrans 𝓕 le] (φ : 𝓕) (φs : List 𝓕) : koszulSignInsert q le φ φs = 𝓢(q φ, ofList q @@ -207,8 +207,8 @@ lemma koszulSignInsert_eq_exchangeSign_take [Std.Total le] [IsTrans 𝓕 le] (φ · simp [orderedInsertPos] lemma koszulSignInsert_insertIdx (i j : 𝓕) (r : List 𝓕) (n : ℕ) (hn : n ≤ r.length) : - koszulSignInsert q le j (List.insertIdx r n i) = koszulSignInsert q le j (i :: r) := by - exact koszulSignInsert_eq_perm q le _ _ _ (List.perm_insertIdx i r hn) + koszulSignInsert q le j (List.insertIdx r n i) = koszulSignInsert q le j (i :: r) := + koszulSignInsert_eq_perm q le _ _ _ (List.perm_insertIdx i r hn) /-- The difference in `koszulSignInsert` on inserting `r0` into `r` compared to into `r1 :: r` for any `r`. -/ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean index c71d2c0a2..8fb183a2b 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean @@ -338,8 +338,8 @@ lemma joinSignLeftExtra_eq_joinSignRightExtra {φs : List 𝓕.FieldOp} funext a have hjneqsnd := singleton_uncontractedEmd_ne_right h (φsucΛ.sndFieldOfContract a) have hl : uncontractedListEmd (φsucΛ.fstFieldOfContract a) < - uncontractedListEmd (φsucΛ.sndFieldOfContract a) := by - exact uncontractedListEmd_strictMono (fstFieldOfContract_lt_sndFieldOfContract φsucΛ a) + uncontractedListEmd (φsucΛ.sndFieldOfContract a) := + uncontractedListEmd_strictMono (fstFieldOfContract_lt_sndFieldOfContract φsucΛ a) by_cases hj1 : ¬ uncontractedListEmd (φsucΛ.fstFieldOfContract a) < j · have hi1 : ¬ uncontractedListEmd (φsucΛ.fstFieldOfContract a) < i := by omega simp [hj1, hi1] From e4a9596f8bde27c01d7ef6e7cc3aa2fcc625cc30 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:23:19 -0700 Subject: [PATCH 074/498] refactor(qft): golf uncontracted-list helpers Co-authored-by: Claude Opus 4.8 --- .../WickContraction/UncontractedList.lean | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index 1a568a140..a0f5ca599 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -50,8 +50,8 @@ lemma fin_list_sorted_succAboveEmb_sorted (l: List (Fin n)) (hl : l.Pairwise (· lemma fin_finset_sort_map_monotone {n m : ℕ} (a : Finset (Fin n)) (f : Fin n ↪ Fin m) (hf : StrictMono f) : (a.sort (· ≤ ·)).map f = ((a.map f).sort (· ≤ ·)) := by - have h1 : ((a.sort (· ≤ ·)).map f).Pairwise (· ≤ ·) := by - exact fin_list_sorted_monotone_sorted _ (a.pairwise_sort (fun x1 x2 => x1 ≤ x2)) f hf + have h1 : ((a.sort (· ≤ ·)).map f).Pairwise (· ≤ ·) := + fin_list_sorted_monotone_sorted _ (a.pairwise_sort (fun x1 x2 => x1 ≤ x2)) f hf have h2 : ((a.sort (· ≤ ·)).map f).Nodup := by refine (List.nodup_map_iff_inj_on ?_).mpr ?_ exact a.sort_nodup (fun x1 x2 => x1 ≤ x2) @@ -215,8 +215,7 @@ lemma uncontractedList_sorted : List.Pairwise (· ≤ ·) c.uncontractedList := rw [uncontractedList] apply List.Pairwise.filter rw [← List.ofFn_id] - refine List.sortedLE_iff_pairwise.mp ?_ - exact Monotone.sortedLE_ofFn fun ⦃a b⦄ a => a + exact List.sortedLE_iff_pairwise.mp (Monotone.sortedLE_ofFn fun ⦃a b⦄ a => a) lemma uncontractedList_sorted_lt : List.Pairwise (· < ·) c.uncontractedList := by rw [uncontractedList] @@ -226,8 +225,7 @@ lemma uncontractedList_sorted_lt : List.Pairwise (· < ·) c.uncontractedList := lemma uncontractedList_nodup : c.uncontractedList.Nodup := by rw [uncontractedList] - refine List.Nodup.filter (fun x => decide (x ∈ c.uncontracted)) ?_ - exact List.nodup_finRange n + exact List.Nodup.filter (fun x => decide (x ∈ c.uncontracted)) (List.nodup_finRange n) lemma uncontractedList_toFinset (c : WickContraction n) : c.uncontractedList.toFinset = c.uncontracted := by @@ -467,8 +465,8 @@ lemma uncontractedList_succAbove_orderedInsert_nodup (c : WickContraction n) (i lemma uncontractedList_succAbove_orderedInsert_sorted (c : WickContraction n) (i : Fin n.succ) : (List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := by - refine List.Pairwise.orderedInsert i (List.map (⇑i.succAboveEmb) c.uncontractedList) ?_ - exact uncontractedList_succAboveEmb_sorted c i + exact List.Pairwise.orderedInsert i (List.map (⇑i.succAboveEmb) c.uncontractedList) + (uncontractedList_succAboveEmb_sorted c i) lemma uncontractedList_succAbove_orderedInsert_toFinset (c : WickContraction n) (i : Fin n.succ) : (List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).toFinset = @@ -534,8 +532,7 @@ lemma uncontractedList_succAboveEmb_eraseIdx_sorted (c : WickContraction n) (i : lemma uncontractedList_succAboveEmb_eraseIdx_nodup (c : WickContraction n) (i : Fin n.succ) (k: ℕ) : ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Nodup := by - refine List.Nodup.eraseIdx k ?_ - exact uncontractedList_succAboveEmb_nodup c i + exact List.Nodup.eraseIdx k (uncontractedList_succAboveEmb_nodup c i) lemma uncontractedList_succAboveEmb_eraseIdx_eq_sort (c : WickContraction n) (i : Fin n.succ) (k : ℕ) (hk : k < c.uncontractedList.length) : From 42d63868411bdd58efc57cec76d0c49df44d4612 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:25:14 -0700 Subject: [PATCH 075/498] refactor: golf wave and linear-map wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Vacuum/Constant.lean | 10 +++++----- Physlib/Electromagnetism/Vacuum/HarmonicWave.lean | 12 ++++++------ Physlib/Mathematics/LinearMaps.lean | 8 ++++---- Physlib/Relativity/LorentzGroup/Basic.lean | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Physlib/Electromagnetism/Vacuum/Constant.lean b/Physlib/Electromagnetism/Vacuum/Constant.lean index cd33bc31a..9ba469e90 100644 --- a/Physlib/Electromagnetism/Vacuum/Constant.lean +++ b/Physlib/Electromagnetism/Vacuum/Constant.lean @@ -85,10 +85,10 @@ The potential is smooth. lemma constantEB_smooth {c : SpeedOfLight} {E₀ : EuclideanSpace ℝ (Fin d)} {B₀ : Fin d × Fin d → ℝ} {B₀_antisymm : ∀ i j, B₀ (i, j) = - B₀ (j, i)} : - ContDiff ℝ ∞ (constantEB c E₀ B₀ B₀_antisymm) := by - exact (Lorentz.Vector.contDiff_apply _).mp fun μ => by + ContDiff ℝ ∞ (constantEB c E₀ B₀ B₀_antisymm) := + (Lorentz.Vector.contDiff_apply _).mp (fun μ => by match μ with - | Sum.inl _ => + | Sum.inl _ => simp [constantEB] apply ContDiff.neg apply ContDiff.mul @@ -96,7 +96,7 @@ lemma constantEB_smooth {c : SpeedOfLight} apply ContDiff.inner · fun_prop · fun_prop - | Sum.inr i => + | Sum.inr i => simp [constantEB] apply ContDiff.mul · fun_prop @@ -104,7 +104,7 @@ lemma constantEB_smooth {c : SpeedOfLight} intro j _ apply ContDiff.mul · fun_prop - fun_prop + fun_prop) /-! diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index 73164e01d..9dc5394fc 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -104,9 +104,9 @@ lemma harmonicWaveX_inr_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → lemma harmonicWaveX_differentiable {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) : - Differentiable ℝ (harmonicWaveX 𝓕 k E₀ φ) := by - exact (Lorentz.Vector.differentiable_apply _).mp fun μ => by - match μ with + Differentiable ℝ (harmonicWaveX 𝓕 k E₀ φ) := + (Lorentz.Vector.differentiable_apply _).mp fun μ => by + match μ with | Sum.inl 0 => simp | Sum.inr ⟨0, h⟩ => simp | Sum.inr ⟨Nat.succ i, h⟩ => @@ -122,9 +122,9 @@ lemma harmonicWaveX_differentiable {d} (𝓕 : FreeSpace) (k : ℝ) lemma harmonicWaveX_contDiff {d} (n : WithTop ℕ∞) (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) : - ContDiff ℝ n (harmonicWaveX 𝓕 k E₀ φ) := by - exact (Lorentz.Vector.contDiff_apply _).mp fun μ => by - match μ with + ContDiff ℝ n (harmonicWaveX 𝓕 k E₀ φ) := + (Lorentz.Vector.contDiff_apply _).mp fun μ => by + match μ with | Sum.inl 0 => simp [harmonicWaveX]; fun_prop | Sum.inr ⟨0, h⟩ => simp [harmonicWaveX]; fun_prop | Sum.inr ⟨Nat.succ i, h⟩ => diff --git a/Physlib/Mathematics/LinearMaps.lean b/Physlib/Mathematics/LinearMaps.lean index 4c4279a07..00cb662a5 100644 --- a/Physlib/Mathematics/LinearMaps.lean +++ b/Physlib/Mathematics/LinearMaps.lean @@ -87,16 +87,16 @@ def mk₂ (f : V × V → ℚ) (map_smul : ∀ a S T, f (a • S, T) = a * f (S, map_add' := fun S1 S2 => LinearMap.ext fun T => map_add S1 S2 T swap' := swap -lemma map_smul₁ (f : BiLinearSymm V) (a : ℚ) (S T : V) : f (a • S) T = a * f S T := by - exact (congrArg (fun g : V →ₗ[ℚ] ℚ => g T) (f.map_smul a S)).trans (by rfl) +lemma map_smul₁ (f : BiLinearSymm V) (a : ℚ) (S T : V) : f (a • S) T = a * f S T := + (congrArg (fun g : V →ₗ[ℚ] ℚ => g T) (f.map_smul a S)).trans (by rfl) lemma swap (f : BiLinearSymm V) (S T : V) : f S T = f T S := f.swap' S T lemma map_smul₂ (f : BiLinearSymm V) (a : ℚ) (S : V) (T : V) : f S (a • T) = a * f S T := by rw [f.swap, f.map_smul₁, f.swap] -lemma map_add₁ (f : BiLinearSymm V) (S1 S2 T : V) : f (S1 + S2) T = f S1 T + f S2 T := by - exact (congrArg (fun g : V →ₗ[ℚ] ℚ => g T) (f.map_add S1 S2)).trans (by rfl) +lemma map_add₁ (f : BiLinearSymm V) (S1 S2 T : V) : f (S1 + S2) T = f S1 T + f S2 T := + (congrArg (fun g : V →ₗ[ℚ] ℚ => g T) (f.map_add S1 S2)).trans (by rfl) lemma map_add₂ (f : BiLinearSymm V) (S : V) (T1 T2 : V) : f S (T1 + T2) = f S T1 + f S T2 := by diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 33e29c8e7..50258a325 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -415,7 +415,7 @@ def parity : LorentzGroup d := ⟨minkowskiMatrix, by -/ lemma eq_of_mulVec_eq {Λ Λ' : LorentzGroup d} - (h : ∀ (x : Fin 1 ⊕ Fin d → ℝ), Λ.1 *ᵥ x = Λ'.1 *ᵥ x) : Λ = Λ' := by - exact Subtype.ext (ext_of_mulVec_single fun i => h (Pi.single i 1)) + (h : ∀ (x : Fin 1 ⊕ Fin d → ℝ), Λ.1 *ᵥ x = Λ'.1 *ᵥ x) : Λ = Λ' := + Subtype.ext (ext_of_mulVec_single fun i => h (Pi.single i 1)) end LorentzGroup From 80bbef7bb4fbc5b264c9846b7f189a86fef8bc54 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:26:44 -0700 Subject: [PATCH 076/498] refactor: golf time and canonical wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/TimeMan.lean | 7 ++----- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 7 ++----- Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean | 5 ++--- Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean | 3 +-- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/TimeMan.lean b/Physlib/SpaceAndTime/Time/TimeMan.lean index 772d26586..c0fdfaa0c 100644 --- a/Physlib/SpaceAndTime/Time/TimeMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeMan.lean @@ -129,16 +129,13 @@ instance : IsManifold 𝓘(ℝ, ℝ) ω TimeMan where exact symm_trans_mem_contDiffGroupoid valHomeomorphism.toOpenPartialHomeomorph lemma val_contDiff : ContMDiff 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ) ω TimeMan.val := by - refine contMDiffOn_univ.mp ?_ - exact contMDiffOn_chart (x := (⟨0⟩ : TimeMan)) + exact contMDiffOn_univ.mp (contMDiffOn_chart (x := (⟨0⟩ : TimeMan))) /-- The choice of map `Time.val` from `TimeMan` to `ℝ` as a diffeomorphism. -/ noncomputable def valDiffeomorphism : TimeMan ≃ₘ^ω⟮𝓘(ℝ, ℝ), 𝓘(ℝ, ℝ)⟯ ℝ where toEquiv := valHomeomorphism.toEquiv contMDiff_toFun := val_contDiff - contMDiff_invFun := by - refine contMDiffOn_univ.mp ?_ - exact contMDiffOn_chart_symm (x := (⟨0⟩ : TimeMan)) + contMDiff_invFun := contMDiffOn_univ.mp (contMDiffOn_chart_symm (x := (⟨0⟩ : TimeMan))) /-! diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index b38955e9b..a3fa5267d 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -148,16 +148,13 @@ instance : IsManifold 𝓘(ℝ, ℝ) ω TimeTransMan where exact symm_trans_mem_contDiffGroupoid valHomeomorphism.toOpenPartialHomeomorph lemma val_contDiff : ContMDiff 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ) ω TimeTransMan.val := by - refine contMDiffOn_univ.mp ?_ - exact contMDiffOn_chart (x := (⟨0⟩ : TimeTransMan)) + exact contMDiffOn_univ.mp (contMDiffOn_chart (x := (⟨0⟩ : TimeTransMan))) /-- The choice of map `Time.val` from `TimeTransMan` to `ℝ` as a diffeomorphism. -/ noncomputable def valDiffeomorphism : TimeTransMan ≃ₘ^ω⟮𝓘(ℝ, ℝ), 𝓘(ℝ, ℝ)⟯ ℝ where toEquiv := valHomeomorphism.toEquiv contMDiff_toFun := val_contDiff - contMDiff_invFun := by - refine contMDiffOn_univ.mp ?_ - exact contMDiffOn_chart_symm (x := (⟨0⟩ : TimeTransMan)) + contMDiff_invFun := contMDiffOn_univ.mp (contMDiffOn_chart_symm (x := (⟨0⟩ : TimeTransMan))) /-! diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 0b9b97e02..160ceba56 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -379,9 +379,8 @@ lemma μBolt_ne_zero_of_μ_ne_zero (T : Temperature) (h : 𝓒.μ ≠ 0) : simp simpa using h -instance (T : Temperature) [NeZero 𝓒.μ] : NeZero (𝓒.μBolt T) := by - refine { out := ?_ } - exact μBolt_ne_zero_of_μ_ne_zero 𝓒 T (Ne.symm (NeZero.ne' 𝓒.μ)) +instance (T : Temperature) [NeZero 𝓒.μ] : NeZero (𝓒.μBolt T) := + ⟨μBolt_ne_zero_of_μ_ne_zero 𝓒 T (Ne.symm (NeZero.ne' 𝓒.μ))⟩ instance (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] [IsFiniteMeasure (𝓒1.μBolt T)] : IsFiniteMeasure ((𝓒 + 𝓒1).μBolt T) := by diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index f1f80ed17..8388081fd 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -187,8 +187,7 @@ lemma μBolt_of_fintype (T : Temperature) [IsFinite 𝓒] (i : ι) : instance {T} [IsFinite 𝓒] : IsFiniteMeasure (𝓒.μBolt T) := by rw [μBolt] - refine isFiniteMeasure_withDensity_ofReal ?_ - exact HasFiniteIntegral.of_finite + exact isFiniteMeasure_withDensity_ofReal HasFiniteIntegral.of_finite @[simp] lemma μProd_of_fintype (T : Temperature) [IsFinite 𝓒] (i : ι) : From 30178505d42cd2e6789b7a6235b5832704683079 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:28:10 -0700 Subject: [PATCH 077/498] refactor: golf norm and uncontracted-list wrappers Co-authored-by: Claude Opus 4.8 --- .../WickContraction/UncontractedList.lean | 8 ++++---- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index a0f5ca599..a7b3b882b 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -464,8 +464,8 @@ lemma uncontractedList_succAbove_orderedInsert_nodup (c : WickContraction n) (i lemma uncontractedList_succAbove_orderedInsert_sorted (c : WickContraction n) (i : Fin n.succ) : (List.orderedInsert (· ≤ ·) i - (List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := by - exact List.Pairwise.orderedInsert i (List.map (⇑i.succAboveEmb) c.uncontractedList) + (List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := + List.Pairwise.orderedInsert i (List.map (⇑i.succAboveEmb) c.uncontractedList) (uncontractedList_succAboveEmb_sorted c i) lemma uncontractedList_succAbove_orderedInsert_toFinset (c : WickContraction n) (i : Fin n.succ) : @@ -531,8 +531,8 @@ lemma uncontractedList_succAboveEmb_eraseIdx_sorted (c : WickContraction n) (i : Physlib.List.eraseIdx_sorted (· ≤ ·) _ k (uncontractedList_succAboveEmb_sorted c i) lemma uncontractedList_succAboveEmb_eraseIdx_nodup (c : WickContraction n) (i : Fin n.succ) (k: ℕ) : - ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Nodup := by - exact List.Nodup.eraseIdx k (uncontractedList_succAboveEmb_nodup c i) + ((List.map i.succAboveEmb c.uncontractedList).eraseIdx k).Nodup := + List.Nodup.eraseIdx k (uncontractedList_succAboveEmb_nodup c i) lemma uncontractedList_succAboveEmb_eraseIdx_eq_sort (c : WickContraction n) (i : Fin n.succ) (k : ℕ) (hk : k < c.uncontractedList.length) : diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index d5352859f..afb434f30 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -1016,8 +1016,8 @@ private lemma radial_power_deriv_integral_by_parts ∂(.comap Subtype.val volume) = ∫ (x : ℝ) in Set.Ioi (0 : ℝ), - x ^ p * _root_.deriv (fun a => η (a • n.1)) x := by - exact MeasureTheory.integral_subtype_comap (μ := volume) + x ^ p * _root_.deriv (fun a => η (a • n.1)) x := + MeasureTheory.integral_subtype_comap (μ := volume) (s := Set.Ioi (0 : ℝ)) measurableSet_Ioi (fun x : ℝ => x ^ p * _root_.deriv (fun a => η (a • n.1)) x) have hright_subtype : @@ -1026,8 +1026,8 @@ private lemma radial_power_deriv_integral_by_parts ∂(.comap Subtype.val volume) = ∫ (x : ℝ) in Set.Ioi (0 : ℝ), - x ^ (p - 1) * η (x • n.1) := by - exact MeasureTheory.integral_subtype_comap (μ := volume) + x ^ (p - 1) * η (x • n.1) := + MeasureTheory.integral_subtype_comap (μ := volume) (s := Set.Ioi (0 : ℝ)) measurableSet_Ioi (fun x : ℝ => x ^ (p - 1) * η (x • n.1)) rw [hleft_subtype, hright_subtype] @@ -1179,8 +1179,8 @@ lemma distDiv_norm_zpow_smul_repr_self_eq_smul = - ∫ n, (∫ (r : Set.Ioi (0 : ℝ)), r.1 ^ p * (_root_.deriv (fun a => η (a • n.1)) r.1) ∂(.comap Subtype.val volume)) - ∂(volume (α := Space d).toSphere) := by - exact distDiv_norm_zpow_smul_repr_self_apply_eq_radial_deriv q hq hp_int η + ∂(volume (α := Space d).toSphere) := + distDiv_norm_zpow_smul_repr_self_apply_eq_radial_deriv q hq hp_int η _ = ∫ n, (p : ℝ) * ∫ (r : Set.Ioi (0 : ℝ)), r.1 ^ (p - 1) * η (r.1 • n.1) ∂(.comap Subtype.val volume) @@ -1444,8 +1444,8 @@ lemma distLaplacian_fundamentalSolution_norm_zpow {d : ℕ} : ‖x‖ ^ (- (d : ℤ)) • basis.repr x) (IsDistBounded.zpow_smul_repr_self (- (d : ℤ)) (by omega))) = (d * (volume (α := Space d)).real - (Metric.ball 0 1)) • diracDelta ℝ 0 := by - exact distDiv_inv_pow_eq_dim (d := d) + (Metric.ball 0 1)) • diracDelta ℝ 0 := + distDiv_inv_pow_eq_dim (d := d) rw [hdiv] rw [smul_smul] ring_nf From a3b932fcfbc0eb68584fed60782338e5afc2520b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:29:40 -0700 Subject: [PATCH 078/498] refactor(ftheory): golf quanta multiset proofs Co-authored-by: Claude Opus 4.8 --- .../FTheory/SU5/Quanta/FiveQuanta.lean | 14 ++++++-------- .../StringTheory/FTheory/SU5/Quanta/TenQuanta.lean | 10 ++++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean index 69f125ad4..9c0a015b7 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean @@ -162,8 +162,8 @@ def reduce (x : FiveQuanta 𝓩) : FiveQuanta 𝓩 := lemma reduce_nodup (x : FiveQuanta 𝓩) : x.reduce.Nodup := by rw [reduce] - refine Multiset.Nodup.map (fun q1 q2 h => ?_) (Multiset.nodup_dedup x.toCharges) - exact congrArg Prod.fst h + exact Multiset.Nodup.map (fun q1 q2 h => congrArg Prod.fst h) + (Multiset.nodup_dedup x.toCharges) @[simp] lemma reduce_dedup (x : FiveQuanta 𝓩) : x.reduce.dedup = x.reduce := @@ -282,8 +282,8 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : FiveQuanta 𝓩) (f rw [Multiset.sum_map_eq_nsmul_single p.1] simp only [↓reduceIte, smul_eq_mul] have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := by - refine Multiset.count_eq_one_of_mem ?_ h_mem_dedup - exact Multiset.nodup_dedup (Multiset.map Prod.fst x) + exact Multiset.count_eq_one_of_mem (Multiset.nodup_dedup (Multiset.map Prod.fst x)) + h_mem_dedup simp [h_count_one] intro q5' h h2 simp_all [eq_comm] @@ -370,8 +370,7 @@ lemma mem_powerset_sum_of_mem_reduce_toFluxesFive {F : FiveQuanta 𝓩} use (Multiset.map (fun x => x.2) (Multiset.filter (fun x => x.1 = q) F)) simp only [and_true] rw [toFluxesFive] - refine Multiset.map_le_map ?_ - exact Multiset.filter_le (fun x => x.1 = q) F + exact Multiset.map_le_map (Multiset.filter_le (fun x => x.1 = q) F) lemma mem_powerset_sum_of_mem_reduce_toFluxesFive_filter {F : FiveQuanta 𝓩} {f : Fluxes} (hf : f ∈ F.reduce.toFluxesFive) : @@ -388,8 +387,7 @@ lemma mem_powerset_sum_of_mem_reduce_toFluxesFive_filter {F : FiveQuanta 𝓩} apply And.intro simp only [Multiset.mem_powerset] rw [toFluxesFive] - refine Multiset.map_le_map ?_ - exact Multiset.filter_le (fun x => x.1 = q) F + exact Multiset.map_le_map (Multiset.filter_le (fun x => x.1 = q) F) simp [Multiset.empty_eq_zero, ne_eq, Multiset.map_eq_zero, Multiset.filter_eq_nil, Prod.forall, not_forall, Decidable.not_not] rw [toCharges, Multiset.mem_map] at hq diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean index 89ba6a9f8..2826abc16 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean @@ -297,8 +297,8 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : TenQuanta 𝓩) (f rw [Multiset.sum_map_eq_nsmul_single p.1] simp only [↓reduceIte, smul_eq_mul] have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := by - refine Multiset.count_eq_one_of_mem ?_ h_mem_dedup - exact Multiset.nodup_dedup (Multiset.map Prod.fst x) + exact Multiset.count_eq_one_of_mem (Multiset.nodup_dedup (Multiset.map Prod.fst x)) + h_mem_dedup simp [h_count_one] intro q5' h h2 simp_all [eq_comm] @@ -386,8 +386,7 @@ lemma mem_powerset_sum_of_mem_reduce_toFluxesTen {F : TenQuanta 𝓩} use (Multiset.map (fun x => x.2) (Multiset.filter (fun x => x.1 = q) F)) simp only [and_true] rw [toFluxesTen] - refine Multiset.map_le_map ?_ - exact Multiset.filter_le (fun x => x.1 = q) F + exact Multiset.map_le_map (Multiset.filter_le (fun x => x.1 = q) F) lemma mem_powerset_sum_of_mem_reduce_toFluxesTen_filter {F : TenQuanta 𝓩} {f : Fluxes} (hf : f ∈ F.reduce.toFluxesTen) : @@ -403,8 +402,7 @@ lemma mem_powerset_sum_of_mem_reduce_toFluxesTen_filter {F : TenQuanta 𝓩} Multiset.filter_eq_nil, Prod.forall, not_forall, Decidable.not_not, and_true] apply And.intro rw [toFluxesTen] - refine Multiset.map_le_map ?_ - exact Multiset.filter_le (fun x => x.1 = q) F + exact Multiset.map_le_map (Multiset.filter_le (fun x => x.1 = q) F) simpa [toCharges] using hq /-! From 123d377717774b73bfaa4e8cbc20aa66f7afc3a2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:31:03 -0700 Subject: [PATCH 079/498] refactor(qft): golf time-order wrappers Co-authored-by: Claude Opus 4.8 --- .../AnomalyCancellation/Basic.lean | 6 +++--- .../FieldOpFreeAlgebra/TimeOrder.lean | 3 +-- .../WickAlgebra/TimeOrder.lean | 17 +++++++---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index 15d743d35..3d00008d3 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -58,9 +58,9 @@ lemma toSpecies_apply_eq (i : Fin 5) (S : (SMCharges n).Charges) : lemma charges_eq_toSpecies_eq (S T : (SMCharges n).Charges) : S = T ↔ ∀ i, toSpecies i S = toSpecies i T := by - refine Iff.intro (fun a i => congrArg (⇑(toSpecies i)) a) (fun h => ?_) - exact toSpeciesEquiv.injective - ((Set.eqOn_univ (toSpeciesEquiv S) (toSpeciesEquiv T)).mp fun ⦃x⦄ _ => h x) + exact Iff.intro (fun a i => congrArg (⇑(toSpecies i)) a) fun h => + toSpeciesEquiv.injective + ((Set.eqOn_univ (toSpeciesEquiv S) (toSpeciesEquiv T)).mp fun ⦃x⦄ _ => h x) lemma toSMSpecies_toSpecies_inv (i : Fin 5) (f : Fin 5 → Fin n → ℚ) : (toSpecies i) (toSpeciesEquiv.symm f) = f i := by diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean index 609add0c7..1a2430219 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean @@ -289,8 +289,7 @@ lemma timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_all_not_crAnTimeOrderRel exact h21 (IsTrans.trans φ2 φ3 φ1 h23 h31) rw [timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_not_crAnTimeOrderRel' h21 h31] simp_all only [Decidable.not_not, forall_const] - refine False.elim (h ?_) - exact IsTrans.trans φ3 φ2 φ1 h32 h21 + exact False.elim (h (IsTrans.trans φ3 φ2 φ1 h32 h21)) lemma timeOrderF_superCommuteF_ofCrAnOpF_ofCrAnOpF_eq_time {φ ψ : 𝓕.CrAnFieldOp} (h1 : crAnTimeOrderRel φ ψ) (h2 : crAnTimeOrderRel ψ φ) : diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 1b3a5c176..4185b92a5 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -71,9 +71,8 @@ lemma ι_timeOrderF_superCommuteF_superCommuteF_eq_time_ofCrAnListF {φ1 φ2 φ3 simp only [decide_not, Bool.decide_and, ofCrAnListF_append, map_smul, map_mul, l1, l2, mul_assoc] congr 1 - have hp : List.Perm [φ1, φ3, φ2] [φ1, φ2, φ3] := by - refine List.Perm.cons φ1 ?_ - exact List.Perm.swap φ2 φ3 [] + have hp : List.Perm [φ1, φ3, φ2] [φ1, φ2, φ3] := + List.Perm.cons φ1 (List.Perm.swap φ2 φ3 []) rw [crAnTimeOrderSign, Wick.koszulSign_perm_eq _ _ φ1 _ _ _ _ _ hp, ← crAnTimeOrderSign] · simp · intro φ4 hφ4 @@ -82,10 +81,9 @@ lemma ι_timeOrderF_superCommuteF_superCommuteF_eq_time_ofCrAnListF {φ1 φ2 φ3 all_goals subst hφ4 simp_all - have hp231 : List.Perm [φ2, φ3, φ1] [φ1, φ2, φ3] := by - refine List.Perm.trans (l₂ := [φ2, φ1, φ3]) ?_ ?_ - refine List.Perm.cons φ2 (List.Perm.swap φ1 φ3 []) - exact List.Perm.swap φ1 φ2 [φ3] + have hp231 : List.Perm [φ2, φ3, φ1] [φ1, φ2, φ3] := + List.Perm.trans (List.Perm.cons φ2 (List.Perm.swap φ1 φ3 [])) + (List.Perm.swap φ1 φ2 [φ3]) have h231 : ι 𝓣ᶠ(ofCrAnListF (φs1 ++ φ2 :: φ3 :: φ1 :: φs2)) = crAnTimeOrderSign (φs1 ++ φ1 :: φ2 :: φ3 :: φs2) • (ι (ofCrAnListF l1) * ι (ofCrAnListF [φ2, φ3, φ1]) * ι (ofCrAnListF l2)) := by @@ -114,9 +112,8 @@ lemma ι_timeOrderF_superCommuteF_superCommuteF_eq_time_ofCrAnListF {φ1 φ2 φ3 simp only [decide_not, Bool.decide_and, ofCrAnListF_append, map_smul, map_mul, l1, l2, mul_assoc] congr 1 - have hp : List.Perm [φ3, φ2, φ1] [φ1, φ2, φ3] := by - refine List.Perm.trans ?_ hp231 - exact List.Perm.swap φ2 φ3 [φ1] + have hp : List.Perm [φ3, φ2, φ1] [φ1, φ2, φ3] := + List.Perm.trans (List.Perm.swap φ2 φ3 [φ1]) hp231 rw [crAnTimeOrderSign, Wick.koszulSign_perm_eq _ _ φ1 _ _ _ _ _ hp, ← crAnTimeOrderSign] · simp · intro φ4 hφ4 From 8c4aaa2281a3c80b2e129a0ec09c54ade869f5b9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:32:36 -0700 Subject: [PATCH 080/498] refactor: golf vector and wick helper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Kinematics/VectorPotential.lean | 6 ++---- .../WickContraction/InsertAndContract.lean | 6 ++---- Physlib/QFT/PerturbationTheory/WickContraction/Join.lean | 3 +-- .../Tensors/RealTensor/Vector/Pre/Contraction.lean | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index 538e3a29a..eaded8ec7 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -239,8 +239,7 @@ lemma vectorPotential_contDiff {n} {d} {c : SpeedOfLight} (A : ElectromagneticPo (hA : ContDiff ℝ n A) : ContDiff ℝ n ↿(A.vectorPotential c) := by simp [vectorPotential] apply timeSlice_contDiff - refine contDiff_euclidean.mpr ?_ - exact fun i => (SpaceTime.contDiff_vector A).mpr hA (Sum.inr i) + exact contDiff_euclidean.mpr fun i => (SpaceTime.contDiff_vector A).mpr hA (Sum.inr i) open ContDiff @[fun_prop] @@ -287,8 +286,7 @@ lemma vectorPotential_differentiable {d} {c : SpeedOfLight} (A : Electromagnetic (hA : Differentiable ℝ A) : Differentiable ℝ ↿(A.vectorPotential c) := by simp [vectorPotential] apply timeSlice_differentiable - refine differentiable_euclidean.mpr ?_ - exact fun i => (SpaceTime.differentiable_vector A).mpr hA (Sum.inr i) + exact differentiable_euclidean.mpr fun i => (SpaceTime.differentiable_vector A).mpr hA (Sum.inr i) lemma vectorPotential_differentiable_time {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : Differentiable ℝ A) (x : Space d) : Differentiable ℝ (A.vectorPotential c · x) := diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean index 3a2ade00b..4b75e3b11 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean @@ -352,14 +352,12 @@ lemma stat_ofFinset_of_insertAndContractLiftFinset (φ : 𝓕.FieldOp) (φs : Li fin_list_sorted_monotone_sorted (a.sort (fun x1 x2 => x1 ≤ x2)) ?hl (⇑(finCongr (Eq.symm (insertIdx_length_fin φ φs i))) ∘ i.succAbove) ?hf exact a.pairwise_sort (fun x1 x2 => x1 ≤ x2) - refine StrictMono.comp (fun ⦃a b⦄ a => a) ?hf.hf - exact Fin.strictMono_succAbove i + exact StrictMono.comp (fun ⦃a b⦄ a => a) (Fin.strictMono_succAbove i) have h2 : (List.map (⇑(finCongr (insertIdx_length_fin φ φs i).symm)) (List.map i.succAbove (a.sort (fun x1 x2 => x1 ≤ x2)))).Nodup := by simp only [Nat.succ_eq_add_one, List.map_map] refine List.Nodup.map ?_ ?_ - apply (Equiv.comp_injective _ (finCongr _)).mpr - exact Fin.succAbove_right_injective + exact (Equiv.comp_injective _ (finCongr _)).mpr Fin.succAbove_right_injective exact a.sort_nodup (fun x1 x2 => x1 ≤ x2) have h3 : (List.map (⇑(finCongr (insertIdx_length_fin φ φs i).symm)) (List.map i.succAbove (a.sort (fun x1 x2 => x1 ≤ x2)))).toFinset diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean index 9837d3343..66b6128f2 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean @@ -163,8 +163,7 @@ lemma joinLift_surjective {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs · rw [Finset.mapEmbedding_apply] at ha3 use Sum.inr ⟨a2, ha3.1⟩ simp only [joinLift, joinLiftRight] - refine Subtype.ext ?_ - exact ha3.2 + exact Subtype.ext ha3.2 lemma joinLift_bijective {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length} {φsucΛ : WickContraction [φsΛ]ᵘᶜ.length} : Function.Bijective (@joinLift _ _ φsΛ φsucΛ) := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 829c1578a..3c492bff7 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -358,8 +358,7 @@ lemma inl_sq_eq (v : Contr d) : v.val (Sum.inl 0) ^ 2 = lemma le_inl_sq (v : Contr d) : ⟪v, v⟫ₘ ≤ v.val (Sum.inl 0) ^ 2 := by rw [inl_sq_eq] apply (le_add_iff_nonneg_right _).mpr - refine Fintype.sum_nonneg ?hf - exact fun i => pow_two_nonneg (v.val (Sum.inr i)) + exact Fintype.sum_nonneg fun i => pow_two_nonneg (v.val (Sum.inr i)) lemma ge_abs_inner_product (v w : Contr d) : v.val (Sum.inl 0) * w.val (Sum.inl 0) - ‖⟪v.toSpace, w.toSpace⟫_ℝ‖ ≤ ⟪v, w⟫ₘ := by From 4a3295d0c2ad661162664d410b684ef57b78f192 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:35:02 -0700 Subject: [PATCH 081/498] refactor: golf measurability and tensor wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Proper.lean | 8 ++++---- .../Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean | 8 ++++---- Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean | 4 ++-- .../MicroCanonicalEnsemble/IdealGas.lean | 7 +++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Proper.lean b/Physlib/Relativity/LorentzGroup/Proper.lean index ced833d3d..f60803aa8 100644 --- a/Physlib/Relativity/LorentzGroup/Proper.lean +++ b/Physlib/Relativity/LorentzGroup/Proper.lean @@ -60,10 +60,10 @@ def coeForℤ₂ : C(({-1, 1} : Set ℝ), ℤ₂) where def detContinuous : C(𝓛 d, ℤ₂) := ContinuousMap.comp coeForℤ₂ { toFun := fun Λ => ⟨Λ.1.det, Or.symm (LorentzGroup.det_eq_one_or_neg_one _)⟩, - continuous_toFun := by - refine Continuous.subtype_mk ?_ _ - exact Continuous.matrix_det $ - Continuous.comp' (continuous_iff_le_induced.mpr fun U a => a) continuous_id' + continuous_toFun := + Continuous.subtype_mk (Continuous.matrix_det $ + Continuous.comp' (continuous_iff_le_induced.mpr fun _ a => a) continuous_id' + ) _ } lemma detContinuous_eq_one (Λ : LorentzGroup d) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index e67a8a186..635b8dcaf 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -111,8 +111,8 @@ lemma stdBasis_apply (μ ν : Fin 1 ⊕ Fin d) : (stdBasis μ).val ν = if μ = simp only [stdBasis, Basis.coe_ofEquivFun] change Pi.single μ 1 ν = _ simp only [Pi.single_apply] - refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) - exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) + exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) + (congrFun rfl) (congrFun rfl) /-- Decomposition of a contravariant Lorentz vector into the standard basis. -/ lemma stdBasis_decomp (v : ContrMod d) : v = ∑ i, v.toFin1dℝ i • stdBasis i := by @@ -369,8 +369,8 @@ lemma stdBasis_apply (μ ν : Fin 1 ⊕ Fin d) : (stdBasis μ).val ν = if μ = simp only [stdBasis, Basis.coe_ofEquivFun] change Pi.single μ 1 ν = _ simp only [Pi.single_apply] - refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) - exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) + exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) + (congrFun rfl) (congrFun rfl) /-- Decomposition of a covariant Lorentz vector into the standard basis. -/ lemma stdBasis_decomp (v : CoMod d) : v = ∑ i, v.toFin1dℝ i • stdBasis i := by diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 160ceba56..f25b3df60 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -268,8 +268,8 @@ lemma nsmul_succ (n : ℕ) [SigmaFinite 𝓒.μ] : nsmul n.succ 𝓒 = (𝓒 + n · simp [Nat.succ_eq_add_one, Nat.succ_mul, dof_nsmul, add_comm] · simp · refine Eq.symm (MeasureTheory.MeasurePreserving.map_eq ?_) - refine MeasurePreserving.symm _ ?_ - exact MeasureTheory.measurePreserving_piFinSuccAbove (n := n) (fun _ => 𝓒.μ) 0 + exact MeasurePreserving.symm _ + (MeasureTheory.measurePreserving_piFinSuccAbove (n := n) (fun _ => 𝓒.μ) 0) /-! diff --git a/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean b/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean index ddef990f3..74190ba29 100644 --- a/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean +++ b/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean @@ -91,13 +91,12 @@ lemma partitionZ_eq (hV : 0 < V) (hβ : 0 < β) : show ∀ (x y i m_i), eq_pm (x, y) (i, Sum.inr m_i) = y (i, m_i) from fun _ _ _ _ => rfl] have h_measurable_box : Measurable fun (a : (Fin n × Fin 3 → ℝ)) => ∃ x_1 x_2, V ^ (3⁻¹:ℝ) / 2 < |a (x_1, x_2)| := by - refine Measurable.exists fun i => Measurable.exists fun j => ?_ - exact measurable_const.lt (by fun_prop) + exact Measurable.exists fun i => Measurable.exists fun j => measurable_const.lt (by fun_prop) have h_measurability : Measurable fun x : (Fin n × Fin 3 → ℝ) × (Fin n × Fin 3 → ℝ) => if ∃ x_1 x_2, V ^ (3⁻¹:ℝ) / 2 < |x.1 (x_1, x_2)| then 0 else Real.exp (-(β * ∑ x_1 : Fin n × Fin 3, x.2 (x_1.1, x_1.2) ^ 2 / 2)) := by - refine Measurable.ite (measurableSet_setOf.mpr ?_) (by fun_prop) (by fun_prop) - exact h_measurable_box.comp measurable_fst + exact Measurable.ite (measurableSet_setOf.mpr (h_measurable_box.comp measurable_fst)) + (by fun_prop) (by fun_prop) rw [MeasureTheory.integral_eq_lintegral_of_nonneg_ae] rotate_left · exact Filter.Eventually.of_forall fun _ => by positivity From 8da7257fc735e0ff2d1fcbf9c01619b687d28bbf Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:36:59 -0700 Subject: [PATCH 082/498] refactor: golf direct wrapper bodies Co-authored-by: Claude Opus 4.8 --- .../StandardModel/AnomalyCancellation/Basic.lean | 4 ++-- Physlib/SpaceAndTime/Time/TimeMan.lean | 4 ++-- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 4 ++-- .../MicroCanonicalEnsemble/IdealGas.lean | 8 ++++---- Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean | 4 ++-- Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index 3d00008d3..6a0d9f4c2 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -57,8 +57,8 @@ lemma toSpecies_apply_eq (i : Fin 5) (S : (SMCharges n).Charges) : rfl lemma charges_eq_toSpecies_eq (S T : (SMCharges n).Charges) : - S = T ↔ ∀ i, toSpecies i S = toSpecies i T := by - exact Iff.intro (fun a i => congrArg (⇑(toSpecies i)) a) fun h => + S = T ↔ ∀ i, toSpecies i S = toSpecies i T := + Iff.intro (fun a i => congrArg (⇑(toSpecies i)) a) fun h => toSpeciesEquiv.injective ((Set.eqOn_univ (toSpeciesEquiv S) (toSpeciesEquiv T)).mp fun ⦃x⦄ _ => h x) diff --git a/Physlib/SpaceAndTime/Time/TimeMan.lean b/Physlib/SpaceAndTime/Time/TimeMan.lean index c0fdfaa0c..7cbd0277f 100644 --- a/Physlib/SpaceAndTime/Time/TimeMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeMan.lean @@ -128,8 +128,8 @@ instance : IsManifold 𝓘(ℝ, ℝ) ω TimeMan where subst h1 h2 exact symm_trans_mem_contDiffGroupoid valHomeomorphism.toOpenPartialHomeomorph -lemma val_contDiff : ContMDiff 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ) ω TimeMan.val := by - exact contMDiffOn_univ.mp (contMDiffOn_chart (x := (⟨0⟩ : TimeMan))) +lemma val_contDiff : ContMDiff 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ) ω TimeMan.val := + contMDiffOn_univ.mp (contMDiffOn_chart (x := (⟨0⟩ : TimeMan))) /-- The choice of map `Time.val` from `TimeMan` to `ℝ` as a diffeomorphism. -/ noncomputable def valDiffeomorphism : TimeMan ≃ₘ^ω⟮𝓘(ℝ, ℝ), 𝓘(ℝ, ℝ)⟯ ℝ where diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index a3fa5267d..f6681bf35 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -147,8 +147,8 @@ instance : IsManifold 𝓘(ℝ, ℝ) ω TimeTransMan where subst h1 h2 exact symm_trans_mem_contDiffGroupoid valHomeomorphism.toOpenPartialHomeomorph -lemma val_contDiff : ContMDiff 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ) ω TimeTransMan.val := by - exact contMDiffOn_univ.mp (contMDiffOn_chart (x := (⟨0⟩ : TimeTransMan))) +lemma val_contDiff : ContMDiff 𝓘(ℝ, ℝ) 𝓘(ℝ, ℝ) ω TimeTransMan.val := + contMDiffOn_univ.mp (contMDiffOn_chart (x := (⟨0⟩ : TimeTransMan))) /-- The choice of map `Time.val` from `TimeTransMan` to `ℝ` as a diffeomorphism. -/ noncomputable def valDiffeomorphism : TimeTransMan ≃ₘ^ω⟮𝓘(ℝ, ℝ), 𝓘(ℝ, ℝ)⟯ ℝ where diff --git a/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean b/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean index 74190ba29..3ec6397fc 100644 --- a/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean +++ b/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean @@ -90,12 +90,12 @@ lemma partitionZ_eq (hV : 0 < V) (hβ : 0 < β) : simp_rw [show ∀ (x y i p_i), eq_pm (x, y) (i, Sum.inl p_i) = x (i, p_i) from fun _ _ _ _ => rfl, show ∀ (x y i m_i), eq_pm (x, y) (i, Sum.inr m_i) = y (i, m_i) from fun _ _ _ _ => rfl] have h_measurable_box : Measurable fun (a : (Fin n × Fin 3 → ℝ)) - => ∃ x_1 x_2, V ^ (3⁻¹:ℝ) / 2 < |a (x_1, x_2)| := by - exact Measurable.exists fun i => Measurable.exists fun j => measurable_const.lt (by fun_prop) + => ∃ x_1 x_2, V ^ (3⁻¹:ℝ) / 2 < |a (x_1, x_2)| := + Measurable.exists fun i => Measurable.exists fun j => measurable_const.lt (by fun_prop) have h_measurability : Measurable fun x : (Fin n × Fin 3 → ℝ) × (Fin n × Fin 3 → ℝ) => if ∃ x_1 x_2, V ^ (3⁻¹:ℝ) / 2 < |x.1 (x_1, x_2)| then 0 - else Real.exp (-(β * ∑ x_1 : Fin n × Fin 3, x.2 (x_1.1, x_1.2) ^ 2 / 2)) := by - exact Measurable.ite (measurableSet_setOf.mpr (h_measurable_box.comp measurable_fst)) + else Real.exp (-(β * ∑ x_1 : Fin n × Fin 3, x.2 (x_1.1, x_1.2) ^ 2 / 2)) := + Measurable.ite (measurableSet_setOf.mpr (h_measurable_box.comp measurable_fst)) (by fun_prop) (by fun_prop) rw [MeasureTheory.integral_eq_lintegral_of_nonneg_ae] rotate_left diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean index 9c0a015b7..5d9d9ccdc 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean @@ -281,8 +281,8 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : FiveQuanta 𝓩) (f · have h_mem_dedup : p.1 ∈ (x.map Prod.fst).dedup := by rwa [Multiset.mem_dedup] rw [Multiset.sum_map_eq_nsmul_single p.1] simp only [↓reduceIte, smul_eq_mul] - have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := by - exact Multiset.count_eq_one_of_mem (Multiset.nodup_dedup (Multiset.map Prod.fst x)) + have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := + Multiset.count_eq_one_of_mem (Multiset.nodup_dedup (Multiset.map Prod.fst x)) h_mem_dedup simp [h_count_one] intro q5' h h2 diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean index 2826abc16..cd1e0feef 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean @@ -296,8 +296,8 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : TenQuanta 𝓩) (f · have h_mem_dedup : p.1 ∈ (x.map Prod.fst).dedup := by rwa [Multiset.mem_dedup] rw [Multiset.sum_map_eq_nsmul_single p.1] simp only [↓reduceIte, smul_eq_mul] - have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := by - exact Multiset.count_eq_one_of_mem (Multiset.nodup_dedup (Multiset.map Prod.fst x)) + have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := + Multiset.count_eq_one_of_mem (Multiset.nodup_dedup (Multiset.map Prod.fst x)) h_mem_dedup simp [h_count_one] intro q5' h h2 From 9d33dd871b4cc93512de7345abb2dabfd5e30822 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:39:01 -0700 Subject: [PATCH 083/498] refactor(relativity): golf complex tensor contraction wrappers Co-authored-by: Claude Opus 4.8 --- .../ComplexTensor/Vector/Pre/Contraction.lean | 4 ++-- .../Tensors/ComplexTensor/Weyl/Contraction.lean | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean index 62f8a2258..889fe4377 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean @@ -109,8 +109,8 @@ lemma contrCoContraction_basis' (i j : Fin 1 ⊕ Fin 3) : rw [contrCoContraction_hom_tmul] simp only [complexContrBasis_toFin13ℂ, complexCoBasis_toFin13ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] - refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) - exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) + exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) + (congrFun rfl) (congrFun rfl) /-- The linear map from complexCo ⊗ complexContr to ℂ given by summing over components of covariant Lorentz vector and diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean index d5a79fe54..0c75ea68e 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean @@ -149,8 +149,8 @@ lemma leftDualContraction_basis (i j : Fin 2) : simp only [leftBasis_toFin2ℂ, dualLeftBasis_toFin2ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] simp only [Fin.ext_iff] - refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) - exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) + exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) + (congrFun rfl) (congrFun rfl) /-- The linear map from DualLeftHandedWeyl ⊗ leftHandedWeyl to ℂ given by summing over components of DualLeftHandedWeyl and leftHandedWeyl in the @@ -175,8 +175,8 @@ lemma dualLeftContraction_basis (i j : Fin 2) : simp only [dualLeftBasis_toFin2ℂ, leftBasis_toFin2ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] simp only [Fin.ext_iff] - refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) - exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) + exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) + (congrFun rfl) (congrFun rfl) /-- The linear map from `rightHandedWeyl ⊗ DualRightHandedWeyl` to `ℂ` given by @@ -216,8 +216,8 @@ lemma rightDualContraction_basis (i j : Fin 2) : simp only [rightBasis_toFin2ℂ, dualRightBasis_toFin2ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] simp only [Fin.ext_iff] - refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) - exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) + exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) + (congrFun rfl) (congrFun rfl) /-- The linear map from DualRightHandedWeyl ⊗ rightHandedWeyl to ℂ given by @@ -257,8 +257,8 @@ lemma dualRightContraction_basis (i j : Fin 2) : simp only [dualRightBasis_toFin2ℂ, rightBasis_toFin2ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] simp only [Fin.ext_iff] - refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) - exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) + exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) + (congrFun rfl) (congrFun rfl) /-! From c9f8e233a3a2c54872d870d6a6ee569c7362d6e5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:41:16 -0700 Subject: [PATCH 084/498] refactor(relativity): golf tensor matrix expansion proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Matrix/Pre.lean | 16 ++++++++-------- .../Tensors/ComplexTensor/Weyl/Two.lean | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean index d0175eb43..2bd29322d 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean @@ -38,8 +38,8 @@ lemma contrContrToMatrix_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin 3) (Fin 1 Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply complexContrBasis complexContrBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply complexContrBasis complexContrBasis i j) · simp /-- Equivalence of `complexCo ⊗ complexCo` to `4 x 4` complex matrices. -/ @@ -55,8 +55,8 @@ lemma coCoToMatrix_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin 3) (Fin 1 ⊕ Fin simp only [coCoToMatrix, LinearEquiv.trans_symm, LinearEquiv.trans_apply, Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply complexCoBasis complexCoBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply complexCoBasis complexCoBasis i j) · simp /-- Equivalence of `complexContr ⊗ complexCo` to `4 x 4` complex matrices. -/ @@ -73,8 +73,8 @@ lemma contrCoToMatrix_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin 3) (Fin 1 ⊕ Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply complexContrBasis complexCoBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply complexContrBasis complexCoBasis i j) · simp /-- Equivalence of `complexCo ⊗ complexContr` to `4 x 4` complex matrices. -/ @@ -91,8 +91,8 @@ lemma coContrToMatrix_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin 3) (Fin 1 ⊕ Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply complexCoBasis complexContrBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply complexCoBasis complexContrBasis i j) · simp /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean index 3f638348d..1cb20435c 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean @@ -42,8 +42,8 @@ lemma leftLeftToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply leftBasis leftBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply leftBasis leftBasis i j) · simp /-- Equivalence of `dualLeftHanded ⊗ dualLeftHanded` to `2 x 2` complex matrices. -/ From ef511cd12016ce2419986b6631857689cd8498b9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:43:11 -0700 Subject: [PATCH 085/498] refactor(relativity): golf weyl matrix expansion proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Weyl/Two.lean | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean index 1cb20435c..98e285566 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean @@ -61,8 +61,8 @@ lemma dualLeftdualLeftToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply dualLeftBasis dualLeftBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply dualLeftBasis dualLeftBasis i j) · simp /-- Equivalence of `leftHanded ⊗ dualLeftHanded` to `2 x 2` complex matrices. -/ @@ -79,8 +79,8 @@ lemma leftDualLeftToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply leftBasis dualLeftBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply leftBasis dualLeftBasis i j) · simp /-- Equivalence of `dualLeftHanded ⊗ leftHanded` to `2 x 2` complex matrices. -/ @@ -97,8 +97,8 @@ lemma dualLeftLeftToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply dualLeftBasis leftBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply dualLeftBasis leftBasis i j) · simp /-- Equivalence of `rightHanded ⊗ rightHanded` to `2 x 2` complex matrices. -/ @@ -115,8 +115,8 @@ lemma rightRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply rightBasis rightBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply rightBasis rightBasis i j) · simp /-- Equivalence of `dualRightHanded ⊗ dualRightHanded` to `2 x 2` complex matrices. -/ @@ -134,8 +134,8 @@ lemma dualRightDualRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply dualRightBasis dualRightBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply dualRightBasis dualRightBasis i j) · simp /-- Equivalence of `rightHanded ⊗ dualRightHanded` to `2 x 2` complex matrices. -/ @@ -152,8 +152,8 @@ lemma rightDualRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply rightBasis dualRightBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply rightBasis dualRightBasis i j) · simp /-- Equivalence of `dualRightHanded ⊗ rightHanded` to `2 x 2` complex matrices. -/ @@ -170,8 +170,8 @@ lemma dualRightRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply dualRightBasis rightBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply dualRightBasis rightBasis i j) · simp /-- Equivalence of `dualLeftHanded ⊗ dualRightHanded` to `2 x 2` complex matrices. -/ @@ -189,8 +189,8 @@ lemma dualLeftDualRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply dualLeftBasis dualRightBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply dualLeftBasis dualRightBasis i j) · simp /-- Equivalence of `leftHanded ⊗ rightHanded` to `2 x 2` complex matrices. -/ @@ -206,8 +206,8 @@ lemma leftRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - exact congrArg _ (Basis.tensorProduct_apply leftBasis rightBasis i j) + exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => + congrArg _ (Basis.tensorProduct_apply leftBasis rightBasis i j) · simp /-- The coercion of `Finsupp.linearEquivFunOnFinite` to a function is the underlying From 3a6e311c3280dc4caf1c32edee4e0749381d38b7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 12:55:00 -0700 Subject: [PATCH 086/498] style(relativity): format Lorentz proper proof Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Proper.lean | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Proper.lean b/Physlib/Relativity/LorentzGroup/Proper.lean index f60803aa8..9bd5c603d 100644 --- a/Physlib/Relativity/LorentzGroup/Proper.lean +++ b/Physlib/Relativity/LorentzGroup/Proper.lean @@ -61,9 +61,9 @@ def detContinuous : C(𝓛 d, ℤ₂) := ContinuousMap.comp coeForℤ₂ { toFun := fun Λ => ⟨Λ.1.det, Or.symm (LorentzGroup.det_eq_one_or_neg_one _)⟩, continuous_toFun := - Continuous.subtype_mk (Continuous.matrix_det $ - Continuous.comp' (continuous_iff_le_induced.mpr fun _ a => a) continuous_id' - ) _ + Continuous.subtype_mk + (Continuous.matrix_det <| + Continuous.comp' (continuous_iff_le_induced.mpr fun _ a => a) continuous_id') _ } lemma detContinuous_eq_one (Λ : LorentzGroup d) : From be8139bd245be3f36dd541b98234a5b61bc1afb3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:00:06 -0700 Subject: [PATCH 087/498] refactor: golf constructor wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List/InsertIdx.lean | 7 +++---- .../Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean | 6 ++---- .../PerturbationTheory/FieldSpecification/NormalOrder.lean | 3 +-- .../QuantumMechanics/DDimensions/Operators/Position.lean | 4 ++-- Physlib/Relativity/Special/ProperTime.lean | 3 +-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Physlib/Mathematics/List/InsertIdx.lean b/Physlib/Mathematics/List/InsertIdx.lean index e132bb919..832a90495 100644 --- a/Physlib/Mathematics/List/InsertIdx.lean +++ b/Physlib/Mathematics/List/InsertIdx.lean @@ -42,8 +42,7 @@ lemma eraseIdx_sorted {I : Type} (le : I → I → Prop) : simp only [List.pairwise_cons] at h refine And.intro ?_ (eraseIdx_sorted le as n h.2) intro b hb - refine h.1 _ ?_ - exact List.mem_of_mem_eraseIdx hb + exact h.1 _ (List.mem_of_mem_eraseIdx hb) lemma mem_eraseIdx_nodup {I : Type} (i : I) : (l : List I) → (n : ℕ) → (hn : n < l.length) → (h : List.Nodup l) → @@ -190,7 +189,7 @@ lemma take_insert_let {I : Type} (i : I) : have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := List.Perm.swap a i (List.take n as) refine List.Perm.trans ?_ hp.symm - refine List.Perm.cons a ?_ - exact take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm) + exact List.Perm.cons a + (take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm)) end Physlib.List diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean index f2270bc7a..c38e78973 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean @@ -227,11 +227,9 @@ lemma mem_map_ofPotentialTerm'_iff[DecidableEq 𝓩] simp only [Multiset.mem_map] constructor · intro ⟨a, h, h1⟩ - refine ⟨a, ?_, h1⟩ - exact mem_ofPotentialTerm_iff_mem_ofPotentialTerm.mp h + exact ⟨a, mem_ofPotentialTerm_iff_mem_ofPotentialTerm.mp h, h1⟩ · intro ⟨a, h, h1⟩ - refine ⟨a, ?_, h1⟩ - exact mem_ofPotentialTerm_iff_mem_ofPotentialTerm.mpr h + exact ⟨a, mem_ofPotentialTerm_iff_mem_ofPotentialTerm.mpr h, h1⟩ lemma map_ofPotentialTerm'_toFinset [DecidableEq 𝓩] (f : 𝓩 →+ 𝓩1) (x : ChargeSpectrum 𝓩) (T : PotentialTerm) : diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index b0f10b2e8..980517796 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -217,8 +217,7 @@ lemma normalOrderSign_swap_annihilate_annihilate (φa φa' : 𝓕.CrAnFieldOp) simp only [mul_eq_mul_right_iff] apply Or.inl apply Wick.koszulSignInsert_eq_perm - refine List.Perm.append_left φs ?h.h.a - exact List.Perm.swap φa' φa φs' + exact List.Perm.append_left φs (List.Perm.swap φa' φa φs') open FieldStatistic /-! diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean index e6d2308c2..4502b7431 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean @@ -111,8 +111,8 @@ lemma radiusRegPowCLM_apply_fun {d : ℕ} (ε : ℝˣ) (s : ℝ) (ψ : 𝓢(Spac 𝐫₀ ε s ψ = fun x ↦ (‖x‖ ^ 2 + ε ^ 2) ^ (s / 2) • ψ x := by ext x dsimp [radiusRegPowCLM] - refine smulLeftCLM_apply_apply ?_ ψ x - exact HasTemperateGrowth.comp (by fun_prop) (normRegularizedPow_hasTemperateGrowth d ε s) + exact smulLeftCLM_apply_apply + (HasTemperateGrowth.comp (by fun_prop) (normRegularizedPow_hasTemperateGrowth d ε s)) ψ x @[simp] lemma radiusRegPowCLM_apply {d : ℕ} (ε : ℝˣ) (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (x : Space d) : diff --git a/Physlib/Relativity/Special/ProperTime.lean b/Physlib/Relativity/Special/ProperTime.lean index 4ca7759fa..a924adf81 100644 --- a/Physlib/Relativity/Special/ProperTime.lean +++ b/Physlib/Relativity/Special/ProperTime.lean @@ -37,8 +37,7 @@ lemma properTime_pos_ofTimeLike {d : ℕ} (q p : SpaceTime d) (h : causalCharacter (p - q) = .timeLike) : 0 < properTime q p := by rw [properTime] - refine sqrt_pos_of_pos ?_ - exact (timeLike_iff_norm_sq_pos (p - q)).mp h + exact sqrt_pos_of_pos ((timeLike_iff_norm_sq_pos (p - q)).mp h) lemma properTime_zero_ofLightLike {d : ℕ} (q p : SpaceTime d) (h : causalCharacter (p - q) = .lightLike) : From 05b06632c51eeba9fc962370603b05db5865cf6f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:03:29 -0700 Subject: [PATCH 088/498] refactor: golf koszul permutation proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List/InsertIdx.lean | 7 ++++--- .../MinimallyAllowsTerm/OfFinset.lean | 8 ++++---- .../QFT/PerturbationTheory/Koszul/KoszulSign.lean | 13 +++++-------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Physlib/Mathematics/List/InsertIdx.lean b/Physlib/Mathematics/List/InsertIdx.lean index 832a90495..063a06317 100644 --- a/Physlib/Mathematics/List/InsertIdx.lean +++ b/Physlib/Mathematics/List/InsertIdx.lean @@ -188,8 +188,9 @@ lemma take_insert_let {I : Type} (i : I) : simp only [List.insertIdx_succ_cons, List.take_succ_cons] have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := List.Perm.swap a i (List.take n as) - refine List.Perm.trans ?_ hp.symm - exact List.Perm.cons a - (take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm)) + exact List.Perm.trans + (List.Perm.cons a + (take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm))) + hp.symm end Physlib.List diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/OfFinset.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/OfFinset.lean index 9a42d6399..770d182a9 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/OfFinset.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/OfFinset.lean @@ -180,8 +180,8 @@ lemma mem_toMultisetsThree_iff [DecidableEq 𝓩] {s : Finset 𝓩} (X : Multise simpa using hsub · right simp [@Finset.insert_subset_iff] at hsub - refine ⟨c, hsub.2, a, (Multiset.mem_erase_of_ne hac).mpr hsub.1, ?_⟩ - exact congrArg (a ::ₘ ·) (Multiset.pair_comm c a) + exact ⟨c, hsub.2, a, (Multiset.mem_erase_of_ne hac).mpr hsub.1, + congrArg (a ::ₘ ·) (Multiset.pair_comm c a)⟩ · rw [or_assoc] right by_cases hac : a = c @@ -193,8 +193,8 @@ lemma mem_toMultisetsThree_iff [DecidableEq 𝓩] {s : Finset 𝓩} (X : Multise · subst hbc left simp [@Finset.insert_subset_iff] at hsub - refine ⟨a, hsub.1, b, (Multiset.mem_erase_of_ne (Ne.symm hac)).mpr hsub.2, ?_⟩ - exact Multiset.cons_swap b a {b} + exact ⟨a, hsub.1, b, (Multiset.mem_erase_of_ne (Ne.symm hac)).mpr hsub.2, + Multiset.cons_swap b a {b}⟩ · right refine (Multiset.le_iff_subset ?_).mpr ?_ · simpa using ⟨⟨hab, hac⟩, hbc⟩ diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index d51d42c8f..41fca03e7 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -175,8 +175,8 @@ lemma koszulSign_insertIdx [Std.Total le] [IsTrans 𝓕 le] (φ : 𝓕) : exact lt_orderedInsertPos_rel le φ1 rs ni hninro have hc2 (hninro : ¬ ni.castSucc < nro) : le φ1 φ := by rw [← hns] - refine gt_orderedInsertPos_rel le φ1 rs ?_ ni hninro - exact List.pairwise_insertionSort le (List.insertIdx φs n φ) + exact gt_orderedInsertPos_rel le φ1 rs + (List.pairwise_insertionSort le (List.insertIdx φs n φ)) ni hninro by_cases hn : ni.castSucc < nro · simp only [hn, ↓reduceIte, Fin.val_castSucc] rw [ofList_take_insertIdx_gt] @@ -379,8 +379,7 @@ lemma koszulSign_of_append_eq_insertionSort [Std.Total le] [IsTrans 𝓕 le] : ( congr 2 apply koszulSignInsert_eq_perm refine (List.perm_append_right_iff φs').mpr ?_ - refine List.Perm.append_left φs'' ?_ - exact List.Perm.symm (List.perm_insertionSort le φs) + exact List.Perm.append_left φs'' (List.Perm.symm (List.perm_insertionSort le φs)) /-! @@ -413,8 +412,7 @@ lemma koszulSign_perm_eq_append [IsTrans 𝓕 le] (φ : 𝓕) (φs φs' φs2 : L simp_all only [and_self, implies_true, nonempty_prop, forall_const, motive] refine (ih2 ?_) intro φ' hφ - refine h φ' ?_ - exact (List.Perm.mem_iff (id (List.Perm.symm h1))).mp hφ + exact h φ' ((List.Perm.mem_iff (id (List.Perm.symm h1))).mp hφ) lemma koszulSign_perm_eq [IsTrans 𝓕 le] (φ : 𝓕) : (φs1 φs φs' φs2 : List 𝓕) → (h : ∀ φ' ∈ φs, le φ φ' ∧ le φ' φ) → (hp : φs.Perm φs') → @@ -428,7 +426,6 @@ lemma koszulSign_perm_eq [IsTrans 𝓕 le] (φ : 𝓕) : (φs1 φs φs' φs2 : L rw [ih] congr 1 apply koszulSignInsert_eq_perm - refine (List.perm_append_right_iff φs2).mpr ?_ - exact List.Perm.append_left φs1 hp + exact (List.perm_append_right_iff φs2).mpr (List.Perm.append_left φs1 hp) end Wick From b089aaa735da2643c02262c631b56f4c911f5c5d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:07:01 -0700 Subject: [PATCH 089/498] refactor: golf koszul and operator wrappers Co-authored-by: Claude Opus 4.8 --- .../FieldSpecification/NormalOrder.lean | 5 ++--- .../QFT/PerturbationTheory/Koszul/KoszulSign.lean | 14 +++++++------- .../DDimensions/Operators/Momentum.lean | 7 ++++--- .../DDimensions/Operators/Position.lean | 8 ++++---- .../Tensors/RealTensor/Vector/Pre/Contraction.lean | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index 980517796..3d85ad38b 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -215,9 +215,8 @@ lemma normalOrderSign_swap_annihilate_annihilate (φa φa' : 𝓕.CrAnFieldOp) dsimp only [normalOrderSign, Wick.koszulSign] rw [← normalOrderSign] simp only [mul_eq_mul_right_iff] - apply Or.inl - apply Wick.koszulSignInsert_eq_perm - exact List.Perm.append_left φs (List.Perm.swap φa' φa φs') + exact Or.inl (Wick.koszulSignInsert_eq_perm _ _ _ _ _ + (List.Perm.append_left φs (List.Perm.swap φa' φa φs'))) open FieldStatistic /-! diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index 41fca03e7..ded05a082 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -306,8 +306,8 @@ lemma koszulSign_eq_rel_eq_stat {ψ φ : 𝓕} [IsTrans 𝓕 le] simp only [mul_eq_mul_right_iff] left trans koszulSignInsert q le φ'' (φ :: ψ :: (φs' ++ φs)) - · apply koszulSignInsert_eq_perm - exact (List.perm_cons_append_cons φ List.perm_middle.symm).symm + · exact koszulSignInsert_eq_perm q le _ _ _ + (List.perm_cons_append_cons φ List.perm_middle.symm).symm · rw [koszulSignInsert_eq_remove_same_stat_append q le h1 h2 hq] lemma koszulSign_of_sorted : (φs : List 𝓕) @@ -377,9 +377,9 @@ lemma koszulSign_of_append_eq_insertionSort [Std.Total le] [IsTrans 𝓕 le] : ( simp only [List.cons_append, koszulSign] rw [koszulSign_of_append_eq_insertionSort φs'' φs φs', ← mul_assoc] congr 2 - apply koszulSignInsert_eq_perm - refine (List.perm_append_right_iff φs').mpr ?_ - exact List.Perm.append_left φs'' (List.Perm.symm (List.perm_insertionSort le φs)) + exact koszulSignInsert_eq_perm q le _ _ _ + ((List.perm_append_right_iff φs').mpr + (List.Perm.append_left φs'' (List.Perm.symm (List.perm_insertionSort le φs)))) /-! @@ -425,7 +425,7 @@ lemma koszulSign_perm_eq [IsTrans 𝓕 le] (φ : 𝓕) : (φs1 φs φs' φs2 : L have ih := koszulSign_perm_eq φ φs1 φs φs' φs2 h hp rw [ih] congr 1 - apply koszulSignInsert_eq_perm - exact (List.perm_append_right_iff φs2).mpr (List.Perm.append_left φs1 hp) + exact koszulSignInsert_eq_perm q le _ _ _ + ((List.perm_append_right_iff φs2).mpr (List.Perm.append_left φs1 hp)) end Wick diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean index 33c7a709f..045f98bae 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean @@ -117,9 +117,10 @@ lemma momentumOperator_isSymmetric : (𝓟 i).IsSymmetric := by exact ((g.fderivCLM ℂ _ _).evalCLM ℂ _ _ _).memLp_top have hI₃ : Integrable fun x ↦ g x * fderiv ℝ (star ∘ f) x (basis i) := by simp_rw [heq] - refine Integrable.mul_of_top_right ?_ g.memLp_top - exact (starL' ℝ).integrable_comp_iff.mpr - ((f.fderivCLM ℂ _ _).evalCLM ℂ _ _ _).integrable + exact Integrable.mul_of_top_right + ((starL' ℝ).integrable_comp_iff.mpr + ((f.fderivCLM ℂ _ _).evalCLM ℂ _ _ (basis i)).integrable) + g.memLp_top have hI₄ : Integrable fun x ↦ g x * star (f x) := hI₁.mul_of_top_right g.memLp_top trans I * ℏ * ∫ x, g x * fderiv ℝ (star ∘ f) x (basis i) · simp_rw [← integral_const_mul_of_integrable hI₃, heq] diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean index 4502b7431..5bd45725c 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean @@ -238,8 +238,8 @@ lemma radiusPowLM_apply_memHS {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (a : exact (le_mul_inv_iff₀' <| Real.rpow_pos_of_pos hx' _).mpr (hC x) calc _ ≤ (C * ‖x‖ ^ (-(⌈s⌉.toNat + d) : ℝ)) ^ 2 * ‖x‖ ^ (2 * s) := by - refine mul_le_mul_of_nonneg_right ?_ (Real.rpow_nonneg hx'.le _) - exact pow_le_pow_left₀ (norm_nonneg _) hψ 2 + exact mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (norm_nonneg _) hψ 2) + (Real.rpow_nonneg hx'.le _) _ = C ^ 2 * ‖x‖ ^ (-2 * d : ℝ) * ‖x‖ ^ (2 * (s - ⌈s⌉.toNat) : ℝ) := by simp_rw [mul_pow, ← Real.rpow_mul_natCast hx'.le, mul_assoc, ← Real.rpow_add hx'] ring_nf @@ -271,8 +271,8 @@ lemma radiusRegPow_tendsto_radiusPow {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ simp [← Real.rpow_natCast_mul, mul_div_cancel₀] simp only [radiusRegPowCLM_apply, radiusPowLM_apply, Complex.real_smul, hpow] refine Tendsto.mul_const (ψ x) <| Tendsto.ofReal ?_ - refine Tendsto.rpow_const ?_ (Or.inl <| by simp [hx]) - exact Tendsto.const_add _ <| Tendsto.pow tendsto_comap 2 + exact Tendsto.rpow_const (Tendsto.const_add _ <| Tendsto.pow tendsto_comap 2) + (Or.inl <| by simp [hx]) /-- `𝐫[ε,s] ψ` converges pointwise to `𝐫[s] ψ` as `ε → 0` provided `𝐫[ε,s] ψ 0` is bounded. -/ lemma radiusRegPow_tendsto_radiusPow' {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (h : 0 ≤ s ∨ ψ 0 = 0) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 3c492bff7..57441ddfd 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -357,8 +357,8 @@ lemma inl_sq_eq (v : Contr d) : v.val (Sum.inl 0) ^ 2 = lemma le_inl_sq (v : Contr d) : ⟪v, v⟫ₘ ≤ v.val (Sum.inl 0) ^ 2 := by rw [inl_sq_eq] - apply (le_add_iff_nonneg_right _).mpr - exact Fintype.sum_nonneg fun i => pow_two_nonneg (v.val (Sum.inr i)) + exact (le_add_iff_nonneg_right _).mpr + (Fintype.sum_nonneg fun i => pow_two_nonneg (v.val (Sum.inr i))) lemma ge_abs_inner_product (v w : Contr d) : v.val (Sum.inl 0) * w.val (Sum.inl 0) - ‖⟪v.toSpace, w.toSpace⟫_ℝ‖ ≤ ⟪v, w⟫ₘ := by From 60e6025c9b00ed9a66745f1094146865c25c1185 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:09:00 -0700 Subject: [PATCH 090/498] refactor: golf list transitivity proofs Co-authored-by: Claude Opus 4.8 --- .../Mathematics/Calculus/ParametricIntegration.lean | 3 +-- Physlib/Mathematics/List/InsertionSort.lean | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Calculus/ParametricIntegration.lean b/Physlib/Mathematics/Calculus/ParametricIntegration.lean index 60dd12ddd..ab16da442 100644 --- a/Physlib/Mathematics/Calculus/ParametricIntegration.lean +++ b/Physlib/Mathematics/Calculus/ParametricIntegration.lean @@ -48,8 +48,7 @@ lemma hasFDerivAt_parametric_intervalIntegral_of_contDiff fun_prop · apply Continuous.intervalIntegrable fun_prop - · apply Continuous.aestronglyMeasurable - exact Continuous.uncurry_left x₀ (by fun_prop) + · exact (Continuous.uncurry_left x₀ (by fun_prop)).aestronglyMeasurable · filter_upwards with t h x hx exact ha.2 (Set.mk_mem_prod hx (Set.Ioc_subset_Icc_self (by simpa using h))) · exact intervalIntegrable_const diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index 02feb815d..2df2d97ba 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -239,8 +239,7 @@ lemma insertionSortEquiv_commute {α : Type} (r : α → α → Prop) [Decidable funext c simp only [Bool.eq_self_and, Bool.not_eq_eq_eq_not, Bool.not_true, decide_eq_false_iff_not] intro hbc hac - refine hbc ?_ - exact IsTrans.trans _ _ _ hrba hac + exact hbc (IsTrans.trans _ _ _ hrba hac) have ha1 : b1.1 ≤ a2.1 := by simp only [orderedInsertPos, decide_not, b1] rw [ht] @@ -437,8 +436,7 @@ lemma takeWhile_sorted_eq_filter {α : Type} (r : α → α → Prop) [Decidable not_false_eq_true, List.takeWhile_cons_of_neg, List.filter_cons_of_neg, List.nil_eq, List.filter_eq_nil_iff, Bool.not_eq_eq_eq_not, decide_eq_false_iff_not] intro c hc - apply IsTrans.trans a b c hb - exact hl.1 c hc + exact IsTrans.trans a b c hb (hl.1 c hc) lemma dropWhile_sorted_eq_filter {α : Type} (r : α → α → Prop) [DecidableRel r] [IsTrans α r] (a : α) : (l : List α) → (hl : l.Pairwise r) → @@ -457,8 +455,7 @@ lemma dropWhile_sorted_eq_filter {α : Type} (r : α → α → Prop) [Decidable rw [List.filter_eq_self] intro c hc simp only [decide_eq_true_eq] - apply IsTrans.trans a b c hb - exact hl.1 c hc + exact IsTrans.trans a b c hb (hl.1 c hc) lemma dropWhile_sorted_eq_filter_filter {α : Type} (r : α → α → Prop) [DecidableRel r] [IsTrans α r] (a : α) :(l : List α) → (hl : l.Pairwise r) → @@ -490,8 +487,7 @@ lemma dropWhile_sorted_eq_filter_filter {α : Type} (r : α → α → Prop) [De simp only [Bool.and_eq_true, decide_eq_true_eq, not_and] intro hac hca apply hba - apply IsTrans.trans b c a _ hca - exact hl.1 c hc + exact IsTrans.trans b c a (hl.1 c hc) hca rw [h1] rw [dropWhile_sorted_eq_filter_filter] simp only [Bool.decide_and, h1, decide_not, List.nil_append] From 19d5eca2d5bc56608954620a323c21c8deb18e5f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:11:38 -0700 Subject: [PATCH 091/498] refactor: golf plane wave differentiability proofs Co-authored-by: Claude Opus 4.8 --- .../Electromagnetism/Vacuum/IsPlaneWave.lean | 55 ++++++------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean b/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean index 0101d269d..761811058 100644 --- a/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean +++ b/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean @@ -377,19 +377,11 @@ lemma time_deriv_magneticFieldMatrix_eq_electricField_mul_propogator {d : ℕ} rw [P.electricField_space_deriv_eq_time_deriv, P.electricField_space_deriv_eq_time_deriv] conv_rhs => rw [Time.deriv_eq] - rw [fderiv_fun_sub (by - apply Differentiable.differentiableAt - apply Differentiable.const_mul - exact electricField_apply_differentiable_time hA _ _) (by - apply Differentiable.differentiableAt - apply Differentiable.const_mul - exact electricField_apply_differentiable_time hA _ _)] - rw [fderiv_const_mul (by - apply Differentiable.differentiableAt - exact electricField_apply_differentiable_time hA _ _)] - rw [fderiv_const_mul (by - apply Differentiable.differentiableAt - exact electricField_apply_differentiable_time hA _ _)] + rw [fderiv_fun_sub + ((electricField_apply_differentiable_time hA _ _).const_mul _).differentiableAt + ((electricField_apply_differentiable_time hA _ _).const_mul _).differentiableAt] + rw [fderiv_const_mul (electricField_apply_differentiable_time hA _ _).differentiableAt] + rw [fderiv_const_mul (electricField_apply_differentiable_time hA _ _).differentiableAt] simp [← Time.deriv_eq] field_simp ring @@ -444,12 +436,8 @@ lemma magneticFieldMatrix_eq_propogator_cross_electricField {d : ℕ} s.unit i * A.electricField 𝓕.c t x j) + C := by apply Space.equal_up_to_const_of_deriv_eq · exact magneticFieldMatrix_differentiable A hA (i, j) - · apply Differentiable.const_mul - apply Differentiable.sub - · apply Differentiable.const_mul - exact electricField_apply_differentiable hA - · apply Differentiable.const_mul - exact electricField_apply_differentiable hA + · exact (Differentiable.sub ((electricField_apply_differentiable hA).const_mul _) + ((electricField_apply_differentiable hA).const_mul _)).const_mul _ · intro t x rw [P.time_deriv_magneticFieldMatrix_eq_electricField_mul_propogator hA t x i j] congr @@ -504,8 +492,7 @@ lemma time_deriv_electricField_eq_magneticFieldMatrix {d : ℕ} ring_nf rfl · intro k _ - apply DifferentiableAt.mul_const - exact (hBd k).differentiableAt + exact (hBd k).differentiableAt.mul_const _ rw [h1, Finset.mul_sum, Finset.mul_sum,← Finset.sum_neg_distrib] field_simp @@ -521,8 +508,7 @@ lemma time_deriv_electricField_eq_magneticFieldMatrix {d : ℕ} simp [← Time.deriv_eq] · refine DifferentiableAt.fun_sum ?_ intro k _ - apply DifferentiableAt.mul_const - exact (hBd k).differentiableAt + exact (hBd k).differentiableAt.mul_const _ · change ContDiff ℝ ∞ (fun _ => 0) fun_prop · exact electricField_differentiable_time (hA.of_le (ENat.LEInfty.out)) x @@ -560,22 +546,16 @@ lemma space_deriv_electricField_eq_magneticFieldMatrix {d : ℕ} field_simp any_goals apply Differentiable.differentiableAt · exact fieldStrengthMatrix_differentiable_space hA2 t - · apply Differentiable.mul_const - exact fieldStrengthMatrix_differentiable_space hA2 t + · exact (fieldStrengthMatrix_differentiable_space hA2 t).mul_const _ · exact fieldStrengthMatrix_differentiable_time hA2 x · intro i _ - apply Differentiable.differentiableAt - apply Differentiable.const_mul - apply Differentiable.mul_const - exact fieldStrengthMatrix_differentiable_space hA2 t + exact + (((fieldStrengthMatrix_differentiable_space hA2 t).mul_const _).const_mul _).differentiableAt · intro i _ - apply Differentiable.differentiableAt - apply Differentiable.mul_const - exact fieldStrengthMatrix_differentiable_time hA2 x + exact ((fieldStrengthMatrix_differentiable_time hA2 x).mul_const _).differentiableAt · apply Differentiable.fun_sum intro i _ - apply Differentiable.mul_const - exact fieldStrengthMatrix_differentiable_time hA2 x + exact (fieldStrengthMatrix_differentiable_time hA2 x).mul_const _ /-! @@ -592,11 +572,8 @@ lemma electricField_eq_propogator_cross_magneticFieldMatrix {d : ℕ} have hA2 : ContDiff ℝ 2 A := hA.of_le ENat.LEInfty.out apply Space.equal_up_to_const_of_deriv_eq · exact electricField_apply_differentiable hA2 - · apply Differentiable.const_mul - apply Differentiable.fun_sum - intro j _ - apply Differentiable.mul_const - exact magneticFieldMatrix_differentiable A hA2 (i, j) + · exact ((Differentiable.fun_sum fun j _ => + (magneticFieldMatrix_differentiable A hA2 (i, j)).mul_const _).const_mul _) · intro t x rw [P.time_deriv_electricField_eq_magneticFieldMatrix hA _ t x i] congr From 06cf9e7ac8b0bf4f35be778d7e680c385f23d103 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:14:11 -0700 Subject: [PATCH 092/498] refactor: golf time slice differentiability proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Kinematics/VectorPotential.lean | 8 ++++---- Physlib/Mathematics/VariationalCalculus/Basic.lean | 3 +-- .../Mathematics/VariationalCalculus/HasVarAdjDeriv.lean | 3 +-- Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean | 6 ++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index eaded8ec7..7963a1089 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -238,8 +238,8 @@ the smoothness of the electromagnetic potential. lemma vectorPotential_contDiff {n} {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ n A) : ContDiff ℝ n ↿(A.vectorPotential c) := by simp [vectorPotential] - apply timeSlice_contDiff - exact contDiff_euclidean.mpr fun i => (SpaceTime.contDiff_vector A).mpr hA (Sum.inr i) + exact timeSlice_contDiff c _ (contDiff_euclidean.mpr fun i => + (SpaceTime.contDiff_vector A).mpr hA (Sum.inr i)) open ContDiff @[fun_prop] @@ -285,8 +285,8 @@ the differentiablity of the electromagnetic potential. lemma vectorPotential_differentiable {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : Differentiable ℝ A) : Differentiable ℝ ↿(A.vectorPotential c) := by simp [vectorPotential] - apply timeSlice_differentiable - exact differentiable_euclidean.mpr fun i => (SpaceTime.differentiable_vector A).mpr hA (Sum.inr i) + exact timeSlice_differentiable c _ (differentiable_euclidean.mpr fun i => + (SpaceTime.differentiable_vector A).mpr hA (Sum.inr i)) lemma vectorPotential_differentiable_time {d} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : Differentiable ℝ A) (x : Space d) : Differentiable ℝ (A.vectorPotential c · x) := diff --git a/Physlib/Mathematics/VariationalCalculus/Basic.lean b/Physlib/Mathematics/VariationalCalculus/Basic.lean index 7244f8f22..98846c383 100644 --- a/Physlib/Mathematics/VariationalCalculus/Basic.lean +++ b/Physlib/Mathematics/VariationalCalculus/Basic.lean @@ -245,5 +245,4 @@ lemma fundamental_theorem_of_variational_calculus {f : X → V} · intro x simp only [Pi.zero_apply] apply real_inner_self_nonneg' - · apply IsTestFunction.integrable - exact IsTestFunction.inner hf hf + · exact (IsTestFunction.inner hf hf).integrable μ diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index 744e68a8c..b3a7a3f72 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -192,8 +192,7 @@ lemma comp {F : (Y → V) → (Z → W)} {G : (X → U) → (Y → V)} {u : X smooth_at := hG.smooth_at diff := by intro φ hφ - apply hF.diff (φ := fun t x => G (φ t) x) - exact hG.diff φ hφ + exact hF.diff (φ := fun t x => G (φ t) x) (hG.diff φ hφ) linearize := by intro φ hφ x rw[hF.linearize (fun t x => G (φ t) x) (hG.diff φ hφ)] diff --git a/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean b/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean index 40e286a5d..052c5b396 100644 --- a/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean +++ b/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean @@ -178,8 +178,7 @@ lemma distTimeSlice_distDeriv_inl {M d} [NormedAddCommGroup M] [NormedSpace ℝ rw [toTimeAndSpace_basis_inl'] rw [map_smul] simp only [one_div, smul_eq_mul] - · apply Differentiable.differentiableAt - exact SchwartzMap.differentiable κ + · exact (SchwartzMap.differentiable κ).differentiableAt · fun_prop lemma distDeriv_inl_distTimeSlice_symm {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] @@ -219,8 +218,7 @@ lemma distTimeSlice_distDeriv_inr {M d} [NormedAddCommGroup M] [NormedSpace ℝ simp only [toTimeAndSpace_fderiv, ContinuousLinearMap.coe_comp, ContinuousLinearEquiv.coe_coe, Function.comp_apply] rw [toTimeAndSpace_basis_inr] - · apply Differentiable.differentiableAt - exact SchwartzMap.differentiable κ + · exact (SchwartzMap.differentiable κ).differentiableAt · fun_prop lemma distDeriv_inr_distTimeSlice_symm {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] From 777c0cfe48ce85a3572ca9fe79a3890579467671 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:17:08 -0700 Subject: [PATCH 093/498] refactor: golf derivative wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Dynamics/CurrentDensity.lean | 8 ++++---- .../Mathematics/VariationalCalculus/HasVarGradient.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 5 ++--- Physlib/SpaceAndTime/SpaceTime/Derivatives.lean | 5 ++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean index 7987e2646..7429735a4 100644 --- a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean @@ -102,8 +102,8 @@ lemma chargeDensity_zero {d : ℕ} {c : SpeedOfLight}: lemma chargeDensity_differentiable {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) : Differentiable ℝ ↿(J.chargeDensity c) := by rw [chargeDensity_eq_timeSlice] - apply timeSlice_differentiable - exact Differentiable.fun_const_smul ((SpaceTime.differentiable_vector J).mpr hJ (Sum.inl 0)) _ + exact timeSlice_differentiable c _ + (Differentiable.fun_const_smul ((SpaceTime.differentiable_vector J).mpr hJ (Sum.inl 0)) _) lemma chargeDensity_differentiable_space {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : Differentiable ℝ J) (t : Time) : @@ -119,8 +119,8 @@ lemma chargeDensity_differentiable_space {d : ℕ} {c : SpeedOfLight} {J : Loren lemma chargeDensity_contDiff {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} (hJ : ContDiff ℝ n J) : ContDiff ℝ n ↿(J.chargeDensity c) := by rw [chargeDensity_eq_timeSlice] - apply timeSlice_contDiff - exact ContDiff.const_smul _ ((SpaceTime.contDiff_vector J).mpr hJ (Sum.inl 0)) + exact timeSlice_contDiff c _ + (ContDiff.const_smul _ ((SpaceTime.contDiff_vector J).mpr hJ (Sum.inl 0))) /-! diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean b/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean index d26795542..2c34070a7 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean @@ -72,8 +72,7 @@ lemma HasVarGradientAt.add (F F' : (X → U) → (X → ℝ)) obtain ⟨F1,hF1,eq1⟩ := h obtain ⟨F2,hF2,eq2⟩ := h' apply HasVarGradientAt.intro (F1 + F2) - · apply hF1.add (V := ℝ) - exact hF2 + · exact HasVarAdjDerivAt.add (V := ℝ) F F' F1 F2 u hF1 hF2 · simp rw [eq1, eq2] diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index 35539c4d4..433fdeb0d 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -243,9 +243,8 @@ lemma deriv_commute [NormedAddCommGroup M] [NormedSpace ℝ M] simp only [fderiv_fun_const, Pi.ofNat_apply, ContinuousLinearMap.comp_zero, zero_add, ContinuousLinearMap.flip_apply] rw [IsSymmSndFDerivAt.eq] - apply ContDiffAt.isSymmSndFDerivAt - exact ContDiff.contDiffAt hf - simp only [minSmoothness_of_isRCLikeNormedField, le_refl] + exact (ContDiff.contDiffAt hf).isSymmSndFDerivAt + (by simp only [minSmoothness_of_isRCLikeNormedField, le_refl]) repeat fun_prop /-! diff --git a/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean b/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean index fa13be9a6..8e3926344 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean @@ -243,9 +243,8 @@ lemma deriv_commute {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : simp only [fderiv_fun_const, Pi.ofNat_apply, ContinuousLinearMap.comp_zero, zero_add, ContinuousLinearMap.flip_apply] rw [IsSymmSndFDerivAt.eq] - · apply ContDiffAt.isSymmSndFDerivAt - exact hf.contDiffAt - simp only [minSmoothness_of_isRCLikeNormedField, le_refl] + · exact hf.contDiffAt.isSymmSndFDerivAt + (by simp only [minSmoothness_of_isRCLikeNormedField, le_refl]) · have h1 := hf.differentiable (by norm_cast); fun_prop · fun_prop · have h1 := hf.differentiable (by norm_cast); fun_prop From 886a6400042583a6829063aec50ea398ef4d573d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:18:41 -0700 Subject: [PATCH 094/498] refactor: golf constant time differentiability proofs Co-authored-by: Claude Opus 4.8 --- .../TimeAndSpace/ConstantTimeDist.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index d7ac9f42b..9d61aad77 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -272,8 +272,7 @@ lemma time_integral_hasFDerivAt {d : ℕ} (η : 𝓢(Time × Space d, ℝ)) (x · rfl fun_prop fun_prop - · apply Differentiable.differentiableAt - exact η.smooth'.differentiable (by simp) + · exact (η.smooth'.differentiable (by simp)).differentiableAt fun_prop · apply Integrable.const_mul convert hrt using 1 @@ -379,8 +378,7 @@ lemma integrable_fderiv_space {d : ℕ} (η : 𝓢(Time × Space d, ℝ)) (x : S · exact hx x t · fun_prop · fun_prop - · apply Differentiable.differentiableAt - exact η.smooth'.differentiable (by simp) + · exact (η.smooth'.differentiable (by simp)).differentiableAt · fun_prop rw [← MeasureTheory.integrable_norm_iff] apply Integrable.mono' (g := fun t => k * ‖ContinuousLinearMap.prod (0 : Space d →L[ℝ] Time) @@ -448,8 +446,7 @@ lemma time_integral_contDiff {d : ℕ} (n : ℕ) (η : 𝓢(Time × Space d, ℝ ContinuousLinearMap.coe_id', id_eq, SchwartzMap.lineDerivOp_apply_eq_fderiv] fun_prop fun_prop - · apply Differentiable.differentiableAt - exact η.smooth'.differentiable (by simp) + · exact (η.smooth'.differentiable (by simp)).differentiableAt fun_prop rw [hl2] apply ih @@ -933,8 +930,7 @@ lemma constantTime_distSpaceDeriv {M : Type} {d : ℕ} [NormedAddCommGroup M] [N ContinuousLinearMap.coe_id', id_eq] · fun_prop · fun_prop - · apply Differentiable.differentiableAt - exact η.smooth'.differentiable (by simp) + · exact (η.smooth'.differentiable (by simp)).differentiableAt · fun_prop /-! @@ -1012,8 +1008,7 @@ lemma constantTime_distTimeDeriv {M : Type} [NormedAddCommGroup M] [NormedSpace ContinuousLinearMap.coe_id', id_eq, _root_.zero_apply] · fun_prop · fun_prop - · apply Differentiable.differentiableAt - exact η.smooth'.differentiable (by simp) + · exact (η.smooth'.differentiable (by simp)).differentiableAt · fun_prop _ = ∫ (t : Time), (fun t => 1) t * fderiv ℝ (fun t => η (t, x)) t 1 := by simp _ = - ∫ (t : Time), fderiv ℝ (fun t => 1) t 1 * (fun t => η (t, x)) t := by From a659931a0434e0f8fcba24efb6dcbe6032776867 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:21:51 -0700 Subject: [PATCH 095/498] refactor: golf constant slice integrability proofs Co-authored-by: Claude Opus 4.8 --- .../SpaceAndTime/Space/ConstantSliceDist.lean | 19 +++++++------------ .../TimeAndSpace/ConstantTimeDist.lean | 6 ++---- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index 9ad5f94c2..59f70c1e3 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -157,10 +157,8 @@ lemma schwartzMap_mul_iteratedFDeriv_integrable_slice_symm {d : ℕ} (n m : ℕ) · fun_prop apply Continuous.norm apply Continuous.comp' - apply ContDiff.continuous_iteratedFDeriv (n := (n + 1 : ℕ)) - exact Nat.cast_le.mpr (by omega) - have hη := η.smooth' - apply hη.of_le (ENat.LEInfty.out) + exact (η.smooth'.of_le (ENat.LEInfty.out)).continuous_iteratedFDeriv + (n := (n + 1 : ℕ)) (Nat.cast_le.mpr (by omega)) fun_prop · filter_upwards with t apply le_trans _ (hbound x t) @@ -235,10 +233,8 @@ lemma schwartzMap_iteratedFDeriv_slice_symm_integrable {n} {d : ℕ} (η : 𝓢( · fun_prop · apply Continuous.aestronglyMeasurable apply Continuous.comp' - apply ContDiff.continuous_iteratedFDeriv (n := (n + 1 : ℕ)) - exact Nat.cast_le.mpr (by omega) - have hη := η.smooth' - apply hη.of_le (ENat.LEInfty.out) + exact (η.smooth'.of_le (ENat.LEInfty.out)).continuous_iteratedFDeriv + (n := (n + 1 : ℕ)) (Nat.cast_le.mpr (by omega)) fun_prop /-! @@ -279,8 +275,8 @@ lemma schwartzMap_slice_integral_hasFDerivAt {d : ℕ} (η : 𝓢(Space d.succ, have hF : ∀ t, ∀ x, HasFDerivAt (F · t) (F' x t) x := by intro t x dsimp only [F, F'] - refine DifferentiableAt.hasFDerivAt ?_ - exact ((η.smooth'.differentiable (by simp)).comp (by fun_prop)).differentiableAt + exact + ((η.smooth'.differentiable (by simp)).comp (by fun_prop)).differentiableAt.hasFDerivAt obtain ⟨rt, hrt⟩ := schwartzMap_slice_bound (m := 0) (n := 1) (d := d) i obtain ⟨k, hrt, hbound, k_eq⟩ := hrt η suffices HasFDerivAt (fun x => ∫ (a : ℝ), F x a) (∫ (a : ℝ), F' x₀ a) x₀ from this @@ -522,8 +518,7 @@ lemma schwartzMap_mul_pow_slice_integral_iteratedFDeriv_norm_le {d : ℕ} (n m : refine mul_le_mul_of_nonneg ?_ (by rfl) (by positivity) (by positivity) refine integral_mono ?_ ?_ ?_ · fun_prop - · apply Integrable.const_mul - exact hrt + · exact hrt.const_mul k · refine Pi.le_def.mpr ?_ intro t convert hbound x t using 1 diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 9d61aad77..4ab0bcfb5 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -808,8 +808,7 @@ lemma time_integral_mul_pow_iteratedFDeriv_norm_le {d : ℕ} (n m : ℕ) : ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n := by refine mul_le_mul_of_nonneg ?_ (by rfl) (by positivity) (by positivity) refine integral_mono ?_ ?_ ?_ - · apply Integrable.const_mul - exact iteratedFDeriv_norm_integrable η x + · exact (iteratedFDeriv_norm_integrable η x).const_mul (‖x‖ ^ m) · exact iteratedFDeriv_norm_mul_pow_integrable n m η x · refine Pi.le_def.mpr ?_ intro t @@ -821,8 +820,7 @@ lemma time_integral_mul_pow_iteratedFDeriv_norm_le {d : ℕ} (n m : ℕ) : refine mul_le_mul_of_nonneg ?_ (by rfl) (by positivity) (by positivity) refine integral_mono ?_ ?_ ?_ · exact iteratedFDeriv_norm_mul_pow_integrable n m η x - · apply Integrable.const_mul - exact hrt + · exact hrt.const_mul k · refine Pi.le_def.mpr ?_ intro t convert! hbound t using 1 From 0dc43a29959501ab4caf2ff5d67a477ac84ac414 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:25:24 -0700 Subject: [PATCH 096/498] refactor: golf distribution integrability proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Distribution/Basic.lean | 23 +++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Physlib/Mathematics/Distribution/Basic.lean b/Physlib/Mathematics/Distribution/Basic.lean index a8d43d391..adeb0d2ef 100644 --- a/Physlib/Mathematics/Distribution/Basic.lean +++ b/Physlib/Mathematics/Distribution/Basic.lean @@ -316,10 +316,8 @@ def const [hμ : Measure.HasTemperateGrowth (volume (α := E))] (c : F) : E →d · subst hc simp rw [MeasureTheory.integral_add] - · refine (integrable_smul_const hc).mpr ?_ - exact integrable η1 - · refine (integrable_smul_const hc).mpr ?_ - exact integrable η2 + · exact (integrable_smul_const hc).mpr (integrable η1) + · exact (integrable_smul_const hc).mpr (integrable η2) · intro a η simp only [smul_apply, RingHom.id_apply, smul_assoc] rw [MeasureTheory.integral_smul] @@ -370,12 +368,13 @@ lemma fderivD_const [hμ : Measure.IsAddHaarMeasure (volume (α := E))] · simp rw [integral_smul_fderiv_eq_neg_fderiv_smul_of_integrable] simp only [evalCLM_apply_apply, fderivCLM_apply, neg_neg] - · apply MeasureTheory.Integrable.smul_const - change Integrable (SchwartzMap.evalCLM (𝕜 := ℝ) E ℝ v (SchwartzMap.fderivCLM ℝ E ℝ η)) volume - exact integrable ((SchwartzMap.evalCLM ℝ E ℝ v) ((fderivCLM ℝ) E ℝ η)) + · exact (show + Integrable + (SchwartzMap.evalCLM (𝕜 := ℝ) E ℝ v + (SchwartzMap.fderivCLM ℝ E ℝ η)) volume from + integrable ((SchwartzMap.evalCLM ℝ E ℝ v) ((fderivCLM ℝ) E ℝ η))).smul_const _ · simp - · apply MeasureTheory.Integrable.smul_const - exact integrable η + · exact (integrable η).smul_const _ · fun_prop · simp @@ -440,10 +439,8 @@ def heavisideStep (d : ℕ) : (EuclideanSpace ℝ (Fin d.succ)) →d[ℝ] ℝ := · intro η1 η2 simp only [Nat.succ_eq_add_one, add_apply] rw [MeasureTheory.integral_add] - · apply MeasureTheory.Integrable.restrict - exact integrable η1 - · apply MeasureTheory.Integrable.restrict - exact integrable η2 + · exact (integrable η1).restrict + · exact (integrable η2).restrict · intro a η simp only [smul_apply, RingHom.id_apply] rw [MeasureTheory.integral_smul] From 23d8c63b8f6854b06beb552ca504a60f5dc5276c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:27:22 -0700 Subject: [PATCH 097/498] refactor: golf variational smoothness proofs Co-authored-by: Claude Opus 4.8 --- .../VariationalCalculus/HasVarAdjDeriv.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index b3a7a3f72..005814dde 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -407,8 +407,7 @@ lemma deriv' (u : ℝ → U) (hu : ContDiff ℝ ∞ u) : rw [← fderiv_apply_one_eq_deriv] rw [fderiv_swap] simp only [fderiv_eq_smul_deriv, one_smul] - · apply ContDiff.of_le hφ - exact ENat.LEInfty.out + · exact hφ.of_le ENat.LEInfty.out · exact differentiableAt_id adjoint := by apply HasVarAdjoint.congr_fun (G := (fun δu x => deriv (fun x' => δu x') x)) @@ -685,8 +684,7 @@ protected lemma fderiv (u : X → U) (dx : X) (hu : ContDiff ℝ ∞ u) rw [← fderiv_apply_one_eq_deriv] rw [fderiv_swap] simp only [fderiv_eq_smul_deriv, one_smul] - · apply ContDiff.of_le hφ - exact ENat.LEInfty.out + · exact hφ.of_le ENat.LEInfty.out · exact hu · exact HasVarAdjoint.fderiv_apply @@ -735,8 +733,7 @@ protected lemma gradient {d} (u : Space d → ℝ) (hu : ContDiff ℝ ∞ u) : rw [← fderiv_apply_one_eq_deriv] rw [fderiv_swap] simp only [fderiv_eq_smul_deriv, smul_eq_mul, one_mul] - · apply ContDiff.of_le hφ - exact ENat.LEInfty.out + · exact hφ.of_le ENat.LEInfty.out · simp [Space.deriv] apply Differentiable.differentiableAt apply fderiv_uncurry_differentiable_snd_comp_fst_apply @@ -780,8 +777,7 @@ protected lemma grad {d} (u : Space d → ℝ) (hu : ContDiff ℝ ∞ u) : rw [← fderiv_apply_one_eq_deriv] rw [fderiv_swap] simp only [fderiv_eq_smul_deriv, smul_eq_mul, one_mul] - · apply ContDiff.of_le hφ - exact ENat.LEInfty.out + · exact hφ.of_le ENat.LEInfty.out · simp [Space.deriv] apply Differentiable.differentiableAt apply fderiv_uncurry_differentiable_snd_comp_fst_apply @@ -834,8 +830,7 @@ lemma div {d} (u : Space d → EuclideanSpace ℝ (Fin d)) (hu : ContDiff ℝ exact hφ.differentiable (by simp) · apply ContDiff.comp (g := EuclideanSpace.proj i) · fun_prop - · apply ContDiff.of_le hφ - exact ENat.LEInfty.out + · exact hφ.of_le ENat.LEInfty.out · intro i _ apply Differentiable.differentiableAt simp [Space.deriv] From 1e5eb2f8c893e98ccc19520a2e085f14c97ba34c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:30:23 -0700 Subject: [PATCH 098/498] refactor: golf small analytic proof wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Distribution/PowMul.lean | 3 +-- Physlib/Mathematics/InnerProductSpace/Basic.lean | 5 +++-- Physlib/Mathematics/InnerProductSpace/Submodule.lean | 4 ++-- .../QuantumMechanics/DDimensions/Operators/Commutation.lean | 4 ++-- Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Physlib/Mathematics/Distribution/PowMul.lean b/Physlib/Mathematics/Distribution/PowMul.lean index 2feed10a9..3a93cd17c 100644 --- a/Physlib/Mathematics/Distribution/PowMul.lean +++ b/Physlib/Mathematics/Distribution/PowMul.lean @@ -76,8 +76,7 @@ def powOneMul : 𝓢(ℝ, 𝕜) →L[𝕜] 𝓢(ℝ, 𝕜) := by · exact SchwartzMap.smooth (ψ) ⊤ · exact right_eq_inf.mp rfl · exact ContinuousMultilinearMap.opNorm_nonneg _ - · refine pow_nonneg ?_ k - exact norm_nonneg x + · exact pow_nonneg (norm_nonneg x) k conv_lhs => enter [2, 2, i, 1, 2] change ‖iteratedFDeriv ℝ i RCLike.ofRealCLM x‖ diff --git a/Physlib/Mathematics/InnerProductSpace/Basic.lean b/Physlib/Mathematics/InnerProductSpace/Basic.lean index cb7c5d000..a5a39c9ca 100644 --- a/Physlib/Mathematics/InnerProductSpace/Basic.lean +++ b/Physlib/Mathematics/InnerProductSpace/Basic.lean @@ -546,8 +546,9 @@ instance {ι : Type*} [Fintype ι] : InnerProductSpace' 𝕜 (ι → E) where ring apply Finset.sum_le_card_nsmul intro j _ - refine mul_le_mul_of_nonneg (by simp) ?_ (by positivity) (by positivity) - exact (sq_le_sq₀ (norm_nonneg (x j)) (norm_nonneg (x i))).mpr (hj j) + exact mul_le_mul_of_nonneg (by simp) + ((sq_le_sq₀ (norm_nonneg (x j)) (norm_nonneg (x i))).mpr (hj j)) + (by positivity) (by positivity) · rw [not_nonempty_iff] at hnEmpty refine ⟨1, 1, zero_lt_one, zero_lt_one, fun x => ?_⟩ rw [Subsingleton.elim x 0] diff --git a/Physlib/Mathematics/InnerProductSpace/Submodule.lean b/Physlib/Mathematics/InnerProductSpace/Submodule.lean index afeb98227..a05415384 100644 --- a/Physlib/Mathematics/InnerProductSpace/Submodule.lean +++ b/Physlib/Mathematics/InnerProductSpace/Submodule.lean @@ -66,8 +66,8 @@ lemma submoduleToLp_closure : apply mem_nhds_iff.mp at ht rcases ht with ⟨t1, ht1, ht1', hx⟩ have : ∃ t' ∈ nhds x, (∀ y ∈ t', y.ofLp ∈ t1) := by - refine Filter.eventually_iff_exists_mem.mp ?_ - exact ContinuousAt.eventually_mem (by fun_prop) (IsOpen.mem_nhds ht1' hx) + exact Filter.eventually_iff_exists_mem.mp + (ContinuousAt.eventually_mem (by fun_prop) (IsOpen.mem_nhds ht1' hx)) rcases this with ⟨t2, ht2, ht2'⟩ rcases h t2 ht2 with ⟨w, hw⟩ use w.ofLp diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean index 689ea9080..9aca73699 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean @@ -187,8 +187,8 @@ lemma radiusRegPow_commutation_momentum : ext ψ x have hne := Ne.symm (ne_of_lt <| Space.norm_sq_add_unit_sq_pos ε x) have hdiff1 : DifferentiableAt ℝ (fun x => (‖x‖ ^ 2 + ↑ε ^ 2) ^ (s / 2)) x := by - refine DifferentiableAt.rpow_const ?_ (Or.intro_left _ hne) - exact Differentiable.differentiableAt (by fun_prop) + exact DifferentiableAt.rpow_const (Differentiable.differentiableAt (by fun_prop)) + (Or.intro_left _ hne) have hdiff2 := Real.differentiableAt_rpow_const_of_ne (s / 2) hne have hdiff3 : DifferentiableAt ℝ (fun x ↦ ‖x‖ ^ 2 + ε ^ 2) x := Differentiable.differentiableAt (by fun_prop) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index f25b3df60..7c0e6599c 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -267,9 +267,9 @@ lemma nsmul_succ (n : ℕ) [SigmaFinite 𝓒.μ] : nsmul n.succ 𝓒 = (𝓒 + n exact Fin.sum_univ_succAbove (fun i => 𝓒.energy (x i)) 0 · simp [Nat.succ_eq_add_one, Nat.succ_mul, dof_nsmul, add_comm] · simp - · refine Eq.symm (MeasureTheory.MeasurePreserving.map_eq ?_) - exact MeasurePreserving.symm _ - (MeasureTheory.measurePreserving_piFinSuccAbove (n := n) (fun _ => 𝓒.μ) 0) + · exact Eq.symm (MeasureTheory.MeasurePreserving.map_eq + (MeasurePreserving.symm _ + (MeasureTheory.measurePreserving_piFinSuccAbove (n := n) (fun _ => 𝓒.μ) 0))) /-! From 3baeba9be7070554fba993c66be33566c22d0405 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:33:41 -0700 Subject: [PATCH 099/498] refactor: golf wick contraction wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/Basic.lean | 3 +-- Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean | 3 +-- .../WickContraction/InsertAndContractNat.lean | 6 ++---- Physlib/QFT/PerturbationTheory/WickContraction/Join.lean | 6 ++---- .../WickContraction/Sign/InsertNone.lean | 3 +-- .../WickContraction/SubContraction.lean | 8 ++++---- Physlib/Relativity/SL2C/Basic.lean | 5 +++-- Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean | 3 +-- 8 files changed, 15 insertions(+), 22 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean index e7c308607..9a3d6d45c 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean @@ -55,8 +55,7 @@ lemma charges_eq_toSpecies_eq (S T : (SMνCharges n).Charges) : S = T ↔ ∀ i, toSpecies i S = toSpecies i T := by refine Iff.intro (fun h => ?_) (fun h => ?_) · exact fun i => congrArg (⇑(toSpecies i)) h - · apply toSpeciesEquiv.injective - exact funext (fun i => h i) + · exact toSpeciesEquiv.injective (funext (fun i => h i)) lemma toSMSpecies_toSpecies_inv (i : Fin 6) (f : Fin 6 → Fin n → ℚ) : (toSpecies i) (toSpeciesEquiv.symm f) = f i := by diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean index c28b361e7..c1eb1d0f9 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean @@ -88,8 +88,7 @@ instance : Fintype FieldStatistic where intro c cases c · exact Finset.mem_insert_self bosonic {fermionic} - · refine Finset.insert_eq_self.mp ?_ - exact rfl + · exact Finset.insert_eq_self.mp rfl @[simp] lemma fermionic_not_eq_bonsic : ¬ fermionic = bosonic := by diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean index 40d148f92..39705a04b 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean @@ -667,8 +667,7 @@ lemma insertAndContractNat_fstFieldOfContract (c : WickContraction n) (i : Fin n · simp only [Nat.succ_eq_add_one, insertLift, Finset.mem_map, Fin.succAboveEmb_apply] use (c.sndFieldOfContract a) simp - · refine Fin.succAbove_lt_succAbove_iff.mpr ?_ - exact fstFieldOfContract_lt_sndFieldOfContract c a + · exact Fin.succAbove_lt_succAbove_iff.mpr (fstFieldOfContract_lt_sndFieldOfContract c a) @[simp] lemma insertAndContractNat_sndFieldOfContract (c : WickContraction n) (i : Fin n.succ) @@ -683,8 +682,7 @@ lemma insertAndContractNat_sndFieldOfContract (c : WickContraction n) (i : Fin n · simp only [Nat.succ_eq_add_one, insertLift, Finset.mem_map, Fin.succAboveEmb_apply] use (c.sndFieldOfContract a) simp - · refine Fin.succAbove_lt_succAbove_iff.mpr ?_ - exact fstFieldOfContract_lt_sndFieldOfContract c a + · exact Fin.succAbove_lt_succAbove_iff.mpr (fstFieldOfContract_lt_sndFieldOfContract c a) /-- Given a contracted pair for a Wick contraction `WickContraction n`, the corresponding contracted pair of a wick contraction `(c.insert i (some j))` formed diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean index 66b6128f2..6fce2aacc 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean @@ -204,8 +204,7 @@ lemma join_fstFieldOfContract_joinLiftRight {φs : List 𝓕.FieldOp} (φsΛ : W apply eq_fstFieldOfContract_of_mem _ _ _ (uncontractedListEmd (φsucΛ.sndFieldOfContract a)) · simp [joinLiftRight] · simp [joinLiftRight] - · apply uncontractedListEmd_strictMono - exact fstFieldOfContract_lt_sndFieldOfContract φsucΛ a + · exact uncontractedListEmd_strictMono (fstFieldOfContract_lt_sndFieldOfContract φsucΛ a) @[simp] lemma join_sndFieldOfContract_joinLiftRight {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) @@ -215,8 +214,7 @@ lemma join_sndFieldOfContract_joinLiftRight {φs : List 𝓕.FieldOp} (φsΛ : W apply eq_sndFieldOfContract_of_mem _ _ (uncontractedListEmd (φsucΛ.fstFieldOfContract a)) · simp [joinLiftRight] · simp [joinLiftRight] - · apply uncontractedListEmd_strictMono - exact fstFieldOfContract_lt_sndFieldOfContract φsucΛ a + · exact uncontractedListEmd_strictMono (fstFieldOfContract_lt_sndFieldOfContract φsucΛ a) @[simp] lemma join_fstFieldOfContract_joinLiftLeft {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean index cad815331..71a8131b8 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean @@ -207,8 +207,7 @@ lemma signInsertNone_eq_filter_map (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) · simp only [map_one] · rename_i h simp [h] - · refine List.Nodup.filter _ ?_ - exact List.nodup_finRange φs.length + · exact List.Nodup.filter _ (List.nodup_finRange φs.length) · exact hG /-- The following signs for a grading compliant Wick contraction are equal: diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean index f81bf4fea..7463bc4a4 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean @@ -158,8 +158,8 @@ lemma quotContraction_fstFieldOfContract_uncontractedListEmd {S : Finset (Finset (uncontractedListEmd ((quotContraction S hs).sndFieldOfContract a)) · simp only [Finset.mem_map', fstFieldOfContract_mem] · simp - · apply uncontractedListEmd_strictMono - exact fstFieldOfContract_lt_sndFieldOfContract (quotContraction S hs) a + · exact uncontractedListEmd_strictMono + (fstFieldOfContract_lt_sndFieldOfContract (quotContraction S hs) a) @[simp] lemma quotContraction_sndFieldOfContract_uncontractedListEmd {S : Finset (Finset (Fin φs.length))} @@ -172,8 +172,8 @@ lemma quotContraction_sndFieldOfContract_uncontractedListEmd {S : Finset (Finset (uncontractedListEmd ((quotContraction S hs).fstFieldOfContract a)) · simp only [Finset.mem_map', fstFieldOfContract_mem] · simp - · apply uncontractedListEmd_strictMono - exact fstFieldOfContract_lt_sndFieldOfContract (quotContraction S hs) a + · exact uncontractedListEmd_strictMono + (fstFieldOfContract_lt_sndFieldOfContract (quotContraction S hs) a) lemma quotContraction_gradingCompliant {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} (hsΛ : φsΛ.GradingCompliant) : diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index 801b9de0c..c1ad0370a 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -199,8 +199,9 @@ lemma toSelfAdjointMap_pauliBasis (i : Fin 1 ⊕ Fin 3) : apply congrArg funext j rw [smul_smul, PauliMatrix.pauliBasis_minkowskiMetric_pauliBasis', smul_smul] - apply congrFun - exact congrArg _ (Eq.symm (minkowskiMatrix.dual_apply_minkowskiMatrix ((toLorentzGroup M).1) i j)) + exact congrFun + (congrArg _ (Eq.symm (minkowskiMatrix.dual_apply_minkowskiMatrix ((toLorentzGroup M).1) i j))) + _ /-- The first column of the Lorentz matrix formed from an element of `SL(2, ℂ)`. -/ lemma toLorentzGroup_fst_col (M : SL(2, ℂ)) : diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean index cd1e0feef..76ad31035 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean @@ -215,8 +215,7 @@ lemma reduce_filter (x : TenQuanta 𝓩) (q : 𝓩) (h : q ∈ x.toCharges) : simp only [Function.comp_apply] have hx : (Multiset.filter (fun x => x = q) x.toCharges.dedup) = {q} := by refine (Multiset.Nodup.ext ?_ ?_).mpr ?_ - · refine Multiset.Nodup.filter (fun x => x = q) ?_ - exact Multiset.nodup_dedup x.toCharges + · exact Multiset.Nodup.filter (fun x => x = q) (Multiset.nodup_dedup x.toCharges) · exact Multiset.nodup_singleton q intro a simp only [Multiset.mem_filter, Multiset.mem_dedup, Multiset.mem_singleton, From f3e9e32d353bd7b93690f5ac49d780c12effdb95 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:35:50 -0700 Subject: [PATCH 100/498] refactor: golf localized transform neighborhood proofs Co-authored-by: Claude Opus 4.8 --- .../IsLocalizedfunctionTransform.lean | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean b/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean index 3f9345b23..54a7a8eb3 100644 --- a/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean +++ b/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean @@ -135,8 +135,8 @@ lemma div {d} : IsLocalizedFunctionTransform fun (φ : Space d → EuclideanSpac (fun x => (φ x) i) =ᶠ[nhds x] fun x => (φ' x) i := by intro i x hx apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · apply Metric.isOpen_thickening.mem_nhds - exact Metric.self_subset_thickening one_pos K hx + · exact Metric.isOpen_thickening.mem_nhds + (Metric.self_subset_thickening one_pos K hx) · intro y hy dsimp only rw [hφ y (Metric.thickening_subset_cthickening 1 K hy)] @@ -156,8 +156,8 @@ lemma div_comp_repr {d} : IsLocalizedFunctionTransform fun (φ : Space d → Spa (fun x => (φ x) i) =ᶠ[nhds x] fun x => (φ' x) i := by intro i x hx apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · apply Metric.isOpen_thickening.mem_nhds - exact Metric.self_subset_thickening one_pos K hx + · exact Metric.isOpen_thickening.mem_nhds + (Metric.self_subset_thickening one_pos K hx) · intro y hy dsimp only rw [hφ y (Metric.thickening_subset_cthickening 1 K hy)] @@ -179,8 +179,8 @@ lemma grad : IsLocalizedFunctionTransform fun (ψ : Space d → ℝ) x => Space. congr 2 have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · apply Metric.isOpen_thickening.mem_nhds - exact Metric.self_subset_thickening one_pos K hx + · exact Metric.isOpen_thickening.mem_nhds + (Metric.self_subset_thickening one_pos K hx) · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) exact Filter.EventuallyEq.fderiv_eq h @@ -198,8 +198,8 @@ lemma gradient : IsLocalizedFunctionTransform fun (ψ : Space d → ℝ) x => gr congr 2 have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · apply Metric.isOpen_thickening.mem_nhds - exact Metric.self_subset_thickening one_pos K hx + · exact Metric.isOpen_thickening.mem_nhds + (Metric.self_subset_thickening one_pos K hx) · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) exact Filter.EventuallyEq.fderiv_eq h @@ -219,8 +219,8 @@ lemma deriv [NormedAddCommGroup U] [NormedSpace ℝ U] : dsimp have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · apply Metric.isOpen_thickening.mem_nhds - exact Metric.self_subset_thickening one_pos K hx + · exact Metric.isOpen_thickening.mem_nhds + (Metric.self_subset_thickening one_pos K hx) · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) exact h.deriv_eq @@ -236,8 +236,8 @@ lemma fderiv [NormedAddCommGroup U] [NormedSpace ℝ U] dsimp; congr 1 have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · apply Metric.isOpen_thickening.mem_nhds - exact Metric.self_subset_thickening one_pos K hx + · exact Metric.isOpen_thickening.mem_nhds + (Metric.self_subset_thickening one_pos K hx) · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) rw [Filter.EventuallyEq.fderiv_eq h] @@ -282,8 +282,8 @@ lemma adjFDeriv {dy} [NormedSpace ℝ X] [ProperSpace X] simp only [DFunLike.coe_fn_eq] have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · apply Metric.isOpen_thickening.mem_nhds - exact Metric.self_subset_thickening one_pos K hx + · exact Metric.isOpen_thickening.mem_nhds + (Metric.self_subset_thickening one_pos K hx) · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) exact Filter.EventuallyEq.fderiv_eq h From 90c40dc12c68112553bb359d6845be342eabbf6c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:38:11 -0700 Subject: [PATCH 101/498] refactor: golf classical derivative wrappers Co-authored-by: Claude Opus 4.8 --- .../Lagrangian/TotalDerivativeEquivalence.lean | 12 ++++-------- Physlib/FluidDynamics/NavierStokes/Basic.lean | 12 ++++++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean index 8df6deb97..965652131 100644 --- a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean +++ b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean @@ -113,8 +113,7 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : · simp rfl · apply ContDiffAt.differentiableAt - · apply ContDiff.contDiffAt - exact h_tq_contDiff q h_ContDiff_q + · exact (h_tq_contDiff q h_ContDiff_q).contDiffAt · by_contra rcases this apply Eq.symm @@ -125,8 +124,7 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : · simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.coe_snd'] rfl · apply ContDiffAt.differentiableAt - · apply ContDiff.contDiffAt - exact h_tq_contDiff q h_ContDiff_q + · exact (h_tq_contDiff q h_ContDiff_q).contDiffAt · by_contra rcases this have h_F_tq_der : ∀ (q : Time → X) (F : Time → X → ℝ) t, (ContDiff ℝ ∞ ↿F) → (ContDiff ℝ ∞ q) → @@ -138,13 +136,11 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : rw [← Time.deriv_eq,h_tq_der] exact hq · apply ContDiffAt.differentiableAt - · apply ContDiff.contDiffAt - exact hF + · exact hF.contDiffAt · by_contra rcases this · apply ContDiffAt.differentiableAt - · apply ContDiff.contDiffAt - exact h_tq_contDiff q hq + · exact (h_tq_contDiff q hq).contDiffAt · by_contra rcases this -- beginning of the proof diff --git a/Physlib/FluidDynamics/NavierStokes/Basic.lean b/Physlib/FluidDynamics/NavierStokes/Basic.lean index 89fa5e940..a309beebe 100644 --- a/Physlib/FluidDynamics/NavierStokes/Basic.lean +++ b/Physlib/FluidDynamics/NavierStokes/Basic.lean @@ -67,12 +67,12 @@ theorem navierStokes_iff_convectiveNavierStokes NavierStokes d data ↔ ConvectiveNavierStokes d data := by constructor · intro hConservative - refine ⟨hConservative.1, ?_⟩ - exact (FluidDynamics.NavierStokes.momentumEquation_iff_convectiveMomentumEquation d data - hConservative.1 hRhoTime hVelocityTime hMomentumDensity hVelocitySpace).mp hConservative.2 + exact ⟨hConservative.1, + (FluidDynamics.NavierStokes.momentumEquation_iff_convectiveMomentumEquation d data + hConservative.1 hRhoTime hVelocityTime hMomentumDensity hVelocitySpace).mp hConservative.2⟩ · intro hConvective - refine ⟨hConvective.1, ?_⟩ - exact (FluidDynamics.NavierStokes.momentumEquation_iff_convectiveMomentumEquation d data - hConvective.1 hRhoTime hVelocityTime hMomentumDensity hVelocitySpace).mpr hConvective.2 + exact ⟨hConvective.1, + (FluidDynamics.NavierStokes.momentumEquation_iff_convectiveMomentumEquation d data + hConvective.1 hRhoTime hVelocityTime hMomentumDensity hVelocitySpace).mpr hConvective.2⟩ end FluidDynamics From 45c07ad548ab17a1b83d5619f0dbf37fe6661937 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:40:26 -0700 Subject: [PATCH 102/498] refactor: golf quantum analytic wrappers Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/Position.lean | 14 +++++++------- .../Operators/SpectralTheory/Basic.lean | 9 +++++---- .../PolyBddSchwartzSubmodule.lean | 8 ++++---- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean index 5bd45725c..b8c9df9a1 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean @@ -246,8 +246,8 @@ lemma radiusPowLM_apply_memHS {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (a : suffices s ≤ ⌈s⌉.toNat by have h' : 0 < C ^ 2 * ‖x‖ ^ (-2 * d : ℝ) := mul_pos (sq_pos_of_pos hC_pos) (Real.rpow_pos_of_pos hx' _) - apply (mul_le_iff_le_one_right h').mpr - exact Real.rpow_le_one_of_one_le_of_nonpos hx (by linarith) + exact (mul_le_iff_le_one_right h').mpr + (Real.rpow_le_one_of_one_le_of_nonpos hx (by linarith)) exact (Int.le_ceil s).trans (by exact_mod_cast Int.self_le_toNat ⌈s⌉) /-! @@ -270,9 +270,9 @@ lemma radiusRegPow_tendsto_radiusPow {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ have hpow : ‖x‖ ^ s = (‖x‖ ^ 2 + 0 ^ 2) ^ (s / 2) := by simp [← Real.rpow_natCast_mul, mul_div_cancel₀] simp only [radiusRegPowCLM_apply, radiusPowLM_apply, Complex.real_smul, hpow] - refine Tendsto.mul_const (ψ x) <| Tendsto.ofReal ?_ - exact Tendsto.rpow_const (Tendsto.const_add _ <| Tendsto.pow tendsto_comap 2) - (Or.inl <| by simp [hx]) + exact Tendsto.mul_const (ψ x) <| Tendsto.ofReal + (Tendsto.rpow_const (Tendsto.const_add _ <| Tendsto.pow tendsto_comap 2) + (Or.inl <| by simp [hx])) /-- `𝐫[ε,s] ψ` converges pointwise to `𝐫[s] ψ` as `ε → 0` provided `𝐫[ε,s] ψ 0` is bounded. -/ lemma radiusRegPow_tendsto_radiusPow' {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (h : 0 ≤ s ∨ ψ 0 = 0) : @@ -285,8 +285,8 @@ lemma radiusRegPow_tendsto_radiusPow' {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, have : (0 : ℝ) ^ s = (0 ^ 2) ^ (s / 2) := by rw [← Real.rpow_natCast_mul (le_refl 0), Nat.cast_ofNat, mul_div_cancel₀ s (by norm_num)] rw [this] - refine Tendsto.mul_const (ψ 0) <| Tendsto.ofReal ?_ - exact Tendsto.rpow_const (Tendsto.pow tendsto_comap 2) (Or.inr <| by linarith) + exact Tendsto.mul_const (ψ 0) <| Tendsto.ofReal + (Tendsto.rpow_const (Tendsto.pow tendsto_comap 2) (Or.inr <| by linarith)) · simp [hψ] · exact radiusRegPow_tendsto_radiusPow s ψ hx.ne diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean index d10a099b4..394e8f028 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean @@ -227,8 +227,8 @@ lemma regularityDomain_isOpen (T : H →ₗ.[ℂ] H) : IsOpen T.regularityDomain /-- `T` and `T.closure` have the same regularity domain. -/ lemma regularityDomain_closure (T : H →ₗ.[ℂ] H) : T.closure.regularityDomain = T.regularityDomain := by - refine eq_of_le_of_ge (regularityDomain_antitone T.le_closure) ?_ - exact fun _ ⟨c, hc, h⟩ ↦ ⟨c, hc, isLowerBound_closure h⟩ + exact eq_of_le_of_ge (regularityDomain_antitone T.le_closure) + fun _ ⟨c, hc, h⟩ ↦ ⟨c, hc, isLowerBound_closure h⟩ lemma IsClosable.closure_range_sub_eq_range_closure_sub [CompleteSpace H] {T : H →ₗ.[ℂ] H} (hT : T.IsClosable) {z : ℂ} (hz : z ∈ T.regularityDomain) : @@ -401,8 +401,9 @@ lemma IsClosable.defectNumber_eq_of_mem_ball [CompleteSpace H] {T : H →ₗ.[ · exact hT.closure_isClosed.exists_inner_eq_zero_of_defectNumber_lt hz₂ hle refine not_le (a := ‖z₁ - z₂‖ * ‖x‖).mpr ?_ le_rfl refine lt_of_lt_of_le (b := ‖Tcl x - z₁ • x‖) ?_ ?_ - · refine lt_of_lt_of_le ?_ (isLowerBound_closure h x) - exact (mul_lt_mul_iff_left₀ <| norm_pos_iff.mpr hx).mpr (mem_ball_iff_norm'.mp h_ball) + · exact lt_of_lt_of_le + ((mul_lt_mul_iff_left₀ <| norm_pos_iff.mpr hx).mpr (mem_ball_iff_norm'.mp h_ball)) + (isLowerBound_closure h x) · rcases eq_or_ne (Tcl x - z₁ • x) 0 with heq | hne · exact heq ▸ norm_zero (E := H) ▸ mul_nonneg (norm_nonneg _) (norm_nonneg x) · apply (mul_le_mul_iff_left₀ (norm_pos_iff.mpr hne)).mp diff --git a/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean b/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean index c2644baa3..0b0c01b1c 100644 --- a/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean +++ b/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean @@ -233,8 +233,8 @@ lemma dense_top (d : ℕ) : Dense (polyBddSchwartzSubmodule d ⊤ : Set (SpaceDH refine mk (f := s n) ⟨?_, ?_⟩ · exact (continuous_ofReal.comp (b n).continuous).aestronglyMeasurable.mul ξ.val.aestronglyMeasurable - · refine lt_of_le_of_lt ?_ (coe_hilbertSpace_memHS ξ).2 - exact eLpNorm_mono_enorm (enorm_bump_mul_le_enorm (b n) ξ) + · exact lt_of_le_of_lt (eLpNorm_mono_enorm (enorm_bump_mul_le_enorm (b n) ξ)) + (coe_hilbertSpace_memHS ξ).2 have hψ_ae (n : ℕ) : ψ n =ᵐ[volume] f n := (schwartzEquiv_symm_coe_ae ⟨ψ n, hψ n⟩).symm have hφ_ae (n : ℕ) : φ n =ᵐ[volume] g n := schwartzEquiv_coe_ae (g n) have hσ_ae (n : ℕ) : σ n =ᵐ[volume] s n := coe_mk_ae _ @@ -260,8 +260,8 @@ lemma dense_top (d : ℕ) : Dense (polyBddSchwartzSubmodule d ⊤ : Set (SpaceDH ENNReal.ofReal_pow (b n).rOut_pos.le] simp_rw [hvolB, ← ENNReal.ofReal_zero, b, ← one_div, mul_pow, ← mul_assoc] rw [← mul_zero (C * 2 ^ d), ← zero_pow (M₀ := ℝ) hd.ne'] - refine ENNReal.tendsto_ofReal <| Tendsto.const_mul (C * 2 ^ d) ?_ - exact tendsto_one_div_add_atTop_nhds_zero_nat.pow d + exact ENNReal.tendsto_ofReal <| Tendsto.const_mul (C * 2 ^ d) + (tendsto_one_div_add_atTop_nhds_zero_nat.pow d) refine Tendsto.squeeze tendsto_const_nhds hξB (zero_le) (fun n ↦ ?_) suffices ∫⁻ x, ‖σ n x‖ₑ ^ 2 = ∫⁻ x in B n, ‖σ n x‖ₑ ^ 2 by rw [this] From 95bffaec02aa292ea95fd6ef9128af6bbbcb7048 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:42:54 -0700 Subject: [PATCH 103/498] refactor: golf spectral and derivative wrappers Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/SpectralTheory/Basic.lean | 13 +++++++------ .../OneDimension/HilbertSpace/Gaussians.lean | 5 ++--- Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 3 +-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean index 394e8f028..4106c2cdd 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean @@ -690,8 +690,8 @@ lemma IsClosed.resolventSet_eq [CompleteSpace H] {T : H →ₗ.[ℂ] H} (hT : T. rw [mem_resolventSet_iff, mem_setOf_eq, and_congr_right_iff, and_iff_left_iff_imp] intro h_ker h_range refine continuous_of_isClosed_domain ?_ ?_ - · apply (inverse_closed_iff h_ker).mpr - exact hT.sub_continuous (Continuous.const_smul (by fun_prop) _) (by simp) + · exact (inverse_closed_iff h_ker).mpr + (hT.sub_continuous (Continuous.const_smul (by fun_prop) _) (by simp)) · simp [inverse_domain, h_range] /-- For a closed operator the resolvent set consists of those regular points for which @@ -835,11 +835,12 @@ lemma IsClosed.spectrum_eq [CompleteSpace H] {T : H →ₗ.[ℂ] H} (hT : T.IsCl rw [mem_continuousSpectrum_iff, ← inverse_domain] refine fun h ↦ h_cont ?_ refine continuous_of_isClosed_domain ?_ h - apply (inverse_closed_iff h_ker).mpr - exact hT.sub_continuous (Continuous.const_smul (by fun_prop) _) le_top + exact (inverse_closed_iff h_ker).mpr + (hT.sub_continuous (Continuous.const_smul (by fun_prop) _) le_top) · left; left; exact h_ker - · refine union_subset ?_ T.continuousSpectrum_subset_spectrum - exact union_subset T.pointSpectrum_subset_spectrum T.residualSpectrum_subset_spectrum + · exact union_subset + (union_subset T.pointSpectrum_subset_spectrum T.residualSpectrum_subset_spectrum) + T.continuousSpectrum_subset_spectrum lemma pointSpectrum_inter_residualSpectrum (T : H →ₗ.[ℂ] H) : σᵖ T ∩ σʳ T = ∅ := by ext diff --git a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Gaussians.lean b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Gaussians.lean index 0d9ac2c39..a8215732a 100644 --- a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Gaussians.lean +++ b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Gaussians.lean @@ -72,9 +72,8 @@ lemma exp_mul_gaussian_integrable (b c : ℝ) (hb : 0 < b) : field_simp ring rw [h1] - apply MeasureTheory.Integrable.const_mul - exact Integrable.comp_sub_right (f := (fun x => Real.exp (- b * x ^ 2))) - (integrable_exp_neg_mul_sq hb) (c / (2 * b)) + exact (Integrable.comp_sub_right (f := (fun x => Real.exp (- b * x ^ 2))) + (integrable_exp_neg_mul_sq hb) (c / (2 * b))).const_mul _ lemma exp_abs_mul_gaussian_integrable (b c : ℝ) (hb : 0 < b) : MeasureTheory.Integrable (fun x => Real.exp (|c * x|) * Real.exp (- b * x ^ 2)) := by diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index 433fdeb0d..881a9f446 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -539,8 +539,7 @@ lemma schwartMap_fderiv_comm {d} ContinuousLinearMap.flip_apply] rw [IsSymmSndFDerivAt.eq] apply ContDiffAt.isSymmSndFDerivAt (n := 2) - · refine ContDiff.contDiffAt ?_ - exact h2 + · exact h2.contDiffAt · simp · fun_prop · exact differentiableAt_const (basis μ) From 1a49b7588f887e8d5b90c28b62319411c0fd292a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:45:21 -0700 Subject: [PATCH 104/498] refactor: golf distribution boundedness wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 19 +++++++------------ Physlib/SpaceAndTime/Space/Norm/Basic.lean | 3 +-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index 8f24c772c..35da2f800 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -1037,8 +1037,7 @@ lemma zpow_smul_self {d : ℕ} (n : ℤ) (hn : - (d - 1 : ℕ) - 1 ≤ n) : lemma zpow_smul_repr_self {d : ℕ} (n : ℤ) (hn : - (d - 1 : ℕ) - 1 ≤ n) : IsDistBounded (d := d) (fun x => ‖x‖ ^ n • basis.repr x) := by apply IsDistBounded.congr (f := fun x => ‖x‖ ^ n • x) - · apply zpow_smul_self - exact hn + · exact zpow_smul_self n hn · apply AEMeasurable.aestronglyMeasurable fun_prop · intro x @@ -1117,8 +1116,8 @@ lemma norm_smul_zpow {d} (p : ℤ) (c : Space d) (hn : - (d - 1 : ℕ) ≤ p) : ring suffices h0 : IsDistBounded (fun x => ‖x‖ * (‖x‖ ^ (p + 1))⁻¹) by apply h0.add - · apply IsDistBounded.const_mul_fun - exact IsDistBounded.pow (d := d) (n := -(p + 1)) (by grind) + · exact IsDistBounded.const_mul_fun + (IsDistBounded.pow (d := d) (n := -(p + 1)) (by grind)) ‖c‖ by_cases hp : p = 0 · subst hp simp only [zero_add, pow_one] @@ -1157,8 +1156,7 @@ lemma norm_smul_isDistBounded {d : ℕ} [NormedSpace ℝ F] {f : Space d → F} · apply IsDistBounded.congr (f := fun x => ∑ i, (c i * (‖x‖ * ‖x + g i‖ ^ (p i)))) · apply IsDistBounded.sum_fun intro i _ - apply IsDistBounded.const_mul_fun - exact norm_smul_zpow (p i) (g i) (p_bound i) + exact IsDistBounded.const_mul_fun (norm_smul_zpow (p i) (g i) (p_bound i)) (c i) · fun_prop · intro x congr @@ -1197,8 +1195,7 @@ lemma component_smul_isDistBounded {d : ℕ} [NormedSpace ℝ F] {f : Space d · fun_prop · intro x simp [norm_smul] - apply mul_le_mul ?_ (by rfl) (by positivity) (by positivity) - exact abs_eval_le_norm x i + exact mul_le_mul (abs_eval_le_norm x i) (by rfl) (by positivity) (by positivity) @[fun_prop] lemma component_mul_isDistBounded {d : ℕ} {f : Space d → ℝ} @@ -1259,8 +1256,7 @@ lemma isDistBounded_smul_inner_of_smul_norm {d : ℕ} [NormedSpace ℝ F] {f : S · fun_prop · intro x simp [norm_smul] - refine mul_le_mul_of_nonneg_right ?_ (by positivity) - exact abs_eval_le_norm x i + exact mul_le_mul_of_nonneg_right (abs_eval_le_norm x i) (by positivity) @[fun_prop] lemma isDistBounded_mul_inner {d : ℕ} {f : Space d → ℝ} @@ -1299,8 +1295,7 @@ lemma mul_inner_pow_neg_two {d : ℕ} (y : Space d) (hd : 2 ≤ d := by omega) : fun_prop · intro x simp - apply mul_le_mul_of_nonneg _ (by rfl) (by positivity) (by positivity) - exact abs_real_inner_le_norm y x + exact mul_le_mul_of_nonneg (abs_real_inner_le_norm y x) (by rfl) (by positivity) (by positivity) end constructors end IsDistBounded diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index afb434f30..bbf00fec0 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -806,8 +806,7 @@ lemma gradient_dist_normPowerSeries_log_tendsTo_distGrad_norm {d : ℕ} (hd : 2 intro x hx simp at hx simp - apply mul_le_mul (by rfl) _ (by positivity) (by positivity) - exact normPowerSeries_log_le n x hx + exact mul_le_mul (by rfl) (normPowerSeries_log_le n x hx) (by positivity) (by positivity) · rw [Filter.eventually_iff_exists_mem] use {0}ᶜ constructor From 0bb913430c6a7ae9393e43eb4e781ded2b841137 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:47:39 -0700 Subject: [PATCH 105/498] refactor: golf integral norm inequality wrappers Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/Multiplication.lean | 4 ++-- Physlib/SpaceAndTime/Space/ConstantSliceDist.lean | 11 ++++++----- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 6 ++---- .../SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean | 11 ++++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean index 090a9a5ab..96e0856c5 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean @@ -200,8 +200,8 @@ private lemma exists_monotone_sets_hasFiniteIntegral simp_rw [norm_pow, norm_norm, RCLike.norm_natCast] refine pow_le_pow_left₀ (norm_nonneg _) ?_ 2 rcases hk <;> simp_all - · refine ENNReal.mul_lt_top (by norm_num) ?_ - exact measure_inter_lt_top_of_left_ne_top measure_closedBall_lt_top.ne + · exact ENNReal.mul_lt_top (by norm_num) + (measure_inter_lt_top_of_left_ne_top measure_closedBall_lt_top.ne) open Complex InnerProductSpace in lemma mulOperator_adjoint_domain_le {f : Space d → ℂ} (hf : AEStronglyMeasurable f) : diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index 59f70c1e3..0cfeea911 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -464,9 +464,9 @@ lemma schwartzMap_slice_integral_iteratedFDeriv_norm_le {d : ℕ} (n : ℕ) (η (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n := by rw [schwartzMap_slice_integral_iteratedFDeriv] apply le_trans (ContinuousMultilinearMap.norm_compContinuousLinearMap_le _ _) - simp - refine mul_le_mul ?_ (by rfl) (by positivity) (by positivity) - exact norm_integral_le_integral_norm fun a => iteratedFDeriv ℝ n ⇑η _ + simp only [Nat.succ_eq_add_one, Finset.prod_const, Finset.card_univ, Fintype.card_fin] + exact mul_le_mul (norm_integral_le_integral_norm fun a => iteratedFDeriv ℝ n ⇑η _) + (by rfl) (by positivity) (by positivity) lemma schwartzMap_mul_pow_slice_integral_iteratedFDeriv_norm_le {d : ℕ} (n m : ℕ) (i : Fin d.succ) : ∃ rt, ∀ (η : 𝓢(Space d.succ, ℝ)),∀ (x : Space d), @@ -491,8 +491,9 @@ lemma schwartzMap_mul_pow_slice_integral_iteratedFDeriv_norm_le {d : ℕ} (n m : _ ≤ ‖x‖ ^ m * ((∫ (r : ℝ), ‖iteratedFDeriv ℝ n η ((slice i).symm (r, x))‖) * ‖(slice i).symm.toContinuousLinearMap.comp ((0 : Space d →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n) := by - refine mul_le_mul_of_nonneg (by rfl) ?_ (by positivity) (by positivity) - exact schwartzMap_slice_integral_iteratedFDeriv_norm_le n η i x + exact mul_le_mul_of_nonneg (by rfl) + (schwartzMap_slice_integral_iteratedFDeriv_norm_le n η i x) (by positivity) + (by positivity) _ ≤ (∫ (r : ℝ), ‖x‖ ^ m * ‖iteratedFDeriv ℝ n η ((slice i).symm (r, x))‖) * ‖(slice i).symm.toContinuousLinearMap.comp ((0 : Space d →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n := by diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index bbf00fec0..dde4947a9 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -279,8 +279,7 @@ lemma normPowerSeries_zpow_le_norm_sq_add_one {d} (n : ℕ) (m : ℤ) (x : Space | .ofNat m => trans (‖x‖ + 1) ^ m · simp - refine pow_le_pow_left₀ (by simp) ?_ m - exact normPowerSeries_le_norm_sq_add_one n x + exact pow_le_pow_left₀ (by simp) (normPowerSeries_le_norm_sq_add_one n x) m · simp | .negSucc m => trans (‖x‖ ^ (m + 1))⁻¹; swap @@ -289,8 +288,7 @@ lemma normPowerSeries_zpow_le_norm_sq_add_one {d} (n : ℕ) (m : ℤ) (x : Space simp only [zpow_negSucc] refine inv_anti₀ ?_ ?_ · positivity - refine pow_le_pow_left₀ (by simp) ?_ (m + 1) - exact norm_le_normPowerSeries n x + exact pow_le_pow_left₀ (by simp) (norm_le_normPowerSeries n x) (m + 1) lemma normPowerSeries_inv_le {d} (n : ℕ) (x : Space d) (hx : x ≠ 0) : (normPowerSeries n x)⁻¹ ≤ ‖x‖⁻¹ := by diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 4ab0bcfb5..633507ee7 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -769,9 +769,10 @@ lemma time_integral_iteratedFDeriv_norm_le {d : ℕ} (n : ℕ) (η : 𝓢(Time (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n := by rw [time_integral_iteratedFDeriv_eq] apply le_trans (ContinuousMultilinearMap.norm_compContinuousLinearMap_le _ _) - simp - refine mul_le_mul ?_ (by rfl) (by positivity) (by positivity) - exact norm_integral_le_integral_norm fun a => iteratedFDeriv ℝ n ⇑η (a, x) + simp only [ContinuousLinearMap.opNorm_prod, Prod.norm_mk, norm_zero, norm_nonneg, + sup_of_le_right, Finset.prod_const, Finset.card_univ, Fintype.card_fin] + exact mul_le_mul (norm_integral_le_integral_norm fun a => iteratedFDeriv ℝ n ⇑η (a, x)) + (by rfl) (by positivity) (by positivity) /-! @@ -798,8 +799,8 @@ lemma time_integral_mul_pow_iteratedFDeriv_norm_le {d : ℕ} (n m : ℕ) : calc _ _ ≤ ‖x‖ ^ m * ((∫ (t : Time), ‖iteratedFDeriv ℝ n η (t, x)‖) * ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n) := by - refine mul_le_mul_of_nonneg (by rfl) ?_ (by positivity) (by positivity) - exact time_integral_iteratedFDeriv_norm_le n η x + exact mul_le_mul_of_nonneg (by rfl) (time_integral_iteratedFDeriv_norm_le n η x) + (by positivity) (by positivity) _ ≤ (∫ (t : Time), ‖x‖ ^ m * ‖iteratedFDeriv ℝ n η (t, x)‖) * ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n := by apply le_of_eq From 3a8aaecaf43dab6a954dede550125f40c01b9593 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:52:26 -0700 Subject: [PATCH 106/498] refactor: golf Hermitian matrix proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 20 +++++++++---------- .../ForMathlib/HermitianMat/NonSingular.lean | 12 +++++------ .../ForMathlib/HermitianMat/Order.lean | 8 ++++---- QuantumInfo/ForMathlib/Matrix.lean | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index b342732de..b11b9b82b 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -33,8 +33,8 @@ variable (A : HermitianMat d 𝕜) (f : ℝ → ℝ) (g : ℝ → ℝ) (q r : /- Adding this to the `CStarAlgebra` aesop set allows `cfc_tac` to use it. -/ omit [Fintype d] [DecidableEq d] in @[aesop safe apply (rule_sets := [CStarAlgebra])] -theorem isSelfAdjoint : IsSelfAdjoint A.mat := by - exact A.H +theorem isSelfAdjoint : IsSelfAdjoint A.mat := + A.H /- Adding this to `fun_prop` allows `cfc_cont_tac` to use it. -/ @[fun_prop] @@ -44,8 +44,8 @@ theorem continuousOn_finite {α β : Type*} (f : α → β) (S : Set α) exact continuous_of_discreteTopology @[simp] -theorem conjTranspose_cfc : (cfc f A.mat).conjTranspose = cfc f A.mat := by - exact cfc_predicate f A.mat +theorem conjTranspose_cfc : (cfc f A.mat).conjTranspose = cfc f A.mat := + cfc_predicate f A.mat protected def cfc : HermitianMat d 𝕜 := ⟨cfc f A.mat, cfc_predicate _ _⟩ @@ -93,8 +93,8 @@ variable {A B : HermitianMat d 𝕜} @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.cfc_left (hAB : Commute A.mat B.mat) : - Commute (A.cfc f).mat B.mat := by - exact hAB.cfc_real f + Commute (A.cfc f).mat B.mat := + hAB.cfc_real f @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.cfc_right (hAB : Commute A.mat B.mat) : @@ -102,8 +102,8 @@ theorem _root_.Commute.cfc_right (hAB : Commute A.mat B.mat) : (hAB.symm.cfc_left f).symm theorem cfc_commute (f g : ℝ → ℝ) (hAB : Commute A.mat B.mat) : - Commute (A.cfc f).mat (B.cfc g).mat := by - exact (hAB.cfc_right g).cfc_left f + Commute (A.cfc f).mat (B.cfc g).mat := + (hAB.cfc_right g).cfc_left f @[aesop safe apply (rule_sets := [Commutes])] theorem cfc_self_commute (A : HermitianMat d 𝕜) (f g : ℝ → ℝ) : @@ -120,8 +120,8 @@ theorem cfc_reindex (e : d ≃ d₂) : (A.reindex e).cfc f = (A.cfc f).reindex e exact Matrix.cfc_reindex f e theorem spectrum_cfc_eq_image (A : HermitianMat d 𝕜) (f : ℝ → ℝ) : - spectrum ℝ (A.cfc f).mat = f '' (spectrum ℝ A.mat) := by - exact cfc_map_spectrum f A.mat + spectrum ℝ (A.cfc f).mat = f '' (spectrum ℝ A.mat) := + cfc_map_spectrum f A.mat set_option backward.isDefEq.respectTransparency false in /-- diff --git a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean index 94b66f777..1aa5a2529 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean @@ -24,15 +24,15 @@ theorem isUnit_smul {c : R} (hA : IsUnit c) {M : Matrix d d S} (hM : IsUnit M) : use d • M' rfl -theorem isUnit_natCast {n : ℕ} (hn : n ≠ 0) [CharZero F] : IsUnit (n : Matrix d d F) := by - exact (IsUnit.mk0 (n : F) (mod_cast hn)).map (algebraMap F _) +theorem isUnit_natCast {n : ℕ} (hn : n ≠ 0) [CharZero F] : IsUnit (n : Matrix d d F) := + (IsUnit.mk0 (n : F) (mod_cast hn)).map (algebraMap F _) theorem isUnit_real_smul {r : ℝ} (hr : r ≠ 0) {M : Matrix d d 𝕜} (hM : IsUnit M) : IsUnit (r • M : Matrix d d 𝕜) := isUnit_smul hr.isUnit hM -theorem isUnit_real_cast {r : ℝ} (hr : r ≠ 0) : IsUnit (r • 1 : Matrix d d 𝕜) := by - exact isUnit_real_smul hr isUnit_one +theorem isUnit_real_cast {r : ℝ} (hr : r ≠ 0) : IsUnit (r • 1 : Matrix d d 𝕜) := + isUnit_real_smul hr isUnit_one end Matrix @@ -49,8 +49,8 @@ class NonSingular (A : HermitianMat n R) : Prop where theorem isUnit_mat_of_nonSingular [NonSingular A] : IsUnit A.mat := NonSingular.isUnit -theorem nonsingular_iff_isUnit : NonSingular A ↔ IsUnit A.mat := by - exact Iff.intro (fun h ↦ h.isUnit) NonSingular.mk +theorem nonsingular_iff_isUnit : NonSingular A ↔ IsUnit A.mat := + Iff.intro (fun h ↦ h.isUnit) NonSingular.mk instance instHasInv_of_invertible [i : Invertible A.mat] : NonSingular A := ⟨isUnit_of_invertible _⟩ diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 5f31efe28..1db655fb9 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -75,11 +75,11 @@ theorem posSemidef_iff_spectrum_Ici [DecidableEq n] (A : HermitianMat n 𝕜) : simp [A.H, Set.Ici.eq_1] theorem posSemidef_iff_spectrum_nonneg [DecidableEq n] (A : HermitianMat n 𝕜) : - 0 ≤ A ↔ ∀ x ∈ spectrum ℝ A.mat, 0 ≤ x := by - exact A.posSemidef_iff_spectrum_Ici + 0 ≤ A ↔ ∀ x ∈ spectrum ℝ A.mat, 0 ≤ x := + A.posSemidef_iff_spectrum_Ici -theorem trace_nonneg (hA : 0 ≤ A) : 0 ≤ A.trace := by - exact (RCLike.nonneg_iff.mp (zero_le_iff.mp hA).trace_nonneg).1 +theorem trace_nonneg (hA : 0 ≤ A) : 0 ≤ A.trace := + (RCLike.nonneg_iff.mp (zero_le_iff.mp hA).trace_nonneg).1 theorem trace_pos (hA : 0 < A) : 0 < A.trace := by open ComplexOrder in diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index a2aee46ca..72ff3db36 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -59,8 +59,8 @@ variable (hA : A.IsHermitian) (hB : B.IsHermitian) include hA in omit [DecidableEq n] in -theorem smul_selfAdjoint {c : 𝕜} (hc : _root_.IsSelfAdjoint c) : (c • A).IsHermitian := by - exact IsSelfAdjoint.smul hc hA +theorem smul_selfAdjoint {c : 𝕜} (hc : _root_.IsSelfAdjoint c) : (c • A).IsHermitian := + IsSelfAdjoint.smul hc hA include hA in omit [DecidableEq n] in From cd721a2af43c58254b5eddf98d1640005ae4880a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:56:50 -0700 Subject: [PATCH 107/498] refactor: golf quantum info wrapper proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Dual.lean | 4 ++-- QuantumInfo/Channels/Unbundled.lean | 4 ++-- QuantumInfo/ForMathlib/HermitianMat/Basic.lean | 4 ++-- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 4 ++-- QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 4 ++-- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 8 ++++---- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 5 +++-- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index b9e38a470..fd55213dc 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -214,8 +214,8 @@ lemma dual_choi_matrix_posSemidef_of_posSemidef (M : MatrixMap dIn dOut 𝕜) (h /-- The dual of the identity map is the identity map. -/ -lemma dual_id : (MatrixMap.id dIn 𝕜).dual = MatrixMap.id dIn 𝕜 := by - exact dual_unique (id dIn 𝕜) (id dIn 𝕜) fun A_1 => congrFun rfl +lemma dual_id : (MatrixMap.id dIn 𝕜).dual = MatrixMap.id dIn 𝕜 := + dual_unique (id dIn 𝕜) (id dIn 𝕜) fun _ => congrFun rfl private theorem matrix_mem_span_kronecker {A C : Type*} [Fintype A] [Fintype C] [DecidableEq A] [DecidableEq C] (X : Matrix (A × C) (A × C) 𝕜) : diff --git a/QuantumInfo/Channels/Unbundled.lean b/QuantumInfo/Channels/Unbundled.lean index 8cf0b84ef..11892f2df 100644 --- a/QuantumInfo/Channels/Unbundled.lean +++ b/QuantumInfo/Channels/Unbundled.lean @@ -459,8 +459,8 @@ def _root_.MatrixMap.conj (y : Matrix B A R) : MatrixMap A B R where map_smul' r x := by rw [RingHom.id_apply, Matrix.mul_smul, Matrix.smul_mul] omit [DecidableEq A] in -theorem conj_isPositive (M : Matrix B A 𝕜) : (conj M).IsPositive := by - exact fun X hX => hX.mul_mul_conjTranspose_same M +theorem conj_isPositive (M : Matrix B A 𝕜) : (conj M).IsPositive := + fun _ hX => hX.mul_mul_conjTranspose_same M omit [DecidableEq A] in theorem IsPositive_sum {ι : Type*} [Fintype ι] (f : ι → MatrixMap A B ℂ) (h : ∀ i, (f i).IsPositive) : diff --git a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean index 31eaa84ad..538e6bb83 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean @@ -480,8 +480,8 @@ noncomputable def support : Submodule 𝕜 (EuclideanSpace 𝕜 n) := LinearMap.range A.lin.toLinearMap /-- The support of a Hermitian matrix is the sum of its nonzero eigenspaces. -/ -theorem support_eq_sup_eigenspace_nonzero : A.support = ⨆ μ ≠ 0, A.eigenspace μ := by - exact A.lin.support_eq_sup_eigenspace_nonzero A.isSymmetric +theorem support_eq_sup_eigenspace_nonzero : A.support = ⨆ μ ≠ 0, A.eigenspace μ := + A.lin.support_eq_sup_eigenspace_nonzero A.isSymmetric @[simp] theorem support_zero : (0 : HermitianMat n 𝕜).support = ⊥ := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index b11b9b82b..1b38f2efc 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -189,8 +189,8 @@ theorem mat_cfc_mul : (A.cfc (f * g)).mat = A.cfc f * A.cfc g := by simp only [mat_cfc] exact cfc_mul .. -theorem mat_cfc_mul_apply : (A.cfc (fun x ↦ f x * g x)).mat = A.cfc f * A.cfc g := by - exact mat_cfc_mul .. +theorem mat_cfc_mul_apply : (A.cfc (fun x ↦ f x * g x)).mat = A.cfc f * A.cfc g := + mat_cfc_mul .. nonrec theorem cfc_comp : A.cfc (g ∘ f) = (A.cfc f).cfc g := by ext1; exact cfc_comp .. diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 36063f7c9..99f144da2 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -62,8 +62,8 @@ theorem reindex_exp (e : d ≃ d₂) : (A.reindex e).exp = A.exp.reindex e := cfc_reindex A Real.exp e variable (A) in -instance nonSingular_exp : NonSingular A.exp := by - exact cfc_nonSingular A Real.exp (fun i ↦ by positivity) +instance nonSingular_exp : NonSingular A.exp := + cfc_nonSingular A Real.exp (fun i ↦ by positivity) /-- The matrix exponential of a Hermitian matrix is nonnegative. -/ theorem exp_nonneg (A : HermitianMat d 𝕜) : 0 ≤ A.exp := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 1db655fb9..22ec226eb 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -157,8 +157,8 @@ theorem kronecker_pos {A : HermitianMat m 𝕜} (hA : 0 < A) (hB : 0 < B) : 0 < omit [Fintype n] in open MatrixOrder in -theorem posSemidef_to_nonneg {A : Matrix n n 𝕜} (hA : A.PosSemidef) : 0 ≤ A := by - exact hA.nonneg +theorem posSemidef_to_nonneg {A : Matrix n n 𝕜} (hA : A.PosSemidef) : 0 ≤ A := + hA.nonneg open MatrixOrder in theorem posDef_to_pos {A : Matrix n n 𝕜} (hA : A.PosDef) [Nonempty n] : 0 < A := by @@ -237,8 +237,8 @@ omit [Fintype n] in theorem mat_posSemidef_to_nonneg (hA : A.mat.PosSemidef) : 0 ≤ A := zero_le_iff.mpr hA -theorem mat_posDef_to_pos [Nonempty n] (hA : A.mat.PosDef) : 0 < A := by - exact posDef_to_pos hA +theorem mat_posDef_to_pos [Nonempty n] (hA : A.mat.PosDef) : 0 < A := + posDef_to_pos hA open Lean Meta in /-- Given an expression `e` (a `HermitianMat`) and a proof expression `p` whose type may be diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 8cea291bd..83b084791 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -64,8 +64,9 @@ theorem diagonal_pow (f : d → ℝ) : rfl @[fun_prop] -theorem rpow_const_continuous {r : ℝ} (hr : 0 ≤ r) : Continuous (fun A : HermitianMat d ℂ ↦ A ^ r) := by - exact HermitianMat.cfc_continuous (Real.continuous_rpow_const hr) +theorem rpow_const_continuous {r : ℝ} (hr : 0 ≤ r) : + Continuous (fun A : HermitianMat d ℂ ↦ A ^ r) := + HermitianMat.cfc_continuous (Real.continuous_rpow_const hr) @[fun_prop] theorem const_rpow_continuous [NonSingular A] : Continuous (fun r : ℝ ↦ A ^ r) := by From 163ef6a7d3bebeb8c77ba2493ec7159c52eec38d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:58:33 -0700 Subject: [PATCH 108/498] refactor: golf channel local proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Dual.lean | 18 ++++++++++-------- QuantumInfo/Channels/Pinching.lean | 13 +++++++++---- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index fd55213dc..481e52c74 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -151,8 +151,8 @@ theorem IsPositive.dual {M : MatrixMap dIn dOut ℂ} (h : M.IsPositive) : M.dual /-- The dual of TracePreserving map is *not* trace-preserving, it's *unital*, that is, M*(I) = I. -/ theorem dual_Unital (h : M.IsTracePreserving) : M.dual.Unital := by -- By definition of dual, we know that for any matrix A, Tr(M(A) * I) = Tr(A * M*(I)). - have h_dual_trace : ∀ A : Matrix dIn dIn 𝕜, (M A * 1).trace = (A * M.dual 1).trace := by - exact fun A => Dual.trace_eq M A 1; + have h_dual_trace : ∀ A : Matrix dIn dIn 𝕜, (M A * 1).trace = (A * M.dual 1).trace := + fun A => Dual.trace_eq M A 1 ext i j specialize h_dual_trace ( Matrix.of ( fun k l => if k = j then if l = i then 1 else 0 else 0 ) ) simp_all [ Matrix.trace, Matrix.mul_apply ] ; @@ -170,11 +170,13 @@ lemma dual_unique (h : ∀ A B, (M A * B).trace = (A * M' B).trace) : M.dual = M' := by -- By definition of dual, we know that for any A and B, the trace of (M A) * B equals the trace of -- A * (M.dual B). - have h_dual : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, (M A * B).trace = (A * M.dual B).trace := by - exact fun A B => Dual.trace_eq M A B; + have h_dual : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, + (M A * B).trace = (A * M.dual B).trace := + fun A B => Dual.trace_eq M A B -- Since these two linear maps agree on all bases, they must be equal. - have h_eq : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, (A * M.dual B).trace = (A * M' B).trace := by - exact fun A B => h_dual A B ▸ h A B; + have h_eq : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, + (A * M.dual B).trace = (A * M' B).trace := + fun A B => h_dual A B ▸ h A B refine' LinearMap.ext fun B => _; exact Matrix.ext_iff_trace_mul_left.mpr fun x => h_eq x B @@ -267,8 +269,8 @@ lemma dual_kron {A B C D : Type*} [Fintype A] [Fintype B] [Fintype C] [Fintype D -- see Lemma 3.1 of https://www.math.uwaterloo.ca/~krdavids/Preprints/CDPRpositivereal.pdf theorem IsCompletelyPositive.dual {M : MatrixMap dIn dOut ℂ} (h : M.IsCompletelyPositive) : M.dual.IsCompletelyPositive := by intro n - have h_dual_pos : (MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ)).IsPositive := by - exact IsPositive.dual (h n); + have h_dual_pos : (MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ)).IsPositive := + IsPositive.dual (h n) -- By definition of complete positivity, we know that $(M ⊗ₖₘ id) dually map = M.dual ⊗ₖₘ id.dual$. have h_dual_kron : (MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ)) = (MatrixMap.dual M) ⊗ₖₘ (MatrixMap.dual (MatrixMap.id (Fin n) ℂ)) := by convert dual_kron M ( MatrixMap.id ( Fin n ) ℂ ) using 1; diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index d734407a7..4f7651ce8 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -282,8 +282,10 @@ theorem inner_cfc_pinching_right (ρ σ : MState d) (f : ℝ → ℝ) : ⟪(pinching_map σ ρ).M, σ.M.cfc f⟫ = ⟪ρ.M, σ.M.cfc f⟫ := by --TODO Cleanup -- By definition of pinching_map, we have pinching_map σ ρ = ∑ k, (pinching_kraus σ k).toMat * ρ.toMat * (pinching_kraus σ k).toMat. - have h_pinching_def : (pinching_map σ ρ).M = ∑ k, (pinching_kraus σ k).mat * ρ.M.mat * (pinching_kraus σ k).mat := by - exact pinching_eq_sum_conj σ ρ + have h_pinching_def : + (pinching_map σ ρ).M = ∑ k, (pinching_kraus σ k).mat * ρ.M.mat * + (pinching_kraus σ k).mat := + pinching_eq_sum_conj σ ρ -- By definition of pinching_map, we know that (pinching_kraus σ k).toMat * (σ.M.cfc f).toMat = (σ.M.cfc f).toMat * (pinching_kraus σ k).toMat. have h_comm_cfc : ∀ k, (pinching_kraus σ k).mat * (σ.M.cfc f).mat = (σ.M.cfc f).mat * (pinching_kraus σ k).mat := by intro k @@ -297,8 +299,11 @@ theorem inner_cfc_pinching_right (ρ σ : MState d) (f : ℝ → ℝ) : convert pinching_sum σ using 1; simp [HermitianMat.ext_iff ]; -- Since each pinching_kraus is a projection, multiplying it by itself gives the same projection. Therefore, the sum of the squares is the same as the sum of the pinching_kraus themselves. - have h_proj : ∀ k : spectrum ℝ σ.m, (pinching_kraus σ k).mat * (pinching_kraus σ k).mat = (pinching_kraus σ k).mat := by - exact fun k => by simpa [ sq, -pinching_sq_eq_self ] using congr_arg ( fun x : HermitianMat d ℂ => x.mat ) ( pinching_sq_eq_self σ k ) ; + have h_proj : ∀ k : spectrum ℝ σ.m, (pinching_kraus σ k).mat * + (pinching_kraus σ k).mat = (pinching_kraus σ k).mat := + fun k => by + simpa [sq, -pinching_sq_eq_self] using + congr_arg (fun x : HermitianMat d ℂ => x.mat) (pinching_sq_eq_self σ k) rw [ Finset.sum_congr rfl fun _ _ => h_proj _ ]; convert congr_arg ( fun x : Matrix d d ℂ => x.trace.re ) ( congr_arg ( fun x : Matrix d d ℂ => x * ( ρ.m * cfc f σ.m ) ) h_sum_kraus ) using 1; · simp [Matrix.sum_mul] From 78ea2a7d60090640240a50b6ce037a1d890fa249 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 13:59:55 -0700 Subject: [PATCH 109/498] refactor: golf limsup helper proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/LimSupInf.lean | 12 ++++++------ QuantumInfo/ForMathlib/Misc.lean | 11 +++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/LimSupInf.lean b/QuantumInfo/ForMathlib/LimSupInf.lean index fdc408a49..a2377881c 100644 --- a/QuantumInfo/ForMathlib/LimSupInf.lean +++ b/QuantumInfo/ForMathlib/LimSupInf.lean @@ -105,8 +105,8 @@ lemma exists_liminf_zero_of_forall_liminf_le (y : ℝ≥0) (f : ℝ≥0 → ℕ exact le_trans ( hn _ ( le_of_lt ( h _ le_rfl ) ) ) ( le_of_lt ( hc₂ _ hx_pos _ hz _ ) )); -- Define $g(m) = 1/(k(m)+1)$ where $k(m)$ is the index such that $n_{k(m)} \leq m < n_{k(m)+1}$. set g : ℕ → ℝ≥0 := fun m => (Nat.findGreatest (fun k => m ≥ n k) m + 1 : ℝ≥0)⁻¹; - have hg_pos : ∀ m, g m > 0 := by - exact fun m => by positivity;; + have hg_pos : ∀ m, g m > 0 := + fun _ => by positivity have hg_tendsto_zero : Filter.Tendsto g Filter.atTop (𝓝 0) := by -- Since $n$ is strictly monotone, $Nat.findGreatest (fun k => m ≥ n k) m$ tends to infinity as $m$ tends to infinity. have h_find_greatest_inf : Filter.Tendsto (fun m => Nat.findGreatest (fun k => m ≥ n k) m) Filter.atTop Filter.atTop := by @@ -366,8 +366,8 @@ lemma limsup_le_of_block_sequence_bound {α : Type*} (y : ℝ≥0) (f : α → -- Let $k$ be such that $b \in [T_k, T_{k+1})$. obtain ⟨k, hk⟩ : ∃ k, T k ≤ b ∧ b < T (k + 1) := by -- Since $T$ is strictly increasing and unbounded, the set $\{n \mid T n \leq b\}$ is finite and non-empty. - have h_finite : Set.Finite {n | T n ≤ b} := by - exact Set.finite_iff_bddAbove.2 ⟨ b, fun n hn => le_trans ( hT.id_le _ ) hn ⟩; + have h_finite : Set.Finite {n | T n ≤ b} := + Set.finite_iff_bddAbove.2 ⟨b, fun n hn => le_trans (hT.id_le _) hn⟩ exact ⟨ Finset.max' ( h_finite.toFinset ) ⟨ K, h_finite.mem_toFinset.mpr a ⟩, h_finite.mem_toFinset.mp ( Finset.max'_mem _ _ ), not_le.mp fun h => not_lt_of_ge ( Finset.le_max' _ _ ( h_finite.mem_toFinset.mpr h ) ) ( Nat.lt_succ_self _ ) ⟩; rw [ hg k b hk.1 hk.2 ]; exact le_trans ( hbound k b hk.1 hk.2 ) ( add_le_add_right ( hK k ( le_of_not_gt fun hk' => by linarith [ hT.monotone hk'.nat_succ_le ] ) ) _ ) @@ -399,8 +399,8 @@ lemma exists_liminf_zero_of_forall_liminf_limsup_le_with_UB (y₁ y₂ : ℝ≥0 · aesop · aesop obtain ⟨N0, hN0⟩ : ∃ N0 : ℕ → ℕ, ∀ k, ∀ n ≥ N0 k, f₂ (x k) n ≤ y₂ + (k + 1 : ℝ≥0)⁻¹ := by - have h_limsup : ∀ k, Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := by - exact fun k => hf₂ _ ( hx.1 k ); + have h_limsup : ∀ k, Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := + fun k => hf₂ _ (hx.1 k) have h_limsup_le : ∀ k, ∀ ε > 0, ∃ N, ∀ n ≥ N, f₂ (x k) n ≤ y₂ + ε := by intro k ε hε_pos have h_limsup_le : Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := h_limsup k; diff --git a/QuantumInfo/ForMathlib/Misc.lean b/QuantumInfo/ForMathlib/Misc.lean index 0e6dd5b76..edb49e2d6 100644 --- a/QuantumInfo/ForMathlib/Misc.lean +++ b/QuantumInfo/ForMathlib/Misc.lean @@ -102,8 +102,10 @@ theorem csInf_mul_nonneg {s t : Set ℝ} intro ε hε obtain ⟨x, hx₁, hx₂, y, hy₁, hy₂⟩ := h_eps ε hε exact ⟨x, hx₁, y, hy₁, by nlinarith [hs₁ x hx₁, ht₁ y hy₁]⟩ - have h_lim : Filter.Tendsto (fun ε => (a + ε) * (b + ε)) (nhdsWithin 0 (Set.Ioi 0)) (nhds (a * b)) := by - exact tendsto_nhdsWithin_of_tendsto_nhds (Continuous.tendsto' (by continuity) _ _ (by norm_num)) + have h_lim : Filter.Tendsto (fun ε => (a + ε) * (b + ε)) + (nhdsWithin 0 (Set.Ioi 0)) (nhds (a * b)) := + tendsto_nhdsWithin_of_tendsto_nhds + (Continuous.tendsto' (by continuity) _ _ (by norm_num)) apply le_of_tendsto_of_tendsto tendsto_const_nhds h_lim filter_upwards [self_mem_nhdsWithin] with ε hε specialize h_prod_eps ε hε @@ -156,8 +158,9 @@ lemma Multiset.map_univ_eq_iff {α β : Type*} [Fintype α] (f g : α → β) : subst h simp_all only [Function.comp_apply, Finset.univ] -- Since $w$ is a bijection, the multiset of $w(x)$ for $x$ in the original multiset is just a permutation of the original multiset. - have h_perm : Multiset.map (fun x => w x) (Finset.val Fintype.elems) = Finset.val Fintype.elems := by - exact Multiset.map_univ_val_equiv w; + have h_perm : + Multiset.map (fun x => w x) (Finset.val Fintype.elems) = Finset.val Fintype.elems := + Multiset.map_univ_val_equiv w conv_rhs => rw [ ← h_perm ]; simp +zetaDelta at * From d180c4668e2ee971a2311b95f027bdd859cb3394 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:01:30 -0700 Subject: [PATCH 110/498] refactor: golf Hermitian rpow proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 83b084791..fa5f0afa9 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -187,10 +187,10 @@ lemma rpow_inv_eq_neg_rpow (hA : A.mat.PosDef) (p : ℝ) : (A ^ p)⁻¹ = A ^ (- ext i j; have h_inv : (A ^ p).mat * (A ^ (-p)).mat = 1 := by have h_inv : (A ^ p).mat * (A ^ (-p)).mat = 1 := by - have h_pow : (A ^ p).mat = A.cfc (fun x => x ^ p) := by - exact rfl - have h_pow_neg : (A ^ (-p)).mat = A.cfc (fun x => x ^ (-p)) := by - exact rfl + have h_pow : (A ^ p).mat = A.cfc (fun x => x ^ p) := + rfl + have h_pow_neg : (A ^ (-p)).mat = A.cfc (fun x => x ^ (-p)) := + rfl have h_inv : (A ^ p).mat * (A ^ (-p)).mat = A.cfc (fun x => x ^ p * x ^ (-p)) := by rw [ h_pow, h_pow_neg, ← mat_cfc_mul ]; rfl; @@ -201,8 +201,8 @@ lemma rpow_inv_eq_neg_rpow (hA : A.mat.PosDef) (p : ℝ) : (A ^ p)⁻¹ = A ^ (- rw [ h_inv, cfc_const ] ; norm_num; exact h_inv; -- By definition of matrix inverse, if $(A^p) * (A^{-p}) = 1$, then $(A^{-p})$ is the inverse of $(A^p)$. - have h_inv_def : (A ^ p).mat⁻¹ = (A ^ (-p)).mat := by - exact Matrix.inv_eq_right_inv h_inv; + have h_inv_def : (A ^ p).mat⁻¹ = (A ^ (-p)).mat := + Matrix.inv_eq_right_inv h_inv convert! congr_fun ( congr_fun h_inv_def i ) j using 1 open ComplexOrder in @@ -219,12 +219,13 @@ lemma rpow_neg_mul_rpow_self (hA : A.mat.PosDef) (p : ℝ) : have h_pos_def : (A ^ p).mat.PosDef := by have h_pos_def : ∀ p : ℝ, A.mat.PosDef → (A ^ p).mat.PosDef := by intro p hA_pos_def - have h_eigenvalues_pos : ∀ i, 0 < (A.H.eigenvalues i) ^ p := by - exact fun i => Real.rpow_pos_of_pos ( by exact Matrix.PosDef.eigenvalues_pos hA i ) _; - have h_eigenvalues_pos : (A ^ p).mat.PosDef ↔ ∀ i, 0 < (A ^ p).H.eigenvalues i := by - exact Matrix.IsHermitian.posDef_iff_eigenvalues_pos (H (A ^ p)); - have h_eigenvalues_pos : ∃ e : d ≃ d, (A ^ p).H.eigenvalues = fun i => (A.H.eigenvalues (e i)) ^ p := by - exact Matrix.IsHermitian.cfc_eigenvalues (H A) fun x => x.rpow p; + have h_eigenvalues_pos : ∀ i, 0 < (A.H.eigenvalues i) ^ p := + fun i => Real.rpow_pos_of_pos (Matrix.PosDef.eigenvalues_pos hA i) _ + have h_eigenvalues_pos : (A ^ p).mat.PosDef ↔ ∀ i, 0 < (A ^ p).H.eigenvalues i := + Matrix.IsHermitian.posDef_iff_eigenvalues_pos (H (A ^ p)) + have h_eigenvalues_pos : + ∃ e : d ≃ d, (A ^ p).H.eigenvalues = fun i => (A.H.eigenvalues (e i)) ^ p := + Matrix.IsHermitian.cfc_eigenvalues (H A) fun x => x.rpow p aesop; exact h_pos_def p hA; convert! Matrix.nonsing_inv_mul _ _; @@ -233,13 +234,13 @@ lemma rpow_neg_mul_rpow_self (hA : A.mat.PosDef) (p : ℝ) : open ComplexOrder in lemma isUnit_rpow_toMat (hA : A.mat.PosDef) (p : ℝ) : IsUnit (A ^ p).mat := by have hA_inv : IsUnit (A ^ (-p)).mat := by - have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := by - exact rpow_neg_mul_rpow_self hA p + have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := + rpow_neg_mul_rpow_self hA p exact IsUnit.of_mul_eq_one _ hA_inv -- Since $(A^{-p}) (A^p) = 1$, we have that $(A^p)$ is the inverse of $(A^{-p})$. have hA_inv : (A ^ p).mat = (A ^ (-p)).mat⁻¹ := by - have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := by - exact rpow_neg_mul_rpow_self hA p; + have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := + rpow_neg_mul_rpow_self hA p exact Eq.symm (Matrix.inv_eq_right_inv hA_inv); aesop From c3f0ea44450b51045dc069362c5ce1fd28683694 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:03:21 -0700 Subject: [PATCH 111/498] refactor: golf Hermitian log proof wrappers Co-authored-by: Claude Opus 4.8 --- .../ForMathlib/HermitianMat/LogExp.lean | 67 ++++++++++++------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 99f144da2..3483fc512 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -27,8 +27,8 @@ noncomputable section theorem Matrix.IsHermitian.log_smul_of_ne_zero {A : Matrix d d 𝕜} (hA : A.IsHermitian) (hx : x ≠ 0) : cfc Real.log (x • A) = (Real.log x) • cfc (if · = 0 then (0 : ℝ) else 1) A + cfc Real.log A := by - have hCFC : cfc (Real.log ∘ (x * ·)) A = cfc Real.log (x • A) := by - exact cfc_comp_smul x Real.log _ (by fun_prop) hA + have hCFC : cfc (Real.log ∘ (x * ·)) A = cfc Real.log (x • A) := + cfc_comp_smul x Real.log _ (by fun_prop) hA rw [← hCFC, ← cfc_smul, ← cfc_add] apply cfc_congr intro t ht @@ -146,13 +146,17 @@ theorem inv_antitone (hA : A.mat.PosDef) (h : A ≤ B) : B⁻¹ ≤ A⁻¹ := by simp_all only [sub_nonneg] exact h -- Using the fact that $B = A + C^*C$, we can write $B^{-1}$ as $(A + C^*C)^{-1}$. - have h_inv_posDef : (1 + C * A.mat⁻¹ * C.conjTranspose).PosDef := by - exact Matrix.PosDef.one.add_posSemidef (hA.inv.posSemidef.mul_mul_conjTranspose_same C) + have h_inv_posDef : (1 + C * A.mat⁻¹ * C.conjTranspose).PosDef := + Matrix.PosDef.one.add_posSemidef (hA.inv.posSemidef.mul_mul_conjTranspose_same C) have hB_inv : B.mat⁻¹ = A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹ := by have hB_inv : (A.mat + C.conjTranspose * C)⁻¹ = A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹ := by have hB_inv : (A.mat + C.conjTranspose * C) * (A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹) = 1 := by - have h_inv : (1 + C * A.mat⁻¹ * C.conjTranspose) * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ = 1 := by - exact Matrix.mul_nonsing_inv _ ( show IsUnit _ from by simpa [ Matrix.isUnit_iff_isUnit_det ] using h_inv_posDef.det_pos.ne' ); + have h_inv : + (1 + C * A.mat⁻¹ * C.conjTranspose) * + (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ = 1 := + Matrix.mul_nonsing_inv _ + (show IsUnit _ from by + simpa [Matrix.isUnit_iff_isUnit_det] using h_inv_posDef.det_pos.ne') simp only [mul_assoc, Matrix.mul_sub] at * simp only [← Matrix.mul_assoc, add_mul, one_mul] at * simp only [isUnit_iff_ne_zero, ne_eq, hA.det_pos.ne', not_false_eq_true, @@ -221,10 +225,10 @@ theorem logApprox_mono {x y : HermitianMat d 𝕜} (hx : x.mat.PosDef) (hy : y.m refine' ContinuousAt.continuousWithinAt _; have h_inv_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m⁻¹) m.mat := by have h_inv_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m⁻¹) m.mat := by - have h_det_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m.det) m.mat := by - exact Continuous.continuousAt ( continuous_id.matrix_det ) - have h_adj_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m.adjugate) m.mat := by - exact Continuous.continuousAt ( continuous_id.matrix_adjugate ) + have h_det_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m.det) m.mat := + Continuous.continuousAt continuous_id.matrix_det + have h_adj_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m.adjugate) m.mat := + Continuous.continuousAt continuous_id.matrix_adjugate simp_all [ Matrix.inv_def ]; exact ContinuousAt.smul ( h_det_cont.inv₀ ( by simpa using hm.det_pos.ne' ) ) h_adj_cont; exact h_inv_cont; @@ -293,8 +297,10 @@ theorem logApprox_mono {x y : HermitianMat d 𝕜} (hx : x.mat.PosDef) (hy : y.m simp [ Matrix.one_apply, Finset.mul_sum, mul_left_comm ]; simp [ mul_left_comm, Algebra.smul_def ]; · exact add_le_add_left hxy _; - have h_integral_limit : ∀ t ∈ Set.Ioc 0 T, (1 + t)⁻¹ • 1 - (x + t • 1)⁻¹ ≤ (1 + t)⁻¹ • 1 - (y + t • 1)⁻¹ := by - exact fun t ht => sub_le_sub_left ( h_integral_limit t <| Set.Ioc_subset_Icc_self ht ) _; + have h_integral_limit : + ∀ t ∈ Set.Ioc 0 T, + (1 + t)⁻¹ • 1 - (x + t • 1)⁻¹ ≤ (1 + t)⁻¹ • 1 - (y + t • 1)⁻¹ := + fun t ht => sub_le_sub_left (h_integral_limit t <| Set.Ioc_subset_Icc_self ht) _ filter_upwards [MeasureTheory.ae_restrict_mem measurableSet_Ioc] with t ht exact h_integral_limit t ht @@ -378,8 +384,12 @@ The error term in the log approximation tends to 0 as T goes to infinity. lemma tendsto_cfc_log_div_add_atTop (x : HermitianMat d 𝕜) : Tendsto (fun T => x.cfc (fun u => Real.log ((1 + T) / (u + T)))) atTop (nhds 0) := by -- Expand `(cfc x ...).mat` using `cfc_toMat_eq_sum_smul_proj`. - have h_expand : ∀ T : ℝ, (x.cfc (fun u => Real.log ((1 + T) / (u + T)))).mat = ∑ i, Real.log ((1 + T) / (x.H.eigenvalues i + T)) • (x.H.eigenvectorUnitary.val * (Matrix.single i i 1) * x.H.eigenvectorUnitary.val.conjTranspose) := by - exact fun T => cfc_toMat_eq_sum_smul_proj x fun u => Real.log ((1 + T) / (u + T)); + have h_expand : + ∀ T : ℝ, (x.cfc (fun u => Real.log ((1 + T) / (u + T)))).mat = + ∑ i, Real.log ((1 + T) / (x.H.eigenvalues i + T)) • + (x.H.eigenvectorUnitary.val * (Matrix.single i i 1) * + x.H.eigenvectorUnitary.val.conjTranspose) := + fun T => cfc_toMat_eq_sum_smul_proj x fun u => Real.log ((1 + T) / (u + T)) -- The limit of a sum is the sum of the limits. have h_sum : Filter.Tendsto (fun T : ℝ => ∑ i, Real.log ((1 + T) / (x.H.eigenvalues i + T)) • (x.H.eigenvectorUnitary.val * (Matrix.single i i 1) * x.H.eigenvectorUnitary.val.conjTranspose)) Filter.atTop (nhds (∑ i, 0 • (x.H.eigenvectorUnitary.val * (Matrix.single i i 1) * x.H.eigenvectorUnitary.val.conjTranspose))) := by refine' tendsto_finsetSum _ fun i _ => _; @@ -448,8 +458,8 @@ lemma inv_convex {x y : HermitianMat d 𝕜} (hx : x.mat.PosDef) (hy : y.mat.Pos have h_block_pos : ∀ A : Matrix d d 𝕜, A.PosDef → (Matrix.fromBlocks A 1 1 A⁻¹).PosSemidef := by intro A hA have h_block_pos : (Matrix.fromBlocks A (1 : Matrix d d 𝕜) (1 : Matrix d d 𝕜) (A⁻¹)).PosSemidef := by - have h_inv_pos : A⁻¹.PosSemidef := by - exact hA.inv.posSemidef + have h_inv_pos : A⁻¹.PosSemidef := + hA.inv.posSemidef have h_block_pos : (Matrix.fromBlocks A (1 : Matrix d d 𝕜) (1 : Matrix d d 𝕜) (A⁻¹)) = (Matrix.fromBlocks 1 0 A⁻¹ 1) * (Matrix.fromBlocks A 0 0 (A⁻¹ - A⁻¹ * A * A⁻¹)) * (Matrix.fromBlocks 1 A⁻¹ 0 1) := by simp [ Matrix.fromBlocks_multiply ]; have := hA.det_pos; @@ -565,13 +575,13 @@ lemma integrable_inv_shift {A : HermitianMat d 𝕜} (hA : A.mat.PosDef) (b : have h_inv_cont : ContinuousAt (fun t : ℝ => (A + t • 1).mat⁻¹) t := by have h_det_cont : ContinuousAt (fun t : ℝ => (A + t • 1).mat.det) t := by fun_prop (disch := solve_by_elim) - have h_adj_cont : ContinuousAt (fun t : ℝ => (A + t • 1).mat.adjugate) t := by - exact Continuous.continuousAt ( by exact Continuous.matrix_adjugate <| by continuity ) + have h_adj_cont : ContinuousAt (fun t : ℝ => (A + t • 1).mat.adjugate) t := + Continuous.continuousAt (Continuous.matrix_adjugate <| by continuity) simp_all [ Matrix.inv_def ]; exact ContinuousAt.smul ( h_det_cont.inv₀ <| by simpa [ Matrix.isUnit_iff_isUnit_det ] using h_inv t ht.1 ) h_adj_cont exact h_inv_cont.continuousWithinAt - have h_inv_cont : ContinuousOn (fun t : ℝ => (A + t • 1)⁻¹) (Set.Icc 0 b) := by - exact (continuousOn_iff_coe fun t => (A + t • 1)⁻¹).mpr h_inv_cont + have h_inv_cont : ContinuousOn (fun t : ℝ => (A + t • 1)⁻¹) (Set.Icc 0 b) := + (continuousOn_iff_coe fun t => (A + t • 1)⁻¹).mpr h_inv_cont exact h_inv_cont.intervalIntegrable_of_Icc hb open ComplexOrder in @@ -589,8 +599,10 @@ theorem logApprox_concave {n 𝕜 : Type*} [Fintype n] [DecidableEq n] [RCLike rw [ intervalIntegrable_iff_integrableOn_Ioc_of_le hT ] at * refine MeasureTheory.Integrable.sub ?_ h_integrable exact ContinuousOn.integrableOn_Icc ( by exact continuousOn_of_forall_continuousAt fun t ht => ContinuousAt.smul ( ContinuousAt.inv₀ ( continuousAt_const.add continuousAt_id ) ( by linarith [ ht.1 ] ) ) continuousAt_const ) |> fun h => h.mono_set ( Set.Ioc_subset_Icc_self ); - have h_int2 : IntervalIntegrable (fun t => (1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - ((a • x + b • y) + t • 1)⁻¹) MeasureTheory.volume 0 T := by - exact h_integrable (Matrix.PosDef.Convex hx hy ha hb hab) + have h_int2 : IntervalIntegrable + (fun t => (1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - + ((a • x + b • y) + t • 1)⁻¹) MeasureTheory.volume 0 T := + h_integrable (Matrix.PosDef.Convex hx hy ha hb hab) have h_integral_mono : ∫ t in (0)..T, a • ((1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - (x + t • 1)⁻¹) + b • ((1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - (y + t • 1)⁻¹) ≤ ∫ t in (0)..T, (1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - ((a • x + b • y) + t • 1)⁻¹ := by have h_integral_mono : ∀ t ∈ Set.Icc 0 T, a • ((1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - (x + t • 1)⁻¹) + b • ((1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - (y + t • 1)⁻¹) ≤ (1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - ((a • x + b • y) + t • 1)⁻¹ := by intros t ht @@ -629,8 +641,10 @@ lemma log_kron_diagonal {m n 𝕜 : Type*} [Fintype m] [DecidableEq m] [Fintype {d₁ : m → ℝ} {d₂ : n → ℝ} (h₁ : ∀ i, 0 < d₁ i) (h₂ : ∀ j, 0 < d₂ j) : (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂).log = (diagonal 𝕜 d₁).log ⊗ₖ 1 + 1 ⊗ₖ (diagonal 𝕜 d₂).log := by - have h_eq : (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂) = (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)) := by - exact kronecker_diagonal d₁ d₂ + have h_eq : + (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂) = + (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)) := + kronecker_diagonal d₁ d₂ convert congr_arg _ h_eq using 1; -- By definition of logarithm, we can rewrite the right-hand side. have h_rhs : (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)).log = @@ -648,8 +662,9 @@ lemma log_kron_diagonal {m n 𝕜 : Type*} [Fintype m] [DecidableEq m] [Fintype · rw [← diagonal_one, kronecker_diagonal] simp · exact cfc_diagonal Real.log d₁ - · have h_rhs : (diagonal 𝕜 d₂).log = (diagonal 𝕜 (fun (i : n) => Real.log (d₂ i))) := by - exact cfc_diagonal Real.log d₂ + · have h_rhs : (diagonal 𝕜 d₂).log = + (diagonal 𝕜 (fun (i : n) => Real.log (d₂ i))) := + cfc_diagonal Real.log d₂ rw [ h_rhs ]; convert kronecker_diagonal 1 ( fun i => Real.log ( d₂ i ) ) using 1; all_goals try infer_instance; From 8741db879d7cf9b3dc1767dbf683c0bd04aa776e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:05:08 -0700 Subject: [PATCH 112/498] refactor: golf Hermitian trace proof wrappers Co-authored-by: Claude Opus 4.8 --- .../ForMathlib/HermitianMat/LiebConcavity.lean | 8 ++++---- QuantumInfo/ForMathlib/HermitianMat/Peierls.lean | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean index db26cb40e..e2e6c8536 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean @@ -255,8 +255,8 @@ private lemma variational_eq_optimizer have h_exp : (X ^ p) ^ ((p - 1) / p) = X ^ (p - 1) := by rw [← rpow_mul hX, mul_div_cancel₀ _ (by positivity)] have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X ^ p).trace := by - have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X * (X ^ (p - 1)).mat).trace.re := by - exact Real.ext_cauchy rfl + have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X * (X ^ (p - 1)).mat).trace.re := + Real.ext_cauchy rfl convert h_inner using 1 have h_exp : (X ^ p).mat = X.mat * (X ^ (p - 1)).mat := by convert mat_rpow_add hX _ @@ -294,8 +294,8 @@ private lemma liebExtension_bridge [Nonempty d] rw [← traceRe_Φ_general] simp [liebExtensionTraceMap, Φ_rpow, hσ, hZ] rw [show star (Φ K.mat) = Φ K.mat from ?_] - have h_rewrite : IsSelfAdjoint (Φ K.mat) := by - exact Φ_isSelfAdjoint K + have h_rewrite : IsSelfAdjoint (Φ K.mat) := + Φ_isSelfAdjoint K exact h_rewrite convert! h_joint_concave (Φ_mem_pdSet σ₁ hσ₁) (Φ_mem_pdSet σ₂ hσ₂) (Φ_mem_pdSet Z₁ hZ₁) (Φ_mem_pdSet Z₂ hZ₂) hθ₀ hθ₁ using 1 diff --git a/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean b/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean index 5db4fab2e..fe25d8a3e 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean @@ -62,8 +62,8 @@ theorem peierls_inequality (A : HermitianMat d ℂ) (g : ℝ → ℝ) (hg : Conv convert! hg.map_sum_le _ _ _ <;> simp_all [mul_comm] convert! Finset.sum_le_sum fun i _ => h_jensen i using 1 rw [Finset.sum_comm, Finset.sum_congr rfl]; intros; rw [Finset.mul_sum]; ac_rfl - have h_unitary : ∀ (j : d), ∑ i, ‖(A.H.eigenvectorUnitary.val i j)‖^2 = 1 := by - exact fun j => Matrix.unitaryGroup_row_norm (H A).eigenvectorUnitary j + have h_unitary : ∀ (j : d), ∑ i, ‖(A.H.eigenvectorUnitary.val i j)‖^2 = 1 := + fun j => Matrix.unitaryGroup_row_norm (H A).eigenvectorUnitary j simp_all [trace_cfc_eq] theorem peierls_inequality_ici (A : HermitianMat d ℂ) (g : ℝ → ℝ) (hg : ConvexOn ℝ (Set.Ici 0) g) @@ -101,8 +101,8 @@ theorem peierls_inequality_ici (A : HermitianMat d ℂ) (g : ℝ → ℝ) (hg : exact A.eigenvalues_nonneg hA i convert! Finset.sum_le_sum fun i _ => h_jensen i using 1 rw [Finset.sum_comm, Finset.sum_congr rfl]; intros; rw [Finset.mul_sum]; ac_rfl - have h_unitary : ∀ (j : d), ∑ i, ‖(A.H.eigenvectorUnitary.val i j)‖^2 = 1 := by - exact fun j => Matrix.unitaryGroup_row_norm (H A).eigenvectorUnitary j + have h_unitary : ∀ (j : d), ∑ i, ‖(A.H.eigenvectorUnitary.val i j)‖^2 = 1 := + fun j => Matrix.unitaryGroup_row_norm (H A).eigenvectorUnitary j simp_all [trace_cfc_eq] /-- @@ -116,8 +116,8 @@ theorem trace_function_convex_univ (g : ℝ → ℝ) (hg : ConvexOn ℝ Set.univ -- Let $C = aA + bB$. set C : HermitianMat d ℂ := a • A + b • B -- By the properties of the trace and the convexity of $g$, we have: - have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := by - exact trace_cfc_eq C g + have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := + trace_cfc_eq C g have h_sum : ∑ i, g (C.H.eigenvalues i) ≤ a * ∑ i, g ((A.conj (star C.H.eigenvectorUnitary.val)).mat i i).re + b * ∑ i, g ((B.conj (star C.H.eigenvectorUnitary.val)).mat i i |> Complex.re) := by @@ -174,8 +174,8 @@ theorem trace_function_convex_ici {g : ℝ → ℝ} (hg : ConvexOn ℝ (Set.Ici -- Let $C = aA + bB$. set C : HermitianMat d ℂ := a • A + b • B -- By the properties of the trace and the convexity of $g$, we have: - have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := by - exact trace_cfc_eq C g + have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := + trace_cfc_eq C g have h_sum : ∑ i, g (C.H.eigenvalues i) ≤ a * ∑ i, g ((A.conj (star C.H.eigenvectorUnitary.val)).mat i i).re + b * ∑ i, g ((B.conj (star C.H.eigenvectorUnitary.val)).mat i i).re := by From 3f04c5e1776e74ba76db4cc3834b9b27d022b2d5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:06:47 -0700 Subject: [PATCH 113/498] refactor: golf Hermitian cfc proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 53 +++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 1b38f2efc..e2ef59c2c 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -386,10 +386,10 @@ theorem Matrix.PosDef.spectrum_subset_Ioi {d 𝕜 : Type*} [Fintype d] [Decidabl {A : Matrix d d 𝕜} (hA : A.PosDef) : spectrum ℝ A ⊆ Set.Ioi 0 := by intro x hx; -- Since $A$ is positive definite, all its eigenvalues are positive. - have h_eigenvalues_pos : ∀ i : d, 0 < hA.1.eigenvalues i := by - exact hA.eigenvalues_pos; - have h_spectrum_eq_range : spectrum ℝ A = Set.range (hA.1.eigenvalues) := by - exact Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues hA.left; + have h_eigenvalues_pos : ∀ i : d, 0 < hA.1.eigenvalues i := + hA.eigenvalues_pos + have h_spectrum_eq_range : spectrum ℝ A = Set.range (hA.1.eigenvalues) := + Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues hA.left aesop /-- @@ -430,8 +430,9 @@ lemma norm_cfc_le_sqrt_card_mul_bound {A : HermitianMat d ℂ} {f : ℝ → ℝ} ‖A.cfc f‖ ≤ Real.sqrt (Fintype.card d) * C := by rw [ ← Real.sqrt_sq ( norm_nonneg _ ) ]; -- Recall that the Frobenius norm of a Hermitian matrix is the square root of the sum of the squares of its eigenvalues. - have h_frobenius_eigenvalues : ∀ (M : HermitianMat d ℂ), ‖M‖ ^ 2 = ∑ i ∈ Finset.univ, (M.H.eigenvalues i) ^ 2 := by - exact fun M => norm_eq_sum_eigenvalues_sq M; + have h_frobenius_eigenvalues : + ∀ (M : HermitianMat d ℂ), ‖M‖ ^ 2 = ∑ i ∈ Finset.univ, (M.H.eigenvalues i) ^ 2 := + fun M => norm_eq_sum_eigenvalues_sq M -- Applying the bound on the eigenvalues to the Frobenius norm. have h_bound : ∑ i ∈ Finset.univ, ((A.cfc f).H.eigenvalues i) ^ 2 ≤ (Fintype.card d) * C ^ 2 := by have h_bound : ∀ i, ((A.cfc f).H.eigenvalues i) ^ 2 ≤ C ^ 2 := by @@ -458,8 +459,8 @@ lemma norm_cfc_sub_cfc_le_sqrt_card {A : HermitianMat d ℂ} {f g : ℝ → ℝ} · intro x hx apply le_csSup; · -- The supremum of a finite set of real numbers is finite. - have h_finite : Set.Finite (spectrum ℝ A.mat) := by - exact Set.toFinite _; + have h_finite : Set.Finite (spectrum ℝ A.mat) := + Set.toFinite _ obtain ⟨ M, hM ⟩ := h_finite.exists_finset_coe; refine' ⟨ ∑ x ∈ M, ‖f x - g x‖, Set.forall_mem_range.2 fun x => _ ⟩; rw [ ← hM ]; @@ -536,8 +537,10 @@ lemma continuousOn_cfc_of_compact {K : Set ℝ} {g : ℝ → ℝ} (hK : IsCompac -- By the properties of the functional calculus, we have `‖A.cfc p_n - A.cfc g‖ ≤ sqrt(d) * ‖p_n - g‖_{∞, K}`. have h_uniform_bound : ∀ n, ∀ A : HermitianMat d ℂ, spectrum ℝ A.mat ⊆ K → ‖A.cfc (fun x => (p_n n).eval x) - A.cfc g‖ ≤ Real.sqrt (Fintype.card d) * (1 / (n + 1)) := by intro n A hA - have h_uniform_bound : ‖A.cfc (fun x => (p_n n).eval x) - A.cfc g‖ ≤ Real.sqrt (Fintype.card d) * ⨆ x ∈ spectrum ℝ A.mat, |(p_n n).eval x - g x| := by - exact norm_cfc_sub_cfc_le_sqrt_card; + have h_uniform_bound : + ‖A.cfc (fun x => (p_n n).eval x) - A.cfc g‖ ≤ + Real.sqrt (Fintype.card d) * ⨆ x ∈ spectrum ℝ A.mat, |(p_n n).eval x - g x| := + norm_cfc_sub_cfc_le_sqrt_card refine' le_trans h_uniform_bound ( mul_le_mul_of_nonneg_left _ ( Real.sqrt_nonneg _ ) ); refine' ciSup_le fun x => _; field_simp; @@ -740,30 +743,32 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} (hg : ContinuousOn g T) (hA₀ : spectrum ℝ A₀.mat ⊆ T) : ContinuousWithinAt (fun B ↦ B.cfc g) {B | spectrum ℝ B.mat ⊆ T} A₀ := by have h_ext : ∃ h : ℝ → ℝ, Continuous h ∧ ∀ x ∈ spectrum ℝ A₀.mat, h x = g x := by - have h_finite : Set.Finite (spectrum ℝ A₀.mat) := by - exact Set.toFinite _ + have h_finite : Set.Finite (spectrum ℝ A₀.mat) := + Set.toFinite _ generalize_proofs at *; ( - have h_cont : ContinuousOn g (spectrum ℝ A₀.val) := by - exact hg.mono hA₀ + have h_cont : ContinuousOn g (spectrum ℝ A₀.val) := + hg.mono hA₀ generalize_proofs at *; ( have := @ContinuousMap.exists_restrict_eq ℝ; specialize this ( show IsClosed ( spectrum ℝ A₀.val ) from h_finite.isClosed ) ( ContinuousMap.mk ( fun x => g x ) <| by exact continuousOn_iff_continuous_restrict.mp h_cont ) ; rcases this with ⟨ h, hh ⟩ ; exact ⟨ h, h.continuous, fun x hx => by simpa using congr_arg ( fun f => f ⟨ x, hx ⟩ ) hh ⟩ ;)); obtain ⟨h, hh_cont, hh_eq⟩ := h_ext; - have h_cfc_cont : ContinuousWithinAt (fun B => B.cfc h) {B : HermitianMat d ℂ | spectrum ℝ B.mat ⊆ T} A₀ := by - exact Continuous.continuousWithinAt (HermitianMat.cfc_continuous hh_cont) + have h_cfc_cont : + ContinuousWithinAt (fun B => B.cfc h) {B : HermitianMat d ℂ | spectrum ℝ B.mat ⊆ T} A₀ := + Continuous.continuousWithinAt (HermitianMat.cfc_continuous hh_cont) have h_diff_small : ∀ ε > 0, ∃ U ∈ nhds A₀, ∀ B ∈ U ∩ {B : HermitianMat d ℂ | spectrum ℝ B.mat ⊆ T}, ‖B.cfc g - B.cfc h‖ < ε := by intro ε ε_pos obtain ⟨δ, δ_pos, hδ⟩ : ∃ δ > 0, ∀ x ∈ T, ∀ y ∈ spectrum ℝ A₀.mat, |x - y| < δ → |g x - h x| < ε / (Real.sqrt (Fintype.card d) + 1) := by have h_diff_small : ∀ y ∈ spectrum ℝ A₀.mat, ∃ δ > 0, ∀ x ∈ T, |x - y| < δ → |g x - h x| < ε / (Real.sqrt (Fintype.card d) + 1) := by intro y hy have h_diff_small : Filter.Tendsto (fun x => |g x - h x|) (nhdsWithin y T) (nhds 0) := by - have h_diff_small : Filter.Tendsto (fun x => g x - h x) (nhdsWithin y T) (nhds (g y - h y)) := by - exact Filter.Tendsto.sub ( hg.continuousWithinAt ( hA₀ hy ) ) ( hh_cont.continuousWithinAt ); + have h_diff_small : + Filter.Tendsto (fun x => g x - h x) (nhdsWithin y T) (nhds (g y - h y)) := + Filter.Tendsto.sub (hg.continuousWithinAt (hA₀ hy)) hh_cont.continuousWithinAt simpa [ hh_eq y hy ] using h_diff_small.abs; have := Metric.tendsto_nhdsWithin_nhds.mp h_diff_small ( ε / ( Real.sqrt ( Fintype.card d ) + 1 ) ) ( div_pos ε_pos ( add_pos_of_nonneg_of_pos ( Real.sqrt_nonneg _ ) zero_lt_one ) ) ; aesop; choose! δ hδ_pos hδ using h_diff_small; - have h_finite : Set.Finite (spectrum ℝ A₀.mat) := by - exact Set.toFinite _; + have h_finite : Set.Finite (spectrum ℝ A₀.mat) := + Set.toFinite _ obtain ⟨δ_min, hδ_min_pos, hδ_min⟩ : ∃ δ_min > 0, ∀ y ∈ spectrum ℝ A₀.mat, δ_min ≤ δ y := by by_cases h_empty : spectrum ℝ A₀.mat = ∅; · exact ⟨ 1, zero_lt_one, by simp [ h_empty ] ⟩; @@ -773,8 +778,8 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} -- By the spectrum_subset_of_isOpen lemma, there exists a neighborhood U of A₀ such that the spectrum of B is within δ of the spectrum of A₀ for all B in U. obtain ⟨U, hU⟩ : ∃ U ∈ nhds A₀, ∀ B ∈ U, spectrum ℝ B.mat ⊆ {x | ∃ y ∈ spectrum ℝ A₀.mat, |x - y| < δ} := by have h_spectrum_subset : ∀ᶠ B in nhds A₀, spectrum ℝ B.mat ⊆ Metric.thickening δ (spectrum ℝ A₀.mat) := by - have h_open : IsOpen (Metric.thickening δ (spectrum ℝ A₀.mat)) := by - exact Metric.isOpen_thickening + have h_open : IsOpen (Metric.thickening δ (spectrum ℝ A₀.mat)) := + Metric.isOpen_thickening have := spectrum_subset_of_isOpen A₀ ( Metric.thickening δ ( spectrum ℝ A₀.mat ) ) h_open ( Metric.self_subset_thickening δ_pos _ ) ; aesop; generalize_proofs at *; ( exact ⟨ _, h_spectrum_subset, fun B hB => fun x hx => by simpa [ dist_eq_norm ] using Metric.mem_thickening_iff.mp ( hB hx ) ⟩) @@ -801,8 +806,8 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} · intro x hx hx' hx'' have hd1 := hδ hx hx' have hd2 := hU x ⟨(Metric.mem_nhds_iff.mp hU_nhds).choose_spec.2 hx'', hx⟩ - have h_eq : A₀.cfc g = A₀.cfc h := by - exact cfc_congr (show Set.EqOn g h (spectrum ℝ A₀.mat) from fun x hx => hh_eq x hx ▸ rfl) ▸ rfl + have h_eq : A₀.cfc g = A₀.cfc h := + cfc_congr (show Set.EqOn g h (spectrum ℝ A₀.mat) from fun x hx => hh_eq x hx ▸ rfl) ▸ rfl rw [dist_eq_norm, h_eq] calc ‖x.cfc g - A₀.cfc h‖ = ‖(x.cfc g - x.cfc h) + (x.cfc h - A₀.cfc h)‖ := by congr 1; abel From 78d20baf57ccded4996e9d3c97f5a7b6965c35ed Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:08:54 -0700 Subject: [PATCH 114/498] refactor: golf remaining Hermitian cfc wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 90 ++++++++++++-------- 1 file changed, 54 insertions(+), 36 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index e2ef59c2c..6a38f2cfd 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -881,8 +881,8 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] choose U_i V_i hU_i hV_i hx₀_i hV_i_i h_cont_i using h_cont; exact ⟨ U_i, V_i, hU_i, hV_i, hx₀_i, hV_i_i, h_cont_i ⟩ ;); -- The open set W := ⋃ᵢ V_i contains spectrum(A x₀) (since each λᵢ ∈ V_i and spectrum = range of eigenvalues). W is open as a union of open sets. set W := ⋃ i, V_i i with hW_def - have hW_open : IsOpen W := by - exact isOpen_iUnion hV_i + have hW_open : IsOpen W := + isOpen_iUnion hV_i have hW_spectrum : spectrum ℝ (A x₀).mat ⊆ W := by intro t ht obtain ⟨i, hi⟩ : ∃ i, t = (A x₀).H.eigenvalues i := by @@ -891,25 +891,27 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] generalize_proofs at *; ( exact h_eigenvalues.subset ht |> Exists.imp fun i hi => hi.symm) aesop - have hW_subset : ∀ᶠ B in nhds (A x₀), spectrum ℝ B.mat ⊆ W := by - exact spectrum_subset_of_isOpen (A x₀) W hW_open hW_spectrum - have hW_subset_S : ∀ᶠ y in nhdsWithin x₀ S, spectrum ℝ (A y).mat ⊆ W := by - exact Filter.mem_of_superset ( hA₂.continuousWithinAt hx₀ |> fun h => h.eventually ( hW_subset ) ) fun y hy => hy + have hW_subset : ∀ᶠ B in nhds (A x₀), spectrum ℝ B.mat ⊆ W := + spectrum_subset_of_isOpen (A x₀) W hW_open hW_spectrum + have hW_subset_S : ∀ᶠ y in nhdsWithin x₀ S, spectrum ℝ (A y).mat ⊆ W := + Filter.mem_of_superset (hA₂.continuousWithinAt hx₀ |> fun h => h.eventually hW_subset) + fun _ hy => hy obtain ⟨U', hU'⟩ : ∃ U' ∈ nhds x₀, ∀ y ∈ U' ∩ S, spectrum ℝ (A y).mat ⊆ W := by obtain ⟨ U', hU' ⟩ := mem_nhdsWithin_iff_exists_mem_nhds_inter.mp hW_subset_S; use U'; aesop; obtain ⟨U'', hU''⟩ : ∃ U'' ∈ nhds x₀, ∀ i, U'' ⊆ U_i i := by exact ⟨ ⋂ i, U_i i, Filter.mem_of_superset ( Filter.iInter_mem.mpr fun i => IsOpen.mem_nhds ( hU_i i ) ( h_cont.1 i ) ) fun x hx => by aesop, fun i => Set.iInter_subset _ i ⟩ set U := U' ∩ U'' with hU_def - have hU_mem : U ∈ nhds x₀ := by - exact Filter.inter_mem hU'.1 hU''.1 - have hU_subset : ∀ y ∈ U ∩ S, spectrum ℝ (A y).mat ⊆ W := by - exact fun y hy => hU'.2 y ⟨ hy.1.1, hy.2 ⟩ |> Set.Subset.trans <| by simp [ hW_def ] ; + have hU_mem : U ∈ nhds x₀ := + Filter.inter_mem hU'.1 hU''.1 + have hU_subset : ∀ y ∈ U ∩ S, spectrum ℝ (A y).mat ⊆ W := + fun y hy => hU'.2 y ⟨hy.1.1, hy.2⟩ |> Set.Subset.trans <| by simp [hW_def] have hU_cont : ∀ y ∈ U ∩ S, ∀ t ∈ spectrum ℝ (A y).mat, ‖f y t - f x₀ t‖ < ε := by intro y hy t ht obtain ⟨i, hi⟩ : ∃ i, t ∈ V_i i := by exact Set.mem_iUnion.mp ( hU_subset y hy ht ) |> Exists.imp fun i => by tauto; - have h_cont_i : ‖f y t - f x₀ t‖ < ε := by - exact h_cont.2.2 i y ⟨ hU''.2 i ( by aesop ), hy.2 ⟩ t ⟨ hi, hA₁ y hy.2 ht ⟩ |> fun h => by simpa using h; + have h_cont_i : ‖f y t - f x₀ t‖ < ε := + h_cont.2.2 i y ⟨hU''.2 i (by aesop), hy.2⟩ t ⟨hi, hA₁ y hy.2 ht⟩ |> + fun h => by simpa using h exact h_cont_i exact h_contra ⟨U, hU_mem, hU_cont⟩ @@ -983,8 +985,12 @@ theorem continuous_cfc_joint {X d : Type*} [TopologicalSpace X] [Fintype d] [Dec · exact abs_le.mpr ⟨ by linarith [ hU₂ x hx t ht ], by linarith [ hU₂ x hx t ht ] ⟩; · linarith [ ε_pos ])) generalize_proofs at *; ( - have h_final : Filter.Tendsto (fun x => ‖(A x).cfc (f x) - (A x).cfc (f x₀)‖) (nhdsWithin x₀ S) (nhds 0) := by - exact squeeze_zero_norm' ( by filter_upwards [ h_triangle ] with x hx; simpa using hx ) ( by simpa using h_sup.const_mul _ ) |> fun h => h.trans ( by simp ) ; + have h_final : + Filter.Tendsto (fun x => ‖(A x).cfc (f x) - (A x).cfc (f x₀)‖) + (nhdsWithin x₀ S) (nhds 0) := + squeeze_zero_norm' (by filter_upwards [h_triangle] with x hx; simpa using hx) + (by simpa using h_sup.const_mul _) |> + fun h => h.trans (by simp) generalize_proofs at *; ( convert h_cont.add ( show ContinuousWithinAt ( fun x => ( A x |> HermitianMat.cfc ) ( f x ) - ( A x |> HermitianMat.cfc ) ( f x₀ ) ) S x₀ from ?_ ) using 1 ; aesop generalize_proofs at *; ( @@ -1031,10 +1037,16 @@ lemma inv_cfc_eq_cfc_inv (hf : ∀ i, f (A.H.eigenvalues i) ≠ 0) : suffices (A.cfc f).mat⁻¹ = (A.cfc (fun u ↦ 1 / f u)).mat by ext1 simpa using this - have h_def : (A.cfc f).mat = ∑ i, f (A.H.eigenvalues i) • (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * A.H.eigenvectorUnitary.val.conjTranspose) := by - exact cfc_toMat_eq_sum_smul_proj A f; - have h_subst : (A.cfc (fun u ↦ 1 / f u)).mat = ∑ i, (1 / f (A.H.eigenvalues i)) • (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * A.H.eigenvectorUnitary.val.conjTranspose) := by - exact cfc_toMat_eq_sum_smul_proj A fun u ↦ 1 / f u; + have h_def : (A.cfc f).mat = + ∑ i, f (A.H.eigenvalues i) • + (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * + A.H.eigenvectorUnitary.val.conjTranspose) := + cfc_toMat_eq_sum_smul_proj A f + have h_subst : (A.cfc (fun u ↦ 1 / f u)).mat = + ∑ i, (1 / f (A.H.eigenvalues i)) • + (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * + A.H.eigenvectorUnitary.val.conjTranspose) := + cfc_toMat_eq_sum_smul_proj A fun u ↦ 1 / f u have h_inv : (A.cfc f).mat * (A.cfc (fun u ↦ 1 / f u)).mat = 1 := by -- Since the eigenvectorUnitary is unitary, we have that the product of the projections is the identity matrix. have h_unitary : A.H.eigenvectorUnitary.val * A.H.eigenvectorUnitary.val.conjTranspose = 1 := by @@ -1103,12 +1115,14 @@ lemma intervalIntegrable_toMat_iff (A : ℝ → HermitianMat d 𝕜) (T₁ T₂ have h_toMat_linear : Function.Injective L := by intro x y hxy; simp_all only [HermitianMat.ext_iff] - have h_toMat_linear : ∃ (L_inv : Matrix d d 𝕜 →ₗ[ℝ] HermitianMat d 𝕜), L_inv.comp L = LinearMap.id := by - exact IsSemisimpleModule.extension_property L h_toMat_linear LinearMap.id; + have h_toMat_linear : + ∃ (L_inv : Matrix d d 𝕜 →ₗ[ℝ] HermitianMat d 𝕜), + L_inv.comp L = LinearMap.id := + IsSemisimpleModule.extension_property L h_toMat_linear LinearMap.id exact ⟨ h_toMat_linear.choose, fun x ↦ by simpa using LinearMap.congr_fun h_toMat_linear.choose_spec x ⟩; obtain ⟨ L_inv, hL_inv ⟩ := h_toMat_linear; - have h_toMat_linear : IntegrableOn (fun t ↦ L_inv (L (A t))) (Set.uIoc T₁ T₂) μ := by - exact ContinuousLinearMap.integrable_comp ( L_inv.toContinuousLinearMap ) h_toMat_integrable; + have h_toMat_linear : IntegrableOn (fun t ↦ L_inv (L (A t))) (Set.uIoc T₁ T₂) μ := + ContinuousLinearMap.integrable_comp L_inv.toContinuousLinearMap h_toMat_integrable aesop; aesop; exact h_toMat_integrable h; @@ -1124,8 +1138,11 @@ The CFC of an integrable function family is integrable. lemma integrable_cfc (T₁ T₂ : ℝ) (f : ℝ → ℝ → ℝ) {μ : Measure ℝ} (hf : ∀ i, IntervalIntegrable (fun t ↦ f t (A.H.eigenvalues i)) μ T₁ T₂) : IntervalIntegrable (fun t ↦ A.cfc (f t)) μ T₁ T₂ := by - have h_expand : ∀ t, (A.cfc (f t)).mat = ∑ i, f t (A.H.eigenvalues i) • (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * A.H.eigenvectorUnitary.val.conjTranspose) := by - exact fun t ↦ cfc_toMat_eq_sum_smul_proj A (f t); + have h_expand : ∀ t, (A.cfc (f t)).mat = + ∑ i, f t (A.H.eigenvalues i) • + (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * + A.H.eigenvectorUnitary.val.conjTranspose) := + fun t ↦ cfc_toMat_eq_sum_smul_proj A (f t) rw [ ← intervalIntegrable_toMat_iff ]; rw [ funext h_expand ]; apply intervalIntegrable_sum_smul_const @@ -1245,18 +1262,18 @@ theorem inv_ge_one_of_le_one (hA : A.mat.PosDef) (h : A ≤ 1) : 1 ≤ A⁻¹ := have h_cfc_nonneg : ∀ i, 0 ≤ (A.H.eigenvalues i)⁻¹ - 1 := by have h_pos : ∀ i, 0 < A.H.eigenvalues i ∧ A.H.eigenvalues i ≤ 1 := by -- Since $A$ is positive definite, all its eigenvalues are positive. - have h_pos : ∀ i, 0 < A.H.eigenvalues i := by - exact fun i => Matrix.PosDef.eigenvalues_pos hA i; + have h_pos : ∀ i, 0 < A.H.eigenvalues i := + fun i => Matrix.PosDef.eigenvalues_pos hA i -- Since $A \leq 1$, for any eigenvalue $\lambda_i$ of $A$, we have $\lambda_i \leq 1$. have h_le_one : ∀ i, A.H.eigenvalues i ≤ 1 := by have h_le_one : ∀ i, A.H.eigenvalues i ≤ 1 := by intro i - have h_eigenvalue : A.mat.PosSemidef := by - exact hA.posSemidef + have h_eigenvalue : A.mat.PosSemidef := + hA.posSemidef have h_eigenvalue_le_one : ∀ x : d → 𝕜, x ≠ 0 → (star x ⬝ᵥ A.mat.mulVec x) / (star x ⬝ᵥ x) ≤ 1 := by intro x hx_ne_zero - have h_eigenvalue_le_one : (star x ⬝ᵥ (1 - A.mat).mulVec x) ≥ 0 := by - exact Matrix.PosSemidef.dotProduct_mulVec_nonneg h x + have h_eigenvalue_le_one : (star x ⬝ᵥ (1 - A.mat).mulVec x) ≥ 0 := + Matrix.PosSemidef.dotProduct_mulVec_nonneg h x generalize_proofs at *; ( rw [ div_le_iff₀ ] <;> simp_all [ Matrix.sub_mulVec, dotProduct_sub ]) generalize_proofs at *; ( @@ -1272,8 +1289,9 @@ theorem inv_ge_one_of_le_one (hA : A.mat.PosDef) (h : A ≤ 1) : 1 ≤ A⁻¹ := exact (cfc_nonneg_iff A fun x => x⁻¹ - 1).mpr h_cfc_nonneg; -- Since $A.cfc (fun x => x⁻¹ - 1) \geq 0$, we have $A.cfc (fun x => x⁻¹) \geq 1$. have h_cfc_ge_one : A.cfc (fun x => x⁻¹) ≥ 1 := by - have h_cfc_sub : A.cfc (fun x => x⁻¹ - 1) = A.cfc (fun x => x⁻¹) - A.cfc (fun _ => 1) := by - exact cfc_sub_apply A Inv.inv fun x => 1; + have h_cfc_sub : A.cfc (fun x => x⁻¹ - 1) = + A.cfc (fun x => x⁻¹) - A.cfc (fun _ => 1) := + cfc_sub_apply A Inv.inv fun x => 1 aesop; convert h_cfc_ge_one.le using 1; convert cfc_inv.symm; @@ -1371,8 +1389,8 @@ lemma ker_cfc_le_ker_on_set (A.cfc f).ker ≤ A.ker := by intro x hx have h_inner : ∀ i, A.H.eigenvalues i ≠ 0 → inner ℂ (A.H.eigenvectorBasis i) x = 0 := by - have h_inner_zero : (A.cfc f).mat.mulVec x = 0 := by - exact (mem_ker_iff_mulVec_zero (A.cfc f) x).mp hx + have h_inner_zero : (A.cfc f).mat.mulVec x = 0 := + (mem_ker_iff_mulVec_zero (A.cfc f) x).mp hx have h_inner_zero_expansion : ∑ i, (f (A.H.eigenvalues i) : ℂ) • inner ℂ (A.H.eigenvectorBasis i) x • A.H.eigenvectorBasis i = 0 := by convert h_inner_zero using 1; rw [ cfc_mulVec_expansion ]; @@ -1408,8 +1426,8 @@ lemma ker_le_ker_cfc_on_set (hs : spectrum ℝ A.mat ⊆ s) (h : ∀ i ∈ s, i intro x hx have h_inner_zero : ∀ i, A.H.eigenvalues i ≠ 0 → inner ℂ (A.H.eigenvectorBasis i) x = 0 := by intro i hi - have h_inner_zero : A.mat.mulVec x = 0 := by - exact (mem_ker_iff_mulVec_zero A x).mp hx; + have h_inner_zero : A.mat.mulVec x = 0 := + (mem_ker_iff_mulVec_zero A x).mp hx have := mulVec_eq_zero_iff_inner_eigenvector_zero A x; aesop; have h_mulVec_zero : (A.cfc f).mat.mulVec x = ∑ i, (f (A.H.eigenvalues i) : ℂ) • inner ℂ (A.H.eigenvectorBasis i) x • A.H.eigenvectorBasis i := by convert cfc_mulVec_expansion A f x using 1; From ee8be3e67539db60f4da592471fc45807a451c9f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:10:31 -0700 Subject: [PATCH 115/498] refactor: golf Hermitian projection norm wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/Proj.lean | 4 ++-- .../ForMathlib/HermitianMat/Schatten.lean | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean index 486d825c3..0b6f301fe 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean @@ -162,8 +162,8 @@ lemma projector_support_eq_sum : A.supportProj.mat = convert h_orthogonal_complement ( A.H.eigenvectorBasis i ) _ using 1; exact (mem_ker_iff_mulVec_zero A ((H A).eigenvectorBasis i)).mpr h_eigenvector_zero; -- By definition of $A.ker$, we know that $x$ can be written as a linear combination of eigenvectors with non-zero eigenvalues. - have h_decomp : x = ∑ i, (inner (𝕜) (A.H.eigenvectorBasis i) x) • A.H.eigenvectorBasis i := by - exact Eq.symm (OrthonormalBasis.sum_repr' (H A).eigenvectorBasis x); + have h_decomp : x = ∑ i, (inner (𝕜) (A.H.eigenvectorBasis i) x) • A.H.eigenvectorBasis i := + Eq.symm (OrthonormalBasis.sum_repr' (H A).eigenvectorBasis x) rw [ h_decomp ]; exact Submodule.sum_mem _ fun i _ => if hi : A.H.eigenvalues i = 0 then by simp [h_orthogonal_zero_eigenvalues i hi ] else Submodule.smul_mem _ _ ( Submodule.subset_span ⟨ i, hi, rfl ⟩ ); · rw [ Submodule.span_le, Set.image_subset_iff ]; diff --git a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean index 5a7a5236f..325a48226 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean @@ -62,8 +62,8 @@ lemma schattenNorm_pow_eq · rw [ mul_comm, ← HermitianMat.rpow_mul ]; exact hA; · -- Since $A$ is positive, $A^{k*p}$ is also positive, and the trace of a positive matrix is non-negative. - have h_pos : 0 ≤ A ^ (k * p) := by - exact HermitianMat.rpow_nonneg hA; + have h_pos : 0 ≤ A ^ (k * p) := + HermitianMat.rpow_nonneg hA exact HermitianMat.trace_nonneg h_pos; · exact HermitianMat.rpow_nonneg hA @@ -97,8 +97,9 @@ lemma schattenNorm_rpow_eq_sum_singularValues (A : Matrix d d ℂ) {p : ℝ} (hp ring_nf simp +zetaDelta at *; exact Matrix.eigenvalues_conjTranspose_mul_self_nonneg A i; - · have h_nonneg : ∀ i : d, 0 ≤ ((Matrix.isHermitian_mul_conjTranspose_self A.conjTranspose).eigenvalues i) ^ (p / 2) := by - exact fun i => Real.rpow_nonneg ( by have := Matrix.eigenvalues_conjTranspose_mul_self_nonneg A; aesop ) _; + · have h_nonneg : ∀ i : d, + 0 ≤ ((Matrix.isHermitian_mul_conjTranspose_self A.conjTranspose).eigenvalues i) ^ (p / 2) := + fun i => Real.rpow_nonneg (by have := Matrix.eigenvalues_conjTranspose_mul_self_nonneg A; aesop) _ convert! Finset.sum_nonneg fun i _ => h_nonneg i using 1; convert schattenNorm_trace_as_eigenvalue_sum A p using 1 @@ -179,8 +180,9 @@ lemma schattenNorm_half_mul_rpow_eq_trace_conj {α : ℝ} (hα : 0 < α) : (schattenNorm ((A ^ (1/2 : ℝ)).mat * B.mat) (2 * α)) ^ (2 * α) = ((A.conj B.mat) ^ α).trace := by - have h_conj : ((A ^ (1 / 2 : ℝ)).mat * B.mat).conjTranspose * ((A ^ (1 / 2 : ℝ)).mat * B.mat) = (A.conj B.mat).mat := by - exact conjTranspose_half_mul_eq_conj hA; + have h_conj : ((A ^ (1 / 2 : ℝ)).mat * B.mat).conjTranspose * + ((A ^ (1 / 2 : ℝ)).mat * B.mat) = (A.conj B.mat).mat := + conjTranspose_half_mul_eq_conj hA unfold schattenNorm; rw [ ← Real.rpow_mul ] <;> norm_num [ hα.ne' ]; · ring_nf; norm_num [ hα.ne' ]; @@ -294,8 +296,9 @@ lemma HermitianMat.trace_rpow_conj_le (((A ^ (p / 2)).trace) ^ (1 / p) * ((B ^ q).trace) ^ (1 / q)) ^ (2 * α) := by -- Raise both sides of the inequality to the power of $2\alpha$. have h_exp : ((A.conj B.mat) ^ α).trace ≤ (schattenNorm (A ^ (1 / 2 : ℝ)).mat p * schattenNorm B.mat q) ^ (2 * α) := by - have h_exp : (schattenNorm ((A ^ (1 / 2 : ℝ)).mat * B.mat) (2 * α)) ^ (2 * α) = ((A.conj B.mat) ^ α).trace := by - exact schattenNorm_half_mul_rpow_eq_trace_conj hA hα + have h_exp : (schattenNorm ((A ^ (1 / 2 : ℝ)).mat * B.mat) (2 * α)) ^ (2 * α) = + ((A.conj B.mat) ^ α).trace := + schattenNorm_half_mul_rpow_eq_trace_conj hA hα rw [← h_exp] -- Apply the Schatten-Hölder inequality to the matrices $A^{1/2} * B$. refine Real.rpow_le_rpow ?_ (schattenNorm_mul_le _ _ (by positivity) hp hq hpq) (by positivity) From 10ff6025f2a6ab7bcc4ba0e889dd1dc19d64f372 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:12:16 -0700 Subject: [PATCH 116/498] refactor: golf majorization proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/Majorization.lean | 77 +++++++++++++++--------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index 5c8324e32..bdab08ba2 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -59,8 +59,8 @@ noncomputable def singularValuesSorted (A : Matrix d d ℂ) : /-- Sorted singular values are nonneg. -/ lemma singularValuesSorted_nonneg (A : Matrix d d ℂ) (i : Fin (Fintype.card d)) : 0 ≤ singularValuesSorted A i := by - have h_nonneg : ∀ i, 0 ≤ (singularValues A i) := by - exact singularValues_nonneg A + have h_nonneg : ∀ i, 0 ≤ (singularValues A i) := + singularValues_nonneg A have h_sorted_nonneg : ∀ {l : List ℝ}, (∀ x ∈ l, 0 ≤ x) → ∀ i < l.length, 0 ≤ l[i]! := by aesop contrapose! h_sorted_nonneg @@ -94,8 +94,8 @@ lemma sum_singularValues_rpow_eq_sum_sorted (A : Matrix d d ℂ) (p : ℝ) : lemma singularValuesSorted_antitone (A : Matrix d d ℂ) : Antitone (singularValuesSorted A) := by intro i j hij - have h_sorted : List.Pairwise (· ≥ ·) (Finset.univ.val.map (singularValues A) |>.sort (· ≥ ·)) := by - exact Multiset.pairwise_sort _ _ + have h_sorted : List.Pairwise (· ≥ ·) (Finset.univ.val.map (singularValues A) |>.sort (· ≥ ·)) := + Multiset.pairwise_sort _ _ exact h_sorted.rel_get_of_le hij /-- The product of nonneg antitone sequences is antitone. -/ @@ -201,15 +201,15 @@ lemma cauchyBinet {m : ℕ} {n : Type*} [Fintype n] [DecidableEq n] [LinearOrder obtain ⟨a, ha⟩ : ∃ a : Fin m → Fin m, ∀ i, σ i = S.val.orderEmbOfFin S.property (a i) := by have h_exists_a : ∀ i, ∃ a : Fin m, σ i = S.val.orderEmbOfFin S.property a := by intro i - have h_exists_a : σ i ∈ S.val := by - exact hσ.2 ▸ Finset.mem_image_of_mem _ (Finset.mem_univ _) + have h_exists_a : σ i ∈ S.val := + hσ.2 ▸ Finset.mem_image_of_mem _ (Finset.mem_univ _) have h_exists_a : Finset.image (fun a : Fin m => S.val.orderEmbOfFin S.property a) Finset.univ = S.val := by refine' Finset.eq_of_subset_of_card_le (Finset.image_subset_iff.mpr fun a _ => Finset.orderEmbOfFin_mem _ _ _) _ rw [Finset.card_image_of_injective _ fun a b h => by simpa [Fin.ext_iff] using h]; simp [S.2] grind exact ⟨fun i => Classical.choose (h_exists_a i), fun i => Classical.choose_spec (h_exists_a i)⟩ - have ha_inj : Function.Injective a := by - exact fun i j hij => hσ.1 <| by simp [ha, hij] + have ha_inj : Function.Injective a := + fun i j hij => hσ.1 <| by simp [ha, hij] exact ⟨Equiv.ofBijective a ⟨ha_inj, Finite.injective_iff_surjective.mp ha_inj⟩, funext fun i => ha i ▸ rfl⟩ · rintro ⟨a, rfl⟩ constructor @@ -317,10 +317,13 @@ lemma singularValues_compoundMatrix_eq (M : Matrix d d ℂ) (k : ℕ) : rotate_right exact compoundMatrix (Matrix.IsHermitian.eigenvectorUnitary (isHermitian_mul_conjTranspose_self M.conjTranspose)) k · exact compoundMatrix_unitary _ (by simp [Matrix.unitaryGroup]) _ - · have h_compoundMatrix_mul : compoundMatrix (M.conjTranspose * M) k = compoundMatrix M.conjTranspose k * compoundMatrix M k := by - exact compoundMatrix_mul _ _ _ - have h_compoundMatrix_conjTranspose : compoundMatrix M.conjTranspose k = (compoundMatrix M k).conjTranspose := by - exact compoundMatrix_conjTranspose M k + · have h_compoundMatrix_mul : + compoundMatrix (M.conjTranspose * M) k = + compoundMatrix M.conjTranspose k * compoundMatrix M k := + compoundMatrix_mul _ _ _ + have h_compoundMatrix_conjTranspose : + compoundMatrix M.conjTranspose k = (compoundMatrix M k).conjTranspose := + compoundMatrix_conjTranspose M k have := Matrix.IsHermitian.spectral_theorem (isHermitian_mul_conjTranspose_self M.conjTranspose) convert congr_arg (fun x => compoundMatrix x k) this using 1 <;> simp [h_compoundMatrix_mul, h_compoundMatrix_conjTranspose] rw [compoundMatrix_mul, compoundMatrix_mul] @@ -389,8 +392,8 @@ lemma singularValuesSorted_zero_eq_sup {e : Type*} [Fintype e] [DecidableEq e] exact h_le_sup _ (by simp [singularValuesSorted]) · have h_max_le_ge : ∀ i, singularValues A i ≤ singularValuesSorted A ⟨0, h⟩ := by intro i - have h_max_le_ge : ∀ j, singularValuesSorted A j ≤ singularValuesSorted A ⟨0, h⟩ := by - exact fun j => singularValuesSorted_antitone A (Nat.zero_le _) + have h_max_le_ge : ∀ j, singularValuesSorted A j ≤ singularValuesSorted A ⟨0, h⟩ := + fun j => singularValuesSorted_antitone A (Nat.zero_le _) exact (by have h_max_le_ge : ∃ j, singularValues A i = singularValuesSorted A j := by have h_exists_j : singularValues A i ∈ Multiset.sort (Finset.univ.val.map (singularValues A)) (· ≥ ·) := by @@ -431,10 +434,13 @@ lemma singularValues_compoundMatrix_perm (M : Matrix d d ℂ) (k : ℕ) : rotate_right exact compoundMatrix (Matrix.IsHermitian.eigenvectorUnitary (isHermitian_mul_conjTranspose_self M.conjTranspose)) k · exact compoundMatrix_unitary _ (by simp [Matrix.unitaryGroup]) _ - · have h_compoundMatrix_mul : compoundMatrix (M.conjTranspose * M) k = compoundMatrix M.conjTranspose k * compoundMatrix M k := by - exact compoundMatrix_mul _ _ _ - have h_compoundMatrix_conjTranspose : compoundMatrix M.conjTranspose k = (compoundMatrix M k).conjTranspose := by - exact compoundMatrix_conjTranspose M k + · have h_compoundMatrix_mul : + compoundMatrix (M.conjTranspose * M) k = + compoundMatrix M.conjTranspose k * compoundMatrix M k := + compoundMatrix_mul _ _ _ + have h_compoundMatrix_conjTranspose : + compoundMatrix M.conjTranspose k = (compoundMatrix M k).conjTranspose := + compoundMatrix_conjTranspose M k have := Matrix.IsHermitian.spectral_theorem (isHermitian_mul_conjTranspose_self M.conjTranspose) convert congr_arg (fun x => compoundMatrix x k) this using 1 <;> simp [h_compoundMatrix_mul, h_compoundMatrix_conjTranspose] rw [compoundMatrix_mul, compoundMatrix_mul] @@ -470,8 +476,9 @@ lemma exists_sorting_equiv (M : Matrix d d ℂ) : have h_bij : ∃ σ : Fin (Fintype.card d) ≃ d, ∀ i, singularValues M (σ i) = singularValuesSorted M i := by have h_perm : Multiset.ofList (List.ofFn (singularValuesSorted M)) = Multiset.ofList (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := by have h_multiset : Multiset.ofList (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) = Finset.univ.val.map (singularValues M) := by - have h_multiset : Finset.univ.val = Multiset.map (fun i => (Fintype.equivFin d).symm i) (Finset.univ.val) := by - exact Eq.symm (Multiset.map_univ_val_equiv (Fintype.equivFin d |> Equiv.symm)) + have h_multiset : + Finset.univ.val = Multiset.map (fun i => (Fintype.equivFin d).symm i) Finset.univ.val := + Eq.symm (Multiset.map_univ_val_equiv (Fintype.equivFin d |> Equiv.symm)) rw [h_multiset, Multiset.map_map] aesop have h_multiset_sorted : Multiset.ofList (List.ofFn (singularValuesSorted M)) = Multiset.map (singularValues M) Finset.univ.val := by @@ -479,8 +486,9 @@ lemma exists_sorting_equiv (M : Matrix d d ℂ) : refine' List.ext_get _ _ <;> simp [List.ofFn_eq_map] at *; aesop (simp_config := { singlePass := true }) exact h_multiset_sorted_eq ▸ by simp rw [h_multiset, h_multiset_sorted] - have h_perm : List.Perm (List.ofFn (singularValuesSorted M)) (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := by - exact Multiset.coe_eq_coe.mp h_perm + have h_perm : List.Perm (List.ofFn (singularValuesSorted M)) + (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := + Multiset.coe_eq_coe.mp h_perm have h_perm : ∃ σ : Fin (Fintype.card d) ≃ Fin (Fintype.card d), ∀ i, singularValuesSorted M i = singularValues M (Fintype.equivFin d |>.symm (σ i)) := by have h_perm : ∀ {l1 l2 : List ℝ}, l1.Perm l2 → ∃ σ : Fin l1.length ≃ Fin l2.length, ∀ i, l1.get i = l2.get (σ i) := by intros l1 l2 h_perm; induction' h_perm with l1 l2 h_perm ih <;> simp_all @@ -564,8 +572,9 @@ lemma exists_subset_prod_eq_sorted_prod (M : Matrix d d ℂ) (k : ℕ) · exact List.Nodup.filter _ (List.nodup_finRange _) · exact Multiset.Nodup.filter _ (Finset.nodup _) exact h_perm.trans (by simp) - have h_perm : List.Perm (List.ofFn (singularValuesSorted M)) (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := by - exact Multiset.coe_eq_coe.mp h_perm + have h_perm : List.Perm (List.ofFn (singularValuesSorted M)) + (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := + Multiset.coe_eq_coe.mp h_perm have h_perm : ∃ σ : Fin (Fintype.card d) ≃ Fin (Fintype.card d), List.ofFn (singularValuesSorted M) = List.map (fun i => singularValues M ((Fintype.equivFin d).symm (σ i))) (List.finRange (Fintype.card d)) := by have := h_perm have h_perm : ∀ {l₁ l₂ : List ℝ}, List.Perm l₁ l₂ → ∃ σ : Fin l₁.length ≃ Fin l₂.length, l₁ = List.map (fun i => l₂.get (σ i)) (List.finRange l₁.length) := by @@ -756,8 +765,12 @@ lemma singularValuesSorted_mul_le {e : Type*} [Fintype e] [DecidableEq e] have h_sqrt_eigenvalue_le : ∀ i, singularValues (M * N) i ≤ singularValuesSorted M ⟨0, h⟩ * singularValuesSorted N ⟨0, h⟩ := by intro i have h_sqrt_eigenvalue_le_i : (isHermitian_mul_conjTranspose_self (M * N).conjTranspose).eigenvalues i ≤ (singularValuesSorted M ⟨0, h⟩ * singularValuesSorted N ⟨0, h⟩) ^ 2 := h_eigenvalue_le i - have h_sqrt_eigenvalue_le_i' : Real.sqrt ((isHermitian_mul_conjTranspose_self (M * N).conjTranspose).eigenvalues i) ≤ singularValuesSorted M ⟨0, h⟩ * singularValuesSorted N ⟨0, h⟩ := by - exact Real.sqrt_le_iff.mpr ⟨mul_nonneg (singularValuesSorted_nonneg M ⟨0, h⟩) (singularValuesSorted_nonneg N ⟨0, h⟩), h_sqrt_eigenvalue_le_i⟩ + have h_sqrt_eigenvalue_le_i' : + Real.sqrt ((isHermitian_mul_conjTranspose_self (M * N).conjTranspose).eigenvalues i) ≤ + singularValuesSorted M ⟨0, h⟩ * singularValuesSorted N ⟨0, h⟩ := + Real.sqrt_le_iff.mpr + ⟨mul_nonneg (singularValuesSorted_nonneg M ⟨0, h⟩) + (singularValuesSorted_nonneg N ⟨0, h⟩), h_sqrt_eigenvalue_le_i⟩ exact h_sqrt_eigenvalue_le_i' |> le_trans (by exact le_rfl) simp_all [Finset.sup'_le_iff] @@ -924,15 +937,19 @@ lemma weak_log_maj_sum_le {n : ℕ} simp exact h_log_maj k (by linarith) · -- Since $x_{\text{last}} > 0$, we have $x_i > 0$ for all $i$. - have hx_pos : ∀ i, 0 < x i := by - exact fun i => lt_of_lt_of_le (lt_of_le_of_ne (hx_nn _) (Ne.symm h_last)) (hx_anti (Fin.le_last _)) + have hx_pos : ∀ i, 0 < x i := + fun i => lt_of_lt_of_le (lt_of_le_of_ne (hx_nn _) (Ne.symm h_last)) + (hx_anti (Fin.le_last _)) have hy_pos : ∀ i, 0 < y i := by intro i; specialize h_log_maj (n + 1) le_rfl; contrapose! h_log_maj; simp_all [Fin.prod_univ_castSucc] exact lt_of_le_of_lt (mul_nonpos_of_nonneg_of_nonpos (Finset.prod_nonneg fun _ _ => hy_nn _) (by linarith [hy_anti (show i ≤ Fin.last n from Fin.le_last i)])) (mul_pos (Finset.prod_pos fun _ _ => hx_pos _) (hx_pos _)) have h_sum_mul_log_nonneg : 0 ≤ ∑ i, x i * Real.log (y i / x i) := by apply sum_mul_log_nonneg_of_weak_log_maj (fun i => hx_pos i) (fun i => hy_pos i) hx_anti (fun k hk => h_log_maj k hk) - have h_sum_mul_log_nonneg : ∑ i, (y i - x i) ≥ ∑ i, x i * Real.log (y i / x i) := by - exact Finset.sum_le_sum fun i _ => by have := sub_ge_mul_log_div (hx_pos i) (hy_pos i); ring_nf at *; linarith + have h_sum_mul_log_nonneg : ∑ i, (y i - x i) ≥ ∑ i, x i * Real.log (y i / x i) := + Finset.sum_le_sum fun i _ => by + have := sub_ge_mul_log_div (hx_pos i) (hy_pos i) + ring_nf at * + linarith norm_num at *; linarith /-- Weak log-majorization of nonneg antitone sequences implies the sum of From f911130b42e6c6739f0b827d0f99f4e437a0e443 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:14:16 -0700 Subject: [PATCH 117/498] refactor: golf relative entropy proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 41 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 4775e59d6..c71075335 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -176,8 +176,11 @@ lemma HermitianMat.trace_rpow_le_trace_of_le_one (p : ℝ) (hp : 1 ≤ p) : (A ^ p).trace ≤ A.trace := by -- Rewrite both sides using trace_rpow_eq_sum: Tr[A^p] = ∑ λ_i^p and Tr[A] = ∑ λ_i (using trace_rpow_eq_sum and rpow_one for the latter). - have h_trace_eq_sum : (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p ∧ A.trace = ∑ i, (A.H.eigenvalues i) := by - exact ⟨ by rw [ HermitianMat.trace_rpow_eq_sum ], by rw [ show A.trace = ∑ i, ( A.H.eigenvalues i ) by simpa using HermitianMat.trace_rpow_eq_sum A 1 ] ⟩; + have h_trace_eq_sum : (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p ∧ + A.trace = ∑ i, A.H.eigenvalues i := + ⟨by rw [HermitianMat.trace_rpow_eq_sum], + by rw [show A.trace = ∑ i, A.H.eigenvalues i by + simpa using HermitianMat.trace_rpow_eq_sum A 1]⟩ rw [ h_trace_eq_sum.1, h_trace_eq_sum.2 ]; apply_rules [ Finset.sum_le_sum ]; intro i hi; by_cases hi0 : A.H.eigenvalues i = 0 <;> simp_all @@ -275,8 +278,8 @@ lemma HermitianMat.supportProj_mul_self (A : HermitianMat d ℂ) : A.supportProj.mat * A.mat = A.mat := by have h_supportProj_mul_A : ∀ (v : d → ℂ), (A.supportProj.val.mulVec (A.val.mulVec v)) = (A.val.mulVec v) := by intro v - have h_range : WithLp.toLp 2 (A.val.mulVec v) ∈ LinearMap.range A.val.toEuclideanLin := by - exact ⟨ _, rfl ⟩ + have h_range : WithLp.toLp 2 (A.val.mulVec v) ∈ LinearMap.range A.val.toEuclideanLin := + ⟨_, rfl⟩ have h_supportProj_mul_A : ∀ (v : EuclideanSpace ℂ d), v ∈ LinearMap.range A.val.toEuclideanLin → (A.supportProj.val.toEuclideanLin v) = v := by intro v hv have h_supportProj_mul_A : (A.supportProj.val.toEuclideanLin v) = (Submodule.orthogonalProjectionOnto (LinearMap.range A.val.toEuclideanLin) v) := by @@ -314,8 +317,8 @@ lemma HermitianMat.mul_supportProj_of_ker_le {A B : HermitianMat d ℂ} (h : LinearMap.ker B.lin.toLinearMap ≤ LinearMap.ker A.lin.toLinearMap) : A.mat * B.supportProj.mat = A.mat := by -- Since $B.supportProj$ is the projection onto $range B$, we have $B.supportProj * B.mat = B.mat$. - have h_supportProj_mul_B : B.supportProj.mat * B.mat = B.mat := by - exact supportProj_mul_self B + have h_supportProj_mul_B : B.supportProj.mat * B.mat = B.mat := + supportProj_mul_self B have h_range_A_subset_range_B : LinearMap.range A.lin.toLinearMap ≤ LinearMap.range B.lin.toLinearMap := by have h_orthogonal_complement : LinearMap.range (B.lin : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d) = (LinearMap.ker (B.lin : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d))ᗮ := by have h_orthogonal_complement : ∀ (T : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d), T = T.adjoint → LinearMap.range T = (LinearMap.ker T)ᗮ := by @@ -477,8 +480,8 @@ private lemma hasDerivAt_trace_rpow_at_one (B : HermitianMat d ℂ) (hB : 0 ≤ by_cases h_pos : 0 < B.H.eigenvalues i; · convert! HasDerivAt.rpow ( hasDerivAt_const _ _ ) ( hasDerivAt_id 1 ) h_pos using 1 simp only [id_eq, mul_one, sub_self, Real.rpow_zero, Real.rpow_one, one_mul, zero_add] - · have h_zero : B.H.eigenvalues i = 0 := by - exact le_antisymm ( le_of_not_gt h_pos ) ( by simpa using hB.eigenvalues_nonneg i ) + · have h_zero : B.H.eigenvalues i = 0 := + le_antisymm (le_of_not_gt h_pos) (by simpa using hB.eigenvalues_nonneg i) simp [h_zero] exact (hasDerivAt_const _ _).congr_of_eventuallyEq (Filter.eventuallyEq_of_mem ( Ioi_mem_nhds zero_lt_one ) fun x hx => Real.zero_rpow hx.out.ne' ) simp only [HermitianMat.trace_rpow_eq_sum, ← Finset.sum_apply] @@ -508,14 +511,15 @@ private lemma trace_conj_eq_inner_rpow {ρ σ : MState d} {t : ℝ} (ht : t ≠ rw [ h_cyclic, two_mul ] ring_nf have h_exp : (σ.M ^ (t + t)).mat = (σ.M ^ t).mat * (σ.M ^ t).mat := by - have h_nonneg : 0 ≤ σ.M := by - exact σ.nonneg - have h_ne_zero : t + t ≠ 0 := by - exact fun h => ht ( by linarith ) + have h_nonneg : 0 ≤ σ.M := + σ.nonneg + have h_ne_zero : t + t ≠ 0 := + fun h => ht (by linarith) exact HermitianMat.mat_rpow_add h_nonneg h_ne_zero rw [ mul_two, h_exp ] - have h_inner : ⟪ρ.M, σ.M ^ (2 * t)⟫ = ((ρ.M.mat * (σ.M ^ (2 * t)).mat).trace).re := by - exact rfl + have h_inner : ⟪ρ.M, σ.M ^ (2 * t)⟫ = + ((ρ.M.mat * (σ.M ^ (2 * t)).mat).trace).re := + rfl simp_all convert congr_arg Complex.re h_cyclic using 1 ; simp [ HermitianMat.conj ] ; ring!; rw [ Matrix.trace_mul_comm ] @@ -527,8 +531,9 @@ private def eigenWeight (ρ σ : MState d) (i : d) : ℝ := private lemma inner_cfc_eq_sum_eigenWeight (ρ σ : MState d) (f : ℝ → ℝ) : ⟪ρ.M, σ.M.cfc f⟫ = ∑ i, f (σ.M.H.eigenvalues i) * eigenWeight ρ σ i := by -- By definition of the inner product in the context of Hermitian matrices, we can expand it using the trace. - have h_inner : ⟪ρ.M, σ.M.cfc f⟫ = RCLike.re (Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat)) := by - exact rfl; + have h_inner : ⟪ρ.M, σ.M.cfc f⟫ = + RCLike.re (Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat)) := + rfl have h_trace : Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat) = ∑ i, f (σ.M.H.eigenvalues i) * (star (σ.M.H.eigenvectorBasis i) ⬝ᵥ ρ.M.mat.mulVec (σ.M.H.eigenvectorBasis i)) := by rw [ Matrix.trace ]; have h_cfc_def : (σ.M.cfc f).mat = ∑ i, (f (Matrix.IsHermitian.eigenvalues σ.M.H i)) • Matrix.of (fun x y => (σ.M.H.eigenvectorBasis i x) * (star (σ.M.H.eigenvectorBasis i y))) := by @@ -658,8 +663,8 @@ private lemma B_of_one (ρ σ : MState d) : B_of ρ σ 1 = ρ.M := by simp [B_of, HermitianMat.rpow_zero, HermitianMat.conj_one] -- B(α) is nonneg for α > 0, because it's a conj of a nonneg matrix. -private lemma B_of_nonneg (ρ σ : MState d) (α : ℝ) : 0 ≤ B_of ρ σ α := by - exact HermitianMat.conj_nonneg _ ρ.nonneg +private lemma B_of_nonneg (ρ σ : MState d) (α : ℝ) : 0 ≤ B_of ρ σ α := + HermitianMat.conj_nonneg _ ρ.nonneg -- The function g(M) = Tr[M^s] - Tr[M] satisfies g(M) = 0 when s = 1. private lemma trace_rpow_sub_trace_at_one (M : HermitianMat d ℂ) : From 52622f9e07bb3d3c63ca86e674d3e6db7a8bcccd Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:16:23 -0700 Subject: [PATCH 118/498] refactor: golf relative entropy kernel wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 68 +++++++++++++++++-------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index c71075335..301eac200 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -999,8 +999,8 @@ private lemma trace_cfc_tendsto_of_tendsto (f : ℝ → ℝ) exact h_cont_cfc.mono fun A hA => h_spectrum_subset A hA exact h_cont_trace exact h_cont _ ( by simp [ ρ.2 ] ) |> ContinuousWithinAt.mono <| Set.Subset.refl _; - have h_trace_cont : Continuous (fun A : HermitianMat d ℂ => A.trace) := by - exact HermitianMat.trace_Continuous; + have h_trace_cont : Continuous (fun A : HermitianMat d ℂ => A.trace) := + HermitianMat.trace_Continuous have h_comp_cont : Filter.Tendsto (fun α => (M α).cfc f) (nhds 1) (nhds ((ρ : HermitianMat d ℂ).cfc f)) := by convert! h_cfc_cont.tendsto.comp _ using 2; exact tendsto_nhdsWithin_iff.mpr ⟨ hM_cont.tendsto.trans ( by simp [ hM_one ] ), hM_nonneg ⟩; @@ -1081,8 +1081,9 @@ private lemma cross_term_slope_tendsto_zero rw [ Filter.EventuallyEq, eventually_nhdsWithin_iff ]; rw [ Metric.eventually_nhds_iff ] at *; obtain ⟨ ε, ε_pos, hε ⟩ := hK; use ε, ε_pos; intro y hy hy'; simp_all [ div_eq_inv_mul] ; - have h_trace_rpow : ∀ (A : HermitianMat d ℂ) (p : ℝ), (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p := by - exact fun A p => HermitianMat.trace_rpow_eq_sum A p; + have h_trace_rpow : ∀ (A : HermitianMat d ℂ) (p : ℝ), + (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p := + fun A p => HermitianMat.trace_rpow_eq_sum A p have := h_trace_rpow ( M ( 1 + y ) ) 1; have := h_trace_rpow ( ρ : HermitianMat d ℂ ) 1; simp_all simp +zetaDelta at *; simp [ ← this, div_eq_inv_mul, mul_sub, hy' ]; @@ -1290,16 +1291,19 @@ lemma ker_le_of_ker_kron_le_left (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSta · exact ⟨ 0, by simp, v, h_contra v hvU, by simp ⟩; have h_union : ∃ v : EuclideanSpace ℂ d₂, v ∉ U ∧ v ∈ V := by have h_union : ∃ v : EuclideanSpace ℂ d₂, v ∈ V ∧ v ∉ U := by - have h_not_subset : ¬V ≤ U := by - exact fun h => hU <| by rw [ eq_top_iff ] ; exact h_union ▸ sup_le ( by tauto ) h; + have h_not_subset : ¬V ≤ U := + fun h => hU <| by + rw [eq_top_iff] + exact h_union ▸ sup_le (by tauto) h exact Set.not_subset.mp h_not_subset; exact ⟨ h_union.choose, h_union.choose_spec.2, h_union.choose_spec.1 ⟩; obtain ⟨ v, hv₁, hv₂ ⟩ := h_union; obtain ⟨ w, hw₁, hw₂ ⟩ : ∃ w : EuclideanSpace ℂ d₂, w ∉ V ∧ w ∈ U := by obtain ⟨ w, hw ⟩ := ( show ∃ w : EuclideanSpace ℂ d₂, w ∉ V from by simpa [ Submodule.eq_top_iff' ] using hV ) ; use w; simp_all [ Submodule.eq_top_iff' ] ; exact Classical.not_not.1 fun hw' => hw <| h_contra _ hw'; - have h_union : v + w ∉ U ∧ v + w ∉ V := by - exact ⟨ fun h => hv₁ <| by simpa using U.sub_mem h hw₂, fun h => hw₁ <| by simpa using V.sub_mem h hv₂ ⟩; + have h_union : v + w ∉ U ∧ v + w ∉ V := + ⟨fun h => hv₁ <| by simpa using U.sub_mem h hw₂, + fun h => hw₁ <| by simpa using V.sub_mem h hv₂⟩ exact h_contra ⟨ v + w, h_union.1, h_union.2 ⟩; exact h_union _ _ ( by tauto ) ( by tauto ); -- Consider $z = u \otimes v$. @@ -1312,8 +1316,8 @@ lemma ker_le_of_ker_kron_le_left (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSta exact Fintype.sum_prod_type_right fun x => A i x.1 * (B j x.2 * (u x.1 * v x.2)); convert! congr_fun ( h_kronecker σ₁.1.mat σ₂.1.mat u v ) ( i, j ) using 1 ; simp exact Or.inl ( by exact congr(WithLp.ofLp $hu i) ); - have hz' : z ∈ (ρ₁ ⊗ᴹ ρ₂ : HermitianMat (d₁ × d₂) ℂ).ker := by - exact h hz; + have hz' : z ∈ (ρ₁ ⊗ᴹ ρ₂ : HermitianMat (d₁ × d₂) ℂ).ker := + h hz have hz'' : ∀ a b, (ρ₁.M.val.mulVec u) a * (ρ₂.M.val.mulVec v) b = 0 := by intro a b have hz'' : (ρ₁.M.val.mulVec u) a * (ρ₂.M.val.mulVec v) b = ((ρ₁ ⊗ᴹ ρ₂ : HermitianMat (d₁ × d₂) ℂ).val.mulVec z) (a, b) := by @@ -1357,13 +1361,14 @@ lemma ker_le_of_ker_kron_le_right (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSt intro U V hU hV by_contra h_contra push Not at h_contra; - have h_union : ∃ u : EuclideanSpace ℂ d₁, u ∉ U ∧ u ∈ V := by - exact Exists.elim ( show ∃ u : EuclideanSpace ℂ d₁, u ∉ U from by simpa [ Submodule.eq_top_iff' ] using hU ) fun u hu => ⟨ u, hu, h_contra u hu ⟩; + have h_union : ∃ u : EuclideanSpace ℂ d₁, u ∉ U ∧ u ∈ V := + Exists.elim (show ∃ u : EuclideanSpace ℂ d₁, u ∉ U from by + simpa [Submodule.eq_top_iff'] using hU) fun u hu => ⟨u, hu, h_contra u hu⟩ obtain ⟨ u, hu₁, hu₂ ⟩ := h_union; have h_union : ∀ v : EuclideanSpace ℂ d₁, v ∈ U → v + u ∈ V := by intro v hv; specialize h_contra ( v + u ) ; simp_all [ Submodule.add_mem_iff_right ] ; - have h_union : ∀ v : EuclideanSpace ℂ d₁, v ∈ U → v ∈ V := by - exact fun v hv => by simpa using V.sub_mem ( h_union v hv ) hu₂; + have h_union : ∀ v : EuclideanSpace ℂ d₁, v ∈ U → v ∈ V := + fun v hv => by simpa using V.sub_mem (h_union v hv) hu₂ exact hV ( eq_top_iff.mpr fun x hx => by by_cases hxU : x ∈ U <;> aesop ); exact h_z _ _ ( by tauto ) ( by tauto ); exact ⟨ h_z.choose, by intro h; simpa [ h ] using h_z.choose_spec.1, h_z.choose_spec.1, h_z.choose_spec.2 ⟩; @@ -1385,8 +1390,8 @@ lemma ker_le_of_ker_kron_le_right (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSt convert! hz_mul using 1; simp_all only [zero_eq_mul] exact Or.inr ( by exact congr(WithLp.ofLp $hv b) ); - have hz' : z ∈ (ρ₁ ⊗ᴹ ρ₂).M.ker := by - exact h hz; + have hz' : z ∈ (ρ₁ ⊗ᴹ ρ₂).M.ker := + h hz have hz'' : ∀ i j, (ρ₁.M.val.mulVec u) i * (ρ₂.M.val.mulVec v) j = 0 := by intro i j; have hz'' : (ρ₁.M.val.kronecker ρ₂.M.val).mulVec (fun p => u p.1 * v p.2) (i, j) = (ρ₁.M.val.mulVec u) i * (ρ₂.M.val.mulVec v) j := by @@ -1470,8 +1475,9 @@ theorem sandwichedRelRentropy_additive_alpha_one_aux (ρ₁ σ₁ : MState d₁) ⟪ρ₁.M, ρ₁.M.log - σ₁.M.log⟫_ℝ + ⟪ρ₂.M, ρ₂.M.log - σ₂.M.log⟫ := by have h_log_kron : (ρ₁ ⊗ᴹ ρ₂).M.log = ρ₁.M.log ⊗ₖ ρ₂.M.supportProj + ρ₁.M.supportProj ⊗ₖ ρ₂.M.log ∧ (σ₁ ⊗ᴹ σ₂).M.log = σ₁.M.log ⊗ₖ σ₂.M.supportProj + σ₁.M.supportProj ⊗ₖ σ₂.M.log := by constructor <;> apply HermitianMat.log_kron_with_proj; - have h_inner_supportProj : ∀ (A : HermitianMat d₁ ℂ) (B : HermitianMat d₂ ℂ), ⟪A ⊗ₖ B, ρ₁ ⊗ᴹ ρ₂⟫ = ⟪A, ρ₁⟫ * ⟪B, ρ₂⟫ := by - exact fun A B => HermitianMat.inner_kron A B ρ₁ ρ₂; + have h_inner_supportProj : ∀ (A : HermitianMat d₁ ℂ) (B : HermitianMat d₂ ℂ), + ⟪A ⊗ₖ B, ρ₁ ⊗ᴹ ρ₂⟫ = ⟪A, ρ₁⟫ * ⟪B, ρ₂⟫ := + fun A B => HermitianMat.inner_kron A B ρ₁ ρ₂ simp only [HermitianMat.ker] at h1 h2 simp_all only [inner_sub_right, inner_add_right, real_inner_comm, HermitianMat.inner_supportProj_self, MState.tr, mul_one, one_mul, @@ -1948,8 +1954,8 @@ private lemma eigenWeight_eq_zero_iff (ρ x : MState d) (i : d) : intro v w have h_inner : star v ⬝ᵥ (ρ.M.mat.mulVec w) = star (star w ⬝ᵥ (ρ.M.mat.mulVec v)) := by have h_inner : star v ⬝ᵥ (ρ.M.mat.mulVec w) = star (star w ⬝ᵥ (ρ.M.mat.mulVec v)) := by - have h_inner : ρ.M.mat = star ρ.M.mat := by - exact ρ.M.2.symm ▸ rfl + have h_inner : ρ.M.mat = star ρ.M.mat := + ρ.M.2.symm ▸ rfl conv_rhs => rw [ h_inner ] simp [ Matrix.mulVec, dotProduct ] ring_nf @@ -1967,8 +1973,8 @@ private lemma eigenWeight_eq_zero_iff (ρ x : MState d) (i : d) : refine ⟨h_forward, fun h ↦ ?_⟩ -- Since ρ e_i = 0, we have e_i^* ρ e_i = 0. have h_zero : (Matrix.vecMul (star (x.M.H.eigenvectorBasis i : d → ℂ)) ρ.M.mat) ⬝ᵥ (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := by - have h_zero : ρ.M.mat.mulVec (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := by - exact congr(WithLp.ofLp $h) + have h_zero : ρ.M.mat.mulVec (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := + congr(WithLp.ofLp $h) convert congr_arg ( fun v => star ( x.M.H.eigenvectorBasis i : d → ℂ ) ⬝ᵥ v ) h_zero using 1 simp [ Matrix.dotProduct_mulVec] ring_nf @@ -1987,8 +1993,10 @@ private lemma ker_le_iff_eigenWeight_zero (ρ x : MState d) : have h_w_zero : ∀ i, x.M.H.eigenvalues i ≠ 0 → w i = 0 := by intro i hi have h_eigenvalue : x.M.val.mulVec v = ∑ i, (x.M.H.eigenvalues i) • w i • x.M.H.eigenvectorBasis i := by - have h_eigenvalue : ∀ i, x.M.val.mulVec (x.M.H.eigenvectorBasis i) = x.M.H.eigenvalues i • x.M.H.eigenvectorBasis i := by - exact fun i => x.M.H.mulVec_eigenvectorBasis i |> fun h => by simpa [ mul_comm ] using h; + have h_eigenvalue : ∀ i, + x.M.val.mulVec (x.M.H.eigenvectorBasis i) = + x.M.H.eigenvalues i • x.M.H.eigenvectorBasis i := + fun i => x.M.H.mulVec_eigenvectorBasis i |> fun h => by simpa [mul_comm] using h rw [ hw] simp only [WithLp.ofLp_sum, WithLp.ofLp_smul] rw [Matrix.mulVec_sum ]; @@ -2060,8 +2068,8 @@ theorem qRelativeEnt_lowerSemicontinuous_2 (ρ x : MState d) (hx : ¬(x.M.ker exact h_cont.continuousAt.eventually ( lt_mem_nhds hN ) |> fun h => h.mono fun x' hx' => hx' |> fun hx'' => by simpa using hx''; filter_upwards [h_cont] with x' hx' hx'' apply lt_of_lt_of_le hx' - have h_inner_le : ⟪ρ.M, x'.M.log⟫ ≤ ⟪ρ.M, x'.M.cfc (approxLog N)⟫ := by - exact inner_cfc_approxLog_ge ρ x' N hx'' + have h_inner_le : ⟪ρ.M, x'.M.log⟫ ≤ ⟪ρ.M, x'.M.cfc (approxLog N)⟫ := + inner_cfc_approxLog_ge ρ x' N hx'' rw [inner_sub_right, inner_sub_right] exact sub_le_sub_left h_inner_le _ filter_upwards [ h_inner_lt_y ] with x' hx'; @@ -2341,8 +2349,8 @@ private lemma posDef_add_eps {A : HermitianMat d ℂ} (hA : 0 ≤ A) {ε : ℝ} private lemma log_add_eps_eq_cfc (A : HermitianMat d 𝕜) (ε : ℝ) : (A + ε • 1).log = A.cfc (Real.log <| · + ε) := by have h_cfc : A + ε • 1 = A.cfc (· + ε) := by - have h_add : A.cfc (fun u => u + ε) = A.cfc (fun u => u) + A.cfc (fun _ => ε) := by - exact A.cfc_add_apply _ _ + have h_add : A.cfc (fun u => u + ε) = A.cfc (fun u => u) + A.cfc (fun _ => ε) := + A.cfc_add_apply _ _ simp only [HermitianMat.cfc_id', HermitianMat.cfc_const, h_add] rw [h_cfc, HermitianMat.log, A.cfc_comp_apply] @@ -2412,8 +2420,8 @@ private lemma HermitianMat.inner_log_sub_le_log_alpha (ρ : MState d) {σ₁ σ (hker₁ : σ₁.M.ker ≤ ρ.M.ker) (hker₂ : σ₂.M.ker ≤ ρ.M.ker) : ⟪ρ.M, σ₂.M.log - σ₁.M.log⟫ ≤ Real.log α := by have h_log_mono : ⟪ρ.M, σ₂.M.log - (α • σ₁.M).log⟫ ≤ 0 := by - have h_log_mono : ⟪ρ.M, σ₂.M.log⟫ ≤ ⟪ρ.M, (α • σ₁.M).log⟫ := by - exact inner_log_mono_of_psd_of_le σ₂.nonneg hσ ρ.nonneg hker₂ + have h_log_mono : ⟪ρ.M, σ₂.M.log⟫ ≤ ⟪ρ.M, (α • σ₁.M).log⟫ := + inner_log_mono_of_psd_of_le σ₂.nonneg hσ ρ.nonneg hker₂ simpa [inner_sub_right] using sub_nonpos_of_le h_log_mono have h_log_smul : (α • σ₁.M).log = (Real.log α) • σ₁.M.supportProj + σ₁.M.log := by apply HermitianMat.log_smul_of_pos From d4d16eb550094837ee85843dfe1ad64ee1102987 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:17:55 -0700 Subject: [PATCH 119/498] refactor: golf sandwiched DPI proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/DPI.lean | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index a85a22508..6eaa53676 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -129,8 +129,8 @@ theorem sandwichedTraceFunctional_conj_unitary_hermitian (conj U.val A).conj ((conj U.val B).mat) = conj U.val (A.conj B.mat) := by intros A B U simp [conj] - have h_unitary : ∀ (U : Matrix.unitaryGroup d ℂ), U.val * U.val.conjTranspose = 1 := by - exact fun U => U.2.2 + have h_unitary : ∀ (U : Matrix.unitaryGroup d ℂ), U.val * U.val.conjTranspose = 1 := + fun U => U.2.2 simp [← mul_assoc] have := h_unitary U; simp_all [Matrix.mul_assoc, mul_eq_one_comm.mp this] simp_all [conj_apply_mat, rpow_conj_unitary] @@ -267,8 +267,9 @@ Proof: f_α(H_hat, ρ, σ) = α · Tr[(σ^γ ρ σ^γ)^α] - (α-1) · Tr[(σ^γ -/ theorem f_alpha_at_optimizer (hα : 1 < α) (ρ σ : MState d) : f_alpha α (H_hat α ρ σ) ρ σ = Q̃_ α(ρ‖σ) := by - have h_inner : ⟪ρ.M, H_hat α ρ σ⟫_ℝ = ((ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ α).trace := by - exact inner_rho_H_hat hα ρ σ + have h_inner : ⟪ρ.M, H_hat α ρ σ⟫_ℝ = + ((ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ α).trace := + inner_rho_H_hat hα ρ σ have h_conj : (H_hat α ρ σ).conj (σ.M ^ ((α - 1) / (2 * α))).mat = (ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ (α - 1) := by convert H_hat_conj_sigma (hα := hα) (ρ := ρ) (σ := σ) using 1 @@ -317,8 +318,8 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} simp [add_comm] simp [← Matrix.ext_iff] intro i j; exact (by - have h_support : A.kerProj + A.supportProj = 1 := by - exact kerProj_add_supportProj A + have h_support : A.kerProj + A.supportProj = 1 := + kerProj_add_supportProj A convert! congr_arg (fun f => f i j) h_support using 1) rw [← Matrix.add_mulVec, h_support, Matrix.one_mulVec] have hsup : B.mat *ᵥ (A.kerProj.mat *ᵥ x.ofLp) = 0 := by @@ -326,8 +327,8 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} have h_support : A.mat * A.kerProj.mat = 0 := by have h_support : A.mat * A.kerProj.mat = A.mat * (1 - A.supportProj.mat) := by congr - have h_support : A.kerProj + A.supportProj = 1 := by - exact kerProj_add_supportProj A + have h_support : A.kerProj + A.supportProj = 1 := + kerProj_add_supportProj A exact eq_sub_of_add_eq <| congr_arg Subtype.val h_support rw [h_support, mul_sub, mul_one, sub_eq_zero] exact Eq.symm (mul_supportProj_of_ker_le fun ⦃x⦄ a => a) @@ -342,8 +343,8 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} · simp [Matrix.mulVec, dotProduct] · simp [Matrix.mulVec, dotProduct] rfl - have h_support : B.mat = B.mat.conjTranspose := by - exact B.2.symm + have h_support : B.mat = B.mat.conjTranspose := + B.2.symm have h_support : (B.mat * A.supportProj.mat).conjTranspose = A.supportProj.mat * B.mat := by simp [Matrix.conjTranspose_mul] lia @@ -1241,8 +1242,8 @@ theorem sandwichedRenyiEntropy_conj_unitary (hα : 0 < α) (ρ σ : MState d) · use (U.val.conjTranspose.toEuclideanLin x) simp_all [ker, Matrix.toEuclideanLin] simp_all [lin, Matrix.toLpLin] - have h_unitary : (U.val * U.val.conjTranspose) = 1 := by - exact U.2.2 + have h_unitary : (U.val * U.val.conjTranspose) = 1 := + U.2.2 generalize_proofs at *; ( apply_fun (U.val.conjTranspose *ᵥ ·) at hx simp_all [Matrix.mul_assoc, Matrix.mulVec_mulVec] @@ -1360,8 +1361,8 @@ theorem sandwichedRenyiEntropy_DPI_gt_one (hα : 1 < α) (ρ σ : MState d₁) ( calc D̃_ α(Φ ρ‖Φ σ) _ = D̃_ α((Φ.purify ((prep ∘ₘ append) ρ)).traceLeft.traceLeft‖ (Φ.purify ((prep ∘ₘ append) σ)).traceLeft.traceLeft) := by - have h_trace (ξ) : Φ ξ = (Φ.purify ((prep ∘ₘ append) ξ)).traceLeft.traceLeft := by - exact congr($Φ.purify_trace ξ) + have h_trace (ξ) : Φ ξ = (Φ.purify ((prep ∘ₘ append) ξ)).traceLeft.traceLeft := + congr($Φ.purify_trace ξ) rw [h_trace ρ, h_trace σ] _ = D̃_ α(((ρ ⊗ᴹ τ).U_conj U).traceLeft.traceLeft‖ ((σ ⊗ᴹ τ).U_conj U).traceLeft.traceLeft) := by From f947095a4d093671210c374a6dc0feec7e73828a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:20:01 -0700 Subject: [PATCH 120/498] refactor: golf SSA proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/SSA.lean | 46 +++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 7b169c0c8..537605bd8 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -397,14 +397,16 @@ private lemma W_mat_sq_eq_conj [Nonempty dA] [Nonempty dB] [Nonempty dC] · exact sqrt_sq (by positivity) · convert sqrt_sq ( show 0 ≤ ( σBC.traceLeft⁻¹ : HermitianMat dC ℂ ) from ?_ ) using 1; have h_inv_pos : (σBC.traceLeft⁻¹ : HermitianMat dC ℂ).mat.PosDef := by - have h_inv_pos : (σBC.traceLeft : Matrix dC dC ℂ).PosDef := by - exact PosDef_traceLeft σBC hσ; + have h_inv_pos : (σBC.traceLeft : Matrix dC dC ℂ).PosDef := + PosDef_traceLeft σBC hσ convert! h_inv_pos.inv using 1; convert! h_inv_pos.posSemidef using 1; exact zero_le_iff; have h_simp : (ρAB.sqrt : Matrix (dA × dB) (dA × dB) ℂ) ⊗ₖ (σBC.traceLeft⁻¹.sqrt : Matrix dC dC ℂ) * (ρAB.sqrt : Matrix (dA × dB) (dA × dB) ℂ) ⊗ₖ (σBC.traceLeft⁻¹.sqrt : Matrix dC dC ℂ) = (ρAB : Matrix (dA × dB) (dA × dB) ℂ) ⊗ₖ (σBC.traceLeft⁻¹ : Matrix dC dC ℂ) := by - have h_simp : ∀ (A B C D : Matrix (dA × dB) (dA × dB) ℂ) (E F : Matrix dC dC ℂ), (A ⊗ₖ E) * (B ⊗ₖ F) = (A * B) ⊗ₖ (E * F) := by - exact fun A B C D E F => Eq.symm (Matrix.mul_kronecker_mul A B E F); + have h_simp : + ∀ (A B C D : Matrix (dA × dB) (dA × dB) ℂ) (E F : Matrix dC dC ℂ), + (A ⊗ₖ E) * (B ⊗ₖ F) = (A * B) ⊗ₖ (E * F) := + fun A B _ _ E F => Eq.symm (Matrix.mul_kronecker_mul A B E F) aesop; simp_all [ ← Matrix.mul_assoc ] @@ -417,8 +419,8 @@ private lemma S_mat_conj_rhs_eq_one [Nonempty dA] [Nonempty dB] [Nonempty dC] S_mat ρAB σBC * ((ρAB.traceRight ⊗ₖ σBC⁻¹).reindex (Equiv.prodAssoc dA dB dC).symm).mat * S_mat ρAB σBC = 1 := by have h_comm : Commute (σBC.sqrt.mat) (σBC⁻¹.mat) := by - have h_comm : Commute (σBC.sqrt.mat) (σBC.mat) := by - exact commute_sqrt_left rfl; + have h_comm : Commute (σBC.sqrt.mat) (σBC.mat) := + commute_sqrt_left rfl have h_comm_inv : Commute (σBC.sqrt.mat) (σBC.mat) → Commute (σBC.sqrt.mat) (σBC⁻¹.mat) := by intro h_comm have h_comm_inv : Commute (σBC.sqrt.mat) (σBC.mat) → Commute (σBC.sqrt.mat) (σBC.mat⁻¹) := by @@ -747,12 +749,12 @@ private lemma S_mat_isUnit [Nonempty dA] [Nonempty dB] [Nonempty dC] constructor; · have h_det_ne_zero : ∀ (A : HermitianMat (dA) ℂ), A.mat.PosDef → (A.sqrt).mat.det ≠ 0 := by intro A hA - have h_det_ne_zero : (A.sqrt).mat.PosDef := by - exact sqrt_posDef hA; + have h_det_ne_zero : (A.sqrt).mat.PosDef := + sqrt_posDef hA exact h_det_ne_zero.det_pos.ne'; exact isUnit_iff_ne_zero.mpr ( h_det_ne_zero _ <| by simpa using PosDef_traceRight _ hρ |> fun h => h.inv ); - · have h_inv_sqrt : σBC.sqrt.mat.PosDef := by - exact sqrt_posDef hσ; + · have h_inv_sqrt : σBC.sqrt.mat.PosDef := + sqrt_posDef hσ exact isUnit_iff_ne_zero.mpr h_inv_sqrt.det_pos.ne'; unfold S_mat; simp_all [ Matrix.det_kronecker] @@ -804,12 +806,12 @@ theorem operator_ineq_SSA [Nonempty dA] [Nonempty dB] [Nonempty dC] convert HermitianMat.inv_kronecker _ _ using 1; · infer_instance; · exact ⟨ ⟨ Classical.arbitrary dB, Classical.arbitrary dC ⟩ ⟩; - · have h_trace_right_pos_def : (ρAB.traceRight).mat.PosDef := by - exact PosDef_traceRight ρAB hρ + · have h_trace_right_pos_def : (ρAB.traceRight).mat.PosDef := + PosDef_traceRight ρAB hρ exact ⟨by exact PosDef_traceRight ρAB hρ |>.isUnit⟩ · have h_inv_symm : σBC⁻¹.NonSingular := by - have h_inv_symm : σBC.NonSingular := by - exact nonSingular_of_posDef hσ + have h_inv_symm : σBC.NonSingular := + nonSingular_of_posDef hσ exact nonSingular_iff_inv.mpr h_inv_symm; exact h_inv_symm; convert congr_arg ( fun x : HermitianMat _ _ => x.reindex ( Equiv.prodAssoc dA dB dC ).symm ) h_inv_symm using 1; @@ -822,8 +824,8 @@ theorem operator_ineq_SSA [Nonempty dA] [Nonempty dB] [Nonempty dC] have h_inv_symm : (ρAB ⊗ₖ σBC.traceLeft⁻¹)⁻¹ = ρAB⁻¹ ⊗ₖ (σBC.traceLeft⁻¹)⁻¹ := by convert HermitianMat.inv_kronecker ρAB ( σBC.traceLeft⁻¹ ) using 1; · exact nonSingular_of_posDef hρ; - · have h_inv_symm : σBC.traceLeft.mat.PosDef := by - exact PosDef_traceLeft σBC hσ; + · have h_inv_symm : σBC.traceLeft.mat.PosDef := + PosDef_traceLeft σBC hσ -- Since σBC.traceLeft is positive definite, its inverse is also positive definite, and hence non-singular. have h_inv_pos_def : (σBC.traceLeft⁻¹).mat.PosDef := by convert! h_inv_symm.inv using 1; @@ -832,8 +834,8 @@ theorem operator_ineq_SSA [Nonempty dA] [Nonempty dB] [Nonempty dC] have h_inv_symm : (σBC.traceLeft⁻¹)⁻¹ = σBC.traceLeft := by have h_inv_symm : (σBC.traceLeft⁻¹).mat * σBC.traceLeft.mat = 1 := by have h_inv_symm : (σBC.traceLeft⁻¹).mat * σBC.traceLeft.mat = 1 := by - have h_inv_symm : σBC.traceLeft.mat.PosDef := by - exact PosDef_traceLeft σBC hσ + have h_inv_symm : σBC.traceLeft.mat.PosDef := + PosDef_traceLeft σBC hσ convert! Matrix.nonsing_inv_mul _ _; exact isUnit_iff_ne_zero.mpr h_inv_symm.det_pos.ne'; exact h_inv_symm @@ -883,8 +885,8 @@ private lemma hermitianMat_log_inv_eq_neg (A : HermitianMat d₁ ℂ) [A.NonSingular] : A⁻¹.log = -A.log := by -- By the property of continuous functional calculus, the logarithm of the inverse of a matrix is the negative of the logarithm of the matrix. have h_log_inv : A⁻¹.log = A.cfc (Real.log ∘ (·⁻¹)) := by - have h_log_inv : A⁻¹ = A.cfc (·⁻¹) := by - exact Eq.symm HermitianMat.cfc_inv; + have h_log_inv : A⁻¹ = A.cfc (·⁻¹) := + Eq.symm HermitianMat.cfc_inv rw [ h_log_inv, HermitianMat.log ]; exact Eq.symm (HermitianMat.cfc_comp A (fun x => x⁻¹) Real.log); simp [ HermitianMat.log ]; @@ -1126,8 +1128,8 @@ private lemma purify_AB_traceRight_eq (ρ : MState (dA × dB × dC)) : Sᵥₙ ((MState.pure ρ.purify).relabel (perm_AB_CR' dA dB dC).symm).traceRight = Sᵥₙ ρ.assoc'.traceRight := by have h_traceRight : ((MState.pure ρ.purify).relabel (perm_AB_CR' dA dB dC).symm).traceRight = ρ.assoc'.traceRight := by - have h_traceRight : (MState.pure ρ.purify).traceRight = ρ := by - exact MState.purify_spec ρ; + have h_traceRight : (MState.pure ρ.purify).traceRight = ρ := + MState.purify_spec ρ convert congr_arg ( fun m => m.assoc'.traceRight ) h_traceRight using 1; ext i j; simp [ MState.traceRight, MState.assoc' ] ; simp [ HermitianMat.traceRight, MState.SWAP, MState.assoc ]; From 510402670aa4ff776ce0e04dd11b30d8664b8372 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:21:40 -0700 Subject: [PATCH 121/498] refactor: golf state proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Capacity/Capacity.lean | 4 ++-- QuantumInfo/States/Entanglement.lean | 8 ++++---- QuantumInfo/States/Mixed/MState.lean | 28 ++++++++++++++-------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/QuantumInfo/Capacity/Capacity.lean b/QuantumInfo/Capacity/Capacity.lean index 0cf72a267..18fd30adc 100644 --- a/QuantumInfo/Capacity/Capacity.lean +++ b/QuantumInfo/Capacity/Capacity.lean @@ -166,8 +166,8 @@ end AristotleLemmas theorem not_achievesRate_gt_log_dim_out (Λ : CPTPMap d₁ d₂) {R : ℝ} (hR : Real.logb 2 (Fintype.card d₂) < R): ¬Λ.AchievesRate R := by intro h; -- We show that the identity channel on the output space `d₂` emulates `Λ`. Since capacity is monotonic under emulation, `Q(Λ) ≤ Q(id_{d₂})`. - have h_emulate : (CPTPMap.id (dIn := d₂)).Emulates Λ := by - exact ⟨Λ, CPTPMap.id, by simp⟩ + have h_emulate : (CPTPMap.id (dIn := d₂)).Emulates Λ := + ⟨Λ, CPTPMap.id, by simp⟩ -- If `Λ` achieves rate `R`, then `id_{d₂}` achieves rate `R`. This follows because if `Λ^{\otimes n}` emulates `B`, and `id^{\otimes n}` emulates `Λ^{\otimes n}` (by functoriality of tensor product), then `id^{\otimes n}` emulates `B`. have h_id_achieves : (CPTPMap.id (dIn := d₂)).AchievesRate R := by intro ε hε_pos diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 7ada04aba..bad2c2e62 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -286,12 +286,12 @@ The von Neumann entropy of a classical state (diagonal in the basis) is equal to theorem Sᵥₙ_ofClassical {d : Type*} [Fintype d] [DecidableEq d] (dist : ProbDistribution d) : Sᵥₙ (MState.ofClassical dist) = Hₛ dist := by -- Let's unfold the definition of `Sᵥₙ` using `Sᵥₙ_eq_trace_cfc`. - have h_def : Sᵥₙ (MState.ofClassical dist) = (HermitianMat.cfc (MState.ofClassical dist).M Real.negMulLog).trace := by - exact Sᵥₙ_eq_trace_cfc (ofClassical dist); + have h_def : Sᵥₙ (MState.ofClassical dist) = (HermitianMat.cfc (MState.ofClassical dist).M Real.negMulLog).trace := + Sᵥₙ_eq_trace_cfc (ofClassical dist); convert h_def using 1; -- By definition of $MState.ofClassical$, we know that $(MState.ofClassical dist).M$ is a diagonal matrix with entries $dist i$. - have h_diag : (MState.ofClassical dist).M = HermitianMat.diagonal ℂ (fun x => dist x) := by - exact rfl; + have h_diag : (MState.ofClassical dist).M = HermitianMat.diagonal ℂ (fun x => dist x) := + rfl; rw [ h_diag, HermitianMat.cfc_diagonal, HermitianMat.trace_diagonal ] ; aesop /-- The entanglement of formation of the maximally entangled state with on-site dimension 𝕕 is log(𝕕). -/ diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 12446857d..40b6ea367 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -750,8 +750,8 @@ theorem pure_eq_pure_iff {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) specialize h_eq i k simp_all -- Since $\overline{z} \cdot \overline{\varphi_k} \neq 0$, we can divide both sides of the equation by $\overline{z} \cdot \overline{\varphi_k}$. - have h_div : ψ.vec i * starRingEnd ℂ z = φ.vec i := by - exact mul_left_cancel₀ ( show starRingEnd ℂ ( φ.vec k ) ≠ 0 from by simpa [ Complex.ext_iff ] using hk ) ( by linear_combination' h_eq ); + have h_div : ψ.vec i * starRingEnd ℂ z = φ.vec i := + mul_left_cancel₀ ( show starRingEnd ℂ ( φ.vec k ) ≠ 0 from by simpa [ Complex.ext_iff ] using hk ) ( by linear_combination' h_eq ); rw [ ← h_div, mul_left_comm, Complex.mul_conj, Complex.normSq_eq_norm_sq ] ; aesop; · cases h rename_i h @@ -788,8 +788,8 @@ theorem pure_separable_imp_IsProd {d₁ d₂ : Type*} [Fintype d₁] [Fintype d obtain ⟨ ρLRs, ps, hps ⟩ := h; -- Since `pure ψ` is pure (`purity = 1`), by `MState.eq_of_sum_eq_pure`, for any `k` with `p_k > 0`, we have `pure ψ = ρL_k ⊗ᴹ ρR_k`. obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) ∧ (MState.pure ψ).M = (k.val.1).M ⊗ₖ (k.val.2).M := by - have h_pure : (MState.pure ψ).purity = 1 := by - exact ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; + have h_pure : (MState.pure ψ).purity = 1 := + ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) := by exact ⟨ Classical.choose ( show ∃ k : ρLRs, 0 < ( ps k : ℝ ) from by exact not_forall_not.mp fun h => by have := ps.2; simp_all ), Classical.choose_spec ( show ∃ k : ρLRs, 0 < ( ps k : ℝ ) from by exact not_forall_not.mp fun h => by have := ps.2; simp_all) ⟩; refine' ⟨ k, hk, _ ⟩; @@ -816,15 +816,15 @@ theorem pure_separable_imp_IsProd {d₁ d₂ : Type*} [Fintype d₁] [Fintype d have h_purity : (pure ψ).purity = (k.val.1).purity * (k.val.2).purity := by convert MState.purity_prod _ _; exact MState.ext hk.2; - have h_purity_one : (pure ψ).purity = 1 := by - exact ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; + have h_purity_one : (pure ψ).purity = 1 := + ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; rw [ h_purity, Prob.mul_eq_one_iff ] at h_purity_one ; aesop obtain ⟨φ, hφ⟩ : ∃ φ : MState d₂, k.val.2 = φ ∧ φ.purity = 1 := by have h_purity_prod : (pure ψ).purity = (k.val.1).purity * (k.val.2).purity := by convert MState.purity_prod _ _; exact MState.ext hk.2; - have h_purity_one : (MState.pure ψ).purity = 1 := by - exact pure_iff_purity_one _ |>.1 ⟨ ψ, rfl ⟩; + have h_purity_one : (MState.pure ψ).purity = 1 := + pure_iff_purity_one _ |>.1 ⟨ ψ, rfl ⟩; aesop; -- Since `ξ` and `φ` are pure states, we have `ξ = pure ξ'` and `φ = pure φ'` for some `ξ', φ'`. obtain ⟨ξ', hξ'⟩ : ∃ ξ' : Ket d₁, ξ = MState.pure ξ' := by @@ -884,15 +884,15 @@ theorem pure_iff_rank_eq_one {d : Type*} [Fintype d] [DecidableEq d] (ρ : MStat -- Since ρ is Hermitian and has rank 1, it must be of the form |ψ⟩⟨ψ| for some ket ψ. Use this fact. have h_pure : ∃ ψ : d → ℂ, ρ.m = Matrix.of (fun i j => ψ i * star (ψ j)) := by have h_rank : ρ.m.rank = 1 := h - have h_herm : ρ.m.IsHermitian := by - exact ρ.M.property + have h_herm : ρ.m.IsHermitian := + ρ.M.property have := h_herm.spectral_theorem; -- Since the rank of ρ.m is 1, the diagonal matrix in the spectral theorem must have exactly one non-zero entry. obtain ⟨i, hi⟩ : ∃ i : d, h_herm.eigenvalues i ≠ 0 ∧ ∀ j : d, j ≠ i → h_herm.eigenvalues j = 0 := by have h_diag : ∑ i : d, (if h_herm.eigenvalues i = 0 then 0 else 1) = 1 := by have h_diag : Matrix.rank (Matrix.diagonal (h_herm.eigenvalues)) = 1 := by - have h_diag : Matrix.rank (Matrix.diagonal (h_herm.eigenvalues)) = Matrix.rank (ρ.m) := by - exact Eq.symm (Matrix.IsHermitian.rank_eq_rank_diagonal h_herm); + have h_diag : Matrix.rank (Matrix.diagonal (h_herm.eigenvalues)) = Matrix.rank (ρ.m) := + Eq.symm (Matrix.IsHermitian.rank_eq_rank_diagonal h_herm); exact h_diag.trans h_rank; rw [ Matrix.rank_diagonal ] at h_diag; simp [ Finset.sum_ite ]; @@ -1132,8 +1132,8 @@ The multiset of values in the spectrum of a relabeled state is the same as the m lemma multiset_spectrum_relabel_eq {d₁ d₂ : Type*} [Fintype d₁] [DecidableEq d₁] [Fintype d₂] [DecidableEq d₂] (ρ : MState d₁) (e : d₂ ≃ d₁) : Multiset.map (ρ.relabel e).spectrum Finset.univ.val = Multiset.map ρ.spectrum Finset.univ.val := by - have h_charpoly : Matrix.charpoly (ρ.relabel e).m = Matrix.charpoly ρ.m := by - exact Matrix.charpoly_reindex e.symm ρ.m + have h_charpoly : Matrix.charpoly (ρ.relabel e).m = Matrix.charpoly ρ.m := + Matrix.charpoly_reindex e.symm ρ.m have h_eigenvalues : Multiset.map (ρ.relabel e).M.H.eigenvalues Finset.univ.val = Multiset.map ρ.M.H.eigenvalues Finset.univ.val := by have h_eigenvalues : Polynomial.roots (Matrix.charpoly (ρ.relabel e).m) = Polynomial.roots (Matrix.charpoly ρ.m) := by rw [h_charpoly]; From a51c282d40a0b907b123c9aa7642a716d037b8e5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:23:30 -0700 Subject: [PATCH 122/498] refactor: golf for-mathlib proof wrappers Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/Commutation.lean | 4 ++-- QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean | 4 ++-- QuantumInfo/ForMathlib/Isometry.lean | 8 ++++---- QuantumInfo/ForMathlib/Matrix.lean | 8 ++++---- QuantumInfo/ForMathlib/SionMinimax.lean | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean index 9aca73699..6b0e19055 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean @@ -186,8 +186,8 @@ lemma radiusRegPow_commutation_momentum : ⁅𝐫₀[d] ε s, 𝐩 i⁆ = (s * I * ℏ) • 𝐫₀ ε (s-2) ∘L 𝐱 i := by ext ψ x have hne := Ne.symm (ne_of_lt <| Space.norm_sq_add_unit_sq_pos ε x) - have hdiff1 : DifferentiableAt ℝ (fun x => (‖x‖ ^ 2 + ↑ε ^ 2) ^ (s / 2)) x := by - exact DifferentiableAt.rpow_const (Differentiable.differentiableAt (by fun_prop)) + have hdiff1 : DifferentiableAt ℝ (fun x => (‖x‖ ^ 2 + ↑ε ^ 2) ^ (s / 2)) x := + DifferentiableAt.rpow_const (Differentiable.differentiableAt (by fun_prop)) (Or.intro_left _ hne) have hdiff2 := Real.differentiableAt_rpow_const_of_ne (s / 2) hne have hdiff3 : DifferentiableAt ℝ (fun x ↦ ‖x‖ ^ 2 + ε ^ 2) x := diff --git a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean index 1b239ca22..5c8033b65 100644 --- a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean +++ b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean @@ -49,8 +49,8 @@ private theorem norm_complexLaplaceIntegrand_le_envelope set e : ℝ := (E x).untop h have hdist : ‖w - z‖ ≤ δ := by simpa [Metric.mem_closedBall, dist_eq_norm, norm_sub_rev] using hw - have hre_abs : |w.re - z.re| ≤ δ := by - exact (Complex.abs_re_le_norm (w - z)).trans (by simpa [Complex.sub_re] using hdist) + have hre_abs : |w.re - z.re| ≤ δ := + (Complex.abs_re_le_norm (w - z)).trans (by simpa [Complex.sub_re] using hdist) rw [Complex.norm_exp, Complex.norm_exp, Complex.norm_exp] rcases le_total 0 e with he | he · refine le_add_of_le_of_nonneg ?_ (Real.exp_pos _).le diff --git a/QuantumInfo/ForMathlib/Isometry.lean b/QuantumInfo/ForMathlib/Isometry.lean index 133acee53..7742b0127 100644 --- a/QuantumInfo/ForMathlib/Isometry.lean +++ b/QuantumInfo/ForMathlib/Isometry.lean @@ -57,8 +57,8 @@ theorem Matrix.submatrix_one_isometry {e : d₂ → d} {f : d₃ → d} (he : e. obtain ⟨ x, hx ⟩ := h_unique i; rw [show ( Finset.univ.filter fun y => e y = f i ) = { x } from Finset.eq_singleton_iff_unique_mem.2 ⟨ by aesop, fun y hy => hx.2 y <| Eq.symm <| Finset.mem_filter.1 hy |>.2.symm ⟩] ; simp ; next h => -- Since $e$ is injective and $e i \neq e j$, there is no $x$ such that $e i = f x$ and $e j = f x$. - have h_no_x : ∀ x : d₂, ¬(e x = f i ∧ e x = f j) := by - exact fun x hx => h ( hf ( hx.1.symm.trans hx.2 ) ); + have h_no_x : ∀ x : d₂, ¬(e x = f i ∧ e x = f j) := + fun x hx => h ( hf ( hx.1.symm.trans hx.2 ) ); exact Finset.sum_eq_zero fun x hx => by specialize h_no_x x; aesop omit [DecidableEq d₂] in @@ -135,8 +135,8 @@ theorem Matrix.IsHermitian.eigenvalue_ext (hA : A.IsHermitian) have h_diag : ∀ v : EuclideanSpace 𝕜 d, ∃ c : d → 𝕜, v = ∑ i, c i • (hA.eigenvectorBasis i) := by intro v set c := fun i => innerₛₗ 𝕜 (hA.eigenvectorBasis i) v - have hv : v = ∑ i, c i • (hA.eigenvectorBasis i) := by - exact Eq.symm (OrthonormalBasis.sum_repr' hA.eigenvectorBasis v) + have hv : v = ∑ i, c i • (hA.eigenvectorBasis i) := + Eq.symm (OrthonormalBasis.sum_repr' hA.eigenvectorBasis v) use c; obtain ⟨c, hc⟩ := h_diag (WithLp.toLp 2 v) use c diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index 72ff3db36..da255fc80 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -820,8 +820,8 @@ lemma IsHermitian.eigenvalues_eq_of_unitary_similarity_diagonal {d 𝕜 : Type*} exact Finset.sum_congr rfl fun _ _ => by congr; ext; aesop; rw [ h, h_char_poly ]; -- The roots of the characteristic polynomial of A are its eigenvalues (by `IsHermitian.charpoly_roots_eq_eigenvalues`). - have h_eigenvalues : (Matrix.charpoly A).roots = Multiset.map (RCLike.ofReal ∘ hA.eigenvalues) Finset.univ.val := by - exact Matrix.IsHermitian.roots_charpoly_eq_eigenvalues hA; + have h_eigenvalues : (Matrix.charpoly A).roots = Multiset.map (RCLike.ofReal ∘ hA.eigenvalues) Finset.univ.val := + Matrix.IsHermitian.roots_charpoly_eq_eigenvalues hA; -- The roots of the characteristic polynomial of D are the diagonal entries f. have h_diag_roots : (Matrix.charpoly (Matrix.diagonal fun i => (f i : 𝕜))).roots = Multiset.map (fun i => (f i : 𝕜)) Finset.univ.val := by simp [ Matrix.charpoly, Matrix.det_diagonal ]; @@ -1215,8 +1215,8 @@ lemma sub_iInf_eignevalues (hA : A.IsHermitian) : -- Since the eigenvalues are real and the sums involving Q and x are complex, the product of a complex number and its conjugate is non-negative. have h_nonneg : ∀ i, 0 ≤ (∑ x_2, Q x_2 i * star (x x_2)) * (∑ x_2, star (Q x_2 i) * x x_2) := by intro i - have h_nonneg : 0 ≤ (∑ x_2, Q x_2 i * star (x x_2)) * star (∑ x_2, Q x_2 i * star (x x_2)) := by - exact mul_star_self_nonneg (∑ x_2, Q x_2 i * star (x x_2)) + have h_nonneg : 0 ≤ (∑ x_2, Q x_2 i * star (x x_2)) * star (∑ x_2, Q x_2 i * star (x x_2)) := + mul_star_self_nonneg (∑ x_2, Q x_2 i * star (x x_2)) convert h_nonneg using 1; simp [ mul_comm, Finset.mul_sum _ _ _]; -- Since each term in the sum is a product of a non-negative number and a non-negative eigenvalue difference, the entire sum is non-negative. diff --git a/QuantumInfo/ForMathlib/SionMinimax.lean b/QuantumInfo/ForMathlib/SionMinimax.lean index c6e379814..550eaa145 100644 --- a/QuantumInfo/ForMathlib/SionMinimax.lean +++ b/QuantumInfo/ForMathlib/SionMinimax.lean @@ -269,8 +269,8 @@ theorem LeftOrdContinuous.comp_lowerSemicontinuousOn_strong_assumptions {α γ by_contra h_contra simp only [not_exists, not_and, not_lt] at h_contra have h_exists_z : ∃ z, z < f x ∧ g z > y := by - have h_lub : IsLUB (Set.Iio (f x)) (f x) := by - exact isLUB_Iio + have h_lub : IsLUB (Set.Iio (f x)) (f x) := + isLUB_Iio have := hg h_lub; have := this.exists_between hy simp_all only [Set.mem_image, Set.mem_Iio, exists_exists_and_eq_and, gt_iff_lt] From 4f2c78c348d8c526831f0e9db8b636a6ff3ec78f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:25:39 -0700 Subject: [PATCH 123/498] refactor: golf Hayata Jensen proof wrappers Co-authored-by: Claude Opus 4.8 --- .../JensenOperatorInequality.lean | 8 ++++---- .../JensenOperatorInequalityIImpIV.lean | 16 ++++++++-------- .../JensenOperatorInequalityIVtoV.lean | 4 ++-- .../TraceInequality/LownerHeinzCore.lean | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean index edd08ffd7..62d3c13f3 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean @@ -213,8 +213,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) simpa [Atilde] using blockDiagonal_selfAdjoint_wrap (ℋ := ℋ) hA hB have hAtilde0 : (0 : L (HSum ℋ)) ≤ Atilde := by simpa [Atilde] using blockDiagonal_nonneg (ℋ := ℋ) hA0 hB0 - have hAtilde_spec : spectrum ℝ Atilde ⊆ Set.Ici (0 : ℝ) := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) Atilde (ha := hAtilde_sa)).1 hAtilde0 + have hAtilde_spec : spectrum ℝ Atilde ⊆ Set.Ici (0 : ℝ) := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) Atilde (ha := hAtilde_sa)).1 hAtilde0 have hXtilde_star_mul : star Xtilde * Xtilde = blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 := by @@ -295,8 +295,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) /-- Uniform consequence of Theorem 2.5.2: `(i) → (v)` via `(iv)`. -/ theorem theorem_2_5_2_i_all_imp_v {f : ℝ → ℝ} (hf : CondIAll.{u} f) : CondV (ℋ := ℋ) f := by - have hconv : OperatorConvex (ℋ := ℋ) f := by - exact hf.1 + have hconv : OperatorConvex (ℋ := ℋ) f := + hf.1 have hcont : ContinuousOn f Set.univ := operatorConvex_continuousOn_univ (ℋ := ℋ) hconv refine theorem_2_5_2_iv_imp_v (ℋ := ℋ) ?_ hcont diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean index c495d7723..882159c4c 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean @@ -500,8 +500,8 @@ private lemma blockSwap_norm_le_one [Nontrivial ℋ] (X : L ℋ) (hX : ‖X‖ have hSstarSle : star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X ≤ (1 : L (HSum ℋ)) := by simpa [hSstarS] using hDiagLe - have hSstarSnonneg : 0 ≤ star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X := by - exact star_mul_self_nonneg (blockSwap (ℋ := ℋ) X) + have hSstarSnonneg : 0 ≤ star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X := + star_mul_self_nonneg (blockSwap (ℋ := ℋ) X) have hnormSq : ‖star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X‖ ≤ 1 := (CStarAlgebra.norm_le_one_iff_of_nonneg _ hSstarSnonneg).2 hSstarSle have hnormSq' : ‖blockSwap (ℋ := ℋ) X‖ * ‖blockSwap (ℋ := ℋ) X‖ ≤ 1 := by @@ -559,8 +559,8 @@ theorem theorem_2_5_2_i_ici_all_imp_iv {f : ℝ → ℝ} (hf : CondIciAll.{u} f) simpa [S] using blockSwap_norm_le_one (ℋ := ℋ) X hX letI : Algebra ℝ (L (HSum ℋ)) := by infer_instance - have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := by - exact IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary S hSsa hSnorm + have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := + IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary S hSsa hSnorm let U : unitary (L (HSum ℋ)) := ⟨S + Complex.I • CFC.sqrt (1 - S ^ 2), hU_mem⟩ let V : unitary (L (HSum ℋ)) := star U @@ -786,8 +786,8 @@ theorem theorem_2_5_2_i_ici_all_imp_iv {f : ℝ → ℝ} (hf : CondIciAll.{u} f) have hterm_nonpos : (f 0) • (R0 * R0) ≤ (0 : L ℋ) := by have hR0sq_nonneg : (0 : L ℋ) ≤ R0 * R0 := by simpa [hR0self.star_eq] using star_mul_self_nonneg R0 - have hneg : (0 : L ℋ) ≤ (- (f 0)) • (R0 * R0) := by - exact smul_nonneg (by linarith [hf0]) hR0sq_nonneg + have hneg : (0 : L ℋ) ≤ (- (f 0)) • (R0 * R0) := + smul_nonneg (by linarith [hf0]) hR0sq_nonneg exact (neg_nonneg.mp (by simpa [neg_smul] using hneg)) have htop : cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := by @@ -813,8 +813,8 @@ theorem theorem_2_5_2_i_all_imp_iv {f : ℝ → ℝ} (hf : CondIAll.{u} f) : simpa [S] using blockSwap_norm_le_one (ℋ := ℋ) X hX letI : Algebra ℝ (L (HSum ℋ)) := by infer_instance - have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := by - exact IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary S hSsa hSnorm + have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := + IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary S hSsa hSnorm let U : unitary (L (HSum ℋ)) := ⟨S + Complex.I • CFC.sqrt (1 - S ^ 2), hU_mem⟩ let V : unitary (L (HSum ℋ)) := star U diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean index 02e3168cf..df78c42bb 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean @@ -205,8 +205,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) simpa [Atilde] using blockDiagonal_selfAdjoint (ℋ := ℋ) hA hB have hAtilde0 : (0 : L (HSum ℋ)) ≤ Atilde := by simpa [Atilde] using blockDiagonal_nonneg (ℋ := ℋ) hA0 hB0 - have hAtilde_spec : spectrum ℝ Atilde ⊆ Set.Ici (0 : ℝ) := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) Atilde (ha := hAtilde_sa)).1 hAtilde0 + have hAtilde_spec : spectrum ℝ Atilde ⊆ Set.Ici (0 : ℝ) := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) Atilde (ha := hAtilde_sa)).1 hAtilde0 have hXtilde_star_mul : star Xtilde * Xtilde = blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 := by diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 93674e3e5..454f026c4 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1363,8 +1363,8 @@ private lemma convexOn_G_rpowIntegrand₀₁_mul {q : NNReal} (hq_real : (q : Real.rpow_nonneg (le_of_lt htpos) _ have hs : Convex ℝ (Set.Ici (0 : 𝓐)) := convex_Ici (𝕜 := ℝ) (0 : 𝓐) have h_aff : ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun X : 𝓐 ↦ X - algebraMap ℝ (𝓐) t) := by - have hid : ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun X : 𝓐 ↦ X) := by - exact convexOn_id (𝕜 := ℝ) (s := Set.Ici (0 : 𝓐)) hs + have hid : ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun X : 𝓐 ↦ X) := + convexOn_id (𝕜 := ℝ) (s := Set.Ici (0 : 𝓐)) hs have hconst : ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun _ : 𝓐 ↦ -algebraMap ℝ (𝓐) t) := convexOn_const (-algebraMap ℝ (𝓐) t) hs simp_all [sub_eq_add_neg] From a075f9d86a56ad8c91fd8ed561d3b8c82f7eeed9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:27:35 -0700 Subject: [PATCH 124/498] refactor: golf Lieb-Ando proof wrappers Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LiebAndoTrace.lean | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean index d50805849..03c670832 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean @@ -147,8 +147,8 @@ private lemma phiK_nonneg (K : L ℋ) {T : L (HSOp ℋ)} (hT : 0 ≤ T) : 0 ≤ phiK (ℋ := ℋ) K T := by dsimp [phiK] have hpos : T.IsPositive := (ContinuousLinearMap.nonneg_iff_isPositive T).1 hT - have hnonneg : 0 ≤ Complex.re (inner ℂ (T (ofOp (star K))) (ofOp (star K))) := by - exact ((ContinuousLinearMap.isPositive_iff_complex T).1 hpos (ofOp (star K))).2 + have hnonneg : 0 ≤ Complex.re (inner ℂ (T (ofOp (star K))) (ofOp (star K))) := + ((ContinuousLinearMap.isPositive_iff_complex T).1 hpos (ofOp (star K))).2 have hre : Complex.re (inner ℂ (ofOp (star K)) (T (ofOp (star K)))) = Complex.re (inner ℂ (T (ofOp (star K))) (ofOp (star K))) := by @@ -309,11 +309,11 @@ private lemma hmiddle_leftMul_rightMul leftMulHS (ℋ := ℋ) (A ^ s) * rightMulHS (ℋ := ℋ) (B ^ (-s)) := by rcases hA with ⟨hA_sa, hA_spec⟩ rcases hB with ⟨hB_sa, hB_spec⟩ - have hA0 : 0 ≤ A := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) - have hB0 : 0 ≤ B := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 + have hB0 : 0 ≤ B := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 (by intro x hx; exact (hB_spec hx).le) have hright_negHalf : cfcR (ℋ := HSOp ℋ) (fun x : ℝ ↦ x ^ ((-1 : ℝ) / 2)) (rightMulHS (ℋ := ℋ) B) = @@ -444,12 +444,12 @@ private lemma hmiddle_leftMul_rightMul · simp [D, hxzero] have hxv0 : Module.End.HasEigenvector T0 α x := ⟨hx0, hxzero⟩ have hxv1 : Module.End.HasEigenvector T1 β x := ⟨hx1, hxzero⟩ - have hαeq : α = (α.re : ℂ) := by - exact (RCLike.conj_eq_iff_re.mp + have hαeq : α = (α.re : ℂ) := + (RCLike.conj_eq_iff_re.mp (hT0_symm.conj_eigenvalue_eq_self (Module.End.hasEigenvalue_of_hasEigenvector hxv0)) ).symm - have hβeq : β = (β.re : ℂ) := by - exact (RCLike.conj_eq_iff_re.mp + have hβeq : β = (β.re : ℂ) := + (RCLike.conj_eq_iff_re.mp (hT1_symm.conj_eigenvalue_eq_self (Module.End.hasEigenvalue_of_hasEigenvector hxv1)) ).symm have hx0r : x ∈ eigenspace T0 (α.re : ℂ) := by @@ -470,12 +470,12 @@ private lemma hmiddle_leftMul_rightMul re_inner_nonneg_of_nonneg (T := rightMulHS (ℋ := ℋ) (B ^ (-1 : ℝ))) (rightMulHS_nonneg (ℋ := ℋ) hBinv0) y - have hαnonneg : 0 ≤ α.re := by - exact eigenvalue_nonneg_of_nonneg + have hαnonneg : 0 ≤ α.re := + eigenvalue_nonneg_of_nonneg (Module.End.hasEigenvalue_of_hasEigenvector ⟨hx0r, hxzero⟩) hT0_nonneg_re - have hβnonneg : 0 ≤ β.re := by - exact eigenvalue_nonneg_of_nonneg + have hβnonneg : 0 ≤ β.re := + eigenvalue_nonneg_of_nonneg (Module.End.hasEigenvalue_of_hasEigenvector ⟨hx1r, hxzero⟩) hT1_nonneg_re have hxprod : @@ -559,11 +559,11 @@ private lemma phiK_operatorPowerMean_eq_liebTraceMap liebTraceMap (ℋ := ℋ) s K A B := by rcases hA with ⟨hA_sa, hA_spec⟩ rcases hB with ⟨hB_sa, hB_spec⟩ - have hA0 : 0 ≤ A := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) - have hB0 : 0 ≤ B := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 + have hB0 : 0 ≤ B := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 (by intro x hx; exact (hB_spec hx).le) have hright_half : cfcR (ℋ := HSOp ℋ) (fun x : ℝ ↦ x ^ ((1 : ℝ) / 2)) (rightMulHS (ℋ := ℋ) B) = @@ -838,8 +838,8 @@ private lemma pdSet_rpow_of_mem_Icc_zero_one {p : ℝ} (hp : p ∈ Set.Icc (0 : ℝ) 1) {A : L ℋ} (hA : A ∈ pdSet (ℋ := ℋ)) : A ^ p ∈ pdSet (ℋ := ℋ) := by rcases hA with ⟨hA_sa, hA_spec⟩ - have hA0 : 0 ≤ A := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) have hApow0 : 0 ≤ A ^ p := by simp @@ -885,14 +885,14 @@ private lemma liebTraceMap_mono_right rcases hA with ⟨hA_sa, hA_spec⟩ rcases hB₁ with ⟨hB₁_sa, hB₁_spec⟩ rcases hB₂ with ⟨hB₂_sa, hB₂_spec⟩ - have hA0 : 0 ≤ A := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) - have hB₁0 : 0 ≤ B₁ := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 + have hB₁0 : 0 ≤ B₁ := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 (by intro x hx; exact (hB₁_spec hx).le) - have hB₂0 : 0 ≤ B₂ := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 + have hB₂0 : 0 ≤ B₂ := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 (by intro x hx; exact (hB₂_spec hx).le) have hcfc := power_Icc_zero_one_operatorMonotoneOn_Ici (ℋ := ℋ) (1 - s) hs @@ -956,8 +956,8 @@ private lemma liebTraceMap_antitone_right rcases hA with ⟨hA_sa, hA_spec⟩ rcases hB₁ with ⟨hB₁_sa, hB₁_spec⟩ rcases hB₂ with ⟨hB₂_sa, hB₂_spec⟩ - have hA0 : 0 ≤ A := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) have hcfc := power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi (ℋ := ℋ) (1 - s) hs @@ -1220,14 +1220,14 @@ theorem liebExtensionTrace_jointlyConcaveOn_pdSet rcases hB₁ with ⟨hB₁_sa, hB₁_spec⟩ rcases hB₂ with ⟨hB₂_sa, hB₂_spec⟩ rcases hB_combo with ⟨hB_combo_sa, hB_combo_spec⟩ - have hB₁0 : 0 ≤ B₁ := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 + have hB₁0 : 0 ≤ B₁ := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 (by intro x hx; exact (hB₁_spec hx).le) - have hB₂0 : 0 ≤ B₂ := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 + have hB₂0 : 0 ≤ B₂ := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 (by intro x hx; exact (hB₂_spec hx).le) - have hBcombo0 : 0 ≤ ((1 - θ) • B₁ + θ • B₂) := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) ((1 - θ) • B₁ + θ • B₂) + have hBcombo0 : 0 ≤ ((1 - θ) • B₁ + θ • B₂) := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) ((1 - θ) • B₁ + θ • B₂) (ha := hB_combo_sa)).2 (by intro x hx; exact (hB_combo_spec hx).le) have hpow_conc := @@ -1281,8 +1281,8 @@ theorem liebExtensionTrace_jointlyConcaveOn_pdSet liebExtensionTraceMap (ℋ := ℋ) q p K A B := by intro A B hB rcases hB with ⟨hB_sa, hB_spec⟩ - have hB0 : 0 ≤ B := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 + have hB0 : 0 ≤ B := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 (by intro x hx; exact (hB_spec hx).le) have hpow : (B ^ β) ^ (1 - q) = B ^ p := by @@ -1346,14 +1346,14 @@ theorem andoTrace_jointlyConvexOn_pdSet rcases hB₁ with ⟨hB₁_sa, hB₁_spec⟩ rcases hB₂ with ⟨hB₂_sa, hB₂_spec⟩ rcases hB_combo with ⟨hB_combo_sa, hB_combo_spec⟩ - have hB₁0 : 0 ≤ B₁ := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 + have hB₁0 : 0 ≤ B₁ := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 (by intro x hx; exact (hB₁_spec hx).le) - have hB₂0 : 0 ≤ B₂ := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 + have hB₂0 : 0 ≤ B₂ := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 (by intro x hx; exact (hB₂_spec hx).le) - have hBcombo0 : 0 ≤ ((1 - θ) • B₁ + θ • B₂) := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) ((1 - θ) • B₁ + θ • B₂) + have hBcombo0 : 0 ≤ ((1 - θ) • B₁ + θ • B₂) := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) ((1 - θ) • B₁ + θ • B₂) (ha := hB_combo_sa)).2 (by intro x hx; exact (hB_combo_spec hx).le) have hpow_conc := @@ -1407,8 +1407,8 @@ theorem andoTrace_jointlyConvexOn_pdSet andoTraceMap (ℋ := ℋ) q r K A B := by intro A B hB rcases hB with ⟨hB_sa, hB_spec⟩ - have hB0 : 0 ≤ B := by - exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 + have hB0 : 0 ≤ B := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 (by intro x hx; exact (hB_spec hx).le) have hBunit : IsUnit B := by refine spectrum.isUnit_of_zero_notMem (R := ℝ) ?_ From 4c9972cd43e9281a46a881c8d2920b93a65f8314 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:30:00 -0700 Subject: [PATCH 125/498] refactor: golf rpow proof wrappers Co-authored-by: Claude Opus 4.8 --- .../JensenOperatorInequalityIImpIV.lean | 4 +- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 52 +++++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean index 882159c4c..740618607 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean @@ -1015,8 +1015,8 @@ theorem theorem_2_5_2_i_all_imp_iv {f : ℝ → ℝ} (hf : CondIAll.{u} f) : have hterm_nonpos : (f 0) • (R0 * R0) ≤ (0 : L ℋ) := by have hR0sq_nonneg : (0 : L ℋ) ≤ R0 * R0 := by simpa [hR0self.star_eq] using star_mul_self_nonneg R0 - have hneg : (0 : L ℋ) ≤ (- (f 0)) • (R0 * R0) := by - exact smul_nonneg (by linarith [hf0]) hR0sq_nonneg + have hneg : (0 : L ℋ) ≤ (- (f 0)) • (R0 * R0) := + smul_nonneg (by linarith [hf0]) hR0sq_nonneg exact (neg_nonneg.mp (by simpa [neg_smul] using hneg)) have htop : cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index fa5f0afa9..cc6463385 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -292,8 +292,8 @@ lemma rpow_kron rw [← rpow_conj_unitary, Matrix.unitary_kron, conj_kron] rw [h_kron_r_pow] subst A B - have h_kron_r_pow_diag : (diagonal ℂ a ⊗ₖ diagonal ℂ b) ^ r = ((diagonal ℂ a) ^ r) ⊗ₖ ((diagonal ℂ b) ^ r) := by - exact rpow_kron_diagonal a b r ha hb + have h_kron_r_pow_diag : (diagonal ℂ a ⊗ₖ diagonal ℂ b) ^ r = ((diagonal ℂ a) ^ r) ⊗ₖ ((diagonal ℂ b) ^ r) := + rpow_kron_diagonal a b r ha hb rw [h_kron_r_pow_diag, Matrix.unitary_kron] rw [rpow_conj_unitary, rpow_conj_unitary, ← conj_kron] @@ -353,8 +353,8 @@ theorem cfc_sq_rpow_eq_cfc_rpow convert rfl; exact cfc_pow A; rw [ h_sqrt ]; - have h_sqrt : ∀ (f g : ℝ → ℝ), Continuous f → Continuous g → ∀ (A : HermitianMat d 𝕜), (A.cfc f).cfc g = A.cfc (fun x => g (f x)) := by - exact fun f g a a A => Eq.symm (cfc_comp_apply A f g); + have h_sqrt : ∀ (f g : ℝ → ℝ), Continuous f → Continuous g → ∀ (A : HermitianMat d 𝕜), (A.cfc f).cfc g = A.cfc (fun x => g (f x)) := + fun f g _ _ A => Eq.symm (cfc_comp_apply A f g); rw [ h_sqrt ]; · have h_sqrt : ∀ x : ℝ, 0 ≤ x → (x ^ 2) ^ (p / 2) = x ^ p := by intro x hx @@ -401,8 +401,8 @@ theorem rpowApprox_mono {A B : HermitianMat d ℂ} (hA : A.mat.PosDef) (hB : B.m · exact hA.add_posSemidef ( Matrix.PosSemidef.smul ( Matrix.PosSemidef.one ) ht.1.le ) · exact add_le_add_left hAB _ exact smul_le_smul_of_nonneg_left (sub_le_sub_left h_inv_antitone _) (Real.rpow_nonneg ht.1.le q) - have h_cont_tq : ContinuousOn (fun t : ℝ => t ^ q) (Set.Icc 0 T) := by - exact continuousOn_id.rpow_const fun _ _ => Or.inr hq + have h_cont_tq : ContinuousOn (fun t : ℝ => t ^ q) (Set.Icc 0 T) := + continuousOn_id.rpow_const fun _ _ => Or.inr hq have h_cont_const : ContinuousOn (fun t : ℝ => (1 + t)⁻¹ • (1 : HermitianMat d ℂ)) (Set.Icc 0 T) := by exact ((continuousOn_const.add continuousOn_id).inv₀ @@ -445,12 +445,12 @@ theorem rpowApprox_eq_cfc_scalar (A : HermitianMat d ℂ) (hA : A.mat.PosDef) (q have h_inv_def : (A + t • 1)⁻¹ = (A.cfc (fun u => u + t))⁻¹ := by rw [ show ( fun u => u + t ) = ( fun u => u ) + fun u => t from rfl, cfc_add ] ; aesop; have h_inv_comp : (A.cfc (fun u => u + t))⁻¹ = A.cfc (fun u => (u + t)⁻¹) := by - have h_inv_smul : ∀ {f : ℝ → ℝ} (hf : ∀ i, f (A.H.eigenvalues i) ≠ 0), (A.cfc f)⁻¹ = A.cfc (fun u => (f u)⁻¹) := by - exact fun {f} hf => inv_cfc_eq_cfc_inv f hf + have h_inv_smul : ∀ {f : ℝ → ℝ} (hf : ∀ i, f (A.H.eigenvalues i) ≠ 0), (A.cfc f)⁻¹ = A.cfc (fun u => (f u)⁻¹) := + fun {f} hf => inv_cfc_eq_cfc_inv f hf apply h_inv_smul intro i - have h_eigenvalue_pos : 0 < A.H.eigenvalues i := by - exact Matrix.PosDef.eigenvalues_pos hA i + have h_eigenvalue_pos : 0 < A.H.eigenvalues i := + Matrix.PosDef.eigenvalues_pos hA i exact ne_of_gt (add_pos h_eigenvalue_pos ht.left); rw [h_inv_def, h_inv_comp]; exact h_inv @@ -463,8 +463,8 @@ theorem rpowApprox_eq_cfc_scalar (A : HermitianMat d ℂ) (hA : A.mat.PosDef) (q have h_integrable : ∀ u : d, IntervalIntegrable (fun t : ℝ => t ^ q * (1 / (1 + t) - 1 / (A.H.eigenvalues u + t))) volume 0 T := by intro u have h_integrable : IntervalIntegrable (fun t : ℝ => t ^ q * (1 / (1 + t) - 1 / (A.H.eigenvalues u + t))) volume 0 T := by - have h_pos : 0 < A.H.eigenvalues u := by - exact Matrix.PosDef.eigenvalues_pos hA u + have h_pos : 0 < A.H.eigenvalues u := + Matrix.PosDef.eigenvalues_pos hA u exact ContinuousOn.intervalIntegrable ( by exact ContinuousOn.mul ( continuousOn_id.rpow_const fun x hx => Or.inr <| by linarith ) <| ContinuousOn.sub ( continuousOn_const.div ( continuousOn_const.add continuousOn_id ) fun x hx => by linarith [ Set.mem_Icc.mp <| by simpa [ hT.le ] using hx ] ) ( continuousOn_const.div ( continuousOn_const.add continuousOn_id ) fun x hx => by linarith [ Set.mem_Icc.mp <| by simpa [ hT.le ] using hx ] ) ) ..; exact h_integrable exact integral_cfc_eq_cfc_integral _ _ _ h_integrable @@ -485,8 +485,8 @@ lemma rpowConst_integrableOn (hq : 0 < q) (hq1 : q < 1) : IntegrableOn (fun u : ℝ => u ^ (q - 1) / (1 + u)) (Set.Ioi 0) := by rw [← Set.Ioc_union_Ioi_eq_Ioi zero_le_one] apply IntegrableOn.union - · have h_integrable_0_1 : IntegrableOn (fun u : ℝ => u ^ (q - 1)) (Set.Ioc 0 1) := by - exact ( intervalIntegral.intervalIntegrable_rpow' ( by linarith ) ).1; + · have h_integrable_0_1 : IntegrableOn (fun u : ℝ => u ^ (q - 1)) (Set.Ioc 0 1) := + ( intervalIntegral.intervalIntegrable_rpow' ( by linarith ) ).1; apply h_integrable_0_1.mono' · apply Measurable.aestronglyMeasurable fun_prop @@ -517,8 +517,8 @@ open MeasureTheory in lemma rpowConst_pos (hq : 0 < q) (hq1 : q < 1) : 0 < rpowConst q := by unfold rpowConst; have h_nonzero : 0 < ∫ u in Set.Ioi (0 : ℝ), u ^ (q - 1) / (1 + u) := by - have h_integrable : IntegrableOn (fun u : ℝ => u ^ (q - 1) / (1 + u)) (Set.Ioi (0 : ℝ)) := by - exact rpowConst_integrableOn hq hq1 + have h_integrable : IntegrableOn (fun u : ℝ => u ^ (q - 1) / (1 + u)) (Set.Ioi (0 : ℝ)) := + rpowConst_integrableOn hq hq1 rw [ integral_pos_iff_support_of_nonneg_ae ]; · simp [Function.support] exact lt_of_lt_of_le ( by norm_num ) ( measure_mono <| show Set.Ioi ( 0 : ℝ ) ⊆ { x : ℝ | ¬x ^ ( q - 1 ) = 0 ∧ ¬1 + x = 0 } ∩ Set.Ioi 0 from fun x hx => ⟨ ⟨ ne_of_gt <| Real.rpow_pos_of_pos hx _, ne_of_gt <| add_pos zero_lt_one hx ⟩, hx ⟩ ); @@ -616,8 +616,8 @@ theorem rpow_le_rpow_of_posDef (hA : A.mat.PosDef) (hAB : A ≤ B) convert le_of_tendsto_of_tendsto ( tendsto_rpowApprox hA hq ( lt_of_le_of_ne hq1 hq_eq_one ) ) ( tendsto_rpowApprox ( posDef_of_posDef_le hA hAB ) hq ( lt_of_le_of_ne hq1 hq_eq_one ) ) _ using 1 generalize_proofs at *; ( filter_upwards [ Filter.eventually_gt_atTop 0 ] with T hT using rpowApprox_mono hA ( posDef_of_posDef_le hA hAB ) hAB hq.le T hT |> le_trans <| by aesop;); - have h_rpow_pos : 0 < rpowConst q := by - exact rpowConst_pos hq ( lt_of_le_of_ne hq1 hq_eq_one ); + have h_rpow_pos : 0 < rpowConst q := + rpowConst_pos hq ( lt_of_le_of_ne hq1 hq_eq_one ); simp_all open ComplexOrder Filter in @@ -641,16 +641,16 @@ theorem rpow_le_rpow_of_le (hA : 0 ≤ A) (hAB : A ≤ B) ring_nf simp [ Matrix.mulVec, dotProduct, Finset.mul_sum _ _ _, mul_assoc, mul_left_comm]; simp [ Matrix.one_apply] - have h_inner_nonneg : 0 ≤ star x ⬝ᵥ A.mat.mulVec x := by - exact inner_mulVec_nonneg hA x + have h_inner_nonneg : 0 ≤ star x ⬝ᵥ A.mat.mulVec x := + inner_mulVec_nonneg hA x have h_inner_pos : 0 < star x ⬝ᵥ x := by simp_all exact h_inner.symm ▸ add_pos_of_nonneg_of_pos h_inner_nonneg ( mul_pos ( mod_cast hε_pos ) ( mod_cast h_inner_pos ) ) |> lt_of_lt_of_le <| le_rfl; have h_pos_def_Bε : (Bε ε).mat.PosDef := by convert posDef_of_posDef_le h_pos_def_Aε _ using 1 exact add_le_add_left hAB _ |> le_trans ( by simp [ Aε ] ) ; - have h_le_Aε_Bε : Aε ε ≤ Bε ε := by - exact add_le_add_left hAB _ |> le_trans <| by simp [ Bε ] ; + have h_le_Aε_Bε : Aε ε ≤ Bε ε := + add_le_add_left hAB _ |> le_trans <| by simp [ Bε ] ; exact ⟨h_pos_def_Aε, h_pos_def_Bε, h_le_Aε_Bε⟩ -- By the continuity of the function $M \mapsto M^q$, we have $(Aε ε)^q \to A^q$ and $(Bε ε)^q \to B^q$ as $\epsilon \to 0^+$. have h_cont : Filter.Tendsto (fun ε => (Aε ε) ^ q) (nhdsWithin 0 (Set.Ioi 0)) (nhds (A ^ q)) ∧ Filter.Tendsto (fun ε => (Bε ε) ^ q) (nhdsWithin 0 (Set.Ioi 0)) (nhds (B ^ q)) := by @@ -659,8 +659,8 @@ theorem rpow_le_rpow_of_le (hA : 0 ≤ A) (hAB : A ≤ B) apply rpow_const_continuous hq.le |> Continuous.continuousOn refine' ⟨ h_cont.continuousAt ( by simp ) |> fun h => h.tendsto.comp ( tendsto_nhdsWithin_of_tendsto_nhds <| Continuous.tendsto' _ _ _ _ ), h_cont.continuousAt ( by simp ) |> fun h => h.tendsto.comp ( tendsto_nhdsWithin_of_tendsto_nhds <| Continuous.tendsto' _ _ _ _ ) ⟩ <;> continuity; -- By the continuity of the function $M \mapsto M^q$, we have $(Aε ε)^q \leq (Bε ε)^q$ for all $\epsilon > 0$. - have h_le : ∀ ε > 0, (Aε ε) ^ q ≤ (Bε ε) ^ q := by - exact fun ε hε => rpow_le_rpow_of_posDef ( h_pos_def ε hε |>.1 ) ( h_pos_def ε hε |>.2.2 ) hq hq1 |> le_trans <| by simp [ * ] ; + have h_le : ∀ ε > 0, (Aε ε) ^ q ≤ (Bε ε) ^ q := + fun ε hε => rpow_le_rpow_of_posDef ( h_pos_def ε hε |>.1 ) ( h_pos_def ε hε |>.2.2 ) hq hq1 |> le_trans <| by simp [ * ] ; exact le_of_tendsto_of_tendsto h_cont.1 h_cont.2 ( Filter.eventually_of_mem self_mem_nhdsWithin fun ε hε => h_le ε hε ) |> fun h => by simpa using h; end LoewnerHeinz @@ -1223,8 +1223,8 @@ private lemma trace_mul_inv_shift_eq_sum_div {A : HermitianMat d ℂ} (hA : 0 _ = ∑ i, A.H.eigenvalues i / (A.H.eigenvalues i + t) := by refine Finset.sum_congr rfl ?_ intro i hi - have hpos : 0 < A.H.eigenvalues i + t := by - exact add_pos_of_nonneg_of_pos (by simpa using (zero_le_iff.mp hA).eigenvalues_nonneg i) ht + have hpos : 0 < A.H.eigenvalues i + t := + add_pos_of_nonneg_of_pos (by simpa using (zero_le_iff.mp hA).eigenvalues_nonneg i) ht rw [show ((↑(A.H.eigenvalues i) + ↑t : ℂ)) = ↑(A.H.eigenvalues i + t) by simp, Complex.normSq_ofReal] field_simp [hpos.ne', div_eq_mul_inv] From 9d1c36d7f4021693368a7513691c3e2b8e1136f6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:32:31 -0700 Subject: [PATCH 126/498] refactor: golf entropy resource proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/SSA.lean | 16 ++++++++-------- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 4 ++-- QuantumInfo/ResourceTheory/SteinsLemma.lean | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 537605bd8..673e80967 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -778,8 +778,8 @@ theorem intermediate_ineq [Nonempty dA] [Nonempty dB] [Nonempty dC] convert! S_mat_conj_rhs_eq_one ρAB σBC hρ hσ using 1; · have := S_mat_isUnit ρAB σBC hρ hσ; cases' this.nonempty_invertible with u hu; - have h_pos_semidef : Matrix.PosSemidef ((S_mat ρAB σBC)⁻¹ * (S_mat ρAB σBC * ((ρAB.traceRight ⊗ₖ σBC⁻¹).reindex (Equiv.prodAssoc dA dB dC).symm).mat * S_mat ρAB σBC - S_mat ρAB σBC * (ρAB ⊗ₖ (σBC.traceLeft)⁻¹).mat * S_mat ρAB σBC) * (S_mat ρAB σBC)⁻¹ᴴ) := by - exact Matrix.PosSemidef.mul_mul_conjTranspose_same h (S_mat ρAB σBC)⁻¹; + have h_pos_semidef : Matrix.PosSemidef ((S_mat ρAB σBC)⁻¹ * (S_mat ρAB σBC * ((ρAB.traceRight ⊗ₖ σBC⁻¹).reindex (Equiv.prodAssoc dA dB dC).symm).mat * S_mat ρAB σBC - S_mat ρAB σBC * (ρAB ⊗ₖ (σBC.traceLeft)⁻¹).mat * S_mat ρAB σBC) * (S_mat ρAB σBC)⁻¹ᴴ) := + Matrix.PosSemidef.mul_mul_conjTranspose_same h (S_mat ρAB σBC)⁻¹; simp_all [ Matrix.mul_assoc, Matrix.sub_mul, Matrix.mul_sub ]; simp_all [ Matrix.posSemidef_iff_dotProduct_mulVec, Matrix.IsHermitian ]; have h_conj : (S_mat ρAB σBC)ᴴ = S_mat ρAB σBC := by @@ -983,8 +983,8 @@ private lemma MState.approx_by_pd constructor <;> simp_all · simp_all [ Matrix.IsHermitian, Matrix.conjTranspose_add, Matrix.conjTranspose_smul ]; · intro x hx_ne_zero - have h_pos : 0 < (1 - ε) * (star x ⬝ᵥ A *ᵥ x) + ε * (star x ⬝ᵥ B *ᵥ x) := by - exact add_pos_of_nonneg_of_pos ( mul_nonneg ( sub_nonneg.2 <| mod_cast hε.2.le ) <| mod_cast hA.2 x ) <| mul_pos ( mod_cast hε.1 ) <| mod_cast hB.2 hx_ne_zero; + have h_pos : 0 < (1 - ε) * (star x ⬝ᵥ A *ᵥ x) + ε * (star x ⬝ᵥ B *ᵥ x) := + add_pos_of_nonneg_of_pos ( mul_nonneg ( sub_nonneg.2 <| mod_cast hε.2.le ) <| mod_cast hA.2 x ) <| mul_pos ( mod_cast hε.1 ) <| mod_cast hB.2 hx_ne_zero; convert h_pos using 1 ; simp [ Matrix.add_mulVec ] ; ring_nf! simp [ Matrix.mulVec, dotProduct, Finset.mul_sum _ _ _, mul_assoc, mul_left_comm, sub_mul, mul_sub ] ; ring!; convert! h_pos_def _ _ _ _ _ ⟨ _, _ ⟩ <;> norm_num [ * ]; @@ -994,8 +994,8 @@ private lemma MState.approx_by_pd · exact one_div_pos.mpr ( by linarith ); · exact div_lt_one ( by positivity ) |>.2 ( by linarith ) · -- Show that the sequence ρn converges to ρ. - have h_conv : Filter.Tendsto (fun n => εn n • (MState.uniform : MState d₁).M + (1 - εn n) • ρ.M) Filter.atTop (nhds ρ.M) := by - exact le_trans ( Filter.Tendsto.add ( Filter.Tendsto.smul ( tendsto_const_nhds.div_atTop <| Filter.tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop ) tendsto_const_nhds ) ( Filter.Tendsto.smul ( tendsto_const_nhds.sub <| tendsto_const_nhds.div_atTop <| Filter.tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop ) tendsto_const_nhds ) ) ( by simp ); + have h_conv : Filter.Tendsto (fun n => εn n • (MState.uniform : MState d₁).M + (1 - εn n) • ρ.M) Filter.atTop (nhds ρ.M) := + le_trans ( Filter.Tendsto.add ( Filter.Tendsto.smul ( tendsto_const_nhds.div_atTop <| Filter.tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop ) tendsto_const_nhds ) ( Filter.Tendsto.smul ( tendsto_const_nhds.sub <| tendsto_const_nhds.div_atTop <| Filter.tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop ) tendsto_const_nhds ) ) ( by simp ); rw [ tendsto_iff_dist_tendsto_zero ] at *; convert h_conv using 1; ext n; simp [ρn, Mixable.mix]; @@ -1007,8 +1007,8 @@ private lemma MState.traceLeft_continuous : Continuous (MState.traceLeft : MState (d₁ × d₂) → MState d₂) := by -- Since the matrix traceLeft is continuous, the function that maps a state to its partial trace is also continuous. have h_traceLeft_cont : Continuous (fun ρ : HermitianMat (d₁ × d₂) ℂ => ρ.traceLeft) := by - have h_cont : Continuous (fun ρ : Matrix (d₁ × d₂) (d₁ × d₂) ℂ => ρ.traceLeft) := by - exact continuous_pi fun _ => continuous_pi fun _ => continuous_finsetSum _ fun _ _ => continuous_apply _ |> Continuous.comp <| continuous_apply _ |> Continuous.comp <| continuous_id'; + have h_cont : Continuous (fun ρ : Matrix (d₁ × d₂) (d₁ × d₂) ℂ => ρ.traceLeft) := + continuous_pi fun _ => continuous_pi fun _ => continuous_finsetSum _ fun _ _ => continuous_apply _ |> Continuous.comp <| continuous_apply _ |> Continuous.comp <| continuous_id'; convert h_cont.comp ( show Continuous fun ρ : HermitianMat ( d₁ × d₂ ) ℂ => ρ.1 from ?_ ) using 1; · constructor <;> intro h <;> rw [ continuous_induced_rng ] at * <;> aesop; · fun_prop; diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 6a38f2cfd..fbad15bc6 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -785,8 +785,8 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} exact ⟨ _, h_spectrum_subset, fun B hB => fun x hx => by simpa [ dist_eq_norm ] using Metric.mem_thickening_iff.mp ( hB hx ) ⟩) generalize_proofs at *; ( refine' ⟨ U, hU.1, fun B hB => _ ⟩ - have h_diff_small : ∀ x ∈ spectrum ℝ B.mat, |g x - h x| ≤ ε / (Real.sqrt (Fintype.card d) + 1) := by - exact fun x hx => le_of_lt ( hδ x ( hB.2 hx ) _ ( hU.2 B hB.1 hx |> Classical.choose_spec |> And.left ) ( hU.2 B hB.1 hx |> Classical.choose_spec |> And.right ) ) |> le_trans <| by norm_num; + have h_diff_small : ∀ x ∈ spectrum ℝ B.mat, |g x - h x| ≤ ε / (Real.sqrt (Fintype.card d) + 1) := + fun x hx => le_of_lt ( hδ x ( hB.2 hx ) _ ( hU.2 B hB.1 hx |> Classical.choose_spec |> And.left ) ( hU.2 B hB.1 hx |> Classical.choose_spec |> And.right ) ) |> le_trans <| by norm_num; generalize_proofs at *; ( have h_diff_small : ‖B.cfc g - B.cfc h‖ ≤ Real.sqrt (Fintype.card d) * (ε / (Real.sqrt (Fintype.card d) + 1)) := by apply_rules [ norm_cfc_sub_le_of_sup_le ]; diff --git a/QuantumInfo/ResourceTheory/SteinsLemma.lean b/QuantumInfo/ResourceTheory/SteinsLemma.lean index 6db4c8b62..65e586fbf 100644 --- a/QuantumInfo/ResourceTheory/SteinsLemma.lean +++ b/QuantumInfo/ResourceTheory/SteinsLemma.lean @@ -577,8 +577,8 @@ private lemma f_image_bound (mineig : ℝ) (n : ℕ) (h : 0 < mineig) (hn : 0 < -- Since the interval [mineig^n / 3, 1] is closed and bounded, and the function Real.log x / (Real.log (1 / mineig) + Real.log 3 / (max n 1)) is continuous on this interval, it must attain a maximum and minimum value on this interval. have h_cont : ContinuousOn (fun x => Real.log x / (Real.log (1 / mineig) + Real.log 3 / (max n 1))) (Set.Icc (mineig^n / 3) 1) := by -- Since Real.log x is continuous on the interval (0, ∞) and the denominator is a non-zero constant, the function Real.log x / (Real.log (1 / mineig) + Real.log 3 / (max n 1)) is continuous on the interval [mineig^n / 3, 1]. - have h_cont : ContinuousOn Real.log (Set.Icc (mineig^n / 3) 1) := by - exact continuousOn_of_forall_continuousAt fun x hx => Real.continuousAt_log ( by linarith [ hx.1, pow_pos h n ] ); + have h_cont : ContinuousOn Real.log (Set.Icc (mineig^n / 3) 1) := + continuousOn_of_forall_continuousAt fun x hx => Real.continuousAt_log ( by linarith [ hx.1, pow_pos h n ] ); exact h_cont.div_const _; exact ⟨ ( InfSet.sInf <| ( fun x => Real.log x / ( Real.log ( 1 / mineig ) + Real.log 3 / ( max n 1 ) ) ) '' Set.Icc ( mineig ^ n / 3 ) 1 ), ( SupSet.sSup <| ( fun x => Real.log x / ( Real.log ( 1 / mineig ) + Real.log 3 / ( max n 1 ) ) ) '' Set.Icc ( mineig ^ n / 3 ) 1 ), fun x hx => ⟨ ( csInf_le <| IsCompact.bddBelow <| isCompact_Icc.image_of_continuousOn h_cont ) <| Set.mem_image_of_mem _ hx, ( le_csSup <| IsCompact.bddAbove <| isCompact_Icc.image_of_continuousOn h_cont ) <| Set.mem_image_of_mem _ hx ⟩ ⟩; obtain ⟨ m, M, hM ⟩ := h_bounded @@ -611,8 +611,8 @@ private lemma f_image_bound (mineig : ℝ) (n : ℕ) (h : 0 < mineig) (hn : 0 < · gcongr; · have := h_f_le n 1 ; norm_num at this ; linarith [ Real.log_le_sub_one_of_pos h ]; · -- Taking the logarithm of both sides of the inequality $mineig^n / 3 \leq w$, we get $n \log(mineig) - \log(3) \leq \log(w)$. - have h_log : Real.log (mineig^n / 3) ≤ Real.log w := by - exact Real.log_le_log ( by positivity ) left; + have h_log : Real.log (mineig^n / 3) ≤ Real.log w := + Real.log_le_log ( by positivity ) left; rwa [ Real.log_div ( by positivity ) ( by positivity ), Real.log_pow ] at h_log; · refine' Int.ceil_le.mpr _; rw [ div_le_iff₀ ] @@ -647,8 +647,8 @@ private lemma c'_bounded {mineig : ℝ} {ε2 : ℕ → ℝ≥0} (∀ (n : ℕ), 0 < c n) → ∃ (C : NNReal), ∀ᶠ (n : ℕ) in Filter.atTop, c' (↑(ε2 n)) n ≤ ↑C := by have h_bound : ∃ C : ℝ, ∀ᶠ n in Filter.atTop, Real.log (1 / mineig) + Real.log 3 / (Max.max n 1) + (Real.log (1 / mineig) + Real.log 3 / (Max.max n 1)) / n ≤ C := by - have h_bound : Filter.Tendsto (fun n => Real.log (1 / mineig) + Real.log 3 / (Max.max n 1) + (Real.log (1 / mineig) + Real.log 3 / (Max.max n 1)) / n) Filter.atTop (nhds (Real.log (1 / mineig) + Real.log 3 / 0 + (Real.log (1 / mineig) + Real.log 3 / 0) / 0)) := by - exact le_trans ( Filter.Tendsto.add ( tendsto_const_nhds.add <| Filter.Tendsto.mul tendsto_const_nhds <| Filter.Tendsto.inv_tendsto_atTop <| Filter.tendsto_atTop_atTop.mpr fun x => ⟨ x + 1, fun y hy => le_max_of_le_left <| by linarith ⟩ ) <| Filter.Tendsto.mul ( tendsto_const_nhds.add <| Filter.Tendsto.mul tendsto_const_nhds <| Filter.Tendsto.inv_tendsto_atTop <| Filter.tendsto_atTop_atTop.mpr fun x => ⟨ x + 1, fun y hy => le_max_of_le_left <| by linarith ⟩ ) <| tendsto_inv_atTop_zero ) <| by norm_num; + have h_bound : Filter.Tendsto (fun n => Real.log (1 / mineig) + Real.log 3 / (Max.max n 1) + (Real.log (1 / mineig) + Real.log 3 / (Max.max n 1)) / n) Filter.atTop (nhds (Real.log (1 / mineig) + Real.log 3 / 0 + (Real.log (1 / mineig) + Real.log 3 / 0) / 0)) := + le_trans ( Filter.Tendsto.add ( tendsto_const_nhds.add <| Filter.Tendsto.mul tendsto_const_nhds <| Filter.Tendsto.inv_tendsto_atTop <| Filter.tendsto_atTop_atTop.mpr fun x => ⟨ x + 1, fun y hy => le_max_of_le_left <| by linarith ⟩ ) <| Filter.Tendsto.mul ( tendsto_const_nhds.add <| Filter.Tendsto.mul tendsto_const_nhds <| Filter.Tendsto.inv_tendsto_atTop <| Filter.tendsto_atTop_atTop.mpr fun x => ⟨ x + 1, fun y hy => le_max_of_le_left <| by linarith ⟩ ) <| tendsto_inv_atTop_zero ) <| by norm_num; exact ⟨ _, h_bound.eventually ( ge_mem_nhds <| lt_add_one _ ) ⟩; intro c c' a simp_all only [one_div, Real.log_inv, Filter.eventually_atTop, Nat.cast_max, Nat.cast_one, @@ -1837,8 +1837,8 @@ theorem Lemma7 (ρ : MState (H i)) {ε : Prob} (hε : 0 < ε ∧ ε < 1) (σ : ( rw [heq] simp only [Set.range_comp, MState.mat_M, EquivLike.range_eq_univ, Set.image_univ, ge_iff_le] let S : Set ℝ := (fun x => Real.exp (f_map i n x)) '' Set.Icc ((σ₁_mineig i ^ n) / 3) 1 - have h_card_subs : Set.ncard S ≤ n + 1 ∧ S.Finite := by - exact f_image_bound (σ₁_mineig i) n (mineig_pos i) hn (log_le_f i) (f_le_log i) + have h_card_subs : Set.ncard S ≤ n + 1 ∧ S.Finite := + f_image_bound (σ₁_mineig i) n (mineig_pos i) hn (log_le_f i) (f_le_log i) let S₂ : Set ℝ := (fun x => (σ''_unnormalized ρ ε m σ n).trace⁻¹ * Real.exp (f_map i n x)) '' Set.Icc ((σ₁_mineig i ^ n) / 3) 1 obtain ⟨h_card_subs₂, h_s₂_finite⟩ : Set.ncard S₂ ≤ n + 1 ∧ S₂.Finite := by have hS₂ : S₂ = ((σ''_unnormalized ρ ε m σ n).trace⁻¹ * ·) '' S := by From b3ffabe7acda31bf6ebd3fc6b9d25b5337b0eac0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:34:39 -0700 Subject: [PATCH 127/498] refactor: golf relative entropy proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 65 +++++++++++++++---------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 301eac200..eaae1ec58 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -697,13 +697,13 @@ private lemma scalar_rpow_cross_term_of_continuous {b : ℝ → ℝ} {c : ℝ} ring_nf norm_num [ hc ] -- Use the fact that $b(1 + t) \to c$ as $t \to 0$. - have h_b : Filter.Tendsto (fun t => b (1 + t)) (nhdsWithin 0 {0}ᶜ) (nhds c) := by - exact hc ▸ hb_cont.tendsto.comp ( tendsto_nhdsWithin_of_tendsto_nhds ( by norm_num [ Filter.Tendsto ] ) ); + have h_b : Filter.Tendsto (fun t => b (1 + t)) (nhdsWithin 0 {0}ᶜ) (nhds c) := + hc ▸ hb_cont.tendsto.comp ( tendsto_nhdsWithin_of_tendsto_nhds ( by norm_num [ Filter.Tendsto ] ) ); -- Use the fact that $b(1 + t)^t - 1 \sim t \log(b(1 + t))$ as $t \to 0$. have h_exp : Filter.Tendsto (fun t => t⁻¹ * (b (1 + t) ^ t - 1)) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := by have h_exp : Filter.Tendsto (fun t => (b (1 + t) ^ t - 1) / t) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := by - have h_log : Filter.Tendsto (fun t => (Real.log (b (1 + t)) * t) / t) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := by - exact Filter.Tendsto.congr' ( by filter_upwards [ self_mem_nhdsWithin ] with t ht using by rw [ mul_div_cancel_right₀ _ ht ] ) ( Filter.Tendsto.log h_b hc_pos.ne' ) + have h_log : Filter.Tendsto (fun t => (Real.log (b (1 + t)) * t) / t) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := + Filter.Tendsto.congr' ( by filter_upwards [ self_mem_nhdsWithin ] with t ht using by rw [ mul_div_cancel_right₀ _ ht ] ) ( Filter.Tendsto.log h_b hc_pos.ne' ) have h_exp : Filter.Tendsto (fun t => (Real.exp (Real.log (b (1 + t)) * t) - 1) / t) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := by have h_exp : HasDerivAt (fun t => Real.exp (Real.log (b (1 + t)) * t)) (Real.log c) 0 := by have h_log : HasDerivAt (fun t => Real.log (b (1 + t)) * t) (Real.log c) 0 := by @@ -758,8 +758,8 @@ private lemma scalar_rpow_cross_term_of_continuous_zero {b : ℝ → ℝ} have h_sqrt_log : Filter.Tendsto (fun x => Real.sqrt x * Real.log x) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by -- Let $y = \sqrt{x}$, so we can rewrite the limit as $\lim_{y \to 0^+} y \log(y^2) = \lim_{y \to 0^+} 2y \log(y)$. suffices h_log_y : Filter.Tendsto (fun y => 2 * y * Real.log y) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) by - have h_subst : Filter.Tendsto (fun x => 2 * Real.sqrt x * Real.log (Real.sqrt x)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by - exact h_log_y.comp <| Filter.Tendsto.inf ( Real.continuous_sqrt.tendsto' _ _ <| by norm_num ) <| Filter.tendsto_principal_principal.mpr fun x hx => Real.sqrt_pos.mpr hx; + have h_subst : Filter.Tendsto (fun x => 2 * Real.sqrt x * Real.log (Real.sqrt x)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := + h_log_y.comp <| Filter.Tendsto.inf ( Real.continuous_sqrt.tendsto' _ _ <| by norm_num ) <| Filter.tendsto_principal_principal.mpr fun x hx => Real.sqrt_pos.mpr hx; generalize_proofs at *; ( exact h_subst.congr' ( Filter.eventuallyEq_of_mem self_mem_nhdsWithin fun x hx => by rw [ Real.log_sqrt hx.out.le ] ; ring ) |> fun h => h.trans ( by norm_num ) ;); exact tendsto_nhdsWithin_of_tendsto_nhds ( by simpa [ mul_assoc ] using Filter.Tendsto.const_mul 2 ( Real.continuous_mul_log.tendsto 0 ) ) |> fun h => h.trans ( by norm_num ) ; @@ -842,11 +842,10 @@ private lemma B_of_continuousAt (ρ σ : MState d) (h : σ.M.ker ≤ ρ.M.ker) : ContinuousAt (B_of ρ σ) 1 := by -- Use the fact that the composition of continuous functions is continuous. have h_cont : ContinuousAt (fun α : ℝ => ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) 1 := by - have h_inner : ContinuousAt (fun r : ℝ => ρ.M.conj (σ.M ^ r).mat) 0 := by - -- Apply the hypothesis `h_cont` directly to conclude the proof. - exact conj_rpow_continuousAt_zero σ.M ρ.M h - have h_exp : ContinuousAt (fun α : ℝ => (1 - α) / (2 * α)) 1 := by - exact ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by norm_num ) + have h_inner : ContinuousAt (fun r : ℝ => ρ.M.conj (σ.M ^ r).mat) 0 := + conj_rpow_continuousAt_zero σ.M ρ.M h + have h_exp : ContinuousAt (fun α : ℝ => (1 - α) / (2 * α)) 1 := + ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by norm_num ) exact ContinuousAt.comp ( by simpa using h_inner ) h_exp |> ContinuousAt.congr <| Filter.eventuallyEq_of_mem ( Ioi_mem_nhds zero_lt_one ) fun x hx ↦ by aesop; exact h_cont @@ -863,8 +862,8 @@ private lemma eigenvalues_bounded_near {M : ℝ → HermitianMat d ℂ} (hM_nonneg : ∀ᶠ α in nhds 1, 0 ≤ M α) (hM_cont : ContinuousAt M 1) : ∃ K > 0, ∀ᶠ α in nhds 1, ∀ i, 0 ≤ (M α).H.eigenvalues i ∧ (M α).H.eigenvalues i ≤ K := by - have h_op_norm_bound : ∃ K > 0, ∀ᶠ α in nhds 1, ‖M α‖ ≤ K := by - exact ⟨ ‖M 1‖ + 1, by positivity, hM_cont.norm.eventually ( ge_mem_nhds ( lt_add_one _ ) ) ⟩ + have h_op_norm_bound : ∃ K > 0, ∀ᶠ α in nhds 1, ‖M α‖ ≤ K := + ⟨ ‖M 1‖ + 1, by positivity, hM_cont.norm.eventually ( ge_mem_nhds ( lt_add_one _ ) ) ⟩ have h_eigenvalue_bound : ∀ᶠ α in nhds 1, ∀ i, 0 ≤ (M α).H.eigenvalues i ∧ (M α).H.eigenvalues i ≤ ‖M α‖ := by have h_eigenvalue_bound : ∀ᶠ α in nhds 1, ∀ i, |(M α).H.eigenvalues i| ≤ ‖M α‖ := by filter_upwards [ hM_nonneg, h_op_norm_bound.choose_spec.2 ] with α hα₁ hα₂ i @@ -884,8 +883,8 @@ private lemma rpow_slope_tendsto_uniformly (K : ℝ) : intro ε ε_pos obtain ⟨δ₁, δ₁_pos, hδ₁⟩ : ∃ δ₁ > 0, ∀ x ∈ Set.Icc 0 K, 0 < x → x < δ₁ → |x * Real.log x| < ε / 4 ∧ ∀ h, 0 < |h| → |h| < 1 / 2 → |(x ^ (1 + h) - x) / h| < ε / 4 := by obtain ⟨δ₁, δ₁_pos, hδ₁⟩ : ∃ δ₁ > 0, ∀ x ∈ Set.Icc 0 K, 0 < x → x < δ₁ → |x * Real.log x| < ε / 4 := by - have h_cont : Filter.Tendsto (fun x => x * Real.log x) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by - exact tendsto_nhdsWithin_of_tendsto_nhds ( by simpa using Real.continuous_mul_log.tendsto 0 ); + have h_cont : Filter.Tendsto (fun x => x * Real.log x) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := + tendsto_nhdsWithin_of_tendsto_nhds ( by simpa using Real.continuous_mul_log.tendsto 0 ); have := Metric.tendsto_nhdsWithin_nhds.mp h_cont ( ε / 4 ) ( by linarith ); exact ⟨ this.choose, this.choose_spec.1, fun x hx₁ hx₂ hx₃ => by simpa [ abs_mul ] using this.choose_spec.2 hx₂ ( by simpa [ abs_of_pos hx₂ ] using hx₃ ) ⟩; have h_bound : ∃ δ₁ > 0, ∀ x ∈ Set.Icc 0 K, 0 < x → x < δ₁ → ∀ h, 0 < |h| → |h| < 1 / 2 → |x ^ (1 + h) - x| ≤ |h| * x * (|Real.log x| + 1) * Real.exp (|h| * (|Real.log x| + 1)) := by @@ -911,8 +910,8 @@ private lemma rpow_slope_tendsto_uniformly (K : ℝ) : have h_bound : Filter.Tendsto (fun x => x * (|Real.log x| + 1) * Real.exp (1 / 2 * (|Real.log x| + 1))) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by -- Let $y = -\log x$, so we can rewrite the limit as $y \to \infty$. suffices h_log : Filter.Tendsto (fun y => Real.exp (-y) * (y + 1) * Real.exp ((y + 1) / 2)) Filter.atTop (nhds 0) by - have h_subst : Filter.Tendsto (fun x => Real.exp (-(-Real.log x)) * ((-Real.log x) + 1) * Real.exp ((-Real.log x + 1) / 2)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by - exact h_log.comp ( Filter.tendsto_neg_atBot_atTop.comp ( Real.tendsto_log_nhdsNE_zero.mono_left <| nhdsWithin_mono _ <| by norm_num ) ); + have h_subst : Filter.Tendsto (fun x => Real.exp (-(-Real.log x)) * ((-Real.log x) + 1) * Real.exp ((-Real.log x + 1) / 2)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := + h_log.comp ( Filter.tendsto_neg_atBot_atTop.comp ( Real.tendsto_log_nhdsNE_zero.mono_left <| nhdsWithin_mono _ <| by norm_num ) ); refine' h_subst.congr' _; filter_upwards [ Ioo_mem_nhdsGT_of_mem ⟨ le_rfl, zero_lt_one ⟩ ] with x hx rw [ abs_of_nonpos ( Real.log_nonpos hx.1.le hx.2.le ) ] @@ -963,8 +962,8 @@ private lemma rpow_slope_tendsto_uniformly (K : ℝ) : obtain ⟨δ₂, δ₂_pos, hδ₂⟩ : ∃ δ₂ > 0, ∀ x ∈ Set.Icc δ₁ K, ∀ h, 0 < |h| → |h| < δ₂ → |h| * x * (Real.log x) ^ 2 * Real.exp (|h| * |Real.log x|) < ε / 4 := by -- Since $x * (\log x)^2 * \exp(|h| * |\log x|)$ is continuous on the compact interval $[\delta₁, K]$, it is bounded. obtain ⟨M, hM⟩ : ∃ M > 0, ∀ x ∈ Set.Icc δ₁ K, ∀ h, 0 < |h| → |h| < 1 / 2 → x * (Real.log x) ^ 2 * Real.exp (|h| * |Real.log x|) ≤ M := by - have h_cont : ContinuousOn (fun x => x * (Real.log x) ^ 2 * Real.exp (1 / 2 * |Real.log x|)) (Set.Icc δ₁ K) := by - exact ContinuousOn.mul ( ContinuousOn.mul continuousOn_id ( ContinuousOn.pow ( Real.continuousOn_log.mono ( by exact fun x hx => ne_of_gt <| lt_of_lt_of_le δ₁_pos hx.1 ) ) _ ) ) ( ContinuousOn.rexp <| ContinuousOn.mul continuousOn_const <| ContinuousOn.abs <| Real.continuousOn_log.mono ( by exact fun x hx => ne_of_gt <| lt_of_lt_of_le δ₁_pos hx.1 ) ); + have h_cont : ContinuousOn (fun x => x * (Real.log x) ^ 2 * Real.exp (1 / 2 * |Real.log x|)) (Set.Icc δ₁ K) := + ContinuousOn.mul ( ContinuousOn.mul continuousOn_id ( ContinuousOn.pow ( Real.continuousOn_log.mono ( by exact fun x hx => ne_of_gt <| lt_of_lt_of_le δ₁_pos hx.1 ) ) _ ) ) ( ContinuousOn.rexp <| ContinuousOn.mul continuousOn_const <| ContinuousOn.abs <| Real.continuousOn_log.mono ( by exact fun x hx => ne_of_gt <| lt_of_lt_of_le δ₁_pos hx.1 ) ); obtain ⟨ M, hM ⟩ := IsCompact.exists_bound_of_continuousOn ( CompactIccSpace.isCompact_Icc ) h_cont; norm_num +zetaDelta at *; exact ⟨ Max.max M 1, by positivity, fun x hx₁ hx₂ h hh₁ hh₂ => le_trans ( by rw [ abs_of_nonneg ( by linarith : 0 ≤ x ) ] ; exact mul_le_mul_of_nonneg_left ( Real.exp_le_exp.mpr <| by nlinarith [ abs_nonneg ( Real.log x ) ] ) <| by nlinarith [ abs_nonneg ( Real.log x ) ] ) <| le_trans ( hM x hx₁ hx₂ ) <| le_max_left _ _ ⟩; @@ -1659,8 +1658,8 @@ private theorem sandwichedRelRentropy.continuousOn_Ioi_1_aux (ρ σ : MState d) have h_cont : ContinuousOn (fun α : ℝ => (HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M) (Set.Ioi 1) := by have h_cont : ContinuousOn (fun α : ℝ => (σ.M ^ ((1 - α) / (2 * α))).mat) (Set.Ioi 1) := by have h_cont : ContinuousOn (fun α : ℝ => σ.M ^ ((1 - α) / (2 * α))) (Set.Ioi 1) := by - have h_cont : ContinuousOn (fun α : ℝ => (1 - α) / (2 * α)) (Set.Ioi 1) := by - exact continuousOn_of_forall_continuousAt fun x hx => ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by linarith [ hx.out ] ) + have h_cont : ContinuousOn (fun α : ℝ => (1 - α) / (2 * α)) (Set.Ioi 1) := + continuousOn_of_forall_continuousAt fun x hx => ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by linarith [ hx.out ] ) have h_cont : ContinuousOn (fun α : ℝ => (σ.M ^ α)) (Set.Iio 0) := by apply_rules [ HermitianMat.continuousOn_rpow_neg ]; exact h_cont.comp ‹_› fun x hx => by rw [ Set.mem_Iio ] ; rw [ div_lt_iff₀ ] <;> linarith [ hx.out ] ; @@ -1706,8 +1705,8 @@ private theorem sandwichedRelRentropy.continuousOn_Ioo_0_1_aux (ρ σ : MState d have h_cont : ContinuousOn (fun α : ℝ => (HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M) (Set.Ioo 0 1) := by have h_cont : ContinuousOn (fun α : ℝ => (σ.M ^ ((1 - α) / (2 * α))).mat) (Set.Ioo 0 1) := by have h_cont : ContinuousOn (fun α : ℝ => σ.M ^ ((1 - α) / (2 * α))) (Set.Ioo 0 1) := by - have h_exp_cont : ContinuousOn (fun α : ℝ => (1 - α) / (2 * α)) (Set.Ioo 0 1) := by - exact continuousOn_of_forall_continuousAt fun x hx => ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by linarith [ hx.1 ] ) + have h_exp_cont : ContinuousOn (fun α : ℝ => (1 - α) / (2 * α)) (Set.Ioo 0 1) := + continuousOn_of_forall_continuousAt fun x hx => ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by linarith [ hx.1 ] ) have h_rpow_cont : ContinuousOn (fun α : ℝ => (σ.M ^ α)) (Set.Ioi 0) := by apply_rules [ HermitianMat.continuousOn_rpow_pos ] exact h_rpow_cont.comp h_exp_cont fun x hx => by rw [ Set.mem_Ioi ] ; apply div_pos <;> linarith [ hx.1, hx.2 ] @@ -1755,8 +1754,8 @@ private theorem sandwichedRelRentropy.continuousAt_1 (ρ σ : MState d) : · simp only [ContinuousWithinAt, SandwichedRelRentropy, dif_pos h, zero_lt_one, if_true] -- Use the fact that the limit of the real-valued function is the inner product. have h_real_limit : Filter.Tendsto (fun α : ℝ => if α = 1 then ⟪ρ.M, ρ.M.log - σ.M.log⟫ else Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1)) (nhdsWithin 1 (Set.Ioi 0)) (nhds ⟪ρ.M, ρ.M.log - σ.M.log⟫) := by - have h_real_limit : Filter.Tendsto (fun α : ℝ => Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1)) (nhdsWithin 1 (Set.Ioi 0 \ {1})) (nhds ⟪ρ.M, ρ.M.log - σ.M.log⟫) := by - exact sandwichedRelRentropy.limit_at_one ρ σ h + have h_real_limit : Filter.Tendsto (fun α : ℝ => Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1)) (nhdsWithin 1 (Set.Ioi 0 \ {1})) (nhds ⟪ρ.M, ρ.M.log - σ.M.log⟫) := + sandwichedRelRentropy.limit_at_one ρ σ h rw [ Metric.tendsto_nhdsWithin_nhds ] at * intro ε hε rcases h_real_limit ε hε with ⟨δ, hδ, H⟩ @@ -1764,8 +1763,8 @@ private theorem sandwichedRelRentropy.continuousAt_1 (ρ σ : MState d) : intro x hx₁ hx₂ by_cases hx₃ : x = 1 <;> simp [*] -- Since the real-valued function tends to the inner product, the ENNReal version should also tend to the same limit because the ENNReal conversion is continuous. - have h_ennreal_limit : Filter.Tendsto (fun α : ℝ => ENNReal.ofReal (if α = 1 then ⟪ρ.M, ρ.M.log - σ.M.log⟫ else Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1))) (nhdsWithin 1 (Set.Ioi 0)) (nhds (ENNReal.ofReal ⟪ρ.M, ρ.M.log - σ.M.log⟫)) := by - exact (ENNReal.tendsto_ofReal h_real_limit).comp Filter.tendsto_id + have h_ennreal_limit : Filter.Tendsto (fun α : ℝ => ENNReal.ofReal (if α = 1 then ⟪ρ.M, ρ.M.log - σ.M.log⟫ else Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1))) (nhdsWithin 1 (Set.Ioi 0)) (nhds (ENNReal.ofReal ⟪ρ.M, ρ.M.log - σ.M.log⟫)) := + (ENNReal.tendsto_ofReal h_real_limit).comp Filter.tendsto_id convert h_ennreal_limit.congr' _ using 2 · symm apply ENNReal.ofReal_eq_coe_nnreal @@ -2019,8 +2018,8 @@ private lemma ker_le_iff_eigenWeight_zero (ρ x : MState d) : private lemma neg_ker_exists_eigenWeight_pos (ρ x : MState d) (hx : ¬(x.M.ker ≤ ρ.M.ker)) : ∃ i, x.M.H.eigenvalues i = 0 ∧ 0 < eigenWeight ρ x i := by -- By `ker_le_iff_eigenWeight_zero`, ¬(x.M.ker ≤ ρ.M.ker) iff ∃ i, eigenvalue_i = 0 ∧ eigenWeight ≠ 0. Use this fact. - have h_eigenWeight_ne_zero : ∃ i, x.M.H.eigenvalues i = 0 ∧ eigenWeight ρ x i ≠ 0 := by - exact Classical.not_forall_not.1 fun h => hx <| by simpa using ker_le_iff_eigenWeight_zero ρ x |>.2 fun i hi => Classical.not_not.1 fun hi' => h i ⟨ hi, hi' ⟩ ; + have h_eigenWeight_ne_zero : ∃ i, x.M.H.eigenvalues i = 0 ∧ eigenWeight ρ x i ≠ 0 := + Classical.not_forall_not.1 fun h => hx <| by simpa using ker_le_iff_eigenWeight_zero ρ x |>.2 fun i hi => Classical.not_not.1 fun hi' => h i ⟨ hi, hi' ⟩ ; exact h_eigenWeight_ne_zero.imp fun i hi => ⟨ hi.1, lt_of_le_of_ne ( eigenWeight_nonneg ρ x i ) hi.2.symm ⟩ private lemma approxLog_at_zero (N : ℕ) : approxLog N 0 = -(N : ℝ) := by @@ -2054,8 +2053,8 @@ theorem qRelativeEnt_lowerSemicontinuous_2 (ρ x : MState d) (hx : ¬(x.M.ker -- Since $y < \top$, we can choose a neighborhood around $x$ where the inner product is less than $y$. have h_inner_lt_y : ∀ᶠ x' in nhds x, x'.M.ker ≤ ρ.M.ker → ⟪ρ.M, ρ.M.log - x'.M.log⟫ > y.toReal := by have h_inner_lt_y : Filter.Tendsto (fun N : ℕ => ⟪ρ.M, ρ.M.log - x.M.cfc (approxLog N)⟫) Filter.atTop Filter.atTop := by - have h_inner_lt_y : Filter.Tendsto (fun N : ℕ => ⟪ρ.M, ρ.M.log⟫ - ⟪ρ.M, x.M.cfc (approxLog N)⟫) Filter.atTop Filter.atTop := by - exact Filter.Tendsto.add_atTop tendsto_const_nhds ( Filter.tendsto_neg_atBot_atTop.comp ( inner_cfc_approxLog_tendsto_bot ρ x hx ) ) |> Filter.Tendsto.congr ( by aesop ) ; + have h_inner_lt_y : Filter.Tendsto (fun N : ℕ => ⟪ρ.M, ρ.M.log⟫ - ⟪ρ.M, x.M.cfc (approxLog N)⟫) Filter.atTop Filter.atTop := + Filter.Tendsto.add_atTop tendsto_const_nhds ( Filter.tendsto_neg_atBot_atTop.comp ( inner_cfc_approxLog_tendsto_bot ρ x hx ) ) |> Filter.Tendsto.congr ( by aesop ) ; convert h_inner_lt_y using 1 ext1 N simp [inner_sub_right] @@ -2064,8 +2063,8 @@ theorem qRelativeEnt_lowerSemicontinuous_2 (ρ x : MState d) (hx : ¬(x.M.ker have h_cont : Continuous (fun σ : MState d => ⟪ρ.M, ρ.M.log - σ.M.cfc (approxLog N)⟫) := by simp only [inner_sub_right] exact continuous_const.sub (continuous_inner_cfc_approxLog ρ N) - have h_cont : ∀ᶠ x' in nhds x, ⟪ρ.M, ρ.M.log - x'.M.cfc (approxLog N)⟫ > y.toReal := by - exact h_cont.continuousAt.eventually ( lt_mem_nhds hN ) |> fun h => h.mono fun x' hx' => hx' |> fun hx'' => by simpa using hx''; + have h_cont : ∀ᶠ x' in nhds x, ⟪ρ.M, ρ.M.log - x'.M.cfc (approxLog N)⟫ > y.toReal := + h_cont.continuousAt.eventually ( lt_mem_nhds hN ) |> fun h => h.mono fun x' hx' => hx' |> fun hx'' => by simpa using hx''; filter_upwards [h_cont] with x' hx' hx'' apply lt_of_lt_of_le hx' have h_inner_le : ⟪ρ.M, x'.M.log⟫ ≤ ⟪ρ.M, x'.M.cfc (approxLog N)⟫ := From 0541ca01aae6a35050ed5661ef4ad15ca3e25913 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:38:41 -0700 Subject: [PATCH 128/498] refactor: golf HermitianMat rfl proofs Co-authored-by: Claude Opus 4.8 --- .../ForMathlib/HermitianMat/Basic.lean | 51 +++++++------------ QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 6 +-- .../ForMathlib/HermitianMat/Inner.lean | 3 +- .../ForMathlib/HermitianMat/Jordan.lean | 3 +- QuantumInfo/ForMathlib/HermitianMat/Proj.lean | 12 ++--- .../ForMathlib/HermitianMat/Reindex.lean | 3 +- .../ForMathlib/HermitianMat/Trace.lean | 6 +-- .../ForMathlib/HermitianMat/Unitary.lean | 3 +- 8 files changed, 29 insertions(+), 58 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean index 538e6bb83..34bb8007e 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean @@ -28,8 +28,7 @@ section addgroup variable [AddGroup α] [StarAddMonoid α] -theorem eq_IsHermitian : HermitianMat n α = { m : Matrix n n α // m.IsHermitian} := by - rfl +theorem eq_IsHermitian : HermitianMat n α = { m : Matrix n n α // m.IsHermitian} := rfl @[coe] def mat : HermitianMat n α → Matrix n n α := Subtype.val @@ -37,16 +36,13 @@ theorem eq_IsHermitian : HermitianMat n α = { m : Matrix n n α // m.IsHermiti instance : Coe (HermitianMat n α) (Matrix n n α) := ⟨mat⟩ @[simp] -theorem val_eq_coe (A : HermitianMat n α) : A.val = A := by - rfl +theorem val_eq_coe (A : HermitianMat n α) : A.val = A := rfl @[simp] -theorem mat_mk (x : Matrix n n α) (h) : mat ⟨x, h⟩ = x := by - rfl +theorem mat_mk (x : Matrix n n α) (h) : mat ⟨x, h⟩ = x := rfl @[simp] -theorem mk_mat {A : HermitianMat n α} (h : A.mat.IsHermitian) : ⟨A.mat, h⟩ = A := by - rfl +theorem mk_mat {A : HermitianMat n α} (h : A.mat.IsHermitian) : ⟨A.mat, h⟩ = A := rfl /-- Alias for HermitianMat.property or HermitianMat.2, this gets the fact that the value is actually `IsHermitian`.-/ @@ -61,8 +57,7 @@ instance instFun : FunLike (HermitianMat n α) n (n → α) where coe_injective _ _ h := HermitianMat.ext h @[simp] -theorem mat_apply {A : HermitianMat n α} {i j : n} : A.mat i j = A i j := by - rfl +theorem mat_apply {A : HermitianMat n α} {i j : n} : A.mat i j = A i j := rfl @[simp] theorem conjTranspose_mat (A : HermitianMat n α) : @@ -77,16 +72,13 @@ instance [IsEmpty n] : Unique (HermitianMat n α) where uniq a := by ext; exact (IsEmpty.false ‹_›).elim @[simp, norm_cast] -theorem mat_zero : (0 : HermitianMat n α).mat = 0 := by - rfl +theorem mat_zero : (0 : HermitianMat n α).mat = 0 := rfl @[simp] -theorem mk_zero (h : (0 : Matrix n n α).IsHermitian) : ⟨0, h⟩ = (0 : HermitianMat n α) := by - rfl +theorem mk_zero (h : (0 : Matrix n n α).IsHermitian) : ⟨0, h⟩ = (0 : HermitianMat n α) := rfl @[simp] -theorem zero_apply (i j : n) : (0 : HermitianMat n 𝕜) i j = 0 := by - rfl +theorem zero_apply (i j : n) : (0 : HermitianMat n 𝕜) i j = 0 := rfl @[simp, norm_cast] theorem mat_add (A B : HermitianMat n α) : @@ -223,16 +215,13 @@ instance : One (HermitianMat n α) := Matrix.one_apply, apply_ite (β := α), eq_comm]⟩ @[simp, norm_cast] -theorem mat_one : (1 : HermitianMat n α).mat = 1 := by - rfl +theorem mat_one : (1 : HermitianMat n α).mat = 1 := rfl @[simp] -theorem mk_one (h : (1 : Matrix n n α).IsHermitian) : ⟨1, h⟩ = (1 : HermitianMat n α) := by - rfl +theorem mk_one (h : (1 : Matrix n n α).IsHermitian) : ⟨1, h⟩ = (1 : HermitianMat n α) := rfl @[simp] -theorem one_apply (i j : n) : (1 : HermitianMat n α) i j = (1 : Matrix n n α) i j := by - rfl +theorem one_apply (i j : n) : (1 : HermitianMat n α) i j = (1 : Matrix n n α) i j := rfl noncomputable instance : AddCommMonoidWithOne (HermitianMat n 𝕜) where @@ -251,8 +240,7 @@ noncomputable instance instInv : Inv (HermitianMat m α) := ⟨fun x ↦ ⟨x⁻¹, x.H.inv⟩⟩ @[simp, norm_cast] -theorem mat_inv : (A⁻¹).mat = A.mat⁻¹ := by - rfl +theorem mat_inv : (A⁻¹).mat = A.mat⁻¹ := rfl @[simp] theorem zero_inv : ((0 : HermitianMat m α)⁻¹) = 0 := by @@ -266,8 +254,7 @@ noncomputable instance instPow : Pow (HermitianMat m α) ℕ := ⟨fun x n ↦ ⟨x ^ n, x.H.pow n⟩⟩ @[simp, norm_cast] -theorem mat_pow (n : ℕ) : (A ^ n).mat = A.mat ^ n := by - rfl +theorem mat_pow (n : ℕ) : (A ^ n).mat = A.mat ^ n := rfl @[simp] theorem pow_zero : A ^ 0 = 1 := by @@ -285,12 +272,10 @@ noncomputable instance instZPow : Pow (HermitianMat m α) ℤ := ⟨fun x z ↦ ⟨x ^ z, x.H.zpow z⟩⟩ @[simp] -theorem mat_zpow (z : ℤ) : (A ^ z).mat = A.mat ^ z := by - rfl +theorem mat_zpow (z : ℤ) : (A ^ z).mat = A.mat ^ z := rfl @[simp, norm_cast] -theorem zpow_natCast : A ^ (n : ℤ) = A ^ n := by - rfl +theorem zpow_natCast : A ^ (n : ℤ) = A ^ n := rfl @[simp] theorem zpow_zero : A ^ (0 : ℤ) = 1 := by @@ -411,8 +396,7 @@ def conjLinear {m} (B : Matrix m n α) : HermitianMat n α →ₗ[R] HermitianMa simp @[simp] -theorem conjLinear_apply (B : Matrix m n α) : conjLinear R B A = conj B A := by - rfl +theorem conjLinear_apply (B : Matrix m n α) : conjLinear R B A = conj B A := rfl @[fun_prop] lemma continuous_conj (ρ : HermitianMat n 𝕜) : Continuous (ρ.conj (m := m) ·) := by @@ -517,8 +501,7 @@ def diagonal (f : n → ℝ) : HermitianMat n 𝕜 := variable (f g : n → ℝ) @[simp] -theorem diagonal_mat : (diagonal 𝕜 f).mat = Matrix.diagonal (f · : n → 𝕜) := by - rfl +theorem diagonal_mat : (diagonal 𝕜 f).mat = Matrix.diagonal (f · : n → 𝕜) := rfl @[simp] theorem diagonal_zero : (diagonal 𝕜 0) = (0 : HermitianMat n 𝕜) := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index fbad15bc6..64d0511d2 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -50,12 +50,10 @@ theorem conjTranspose_cfc : (cfc f A.mat).conjTranspose = cfc f A.mat := protected def cfc : HermitianMat d 𝕜 := ⟨cfc f A.mat, cfc_predicate _ _⟩ -theorem cfc_eq : A.cfc f = ⟨cfc f A.mat, cfc_predicate f A.mat⟩ := by - rfl +theorem cfc_eq : A.cfc f = ⟨cfc f A.mat, cfc_predicate f A.mat⟩ := rfl @[simp] -theorem mat_cfc : (A.cfc f).mat = _root_.cfc f A.mat := by - rfl +theorem mat_cfc : (A.cfc f).mat = _root_.cfc f A.mat := rfl section congr diff --git a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean index a7278fad0..7ede72550 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean @@ -162,8 +162,7 @@ open ComplexOrder variable {n 𝕜 : Type*} [Fintype n] [RCLike 𝕜] (A B C : HermitianMat n 𝕜) -theorem inner_eq_re_trace : ⟪A, B⟫ = RCLike.re (A.mat * B.mat).trace := by - rfl +theorem inner_eq_re_trace : ⟪A, B⟫ = RCLike.re (A.mat * B.mat).trace := rfl theorem inner_eq_trace_rc : ⟪A, B⟫ = (A.mat * B.mat).trace := by rw [inner_eq_re_trace, ← RCLike.conj_eq_iff_re] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean b/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean index cf43f296d..8b96bddaa 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean @@ -97,8 +97,7 @@ scoped instance : CommMagma (HermitianMat d 𝕜) where -- scoped instance : Mul (HermitianMat d 𝕜) := -- CommMagma.toMul -theorem mul_eq_symmMul : A * B = A.symmMul B := by - rfl +theorem mul_eq_symmMul : A * B = A.symmMul B := rfl scoped instance : IsCommJordan (HermitianMat d 𝕜) where lmul_comm_rmul_rmul a b := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean index 0b6f301fe..f9c1ca789 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean @@ -230,11 +230,9 @@ scoped notation "{" A " ≤ₚ " B "}" => projLE A B scoped notation "{" A " >ₚ " B "}" => projLT B A scoped notation "{" A " <ₚ " B "}" => projLT A B -theorem projLE_def : {A ≤ₚ B} = (B - A).cfc (fun x ↦ if 0 ≤ x then 1 else 0) := by - rfl +theorem projLE_def : {A ≤ₚ B} = (B - A).cfc (fun x ↦ if 0 ≤ x then 1 else 0) := rfl -theorem projLT_def : {A <ₚ B} = (B - A).cfc (fun x ↦ if 0 < x then 1 else 0) := by - rfl +theorem projLT_def : {A <ₚ B} = (B - A).cfc (fun x ↦ if 0 < x then 1 else 0) := rfl theorem projLE_sq : {A ≤ₚ B}^2 = {A ≤ₚ B} := by rw [projLE_def, ← cfc_pow, ← cfc_comp] @@ -334,11 +332,9 @@ instance : PosPart (HermitianMat n 𝕜) where instance : NegPart (HermitianMat n 𝕜) where negPart A := A.cfc (fun x ↦ -x ⊔ 0) -theorem posPart_eq_cfc_max : A⁺ = A.cfc (fun x ↦ x ⊔ 0) := by - rfl +theorem posPart_eq_cfc_max : A⁺ = A.cfc (fun x ↦ x ⊔ 0) := rfl -theorem negPart_eq_cfc_min : A⁻ = A.cfc (fun x ↦ -x ⊔ 0) := by - rfl +theorem negPart_eq_cfc_min : A⁻ = A.cfc (fun x ↦ -x ⊔ 0) := rfl theorem posPart_eq_cfc_ite : A⁺ = A.cfc (fun x ↦ if 0 ≤ x then x else 0) := by simp only [← max_def', posPart_eq_cfc_max] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Reindex.lean b/QuantumInfo/ForMathlib/HermitianMat/Reindex.lean index 9cc20aea9..51c4c39b6 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Reindex.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Reindex.lean @@ -28,8 +28,7 @@ def reindex (e : d ≃ d₂) : HermitianMat d₂ 𝕜 := ⟨A.mat.reindex e e, A.H.submatrix e.symm⟩ @[simp] -theorem mat_reindex : (A.reindex e).mat = A.mat.reindex e e := by - rfl +theorem mat_reindex : (A.reindex e).mat = A.mat.reindex e e := rfl /-! Our simp-normal form for expressions involving `HermitianMat.reindex` is that we try to push the reindexing as far out as possible, so that it can be absorbed by `HermitianMat.trace`, or diff --git a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean index 3df4fc059..173fe1372 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean @@ -117,8 +117,7 @@ section RCLike variable {n m 𝕜 : Type*} [Fintype n] [Fintype m] [RCLike 𝕜] -theorem trace_eq_re_trace (A : HermitianMat n 𝕜) : A.trace = RCLike.re A.mat.trace := by - rfl +theorem trace_eq_re_trace (A : HermitianMat n 𝕜) : A.trace = RCLike.re A.mat.trace := rfl @[simp] theorem trace_one [DecidableEq n] : (1 : HermitianMat n 𝕜).trace = Fintype.card n := by @@ -172,8 +171,7 @@ def traceRight (A : HermitianMat (m × n) α) : HermitianMat m α := variable (A B : HermitianMat (m × n) α) @[simp] -theorem traceLeft_mat : A.traceLeft.mat = A.mat.traceLeft := by - rfl +theorem traceLeft_mat : A.traceLeft.mat = A.mat.traceLeft := rfl @[simp] theorem traceLeft_add : (A + B).traceLeft = A.traceLeft + B.traceLeft := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Unitary.lean b/QuantumInfo/ForMathlib/HermitianMat/Unitary.lean index feab49853..2290d4894 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Unitary.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Unitary.lean @@ -20,8 +20,7 @@ variable {α : Type*} [NonUnitalNonAssocSemiring α] [StarRing α] variable {α β : Type*} [DecidableEq α] [Fintype α] [DecidableEq β] [Fintype β] @[simp] -theorem neg_unitary_val (u : 𝐔[α]) : (-u).val = -u := by - rfl +theorem neg_unitary_val (u : 𝐔[α]) : (-u).val = -u := rfl omit [DecidableEq α] [Fintype α] [DecidableEq β] [Fintype β] in open Kronecker in From dd97890e2c9c13c7998f9c4ba0240ba6f48294e5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:42:26 -0700 Subject: [PATCH 129/498] refactor: golf QuantumInfo rfl proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/CPTP.lean | 3 +-- QuantumInfo/ClassicalInfo/Distribution.lean | 9 +++------ QuantumInfo/ClassicalInfo/Prob.lean | 6 ++---- .../ForMathlib/IsMaximalSelfAdjoint.lean | 3 +-- QuantumInfo/ForMathlib/LinearEquiv.lean | 3 +-- QuantumInfo/ForMathlib/ULift.lean | 3 +-- QuantumInfo/ResourceTheory/FreeState.lean | 9 +++------ QuantumInfo/States/Ensemble.lean | 3 +-- QuantumInfo/States/Mixed/MState.lean | 18 ++++++------------ QuantumInfo/States/Pure/Braket.lean | 3 +-- QuantumInfo/States/Pure/Qubit.lean | 12 ++++-------- 11 files changed, 24 insertions(+), 48 deletions(-) diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index 6e89dff55..6c957967b 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -154,8 +154,7 @@ def id : CPTPMap dIn dIn where /-- The map `CPTPMap.id` leaves any matrix unchanged. -/ @[simp] -theorem id_map : (id (dIn := dIn)).map = LinearMap.id := by - rfl +theorem id_map : (id (dIn := dIn)).map = LinearMap.id := rfl /-- The map `CPTPMap.id` leaves the input state unchanged. -/ @[simp] diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 7ec3fd2f0..6d8056ceb 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -87,12 +87,10 @@ def constant (x : α) : ProbDistribution α := ⟨fun y ↦ if x = y then 1 else 0, by simp [apply_ite]⟩ -theorem constant_def (x : α) : (constant x : α → Prob) = fun y ↦ if x = y then 1 else 0 := by - rfl +theorem constant_def (x : α) : (constant x : α → Prob) = fun y ↦ if x = y then 1 else 0 := rfl @[simp] -theorem constant_eq (x : α) : constant x y = if x = y then 1 else 0 := by - rfl +theorem constant_eq (x : α) : constant x y = if x = y then 1 else 0 := rfl @[simp] theorem constant_def' (x y : α) : (constant x : α → Prob) y = if x = y then 1 else 0 := by @@ -181,8 +179,7 @@ def congr (σ : α ≃ β) : ProbDistribution α ≃ ProbDistribution β := by simp only [← fun_eq_val, Equiv.apply_symm_apply, Subtype.coe_eta] @[simp] -theorem congr_apply (σ : α ≃ β) (d : ProbDistribution α) (j : β): (congr σ d) j = d (σ.symm j) := by - rfl +theorem congr_apply (σ : α ≃ β) (d : ProbDistribution α) (j : β): (congr σ d) j = d (σ.symm j) := rfl /-- The inverse and congruence operations for distributions commute -/ @[simp] diff --git a/QuantumInfo/ClassicalInfo/Prob.lean b/QuantumInfo/ClassicalInfo/Prob.lean index ab934e428..47b02dd15 100644 --- a/QuantumInfo/ClassicalInfo/Prob.lean +++ b/QuantumInfo/ClassicalInfo/Prob.lean @@ -170,8 +170,7 @@ instance instSub : Sub Prob where simpa using le_add_of_le_of_nonneg p.2.2 q.2.1 ⟩ -theorem coe_sub (p q : Prob) : (p - q : Prob) = (p.val - q.val) ⊔ (0 : ℝ) := by - rfl +theorem coe_sub (p q : Prob) : (p - q : Prob) = (p.val - q.val) ⊔ (0 : ℝ) := rfl @[simp, norm_cast] theorem coe_one_minus (p : Prob) : (1 - p : Prob) = 1 - (p : ℝ) := by @@ -200,8 +199,7 @@ instance : Nontrivial Prob where exists_pair_ne := ⟨0, 1, by simp [← Prob.ne_iff]⟩ @[simp] -theorem top_eq_one : (⊤ : Prob) = 1 := by - rfl +theorem top_eq_one : (⊤ : Prob) = 1 := rfl @[simp] theorem sub_zero (p : Prob) : p - 0 = p := by diff --git a/QuantumInfo/ForMathlib/IsMaximalSelfAdjoint.lean b/QuantumInfo/ForMathlib/IsMaximalSelfAdjoint.lean index 113394d4a..558f91b57 100644 --- a/QuantumInfo/ForMathlib/IsMaximalSelfAdjoint.lean +++ b/QuantumInfo/ForMathlib/IsMaximalSelfAdjoint.lean @@ -58,7 +58,6 @@ theorem trivial_selfadjMap {R} [Star R] [TrivialStar R] [CommSemiring R] : rfl @[simp] -theorem RCLike_selfadjMap {α} [RCLike α] : (selfadjMap : α →+ ℝ) = RCLike.re := by - rfl +theorem RCLike_selfadjMap {α} [RCLike α] : (selfadjMap : α →+ ℝ) = RCLike.re := rfl end IsMaximalSelfAdjoint diff --git a/QuantumInfo/ForMathlib/LinearEquiv.lean b/QuantumInfo/ForMathlib/LinearEquiv.lean index 144eb99e1..866a33729 100644 --- a/QuantumInfo/ForMathlib/LinearEquiv.lean +++ b/QuantumInfo/ForMathlib/LinearEquiv.lean @@ -61,8 +61,7 @@ def euclidean_of_relabel (e : d ≃ d₂) : EuclideanSpace 𝕜 d₂ ≃ₗ[𝕜 (WithLp.linearEquiv 2 𝕜 _).trans ((of_relabel _ e).trans (WithLp.linearEquiv 2 𝕜 _).symm) @[simp] -theorem of_relabel_refl : of_relabel R (.refl d) = LinearEquiv.refl R (d → R) := by - rfl +theorem of_relabel_refl : of_relabel R (.refl d) = LinearEquiv.refl R (d → R) := rfl @[simp] theorem euclidean_of_relabel_refl : euclidean_of_relabel 𝕜 (.refl d) = diff --git a/QuantumInfo/ForMathlib/ULift.lean b/QuantumInfo/ForMathlib/ULift.lean index 82195f7de..6c4c4170a 100644 --- a/QuantumInfo/ForMathlib/ULift.lean +++ b/QuantumInfo/ForMathlib/ULift.lean @@ -28,8 +28,7 @@ instance ULift.instStar {𝕜 : Type u} [Star 𝕜] : Star (ULift.{v,u} 𝕜) wh star x := .up (star x.down) @[simp] -theorem ULift.star_eq {𝕜 : Type u} [Star 𝕜] (x : ULift.{v,u} 𝕜) : star x = .up (star x.down) := by - rfl +theorem ULift.star_eq {𝕜 : Type u} [Star 𝕜] (x : ULift.{v,u} 𝕜) : star x = .up (star x.down) := rfl instance ULift.instInvolutiveStar {𝕜 : Type u} [InvolutiveStar 𝕜] : InvolutiveStar (ULift.{v,u} 𝕜) where diff --git a/QuantumInfo/ResourceTheory/FreeState.lean b/QuantumInfo/ResourceTheory/FreeState.lean index 1140fb184..acd2db3a8 100644 --- a/QuantumInfo/ResourceTheory/FreeState.lean +++ b/QuantumInfo/ResourceTheory/FreeState.lean @@ -193,15 +193,13 @@ noncomputable def spacePow (i : ι) (n : ℕ) : ι := scoped notation i "⊗^H[" n "]" => spacePow i n @[simp] -theorem spacePow_zero (i : ι) : i ^ 0 = 1 := by - rfl +theorem spacePow_zero (i : ι) : i ^ 0 = 1 := rfl @[simp] theorem spacePow_one (i : ι) : i ^ 1 = i := by simp -theorem spacePow_succ (i : ι) (n : ℕ) : i ^ (n + 1) = (i ^ n) * i := by - rfl +theorem spacePow_succ (i : ι) (n : ℕ) : i ^ (n + 1) = (i ^ n) * i := rfl theorem spacePow_add (m n : ℕ) : i ^ (m + n) = (i ^ m) * (i ^ n) := by @@ -233,8 +231,7 @@ theorem statePow_one (ρ : MState (H i)) : ρ ⊗ᵣ^[1] ≍ ρ := by · rw [eq_cast_iff_heq, statePow] exact default_prod ρ -theorem statePow_succ (ρ : MState (H i)) (n : ℕ) : ρ ⊗ᵣ^[n + 1] = ρ ⊗ᵣ^[n] ⊗ᵣ ρ := by - rfl +theorem statePow_succ (ρ : MState (H i)) (n : ℕ) : ρ ⊗ᵣ^[n + 1] = ρ ⊗ᵣ^[n] ⊗ᵣ ρ := rfl theorem statePow_add (ρ : MState (H i)) (m n : ℕ) : ρ ⊗ᵣ^[m + n] ≍ ρ ⊗ᵣ^[m] ⊗ᵣ ρ ⊗ᵣ^[n] := by rw [← eq_cast_iff_heq]; swap diff --git a/QuantumInfo/States/Ensemble.lean b/QuantumInfo/States/Ensemble.lean index 621e1fe4a..bab656ee9 100644 --- a/QuantumInfo/States/Ensemble.lean +++ b/QuantumInfo/States/Ensemble.lean @@ -118,8 +118,7 @@ theorem average_of_pure_ensemble {T : Type _} {U : Type*} [AddCommGroup U] [Modu variable {ψ : Ket d} @[simp] -theorem distr_toMEnsemble (e : PEnsemble d α) : (toMEnsemble e).distr = e.distr := by - rfl +theorem distr_toMEnsemble (e : PEnsemble d α) : (toMEnsemble e).distr = e.distr := rfl /- A pure-state ensemble mixes into a pure state if and only if diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 40b6ea367..3cc324f87 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -83,8 +83,7 @@ attribute [simp] MState.tr def m (ρ : MState d) : Matrix d d ℂ := ρ.M.mat @[simp] -theorem mat_M : ρ.M.mat = ρ.m := by - rfl +theorem mat_M : ρ.M.mat = ρ.m := rfl theorem pos (ρ : MState d) : 0 < ρ.M := by apply ρ.nonneg.lt_of_ne' @@ -191,8 +190,7 @@ theorem inner_def : ⟪ρ, σ⟫_Prob = ⟨⟪ρ.M, σ.M⟫, (inner_le_mul_trace ρ.nonneg σ.nonneg).trans (by simp)⟩ := by rfl -theorem val_inner : (⟪ρ, σ⟫_Prob : ℝ) = ⟪ρ.M, σ.M⟫ := by - rfl +theorem val_inner : (⟪ρ, σ⟫_Prob : ℝ) = ⟪ρ.M, σ.M⟫ := rfl section exp_val @@ -290,8 +288,7 @@ theorem pure_inner : ⟪pure ψ, pure φ⟫_Prob = ‖Braket.dot ψ φ‖^2 := b Complex.normSq_eq_norm_sq (((ψ : Bra d) : d → ℂ) ⬝ᵥ (φ : d → ℂ)) @[simp] -theorem pure_apply {i j : d} : (pure ψ).m i j = (ψ i) * conj (ψ j) := by - rfl +theorem pure_apply {i j : d} : (pure ψ).m i j = (ψ i) * conj (ψ j) := rfl theorem pure_mul_self : (pure ψ).m * (pure ψ).m = (pure ψ : Matrix d d ℂ) := by dsimp [pure, MState.m] @@ -1187,12 +1184,10 @@ def assoc' (ρ : MState (d₁ × d₂ × d₃)) : MState ((d₁ × d₂) × d₃ ρ.SWAP.assoc.SWAP.assoc.SWAP @[simp] -theorem assoc_assoc' (ρ : MState (d₁ × d₂ × d₃)) : ρ.assoc'.assoc = ρ := by - rfl +theorem assoc_assoc' (ρ : MState (d₁ × d₂ × d₃)) : ρ.assoc'.assoc = ρ := rfl @[simp] -theorem assoc'_assoc (ρ : MState ((d₁ × d₂) × d₃)) : ρ.assoc.assoc' = ρ := by - rfl +theorem assoc'_assoc (ρ : MState ((d₁ × d₂) × d₃)) : ρ.assoc.assoc' = ρ := rfl @[simp] theorem traceLeft_right_assoc (ρ : MState ((d₁ × d₂) × d₃)) : @@ -1282,8 +1277,7 @@ instance : CompactSpace (MState d) := by noncomputable instance : MetricSpace (MState d) := MetricSpace.induced MState.M MState.M_Injective inferInstance -theorem dist_eq (x y : MState d) : dist x y = dist x.M y.M := by - rfl +theorem dist_eq (x y : MState d) : dist x y = dist x.M y.M := rfl set_option backward.isDefEq.respectTransparency false in instance : BoundedSpace (MState d) where diff --git a/QuantumInfo/States/Pure/Braket.lean b/QuantumInfo/States/Pure/Braket.lean index e23c1e2a3..6fb11971b 100644 --- a/QuantumInfo/States/Pure/Braket.lean +++ b/QuantumInfo/States/Pure/Braket.lean @@ -85,8 +85,7 @@ def dot (ξ : Bra d) (ψ : Ket d) : ℂ := ∑ x, (ξ x) * (ψ x) scoped notation "〈" ξ:90 "‖" ψ:90 "〉" => dot (ξ : Bra _) (ψ : Ket _) -theorem dot_eq_dotProduct (ψ : Bra d) (φ : Ket d) :〈ψ‖φ〉= dotProduct (m := d) ψ φ := by - rfl +theorem dot_eq_dotProduct (ψ : Bra d) (φ : Ket d) :〈ψ‖φ〉= dotProduct (m := d) ψ φ := rfl end Braket diff --git a/QuantumInfo/States/Pure/Qubit.lean b/QuantumInfo/States/Pure/Qubit.lean index 52d00715b..66666ec7c 100644 --- a/QuantumInfo/States/Pure/Qubit.lean +++ b/QuantumInfo/States/Pure/Qubit.lean @@ -180,20 +180,16 @@ lemma CNOT_matrix : variable (g : 𝐔[k]) (j₁ j₂ : k) @[simp] -theorem controllize_apply_zero_zero : C[g] (0, j₁) (0, j₂) = (1 : 𝐔[k]) j₁ j₂ := by - rfl +theorem controllize_apply_zero_zero : C[g] (0, j₁) (0, j₂) = (1 : 𝐔[k]) j₁ j₂ := rfl @[simp] -theorem controllize_apply_zero_one : C[g] (0, j₁) (1, j₂) = 0 := by - rfl +theorem controllize_apply_zero_one : C[g] (0, j₁) (1, j₂) = 0 := rfl @[simp] -theorem controllize_apply_one_zero : C[g] (1, j₁) (0, j₂) = 0 := by - rfl +theorem controllize_apply_one_zero : C[g] (1, j₁) (0, j₂) = 0 := rfl @[simp] -theorem controllize_apply_one_one : C[g] (1, j₁) (1, j₂) = g j₁ j₂ := by - rfl +theorem controllize_apply_one_one : C[g] (1, j₁) (1, j₂) = g j₁ j₂ := rfl @[simp] theorem controllize_mul (g₁ g₂ : 𝐔[k]) : C[g₁] * C[g₂] = C[g₁ * g₂] := by From 9adaa4f7f1efdaeeb09015f337de563b3c6bd6d0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:56:11 -0700 Subject: [PATCH 130/498] refactor: golf small proof reductions Co-authored-by: Claude Opus 4.8 --- .../QuantumMechanics/OneDimension/Operators/Position.lean | 8 ++------ Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 3 +-- Physlib/SpaceAndTime/Time/Derivatives.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Inner.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Trace.lean | 3 +-- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Physlib/QuantumMechanics/OneDimension/Operators/Position.lean b/Physlib/QuantumMechanics/OneDimension/Operators/Position.lean index d0e8de9a2..66af1751c 100644 --- a/Physlib/QuantumMechanics/OneDimension/Operators/Position.lean +++ b/Physlib/QuantumMechanics/OneDimension/Operators/Position.lean @@ -64,15 +64,11 @@ open SchwartzMap def positionOperatorSchwartz : 𝓢(ℝ, ℂ) →L[ℂ] 𝓢(ℝ, ℂ) := Distribution.powOneMul ℂ lemma positionOperatorSchwartz_apply_fun (ψ : 𝓢(ℝ, ℂ)) : - (positionOperatorSchwartz ψ) = fun x => x * ψ x := by - simp [positionOperatorSchwartz] - rfl + (positionOperatorSchwartz ψ) = fun x => x * ψ x := rfl @[simp] lemma positionOperatorSchwartz_apply (ψ : 𝓢(ℝ, ℂ)) (x : ℝ) : - (positionOperatorSchwartz ψ) x = x * ψ x := by - simp [positionOperatorSchwartz] - rfl + (positionOperatorSchwartz ψ) x = x * ψ x := rfl /-- The unbounded position operator, whose domain is Schwartz maps. -/ def positionOperatorUnbounded : UnboundedOperator schwartzIncl schwartzIncl_injective := diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index 881a9f446..5f611bdf5 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -208,8 +208,7 @@ lemma deriv_smul [NormedAddCommGroup M] [NormedSpace ℝ M] [NontriviallyNormedF [NormedAlgebra ℝ 𝕜] [NormedSpace 𝕜 M] {c : Space d → 𝕜} {f : Space d → M} (hc : DifferentiableAt ℝ c x) (hf : DifferentiableAt ℝ f x) : ∂[u] (c • f) x = c x • ∂[u] f x + ∂[u] c x • f x := by - rw [deriv_eq_fderiv_basis, deriv_eq_fderiv_basis, deriv_eq_fderiv_basis, fderiv_smul hc hf] - rfl + simp [deriv_eq_fderiv_basis, fderiv_smul hc hf] /-- Space derivatives on scalar times function. -/ lemma deriv_const_smul [NormedAddCommGroup M] [NormedSpace ℝ M] [Semiring R] diff --git a/Physlib/SpaceAndTime/Time/Derivatives.lean b/Physlib/SpaceAndTime/Time/Derivatives.lean index 00c2dd385..6f292be43 100644 --- a/Physlib/SpaceAndTime/Time/Derivatives.lean +++ b/Physlib/SpaceAndTime/Time/Derivatives.lean @@ -126,8 +126,7 @@ lemma deriv_smul (f : Time → EuclideanSpace ℝ (Fin d)) (k : ℝ) lemma deriv_neg [NormedAddCommGroup M] [NormedSpace ℝ M] (f : Time → M) : ∂ₜ (-f) t = -∂ₜ f t := by - rw [deriv, fderiv_neg] - rfl + simp [deriv, fderiv_neg] /-- Quotient rule for `Time.deriv` on real-valued functions: if `c` and `g` are differentiable at `t` and `g t ≠ 0`, then diff --git a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean index 7ede72550..64eecbaeb 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean @@ -151,8 +151,7 @@ variable (A B : HermitianMat n α) /-- `HermitianMat.inner` reduces to `Matrix.trace (A * B)` when the elements are a `TrivialStar`. -/ theorem inner_eq_trace_trivial : ⟪A, B⟫_α = (A.mat * B.mat).trace := by - rw [← inner_eq_trace_mul] - rfl + simpa using inner_eq_trace_mul A B end trivialstar diff --git a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean index 173fe1372..881ba06ea 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean @@ -108,8 +108,7 @@ variable [Star α] [TrivialStar α] [CommSemiring α] /-- `HermitianMat.trace` reduces to `Matrix.trace` when the elements are a `TrivialStar`. -/ @[simp] theorem trace_eq_trace_trivial (A : HermitianMat n ℝ) : A.trace = A.mat.trace := by - rw [← trace_eq_trace] - rfl + simpa using trace_eq_trace A end trivialstar From 1f6306692f73a2bef168a52397874232cc6fdf9b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 14:58:21 -0700 Subject: [PATCH 131/498] refactor: golf QuantumInfo rfl wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Bundled.lean | 3 +-- QuantumInfo/Channels/CPTP.lean | 9 +++------ QuantumInfo/Channels/Pinching.lean | 3 +-- QuantumInfo/ClassicalInfo/Distribution.lean | 3 +-- QuantumInfo/States/Mixed/MState.lean | 18 ++++++------------ 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/QuantumInfo/Channels/Bundled.lean b/QuantumInfo/Channels/Bundled.lean index 63676a449..aa54a6938 100644 --- a/QuantumInfo/Channels/Bundled.lean +++ b/QuantumInfo/Channels/Bundled.lean @@ -288,8 +288,7 @@ instance instMContinuousMapClass [DecidableEq dIn] [DecidableEq dOut] : -- @[norm_cast] theorem val_apply_MState [DecidableEq dIn] (M : PTPMap dIn dOut) (ρ : MState dIn) : - (M ρ : HermitianMat dOut ℂ) = (instFunLike.coe M) ρ := by - rfl + (M ρ : HermitianMat dOut ℂ) = (instFunLike.coe M) ρ := rfl --If we have a PTPMap, the input and output dimensions are always both nonempty (otherwise --we can't preserve trace) - or they're both empty. So `[Nonempty dIn]` will always suffice. diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index 6c957967b..b7f98006c 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -189,8 +189,7 @@ def ofEquiv (σ : dIn ≃ dOut) : CPTPMap dIn dOut where @[simp] theorem ofEquiv_apply (σ : dIn ≃ dOut) (ρ : MState dIn) : - ofEquiv σ ρ = ρ.relabel σ.symm := by - rfl + ofEquiv σ ρ = ρ.relabel σ.symm := rfl @[simp] theorem equiv_inverse (σ : dIn ≃ dOut) : (ofEquiv σ) ∘ (ofEquiv σ.symm) = id (dIn := dOut) := by @@ -276,13 +275,11 @@ def traceRight : CPTPMap (d₁ × d₂) d₁ := @[simp] theorem traceLeft_eq_MState_traceLeft (ρ : MState (d₁ × d₂)) : - traceLeft (d₁ := d₁) (d₂ := d₂) ρ = ρ.traceLeft := by - rfl + traceLeft (d₁ := d₁) (d₂ := d₂) ρ = ρ.traceLeft := rfl @[simp] theorem traceRight_eq_MState_traceRight (ρ : MState (d₁ × d₂)) : - traceRight (d₁ := d₁) (d₂ := d₂) ρ = ρ.traceRight := by - rfl --It's actually pretty crazy that this is a definitional equality, cool + traceRight (d₁ := d₁) (d₂ := d₂) ρ = ρ.traceRight := rfl end trace diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 4f7651ce8..4dfe03eca 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -103,8 +103,7 @@ def pinching_map (ρ : MState d) : CPTPMap d d ℂ := theorem pinchingMap_apply_M (σ ρ : MState d) : (pinching_map σ ρ).M = ⟨_, (MatrixMap.of_kraus_isCompletelyPositive - (HermitianMat.mat ∘ pinching_kraus σ)).IsPositive.IsHermitianPreserving ρ.M.H⟩ := by - rfl + (HermitianMat.mat ∘ pinching_kraus σ)).IsPositive.IsHermitianPreserving ρ.M.H⟩ := rfl theorem pinching_eq_sum_conj (σ ρ : MState d) : (pinching_map σ ρ).M = ∑ k, (pinching_kraus σ k).mat * ρ.M * (pinching_kraus σ k).mat := by diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 6d8056ceb..93bdf4a51 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -184,8 +184,7 @@ theorem congr_apply (σ : α ≃ β) (d : ProbDistribution α) (j : β): (congr /-- The inverse and congruence operations for distributions commute -/ @[simp] theorem congr_symm_apply (σ : α ≃ β) : - (ProbDistribution.congr σ).symm = ProbDistribution.congr σ.symm := by - rfl + (ProbDistribution.congr σ).symm = ProbDistribution.congr σ.symm := rfl /-- The distribution on Fin 2 corresponding to a coin with probability p. Chance p of 1, 1-p of 0. -/ diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 3cc324f87..6a9334165 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -187,8 +187,7 @@ scoped instance : Inner Prob (MState d) where theorem inner_def : ⟪ρ, σ⟫_Prob = ⟨⟪ρ.M, σ.M⟫, inner_ge_zero ρ.nonneg σ.nonneg, - (inner_le_mul_trace ρ.nonneg σ.nonneg).trans (by simp)⟩ := by - rfl + (inner_le_mul_trace ρ.nonneg σ.nonneg).trans (by simp)⟩ := rfl theorem val_inner : (⟪ρ, σ⟫_Prob : ℝ) = ⟪ρ.M, σ.M⟫ := rfl @@ -526,8 +525,7 @@ def ofClassical (dist : ProbDistribution d) : MState d where @[simp] theorem coe_ofClassical (dist : ProbDistribution d) : - (ofClassical dist).M = diagonal ℂ (dist ·) := by - rfl + (ofClassical dist).M = diagonal ℂ (dist ·) := rfl theorem ofClassical_pow (dist : ProbDistribution d) (p : ℝ) : (ofClassical dist).M ^ p = diagonal ℂ (fun i ↦ (dist i) ^ p) := by @@ -1052,8 +1050,7 @@ def relabel (ρ : MState d₁) (e : d₂ ≃ d₁) : MState d₂ where @[simp] theorem relabel_m (ρ : MState d₁) (e : d₂ ≃ d₁) : - (ρ.relabel e).m = ρ.m.submatrix e e := by - rfl + (ρ.relabel e).m = ρ.m.submatrix e e := rfl @[simp] theorem relabel_refl {d : Type*} [Fintype d] [DecidableEq d] (ρ : MState d) : @@ -1071,8 +1068,7 @@ theorem relabel_pure_exists (ψ : Ket d₁) (e : d₂ ≃ d₁) : @[simp] theorem relabel_relabel {d d₂ d₃ : Type*} [Fintype d] [DecidableEq d] [Fintype d₂] [DecidableEq d₂] [Fintype d₃] [DecidableEq d₃] - (ρ : MState d) (e : d₂ ≃ d) (e₂ : d₃ ≃ d₂) : (ρ.relabel e).relabel e₂ = ρ.relabel (e₂.trans e) := by - rfl + (ρ : MState d) (e : d₂ ≃ d) (e₂ : d₃ ≃ d₂) : (ρ.relabel e).relabel e₂ = ρ.relabel (e₂.trans e) := rfl theorem eq_relabel_iff {d₁ d₂ : Type u} [Fintype d₁] [DecidableEq d₁] [Fintype d₂] [DecidableEq d₂] (ρ : MState d₁) (σ : MState d₂) (h : d₁ ≃ d₂) : @@ -1232,12 +1228,10 @@ theorem traceNorm_eq_one (ρ : MState d) : ρ.m.traceNorm = 1 := --TODO: This naming is very inconsistent. Should be better about "prod" vs "kron" theorem relabel_kron (ρ : MState d₁) (σ : MState d₂) (e : d₃ ≃ d₁) : - ((ρ.relabel e) ⊗ᴹ σ) = (ρ ⊗ᴹ σ).relabel (e.prodCongr (Equiv.refl d₂)) := by - rfl --is this defeq abuse? I don't know + ((ρ.relabel e) ⊗ᴹ σ) = (ρ ⊗ᴹ σ).relabel (e.prodCongr (Equiv.refl d₂)) := rfl theorem kron_relabel (ρ : MState d₁) (σ : MState d₂) (e : d₃ ≃ d₂) : - (ρ ⊗ᴹ σ.relabel e) = (ρ ⊗ᴹ σ).relabel ((Equiv.refl d₁).prodCongr e) := by - rfl + (ρ ⊗ᴹ σ.relabel e) = (ρ ⊗ᴹ σ).relabel ((Equiv.refl d₁).prodCongr e) := rfl theorem prod_assoc (ρ : MState d₁) (σ : MState d₂) (τ : MState d₃) : (ρ ⊗ᴹ (σ ⊗ᴹ τ)) = (ρ ⊗ᴹ σ ⊗ᴹ τ).relabel (Equiv.prodAssoc d₁ d₂ d₃).symm := by From a6b4ad4d51a130dc793dff78791f6362ad251b0a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:00:37 -0700 Subject: [PATCH 132/498] refactor: golf QuantumInfo direct rfl proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/DPI.lean | 3 +-- .../ForMathlib/ContinuousLinearMap.lean | 3 +-- .../ForMathlib/HermitianMat/Basic.lean | 24 +++++++------------ .../ForMathlib/HermitianMat/Inner.lean | 3 +-- .../ForMathlib/HermitianMat/Jordan.lean | 3 +-- .../ForMathlib/HermitianMat/Reindex.lean | 3 +-- .../ForMathlib/HermitianMat/Trace.lean | 3 +-- .../ForMathlib/HermitianMat/Unitary.lean | 3 +-- .../ForMathlib/IsMaximalSelfAdjoint.lean | 3 +-- QuantumInfo/ForMathlib/LinearEquiv.lean | 3 +-- QuantumInfo/ForMathlib/Matrix.lean | 6 ++--- QuantumInfo/ForMathlib/ULift.lean | 6 ++--- QuantumInfo/States/Entanglement.lean | 3 +-- 13 files changed, 22 insertions(+), 44 deletions(-) diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 6eaa53676..1d77a21e0 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -878,8 +878,7 @@ def MState.conjTensorUnitary (ρ : MState (dA × dB)) (V : Matrix.unitaryGroup d the twirling set gives `ρ_A ⊗ uniform_B`. We state the HermitianMat-level equality needed for the joint convexity argument. -/ theorem MState.conjTensorUnitary_M (ρ : MState (dA × dB)) (V : Matrix.unitaryGroup dB ℂ) : - (ρ.conjTensorUnitary V).M = ρ.M.conj ((1 : Matrix.unitaryGroup dA ℂ) ⊗ᵤ V).val := by - rfl + (ρ.conjTensorUnitary V).M = ρ.M.conj ((1 : Matrix.unitaryGroup dA ℂ) ⊗ᵤ V).val := rfl /-- The trace functional is invariant under `1_A ⊗ V` conjugation. -/ theorem sandwichedTraceFunctional_conj_tensorUnitary diff --git a/QuantumInfo/ForMathlib/ContinuousLinearMap.lean b/QuantumInfo/ForMathlib/ContinuousLinearMap.lean index e1e96b3d0..2353e2b24 100644 --- a/QuantumInfo/ForMathlib/ContinuousLinearMap.lean +++ b/QuantumInfo/ForMathlib/ContinuousLinearMap.lean @@ -32,8 +32,7 @@ variable [TopologicalSpace M] [AddCommMonoid M] [TopologicalSpace M₂] [AddComm variable [Module R M] [Module S M₂] theorem ker_mk (f : M →ₛₗ[σ] M₂) (hf : Continuous f.toFun) : - (ContinuousLinearMap.mk f hf).ker = LinearMap.ker f := by - rfl + (ContinuousLinearMap.mk f hf).ker = LinearMap.ker f := rfl end ContinuousLinearMap diff --git a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean index 34bb8007e..3b6e3bcd1 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean @@ -82,18 +82,15 @@ theorem zero_apply (i j : n) : (0 : HermitianMat n 𝕜) i j = 0 := rfl @[simp, norm_cast] theorem mat_add (A B : HermitianMat n α) : - (A + B).mat = A.mat + B.mat := by - rfl + (A + B).mat = A.mat + B.mat := rfl @[simp, norm_cast] theorem mat_sub (A B : HermitianMat n α) : - (A - B).mat = A.mat - B.mat := by - rfl + (A - B).mat = A.mat - B.mat := rfl @[simp, norm_cast] theorem mat_neg (A : HermitianMat n α) : - (-A).mat = -A.mat := by - rfl + (-A).mat = -A.mat := rfl section smul variable [SMul R α] [StarModule R α] @@ -103,13 +100,11 @@ instance : SMul R (HermitianMat n α) := @[simp, norm_cast] theorem mat_smul (c : R) (A : HermitianMat n α) : - (c • A).mat = c • A.mat := by - rfl + (c • A).mat = c • A.mat := rfl @[simp] theorem smul_apply (c : R) (A : HermitianMat n α) (i j : n) : - (c • A) i j = c • A i j := by - rfl + (c • A) i j = c • A i j := rfl end smul section topology @@ -356,13 +351,11 @@ def conj {m} (B : Matrix m n α) : HermitianMat n α →+ HermitianMat m α wher map_zero' := by simp theorem conj_apply (B : Matrix m n α) (A : HermitianMat n α) : - conj B A = ⟨B * A.mat * B.conjTranspose, (conj B A).2⟩ := by - rfl + conj B A = ⟨B * A.mat * B.conjTranspose, (conj B A).2⟩ := rfl @[simp] theorem conj_apply_mat (B : Matrix m n α) (A : HermitianMat n α) : - (A.conj B).mat = B * A.mat * B.conjTranspose := by - rfl + (A.conj B).mat = B * A.mat * B.conjTranspose := rfl theorem conj_conj {m l} [Fintype m] (B : Matrix m n α) (C : Matrix l m α) : (A.conj B).conj C = A.conj (C * B) := by @@ -556,8 +549,7 @@ scoped[HermitianMat] infixl:100 " ⊗ₖ " => HermitianMat.kronecker @[simp, norm_cast] theorem kronecker_mat (A : HermitianMat m α) (B : HermitianMat n α) : - (A ⊗ₖ B).mat = A.mat ⊗ₖ B.mat := by - rfl + (A ⊗ₖ B).mat = A.mat ⊗ₖ B.mat := rfl @[simp] theorem zero_kronecker (A : HermitianMat m α) : (0 : HermitianMat n α) ⊗ₖ A = 0 := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean index 64eecbaeb..ec7c9b135 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean @@ -45,8 +45,7 @@ instance : Inner R (HermitianMat n α) where inner A B := selfadjMap (A.mat * B.mat).trace theorem inner_def (A B : HermitianMat n α) : - ⟪A, B⟫_R = selfadjMap (A.mat * B.mat).trace := by - rfl + ⟪A, B⟫_R = selfadjMap (A.mat * B.mat).trace := rfl end defs section semiring diff --git a/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean b/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean index 8b96bddaa..fef86356d 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean @@ -45,8 +45,7 @@ theorem zero_symmMul : symmMul 0 A = 0 := by simp [symmMul] theorem symmMul_toMat : (A.symmMul B).mat = - (2 : 𝕜)⁻¹ • (A.mat * B.mat + B.mat * A.mat) := by - rfl + (2 : 𝕜)⁻¹ • (A.mat * B.mat + B.mat * A.mat) := rfl variable [Invertible (2 : 𝕜)] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Reindex.lean b/QuantumInfo/ForMathlib/HermitianMat/Reindex.lean index 51c4c39b6..4e816a204 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Reindex.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Reindex.lean @@ -37,8 +37,7 @@ we push it to the right side. One downside is that we're not as likely to hit `r @[simp] theorem reindex_refl (A : HermitianMat d 𝕜) : - A.reindex (.refl _) = A := by - rfl + A.reindex (.refl _) = A := rfl @[simp] theorem reindex_reindex (A : HermitianMat d 𝕜) (e : d ≃ d₂) (f : d₂ ≃ d₃) : diff --git a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean index 881ba06ea..ca5cca95d 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean @@ -188,8 +188,7 @@ variable (A B : HermitianMat (n × m) α) @[simp] theorem traceRight_mat : - (traceRight A).mat = A.mat.traceRight := by - rfl + (traceRight A).mat = A.mat.traceRight := rfl @[simp] theorem traceRight_add : (A + B).traceRight = A.traceRight + B.traceRight := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Unitary.lean b/QuantumInfo/ForMathlib/HermitianMat/Unitary.lean index 2290d4894..fb8e708c4 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Unitary.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Unitary.lean @@ -41,8 +41,7 @@ scoped infixl:60 " ⊗ᵤ " => unitary_kron @[simp] theorem unitary_kron_apply (a : 𝐔[α]) (b : 𝐔[β]) (i₁ i₂ : α) (j₁ j₂ : β) : - (a ⊗ᵤ b) (i₁, j₁) (i₂, j₂) = (a i₁ i₂) * (b j₁ j₂) := by - rfl + (a ⊗ᵤ b) (i₁, j₁) (i₂, j₂) = (a i₁ i₂) * (b j₁ j₂) := rfl @[simp] theorem unitary_kron_one_one : (1 : 𝐔[α]) ⊗ᵤ (1 : 𝐔[β]) = (1 : 𝐔[α × β]) := by diff --git a/QuantumInfo/ForMathlib/IsMaximalSelfAdjoint.lean b/QuantumInfo/ForMathlib/IsMaximalSelfAdjoint.lean index 558f91b57..c66c117e0 100644 --- a/QuantumInfo/ForMathlib/IsMaximalSelfAdjoint.lean +++ b/QuantumInfo/ForMathlib/IsMaximalSelfAdjoint.lean @@ -54,8 +54,7 @@ namespace IsMaximalSelfAdjoint @[simp] theorem trivial_selfadjMap {R} [Star R] [TrivialStar R] [CommSemiring R] : - (selfadjMap : R →+ R) = .id R := by - rfl + (selfadjMap : R →+ R) = .id R := rfl @[simp] theorem RCLike_selfadjMap {α} [RCLike α] : (selfadjMap : α →+ ℝ) = RCLike.re := rfl diff --git a/QuantumInfo/ForMathlib/LinearEquiv.lean b/QuantumInfo/ForMathlib/LinearEquiv.lean index 866a33729..d3e4d6826 100644 --- a/QuantumInfo/ForMathlib/LinearEquiv.lean +++ b/QuantumInfo/ForMathlib/LinearEquiv.lean @@ -65,8 +65,7 @@ theorem of_relabel_refl : of_relabel R (.refl d) = LinearEquiv.refl R (d → R) @[simp] theorem euclidean_of_relabel_refl : euclidean_of_relabel 𝕜 (.refl d) = - LinearEquiv.refl 𝕜 (EuclideanSpace 𝕜 d) := by - rfl + LinearEquiv.refl 𝕜 (EuclideanSpace 𝕜 d) := rfl end LinearEquiv diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index da255fc80..ed9f69648 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -748,8 +748,7 @@ theorem PosDef_iff_eigenvalues' (M : Matrix d d 𝕜) : --These is disgusting atm. There's cleaner versions of them headed to Mathlib. See #29526 and follow-ups theorem IsHermitian.cfc_eigenvalues {M : Matrix d d 𝕜} (hM : M.IsHermitian) (f : ℝ → ℝ) : ∃ (e : d ≃ d), Matrix.IsHermitian.eigenvalues (cfc_predicate f M) = f ∘ hM.eigenvalues ∘ e := by - have h_eigenvalues : Multiset.map hM.eigenvalues Finset.univ.val = Multiset.map (fun i => hM.eigenvalues i) Finset.univ.val := by - rfl + have h_eigenvalues : Multiset.map hM.eigenvalues Finset.univ.val = Multiset.map (fun i => hM.eigenvalues i) Finset.univ.val := rfl generalize_proofs at *; have h_eigenvalues_cfc : (IsHermitian.cfc hM f).charpoly.roots = Multiset.map (fun i => (f (hM.eigenvalues i) : 𝕜)) Finset.univ.val := by rw [ Matrix.IsHermitian.cfc, Matrix.charpoly ]; @@ -1446,8 +1445,7 @@ The right partial trace of a matrix is equal to the left partial trace of the ma -/ theorem traceRight_eq_traceLeft_reindex {n m R : Type*} [Fintype m] [AddCommMonoid R] (M : Matrix (n × m) (n × m) R) : - M.traceRight = (M.reindex (.prodComm ..) (.prodComm ..)).traceLeft := by - rfl + M.traceRight = (M.reindex (.prodComm ..) (.prodComm ..)).traceLeft := rfl open ComplexOrder in theorem PosSemidef.trace_pos {n 𝕜 : Type*} [Fintype n] [RCLike 𝕜] diff --git a/QuantumInfo/ForMathlib/ULift.lean b/QuantumInfo/ForMathlib/ULift.lean index 6c4c4170a..355989d42 100644 --- a/QuantumInfo/ForMathlib/ULift.lean +++ b/QuantumInfo/ForMathlib/ULift.lean @@ -42,8 +42,7 @@ instance {𝕜 : Type u} [NonUnitalNonAssocSemiring 𝕜] [StarRing 𝕜] : Star @[simp] theorem ULift.starRingEnd_down {𝕜 : Type u} (x : ULift.{v,u} 𝕜) [CommSemiring 𝕜] [StarRing 𝕜] : - ((starRingEnd (ULift.{v, u} 𝕜)) x).down = star x.down := by - rfl + ((starRingEnd (ULift.{v, u} 𝕜)) x).down = star x.down := rfl instance {𝕜 : Type u} [NormedField 𝕜] : NormedField (ULift.{v,u} 𝕜) where dist_eq x y := NormedField.dist_eq x.down y.down @@ -54,8 +53,7 @@ instance {𝕜 : Type u} [DenselyNormedField 𝕜] : DenselyNormedField (ULift.{ @[simp] theorem AddEquiv.ulift_apply {α : Type u} [Add α] (x : ULift.{v, u} α) : - AddEquiv.ulift.{u, v} x = x.down := by - rfl + AddEquiv.ulift.{u, v} x = x.down := rfl noncomputable instance {𝕜 : Type u} [RCLike 𝕜] : RCLike (ULift.{v,u} 𝕜) where re := RCLike.re.comp AddEquiv.ulift.toAddMonoidHom (N := 𝕜) diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index bad2c2e62..52daee2cb 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -267,8 +267,7 @@ The von Neumann entropy of a state is equal to the trace of `ρ log ρ` (technic theorem Sᵥₙ_eq_trace_cfc {d : Type*} [Fintype d] [DecidableEq d] (ρ : MState d) : Sᵥₙ ρ = (HermitianMat.cfc ρ.M Real.negMulLog).trace := by -- By definition of von Neumann entropy, we have Sᵥₙ ρ = Finset.sum Finset.univ (fun x ↦ Real.negMulLog (ρ.M.H.eigenvalues x)). - have h_def : Sᵥₙ ρ = Finset.sum Finset.univ (fun x ↦ Real.negMulLog (ρ.M.H.eigenvalues x)) := by - rfl + have h_def : Sᵥₙ ρ = Finset.sum Finset.univ (fun x ↦ Real.negMulLog (ρ.M.H.eigenvalues x)) := rfl -- By definition of trace, the trace of `cfc ρ.M Real.negMulLog` is the sum of its eigenvalues. have h_trace : (ρ.M.cfc Real.negMulLog).trace = ∑ x, (ρ.M.cfc Real.negMulLog).H.eigenvalues x := by From 68fd42fb5f68198d369e0a55a6520fa5726af687 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:03:09 -0700 Subject: [PATCH 133/498] refactor: golf calc rfl proofs Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/GeneralizedPerspectiveFunction.lean | 9 +++------ .../TraceInequality/JensenOperatorInequalityIImpIV.lean | 6 ++---- .../HayataGroup/TraceInequality/LiebAndoTrace.lean | 3 +-- QuantumInfo/ResourceTheory/SteinsLemma.lean | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean index d92d8e73c..2ffedfc62 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean @@ -423,8 +423,7 @@ private theorem theorem_2_5_forward_jointlyConvexOn_psd_pd_of_condV rw [Real.mul_self_sqrt (sub_nonneg.mpr hθ1)] _ = (1 - θ) • (S₁ * cfcR (ℋ := ℋ) f M₁ * S₁) := by simp [mul_assoc, hSIR, hIRS] - _ = (1 - θ) • ((f Δ h) A₁ B₁) := by - rfl + _ = (1 - θ) • ((f Δ h) A₁ B₁) := rfl have hright₂ : S * (star T₂ * cfcR (ℋ := ℋ) f M₂ * T₂) * S = θ • ((f Δ h) A₂ B₂) := by @@ -437,15 +436,13 @@ private theorem theorem_2_5_forward_jointlyConvexOn_psd_pd_of_condV rw [Real.mul_self_sqrt hθ0] _ = θ • (S₂ * cfcR (ℋ := ℋ) f M₂ * S₂) := by simp [mul_assoc, hSIR, hIRS] - _ = θ • ((f Δ h) A₂ B₂) := by - rfl + _ = θ • ((f Δ h) A₂ B₂) := rfl have hright : S * (star T₁ * cfcR (ℋ := ℋ) f M₁ * T₁ + star T₂ * cfcR (ℋ := ℋ) f M₂ * T₂) * S = (1 - θ) • ((f Δ h) A₁ B₁) + θ • ((f Δ h) A₂ B₂) := by rw [mul_add, add_mul, hright₁, hright₂] have hleft : - S * cfcR (ℋ := ℋ) f (IR * A * IR) * S = (f Δ h) A B := by - rfl + S * cfcR (ℋ := ℋ) f (IR * A * IR) * S = (f Δ h) A B := rfl simpa [hleft, hright] using houter -- Restricted forward form of Theorem 2.5 on the positive cone. diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean index 740618607..d0146f8a1 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean @@ -329,8 +329,7 @@ private lemma complex_I_smul_real_I_smul_invTwo (r : ℝ) (T : L ℋ) : simpa using (smul_comm r (Complex.I : ℂ) ((2⁻¹ : ℝ) • T x)) calc Complex.I • r • Complex.I • (2⁻¹ : ℝ) • T x - = Complex.I • (r • (Complex.I • ((2⁻¹ : ℝ) • T x))) := by - rfl + = Complex.I • (r • (Complex.I • ((2⁻¹ : ℝ) • T x))) := rfl _ = Complex.I • (Complex.I • (r • ((2⁻¹ : ℝ) • T x))) := by rw [hcomm] _ = ((Complex.I : ℂ) * Complex.I) • (r • ((2⁻¹ : ℝ) • T x)) := by @@ -354,8 +353,7 @@ private lemma real_smul_complex_I_real_smul_complex_I_comm (s r : ℝ) (T : L rw [smul_comm (s : ℝ) r (Complex.I • T)] _ = Complex.I • (r • (Complex.I • ((s : ℝ) • T))) := by rw [smul_comm (s : ℝ) (Complex.I : ℂ) T] - _ = Complex.I • r • Complex.I • (s : ℝ) • T := by - rfl + _ = Complex.I • r • Complex.I • (s : ℝ) • T := rfl omit [CompleteSpace ℋ] in private lemma half_add_half_eq (T : L ℋ) : diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean index 03c670832..b7ca305a3 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean @@ -750,8 +750,7 @@ private lemma phiK_operatorPowerMean_eq_liebTraceMap congrArg Complex.re (LinearMap.trace_mul_comm (R := ℂ) (M := ℋ) K.toLinearMap X.toLinearMap) simpa [X, mul_assoc] using htrace'.trans hcycle - _ = liebTraceMap (ℋ := ℋ) s K A B := by - rfl + _ = liebTraceMap (ℋ := ℋ) s K A B := rfl omit [FiniteDimensional ℂ ℋ] in /-- Convex combinations preserve `pdSet` (strict positivity). -/ diff --git a/QuantumInfo/ResourceTheory/SteinsLemma.lean b/QuantumInfo/ResourceTheory/SteinsLemma.lean index 65e586fbf..f16c81b09 100644 --- a/QuantumInfo/ResourceTheory/SteinsLemma.lean +++ b/QuantumInfo/ResourceTheory/SteinsLemma.lean @@ -781,14 +781,12 @@ private theorem log_le_f (n : ℕ) (lam : ℝ) : Real.log lam ≤ f_map i n lam _ ≤ (⌈Real.log lam / (σ₁_c i n)⌉) * σ₁_c i n := by rw [← mul_inv_le_iff₀ (σ₁_c_pos i n)] apply Int.le_ceil _ - _ = _ := by - rfl + _ = _ := rfl /-- (S46), part 2 -/ private theorem f_le_log (n : ℕ) (lam : ℝ) : f_map i n lam < Real.log lam + σ₁_c i n := calc - _ = ⌈Real.log lam / σ₁_c i n⌉ * σ₁_c i n := by - rfl + _ = ⌈Real.log lam / σ₁_c i n⌉ * σ₁_c i n := rfl _ < (Real.log lam / σ₁_c i n + 1) * σ₁_c i n := by gcongr · exact σ₁_c_pos i n From c666c1c983e719fd43831fa42f0a470767b4201d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:06:19 -0700 Subject: [PATCH 134/498] refactor: golf exact proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Dual.lean | 6 ++---- QuantumInfo/ForMathlib/ContinuousSup.lean | 3 +-- .../TraceInequality/LownerHeinzTheorem.lean | 8 ++++---- QuantumInfo/ForMathlib/HermitianMat/Basic.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 10 ++++------ QuantumInfo/States/Mixed/MState.lean | 11 +++++------ 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index 481e52c74..101b48086 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -329,8 +329,7 @@ def dual (M : CPTPMap dIn dOut) : CPUMap dOut dIn where cp := .dual M.cp theorem dual_pos (M : CPTPMap dIn dOut) {T : HermitianMat dOut ℂ} (hT : 0 ≤ T) : - 0 ≤ M.dual T := by - exact M.dual.pos_Hermitian hT + 0 ≤ M.dual T := M.dual.pos_Hermitian hT /-- The dual of a CPTP map preserves POVMs. Stated here just for two-element POVMs, that is, an operator `T` between 0 and 1. -/ @@ -489,8 +488,7 @@ def hermDual (M : PTPMap dIn dOut) : PUMap dOut dIn where unital := M.TP.hermDual theorem hermDual_pos (M : PTPMap dIn dOut) {T : HermitianMat dOut ℂ} (hT : 0 ≤ T) : - 0 ≤ M.hermDual T := by - exact M.hermDual.pos_Hermitian hT + 0 ≤ M.hermDual T := M.hermDual.pos_Hermitian hT /-- The dual of a PTP map preserves POVMs. Stated here just for two-element POVMs, that is, an operator `T` between 0 and 1. -/ diff --git a/QuantumInfo/ForMathlib/ContinuousSup.lean b/QuantumInfo/ForMathlib/ContinuousSup.lean index a8ea0c1d0..04456d914 100644 --- a/QuantumInfo/ForMathlib/ContinuousSup.lean +++ b/QuantumInfo/ForMathlib/ContinuousSup.lean @@ -182,8 +182,7 @@ end ContinuousLinearMap theorem LinearMap.BilinForm.continuous_iSup_fst {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] [FiniteDimensional ℝ E] (f : LinearMap.BilinForm ℝ E) {S : Set E} (hS : Bornology.IsBounded S) : - Continuous fun x ↦ ⨆ y : S, f y x := by - exact LinearMap.BilinForm.continuous_iSup f.flip hS + Continuous fun x ↦ ⨆ y : S, f y x := LinearMap.BilinForm.continuous_iSup f.flip hS --Old "direct" proof: -- -- Since $f$ is continuous, there exists $C > 0$ such that for all $y \in S$ and $x \in E$, $|f y x| \leq C \|y\| \|x\|$. -- obtain ⟨C, hC1, hC2⟩ : ∃ C > 0, ∀ y ∈ S, ∀ x : E, |f y x| ≤ C * ‖y‖ * ‖x‖ := by diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean index 7f89cad56..5f05b9fd7 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean @@ -220,12 +220,12 @@ theorem operatorConvex_continuousOn_spectrum_union {f : ℝ → ℝ} omit [Nontrivial ℋ] in theorem one_div_operatorAntitoneOn_Ioi : - OperatorAntitoneOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x : ℝ ↦ 1 / x) := by - exact (LownerHeinzCore.one_div_operatorAntitoneOn_Ioi (𝓐 := L ℋ)) + OperatorAntitoneOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x : ℝ ↦ 1 / x) := + LownerHeinzCore.one_div_operatorAntitoneOn_Ioi (𝓐 := L ℋ) theorem one_div_operatorConvexOn_Ioi : - OperatorConvexOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x : ℝ ↦ 1 / x) := by - exact (LownerHeinzCore.one_div_operatorConvexOn_Ioi (𝓐 := L ℋ)) + OperatorConvexOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x : ℝ ↦ 1 / x) := + LownerHeinzCore.one_div_operatorConvexOn_Ioi (𝓐 := L ℋ) omit [Nontrivial ℋ] in theorem one_div_add_t_operatorAntitoneOn_Ici : ∀ (t : ℝ), 0 < t → diff --git a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean index 3b6e3bcd1..79f7cdd5b 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean @@ -716,8 +716,7 @@ theorem _root_.Matrix.IsHermitian.spectrum_rcLike {A : Matrix n n 𝕜} (hA : A. of the real spectrum. -/ @[simp] theorem spectrum_rcLike (A : HermitianMat n 𝕜) : - spectrum 𝕜 A.mat = RCLike.ofReal '' spectrum ℝ A.mat := by - exact A.H.spectrum_rcLike.symm + spectrum 𝕜 A.mat = RCLike.ofReal '' spectrum ℝ A.mat := A.H.spectrum_rcLike.symm theorem ne_zero_iff_ne_zero_spectrum (A : HermitianMat n 𝕜) : A ≠ 0 ↔ ∃ x ∈ spectrum ℝ A.mat, x ≠ 0 := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index cc6463385..4024f5711 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -49,8 +49,8 @@ instance instRPow : Pow (HermitianMat d 𝕜) ℝ := ⟨rpow⟩ theorem rpow_conj_unitary (A : HermitianMat d 𝕜) (U : Matrix.unitaryGroup d 𝕜) (r : ℝ) : - (HermitianMat.conj U.val A) ^ r = HermitianMat.conj U.val (A ^ r) := by - exact A.cfc_conj_unitary (· ^ r) U + (HermitianMat.conj U.val A) ^ r = HermitianMat.conj U.val (A ^ r) := + A.cfc_conj_unitary (· ^ r) U theorem pow_eq_rpow : A ^ r = A.rpow r := rfl @@ -119,8 +119,7 @@ lemma rpow_zero (A : HermitianMat d 𝕜) : A ^ (0 : ℝ) = 1 := by simp [rpow_eq_cfc] lemma rpow_diagonal (a : d → ℝ) (r : ℝ) : - (diagonal ℂ a) ^ r = diagonal ℂ (fun i => a i ^ r) := by - exact cfc_diagonal _ _ + (diagonal ℂ a) ^ r = diagonal ℂ (fun i => a i ^ r) := cfc_diagonal _ _ /-- Keeps in line with our simp-normal form for moving reindex outwards. -/ @[simp] @@ -207,8 +206,7 @@ lemma rpow_inv_eq_neg_rpow (hA : A.mat.PosDef) (p : ℝ) : (A ^ p)⁻¹ = A ^ (- open ComplexOrder in lemma sandwich_le_one (hB : B.mat.PosDef) (h : A ≤ B) : - (A.conj (B ^ (-1/2 : ℝ)).mat) ≤ 1 := by - exact le_trans (conj_mono h) (sandwich_self hB).le + (A.conj (B ^ (-1/2 : ℝ)).mat) ≤ 1 := le_trans (conj_mono h) (sandwich_self hB).le open ComplexOrder in lemma rpow_neg_mul_rpow_self (hA : A.mat.PosDef) (p : ℝ) : diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 6a9334165..ce0f34cee 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -230,8 +230,7 @@ theorem exp_val_sub (A B : HermitianMat d ℂ) : /-- If a PSD observable `A` has expectation value of 0 on a state `ρ`, it must entirely contain the support of `ρ` in its kernel. -/ theorem exp_val_eq_zero_iff {A : HermitianMat d ℂ} (hA₁ : 0 ≤ A) : - ρ.exp_val A = 0 ↔ ρ.M.support ≤ A.ker := by - exact inner_zero_iff ρ.nonneg hA₁ + ρ.exp_val A = 0 ↔ ρ.M.support ≤ A.ker := inner_zero_iff ρ.nonneg hA₁ /-- If an observable `A` has expectation value of 1 on a state `ρ`, it must entirely contain the support of `ρ` in its 1-eigenspace. -/ @@ -722,8 +721,8 @@ theorem eq_of_sum_eq_pure {d : Type*} [Fintype d] [DecidableEq d] exact MState.ext h_eq.symm theorem purity_prod {d₁ d₂ : Type*} [Fintype d₁] [Fintype d₂] [DecidableEq d₁] [DecidableEq d₂] - (ρ₁ : MState d₁) (ρ₂ : MState d₂) : (ρ₁ ⊗ᴹ ρ₂).purity = ρ₁.purity * ρ₂.purity := by - exact prod_inner_prod ρ₁ ρ₁ ρ₂ ρ₂ + (ρ₁ : MState d₁) (ρ₂ : MState d₂) : (ρ₁ ⊗ᴹ ρ₂).purity = ρ₁.purity * ρ₂.purity := + prod_inner_prod ρ₁ ρ₁ ρ₂ ρ₂ theorem pure_eq_pure_iff {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) : pure ψ = pure φ ↔ ∃ z : ℂ, ‖z‖ = 1 ∧ ψ.vec = z • φ.vec := by @@ -760,8 +759,8 @@ theorem pure_eq_pure_iff {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) /-- Two kets are phase-equivalent if and only if their pure states are equal. -/ theorem PhaseEquiv_iff_pure_eq {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) : - Ket.PhaseEquiv.r ψ φ ↔ MState.pure ψ = MState.pure φ := by - exact (pure_eq_pure_iff ψ φ).symm + Ket.PhaseEquiv.r ψ φ ↔ MState.pure ψ = MState.pure φ := + (pure_eq_pure_iff ψ φ).symm /-- `MState.pure` descends to the quotient `KetUpToPhase`. -/ def pureQ {d : Type*} [Fintype d] [DecidableEq d] : KetUpToPhase d → MState d := From 5f5bf96e8a7f4d5c0aa97010663a95ef485b766e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:07:39 -0700 Subject: [PATCH 135/498] refactor: golf Lieb-Ando exact wrappers Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LiebAndoTrace.lean | 63 +++++++------------ 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean index b7ca305a3..0ef287d9d 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean @@ -422,8 +422,7 @@ private lemma hmiddle_leftMul_rightMul exact spectrum.zero_notMem (R := ℝ) hBinv_unit (by simpa [hx0] using hx) exact (Real.continuousAt_rpow_const x s (Or.inl hx0)).continuousWithinAt)).symm have hprod0 : - 0 ≤ leftMulHS (ℋ := ℋ) A * rightMulHS (ℋ := ℋ) (B ^ (-1 : ℝ)) := by - exact (leftMulHS_rightMulHS_commute (ℋ := ℋ) A (B ^ (-1 : ℝ))).mul_nonneg + 0 ≤ leftMulHS (ℋ := ℋ) A * rightMulHS (ℋ := ℋ) (B ^ (-1 : ℝ)) := (leftMulHS_rightMulHS_commute (ℋ := ℋ) A (B ^ (-1 : ℝ))).mul_nonneg (leftMulHS_nonneg (ℋ := ℋ) hA0) (rightMulHS_nonneg (ℋ := ℋ) hBinv0) have hprod_sa : @@ -431,8 +430,7 @@ private lemma hmiddle_leftMul_rightMul (leftMulHS (ℋ := ℋ) A * rightMulHS (ℋ := ℋ) (B ^ (-1 : ℝ))) := IsSelfAdjoint.of_nonneg hprod0 have htop : - (⨆ α, ⨆ β, eigenspace T0 α ⊓ eigenspace T1 β) = ⊤ := by - exact LinearMap.IsSymmetric.iSup_iSup_eigenspace_inf_eigenspace_eq_top_of_commute + (⨆ α, ⨆ β, eigenspace T0 α ⊓ eigenspace T1 β) = ⊤ := LinearMap.IsSymmetric.iSup_iSup_eigenspace_inf_eigenspace_eq_top_of_commute hT0_symm hT1_symm hcomm have hjoint_ker : ∀ α β, @@ -530,8 +528,7 @@ private lemma hmiddle_leftMul_rightMul simp [mul_comm] have hscal : (((α.re * β.re : ℝ) ^ s : ℝ) : ℂ) = - ((((α.re ^ s) * (β.re ^ s) : ℝ)) : ℂ) := by - exact congrArg (fun t : ℝ => (t : ℂ)) (Real.mul_rpow hαnonneg hβnonneg) + ((((α.re ^ s) * (β.re ^ s) : ℝ)) : ℂ) := congrArg (fun t : ℝ => (t : ℂ)) (Real.mul_rpow hαnonneg hβnonneg) simpa [D] using sub_eq_zero.mpr (hlhsx.trans (hscal ▸ hrhsx.symm)) have hker_top : LinearMap.ker D.toLinearMap = ⊤ := by @@ -617,8 +614,7 @@ private lemma phiK_operatorPowerMean_eq_liebTraceMap simp have hBinv_sa : IsSelfAdjoint (B ^ (-1 : ℝ)) := IsSelfAdjoint.of_nonneg hBinv0 have hright_invHalf0 : - 0 ≤ rightMulHS (ℋ := ℋ) (B ^ ((-1 : ℝ) / 2)) := by - exact rightMulHS_nonneg (ℋ := ℋ) hBinvHalf0 + 0 ≤ rightMulHS (ℋ := ℋ) (B ^ ((-1 : ℝ) / 2)) := rightMulHS_nonneg (ℋ := ℋ) hBinvHalf0 have hmid_nonneg : 0 ≤ cfcR (ℋ := HSOp ℋ) (fun x : ℝ ↦ x ^ ((-1 : ℝ) / 2)) (rightMulHS (ℋ := ℋ) B) * leftMulHS (ℋ := ℋ) A * @@ -650,8 +646,7 @@ private lemma phiK_operatorPowerMean_eq_liebTraceMap (cfcR (ℋ := HSOp ℋ) (fun x : ℝ ↦ x ^ ((-1 : ℝ) / 2)) (rightMulHS (ℋ := ℋ) B) * leftMulHS (ℋ := ℋ) A * cfcR (ℋ := HSOp ℋ) (fun x : ℝ ↦ x ^ ((-1 : ℝ) / 2)) (rightMulHS (ℋ := ℋ) B)) = - leftMulHS (ℋ := ℋ) (A ^ s) * rightMulHS (ℋ := ℋ) (B ^ (-s)) := by - exact hmiddle_leftMul_rightMul (ℋ := ℋ) (s := s) ⟨hA_sa, hA_spec⟩ ⟨hB_sa, hB_spec⟩ + leftMulHS (ℋ := ℋ) (A ^ s) * rightMulHS (ℋ := ℋ) (B ^ (-s)) := hmiddle_leftMul_rightMul (ℋ := ℋ) (s := s) ⟨hA_sa, hA_spec⟩ ⟨hB_sa, hB_spec⟩ have happly : operatorPowerMean (ℋ := HSOp ℋ) s 1 (leftMulHS (ℋ := ℋ) A) (rightMulHS (ℋ := ℋ) B) (ofOp (star K)) = @@ -914,8 +909,7 @@ private lemma liebTraceMap_mono_right have hdiff0 : 0 ≤ B₂ ^ (1 - s) - B₁ ^ (1 - s) := sub_nonneg.mpr hpow have hprod0 : 0 ≤ leftMulHS (ℋ := ℋ) (A ^ s) * - rightMulHS (ℋ := ℋ) (B₂ ^ (1 - s) - B₁ ^ (1 - s)) := by - exact (leftMulHS_rightMulHS_commute (ℋ := ℋ) (A ^ s) (B₂ ^ (1 - s) - B₁ ^ (1 - s))).mul_nonneg + rightMulHS (ℋ := ℋ) (B₂ ^ (1 - s) - B₁ ^ (1 - s)) := (leftMulHS_rightMulHS_commute (ℋ := ℋ) (A ^ s) (B₂ ^ (1 - s) - B₁ ^ (1 - s))).mul_nonneg (leftMulHS_nonneg (ℋ := ℋ) hApow0) (rightMulHS_nonneg (ℋ := ℋ) hdiff0) have hphi : 0 ≤ @@ -992,8 +986,7 @@ private lemma liebTraceMap_antitone_right have hdiff0 : 0 ≤ B₁ ^ (1 - s) - B₂ ^ (1 - s) := sub_nonneg.mpr hpow have hprod0 : 0 ≤ leftMulHS (ℋ := ℋ) (A ^ s) * - rightMulHS (ℋ := ℋ) (B₁ ^ (1 - s) - B₂ ^ (1 - s)) := by - exact (leftMulHS_rightMulHS_commute (ℋ := ℋ) (A ^ s) (B₁ ^ (1 - s) - B₂ ^ (1 - s))).mul_nonneg + rightMulHS (ℋ := ℋ) (B₁ ^ (1 - s) - B₂ ^ (1 - s)) := (leftMulHS_rightMulHS_commute (ℋ := ℋ) (A ^ s) (B₁ ^ (1 - s) - B₂ ^ (1 - s))).mul_nonneg (leftMulHS_nonneg (ℋ := ℋ) hApow0) (rightMulHS_nonneg (ℋ := ℋ) hdiff0) have hphi : 0 ≤ @@ -1067,11 +1060,9 @@ theorem liebTrace_jointlyConcaveOn_pdSet toOp T * ((1 - θ) • B₁ + θ • B₂) rw [mul_add, mul_smul_comm, mul_smul_comm] have hA_combo : - ((1 - θ) • A₁ + θ • A₂) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hA₁ hA₂ hθ0 hθ1 + ((1 - θ) • A₁ + θ • A₂) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hA₁ hA₂ hθ0 hθ1 have hB_combo : - ((1 - θ) • B₁ + θ • B₂) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hB₁ hB₂ hθ0 hθ1 + ((1 - θ) • B₁ + θ • B₂) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hB₁ hB₂ hθ0 hθ1 letI : Nontrivial (HSOp ℋ) := by delta HSOp infer_instance @@ -1104,8 +1095,7 @@ theorem liebTrace_jointlyConcaveOn_pdSet phiK (ℋ := ℋ) K (operatorPowerMean (ℋ := HSOp ℋ) s 1 (leftMulHS (ℋ := ℋ) ((1 - θ) • A₁ + θ • A₂)) - (rightMulHS (ℋ := ℋ) ((1 - θ) • B₁ + θ • B₂))) := by - exact phiK_mono (ℋ := ℋ) K hconc + (rightMulHS (ℋ := ℋ) ((1 - θ) • B₁ + θ • B₂))) := phiK_mono (ℋ := ℋ) K hconc rw [phiK_weightedSum_operatorPowerMean_eq (ℋ := ℋ) (s := s) (θ := θ) K A₁ A₂ B₁ B₂ hA₁ hA₂ hB₁ hB₂] at hphi_mono rw [phiK_operatorPowerMean_eq_liebTraceMap (ℋ := ℋ) (s := s) K @@ -1132,11 +1122,9 @@ theorem liebTrace_jointlyConvexOn_pdSet toOp T * ((1 - θ) • B₁ + θ • B₂) rw [mul_add, mul_smul_comm, mul_smul_comm] have hA_combo : - ((1 - θ) • A₁ + θ • A₂) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hA₁ hA₂ hθ0 hθ1 + ((1 - θ) • A₁ + θ • A₂) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hA₁ hA₂ hθ0 hθ1 have hB_combo : - ((1 - θ) • B₁ + θ • B₂) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hB₁ hB₂ hθ0 hθ1 + ((1 - θ) • B₁ + θ • B₂) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hB₁ hB₂ hθ0 hθ1 letI : Nontrivial (HSOp ℋ) := by delta HSOp infer_instance @@ -1169,8 +1157,7 @@ theorem liebTrace_jointlyConvexOn_pdSet ((1 - θ) • operatorPowerMean (ℋ := HSOp ℋ) s 1 (leftMulHS (ℋ := ℋ) A₁) (rightMulHS (ℋ := ℋ) B₁) + θ • operatorPowerMean (ℋ := HSOp ℋ) s 1 - (leftMulHS (ℋ := ℋ) A₂) (rightMulHS (ℋ := ℋ) B₂)) := by - exact phiK_mono (ℋ := ℋ) K hconv + (leftMulHS (ℋ := ℋ) A₂) (rightMulHS (ℋ := ℋ) B₂)) := phiK_mono (ℋ := ℋ) K hconv rw [phiK_operatorPowerMean_eq_liebTraceMap (ℋ := ℋ) (s := s) K ((1 - θ) • A₁ + θ • A₂) ((1 - θ) • B₁ + θ • B₂) hA_combo hB_combo] at hphi_mono rw [phiK_weightedSum_operatorPowerMean_eq (ℋ := ℋ) (s := s) (θ := θ) K A₁ A₂ B₁ B₂ @@ -1198,11 +1185,9 @@ theorem liebExtensionTrace_jointlyConcaveOn_pdSet field_simp [h1q.ne'] intro A₁ A₂ B₁ B₂ θ hA₁ hA₂ hB₁ hB₂ hθ0 hθ1 have hA_combo : - ((1 - θ) • A₁ + θ • A₂) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hA₁ hA₂ hθ0 hθ1 + ((1 - θ) • A₁ + θ • A₂) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hA₁ hA₂ hθ0 hθ1 have hB_combo : - ((1 - θ) • B₁ + θ • B₂) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hB₁ hB₂ hθ0 hθ1 + ((1 - θ) • B₁ + θ • B₂) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hB₁ hB₂ hθ0 hθ1 have hB₁β : B₁ ^ β ∈ pdSet (ℋ := ℋ) := pdSet_rpow_of_mem_Icc_zero_one (ℋ := ℋ) hβ hB₁ have hB₂β : B₂ ^ β ∈ pdSet (ℋ := ℋ) := @@ -1211,8 +1196,7 @@ theorem liebExtensionTrace_jointlyConcaveOn_pdSet (((1 - θ) • B₁ + θ • B₂) ^ β) ∈ pdSet (ℋ := ℋ) := pdSet_rpow_of_mem_Icc_zero_one (ℋ := ℋ) hβ hB_combo have hBpow_combo : - ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hB₁β hB₂β hθ0 hθ1 + ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hB₁β hB₂β hθ0 hθ1 have hB₁_mem := hB₁ have hB₂_mem := hB₂ have hB_combo_mem := hB_combo @@ -1264,8 +1248,7 @@ theorem liebExtensionTrace_jointlyConcaveOn_pdSet ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) ≤ liebTraceMap (ℋ := ℋ) q K ((1 - θ) • A₁ + θ • A₂) - (((1 - θ) • B₁ + θ • B₂) ^ β) := by - exact liebTraceMap_mono_right (ℋ := ℋ) (s := q) hsmono K + (((1 - θ) • B₁ + θ • B₂) ^ β) := liebTraceMap_mono_right (ℋ := ℋ) (s := q) hsmono K ((1 - θ) • A₁ + θ • A₂) ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) (((1 - θ) • B₁ + θ • B₂) ^ β) @@ -1324,11 +1307,9 @@ theorem andoTrace_jointlyConvexOn_pdSet ring intro A₁ A₂ B₁ B₂ θ hA₁ hA₂ hB₁ hB₂ hθ0 hθ1 have hA_combo : - ((1 - θ) • A₁ + θ • A₂) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hA₁ hA₂ hθ0 hθ1 + ((1 - θ) • A₁ + θ • A₂) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hA₁ hA₂ hθ0 hθ1 have hB_combo : - ((1 - θ) • B₁ + θ • B₂) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hB₁ hB₂ hθ0 hθ1 + ((1 - θ) • B₁ + θ • B₂) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hB₁ hB₂ hθ0 hθ1 have hB₁β : B₁ ^ β ∈ pdSet (ℋ := ℋ) := pdSet_rpow_of_mem_Icc_zero_one (ℋ := ℋ) hβ hB₁ have hB₂β : B₂ ^ β ∈ pdSet (ℋ := ℋ) := @@ -1337,8 +1318,7 @@ theorem andoTrace_jointlyConvexOn_pdSet (((1 - θ) • B₁ + θ • B₂) ^ β) ∈ pdSet (ℋ := ℋ) := pdSet_rpow_of_mem_Icc_zero_one (ℋ := ℋ) hβ hB_combo have hBpow_combo : - ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) ∈ pdSet (ℋ := ℋ) := by - exact pdSet_convexCombo (ℋ := ℋ) hB₁β hB₂β hθ0 hθ1 + ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) ∈ pdSet (ℋ := ℋ) := pdSet_convexCombo (ℋ := ℋ) hB₁β hB₂β hθ0 hθ1 have hB₁_mem := hB₁ have hB₂_mem := hB₂ have hB_combo_mem := hB_combo @@ -1390,8 +1370,7 @@ theorem andoTrace_jointlyConvexOn_pdSet (((1 - θ) • B₁ + θ • B₂) ^ β) ≤ liebTraceMap (ℋ := ℋ) q K ((1 - θ) • A₁ + θ • A₂) - ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) := by - exact liebTraceMap_antitone_right (ℋ := ℋ) (s := q) hsanti K + ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) := liebTraceMap_antitone_right (ℋ := ℋ) (s := q) hsanti K ((1 - θ) • A₁ + θ • A₂) ((1 - θ) • (B₁ ^ β) + θ • (B₂ ^ β)) (((1 - θ) • B₁ + θ • B₂) ^ β) From 20a99e6a26f583b88c7d93d9d384a51a981384a2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:10:37 -0700 Subject: [PATCH 136/498] refactor: golf exact helper proofs Co-authored-by: Claude Opus 4.8 --- .../HilbertSchmidtOperatorSpace.lean | 3 +-- .../TraceInequality/JensenOperatorInequality.lean | 8 ++++---- .../JensenOperatorInequalityIImpIV.lean | 12 ++++++------ QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 14 ++++++-------- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 3 +-- QuantumInfo/States/Entanglement.lean | 8 ++++---- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean index 212343dbc..69b259294 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean @@ -550,8 +550,7 @@ private noncomputable def opStarHSAlgEquiv : L ℋ ≃ₐ[ℝ] (L ℋ)ᵐᵒᵖ omit [FiniteDimensional ℂ ℋ] in lemma op_isSelfAdjoint (A : L ℋ) (hA : IsSelfAdjoint A) : - IsSelfAdjoint (MulOpposite.op A : (L ℋ)ᵐᵒᵖ) := by - exact congrArg MulOpposite.op hA.star_eq + IsSelfAdjoint (MulOpposite.op A : (L ℋ)ᵐᵒᵖ) := congrArg MulOpposite.op hA.star_eq private noncomputable def opStarHSLinearMap : L ℋ →ₗ[ℝ] (L ℋ)ᵐᵒᵖ where toFun := fun A => MulOpposite.op (star A) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean index 62d3c13f3..2d42e4e41 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean @@ -239,8 +239,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) · intro z simp [sub_eq_add_neg] have hblock : - blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by - exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) + blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := + sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp @@ -354,8 +354,8 @@ theorem theorem_2_5_2_i_ici_all_imp_v {f : ℝ → ℝ} · intro z simp [sub_eq_add_neg] have hblock : - blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by - exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) + blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := + sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean index d0146f8a1..c2765c3ca 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean @@ -288,8 +288,8 @@ private theorem nontrivial_hsumL [Nontrivial ℋ] : Nontrivial (L (HSum ℋ)) := have hdiag_ne_zero : (blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 : L (HSum ℋ)) ≠ 0 := by intro h0 have hz : - blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 (hsumIncl ℋ 0 w) = 0 := by - exact congrArg (fun T : L (HSum ℋ) => T (hsumIncl ℋ 0 w)) h0 + blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 (hsumIncl ℋ 0 w) = 0 := + congrArg (fun T : L (HSum ℋ) => T (hsumIncl ℋ 0 w)) h0 have hw0 : w = 0 := by have hz0 := congrArg (fun z : HSum ℋ => hsumProj ℋ 0 z) hz simpa [blockDiagonal] using hz0 @@ -788,8 +788,8 @@ theorem theorem_2_5_2_i_ici_all_imp_iv {f : ℝ → ℝ} (hf : CondIciAll.{u} f) smul_nonneg (by linarith [hf0]) hR0sq_nonneg exact (neg_nonneg.mp (by simpa [neg_smul] using hneg)) have htop : - cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := by - exact blockDiagonal_le_left (ℋ := ℋ) hcore + cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := + blockDiagonal_le_left (ℋ := ℋ) hcore have hdrop : star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) ≤ star X * cfcR (ℋ := ℋ) f A * X := by simpa [add_comm, add_left_comm, add_assoc] using @@ -1017,8 +1017,8 @@ theorem theorem_2_5_2_i_all_imp_iv {f : ℝ → ℝ} (hf : CondIAll.{u} f) : smul_nonneg (by linarith [hf0]) hR0sq_nonneg exact (neg_nonneg.mp (by simpa [neg_smul] using hneg)) have htop : - cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := by - exact blockDiagonal_le_left (ℋ := ℋ) hcore + cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := + blockDiagonal_le_left (ℋ := ℋ) hcore have hdrop : star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) ≤ star X * cfcR (ℋ := ℋ) f A * X := by simpa [add_comm, add_left_comm, add_assoc] using diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 64d0511d2..456664a9b 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -1077,8 +1077,8 @@ The integral of a Hermitian matrix function commutes with `toMat`. -/ lemma integral_toMat (A : ℝ → HermitianMat d 𝕜) (T₁ T₂ : ℝ) {μ : Measure ℝ} (hA : IntervalIntegrable A μ T₁ T₂) : - (∫ t in T₁..T₂, A t ∂μ).mat = ∫ t in T₁..T₂, (A t).mat ∂μ := by - exact ((matₗ (R := ℝ)).intervalIntegral_comp_comm hA).symm + (∫ t in T₁..T₂, A t ∂μ).mat = ∫ t in T₁..T₂, (A t).mat ∂μ := + ((matₗ (R := ℝ)).intervalIntegral_comp_comm hA).symm set_option backward.isDefEq.respectTransparency false in /-- @@ -1248,8 +1248,8 @@ theorem cfc_le_cfc_of_commute (hf : Monotone f) (hAB₁ : Commute A.mat B.mat) ( open ComplexOrder in theorem cfc_monoOn_pos_of_monoOn_posDef {d : Type*} [Fintype d] [DecidableEq d] {f : ℝ → ℝ} (hf_is_operator_convex : False) : - MonotoneOn (HermitianMat.cfc · f) { A : HermitianMat d ℂ | A.mat.PosDef } := by - exact False.elim hf_is_operator_convex + MonotoneOn (HermitianMat.cfc · f) { A : HermitianMat d ℂ | A.mat.PosDef } := + False.elim hf_is_operator_convex section uncategorized_cleanup @@ -1411,8 +1411,7 @@ lemma ker_cfc_le_ker_on_set exact mem_ker_iff_mulVec_zero A x lemma ker_cfc_le_ker (h : ∀ i, f i = 0 → i = 0) : - (A.cfc f).ker ≤ A.ker := by - exact ker_cfc_le_ker_on_set (Set.subset_univ _) (by simpa using h) + (A.cfc f).ker ≤ A.ker := ker_cfc_le_ker_on_set (Set.subset_univ _) (by simpa using h) lemma ker_cfc_le_ker_nonneg (hA : 0 ≤ A) (h : ∀ i ≥ 0, f i = 0 → i = 0) : (A.cfc f).ker ≤ A.ker := by @@ -1437,8 +1436,7 @@ lemma ker_le_ker_cfc_on_set (hs : spectrum ℝ A.mat ⊆ s) (h : ∀ i ∈ s, i exact Or.inl ( h _ ( hs (Matrix.IsHermitian.eigenvalues_mem_spectrum_real (H A) j ) ) hj ) lemma ker_le_ker_cfc (h : ∀ i, i = 0 → f i = 0) : - A.ker ≤ (A.cfc f).ker := by - exact ker_le_ker_cfc_on_set (Set.subset_univ _) (by simpa using h) + A.ker ≤ (A.cfc f).ker := ker_le_ker_cfc_on_set (Set.subset_univ _) (by simpa using h) lemma ker_le_ker_cfc_nonneg (hA : 0 ≤ A) (h : ∀ i ≥ 0, i = 0 → f i = 0) : A.ker ≤ (A.cfc f).ker := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 4024f5711..a6f19d9eb 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -364,8 +364,7 @@ theorem cfc_sq_rpow_eq_cfc_rpow /-- Tr[A^p] = ∑ᵢ λᵢ^p for a Hermitian matrix A. -/ lemma trace_rpow_eq_sum (A : HermitianMat d ℂ) (p : ℝ) : - (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p := by - exact A.trace_cfc_eq (· ^ p) + (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p := A.trace_cfc_eq (· ^ p) /-! ## Loewner-Heinz Theorem The operator monotonicity of `x ↦ x ^ q` for `0 < q ≤ 1`: diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 52daee2cb..5e61bddcb 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -270,11 +270,11 @@ theorem Sᵥₙ_eq_trace_cfc {d : Type*} [Fintype d] [DecidableEq d] (ρ : MStat have h_def : Sᵥₙ ρ = Finset.sum Finset.univ (fun x ↦ Real.negMulLog (ρ.M.H.eigenvalues x)) := rfl -- By definition of trace, the trace of `cfc ρ.M Real.negMulLog` is the sum of its eigenvalues. have h_trace : (ρ.M.cfc Real.negMulLog).trace = - ∑ x, (ρ.M.cfc Real.negMulLog).H.eigenvalues x := by - exact (HermitianMat.sum_eigenvalues_eq_trace _).symm + ∑ x, (ρ.M.cfc Real.negMulLog).H.eigenvalues x := + (HermitianMat.sum_eigenvalues_eq_trace _).symm obtain ⟨e, he⟩ : ∃ e : d ≃ d, (ρ.M.cfc Real.negMulLog).H.eigenvalues = - Real.negMulLog ∘ ρ.M.H.eigenvalues ∘ e := by - exact Matrix.IsHermitian.cfc_eigenvalues _ _ + Real.negMulLog ∘ ρ.M.H.eigenvalues ∘ e := + Matrix.IsHermitian.cfc_eigenvalues _ _ rw [h_def, h_trace, he] simp only [Function.comp_apply] conv_lhs => rw [ ← Equiv.sum_comp e ] From 864bf17966cc33b41dcaee0c3ae945ab191260ec Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:13:19 -0700 Subject: [PATCH 137/498] refactor: golf entropy exact wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/DPI.lean | 19 +++++++++---------- QuantumInfo/Entropy/Relative.lean | 15 ++++++--------- QuantumInfo/Entropy/SSA.lean | 6 ++---- QuantumInfo/Entropy/VonNeumann.lean | 7 +++---- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 1d77a21e0..2ddbf5800 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -371,8 +371,8 @@ lemma inner_eq_inner_conj_of_ker_le (ρ σ : MState d) simp only [inner_def, conj_apply_mat] have h_support : σ.M.supportProj.mat * ρ.M.mat = ρ.M.mat ∧ - ρ.M.mat * σ.M.supportProj.mat = ρ.M.mat := by - exact ⟨supportProj_mul_of_ker_le hker, mul_supportProj_of_ker_le hker⟩ + ρ.M.mat * σ.M.supportProj.mat = ρ.M.mat := + ⟨supportProj_mul_of_ker_le hker, mul_supportProj_of_ker_le hker⟩ have h_trace_cyclic : Matrix.trace ((σ.M ^ γ).mat * ρ.M.mat * (σ.M ^ γ).mat * (σ.M ^ (-γ)).mat * H.mat * (σ.M ^ (-γ)).mat) = @@ -516,8 +516,8 @@ This follows from the variational formula: the supremum equals `Q̃_α(ρ‖σ)` which is a finite real number. -/ theorem f_alpha_bddAbove (hα : 1 < α) (ρ σ : MState d) (hker : σ.M.ker ≤ ρ.M.ker) : - BddAbove (Set.range (fun H : {H : HermitianMat d ℂ // 0 ≤ H} => f_alpha α H.1 ρ σ)) := by - exact ⟨_, Set.forall_mem_range.mpr fun H => f_alpha_le_at_optimizer hα ρ σ _ H.2 hker⟩ + BddAbove (Set.range (fun H : {H : HermitianMat d ℂ // 0 ≤ H} => f_alpha α H.1 ρ σ)) := + ⟨_, Set.forall_mem_range.mpr fun H => f_alpha_le_at_optimizer hα ρ σ _ H.2 hker⟩ /- **Step 5 (Sup preserves convexity)**: The supremum over `H ≥ 0` of the jointly @@ -827,8 +827,8 @@ The trace functional is multiplicative over tensor products: -/ theorem sandwichedTraceFunctional_mul (ρ₁ σ₁ : MState dA) (ρ₂ σ₂ : MState dB) : - Q̃_ α(ρ₁ ⊗ᴹ ρ₂‖σ₁ ⊗ᴹ σ₂) = Q̃_ α(ρ₁‖σ₁) * Q̃_ α(ρ₂‖σ₂) := by - exact sandwiched_term_product ρ₁ σ₁ ρ₂ σ₂ α ((1 - α) / (2 * α)) + Q̃_ α(ρ₁ ⊗ᴹ ρ₂‖σ₁ ⊗ᴹ σ₂) = Q̃_ α(ρ₁‖σ₁) * Q̃_ α(ρ₂‖σ₂) := + sandwiched_term_product ρ₁ σ₁ ρ₂ σ₂ α ((1 - α) / (2 * α)) /- The trace functional of a state with itself equals 1. @@ -883,8 +883,8 @@ theorem MState.conjTensorUnitary_M (ρ : MState (dA × dB)) (V : Matrix.unitaryG /-- The trace functional is invariant under `1_A ⊗ V` conjugation. -/ theorem sandwichedTraceFunctional_conj_tensorUnitary (ρ σ : MState (dA × dB)) (V : Matrix.unitaryGroup dB ℂ) : - Q̃_ α(ρ.conjTensorUnitary V‖σ.conjTensorUnitary V) = Q̃_ α(ρ‖σ) := by - exact sandwichedTraceFunctional_conj_unitary_MState _ ρ σ + Q̃_ α(ρ.conjTensorUnitary V‖σ.conjTensorUnitary V) = Q̃_ α(ρ‖σ) := + sandwichedTraceFunctional_conj_unitary_MState _ ρ σ section twirling @@ -1290,8 +1290,7 @@ theorem sandwichedRenyiEntropy_tensor_pure (hα : 0 < α) (ρ σ : MState d₁) /-- The sandwiched Rényi divergence is invariant under SWAP. -/ @[simp] theorem sandwichedRenyiEntropy_SWAP (ρ σ : MState (dA × dB)) : - D̃_ α(ρ.SWAP‖σ.SWAP) = D̃_ α(ρ‖σ) := by - exact sandwichedRelRentropy_relabel ρ σ _ + D̃_ α(ρ.SWAP‖σ.SWAP) = D̃_ α(ρ‖σ) := sandwichedRelRentropy_relabel ρ σ _ /- Monotonicity of the sandwiched Rényi divergence under traceRight for `α > 1`, diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index eaae1ec58..30aa67418 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -1820,8 +1820,7 @@ theorem sandwichedRelRentropy_of_unique [Unique d] (ρ σ : MState d) : @[simp] theorem qRelEntropy_of_unique [Unique d] (ρ σ : MState d) : - 𝐃(ρ‖σ) = 0 := by - exact sandwichedRelRentropy_of_unique ρ σ + 𝐃(ρ‖σ) = 0 := sandwichedRelRentropy_of_unique ρ σ theorem sandwichedRelRentropy_heq_congr {d₁ d₂ : Type u} [Fintype d₁] [DecidableEq d₁] [Fintype d₂] [DecidableEq d₂] @@ -1845,9 +1844,8 @@ theorem sandwichedRelRentropy_congr {α : ℝ} simp theorem qRelEntropy_heq_congr {d₁ d₂ : Type u} [Fintype d₁] [DecidableEq d₁] [Fintype d₂] [DecidableEq d₂] - {ρ₁ σ₁ : MState d₁} {ρ₂ σ₂ : MState d₂} (hd : d₁ = d₂) (hρ : ρ₁ ≍ ρ₂) (hσ : σ₁ ≍ σ₂) : - 𝐃(ρ₁‖σ₁) = 𝐃(ρ₂‖σ₂) := by - exact sandwichedRelRentropy_heq_congr hd hρ hσ + {ρ₁ σ₁ : MState d₁} {ρ₂ σ₂ : MState d₂} (hd : d₁ = d₂) (hρ : ρ₁ ≍ ρ₂) (hσ : σ₁ ≍ σ₂) : + 𝐃(ρ₁‖σ₁) = 𝐃(ρ₂‖σ₂) := sandwichedRelRentropy_heq_congr hd hρ hσ /-- Quantum relative entropy when σ has full rank -/ theorem qRelativeEnt_rank {ρ σ : MState d} [σ.M.NonSingular] : @@ -2058,8 +2056,8 @@ theorem qRelativeEnt_lowerSemicontinuous_2 (ρ x : MState d) (hx : ¬(x.M.ker convert h_inner_lt_y using 1 ext1 N simp [inner_sub_right] - obtain ⟨N, hN⟩ : ∃ N : ℕ, ⟪ρ.M, ρ.M.log - x.M.cfc (approxLog N)⟫ > y.toReal := by - exact (h_inner_lt_y.eventually_gt_atTop _ ).exists + obtain ⟨N, hN⟩ : ∃ N : ℕ, ⟪ρ.M, ρ.M.log - x.M.cfc (approxLog N)⟫ > y.toReal := + (h_inner_lt_y.eventually_gt_atTop _ ).exists have h_cont : Continuous (fun σ : MState d => ⟪ρ.M, ρ.M.log - σ.M.cfc (approxLog N)⟫) := by simp only [inner_sub_right] exact continuous_const.sub (continuous_inner_cfc_approxLog ρ N) @@ -2326,8 +2324,7 @@ private lemma pos_of_MState_le_smul {σ₁ σ₂ : MState d} (hσ : σ₂.M ≤ open ComplexOrder in private lemma HermitianMat.inner_log_mono_of_posDef_of_le {A B C : HermitianMat d 𝕜} (hC : 0 ≤ C) (hA : A.mat.PosDef) (hAB : A ≤ B) : - ⟪C, A.log⟫ ≤ ⟪C, B.log⟫ := by - exact inner_mono hC (log_mono hA hAB) + ⟪C, A.log⟫ ≤ ⟪C, B.log⟫ := inner_mono hC (log_mono hA hAB) open ComplexOrder in private lemma posDef_add_eps {A : HermitianMat d ℂ} (hA : 0 ≤ A) {ε : ℝ} (hε : 0 < ε) : diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 673e80967..662b13edf 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -188,8 +188,7 @@ lemma PosDef_traceRight [Nonempty dB] (A : HermitianMat (dA × dB) ℂ) (hA : A. rw [Finset.sum_comm_cycle] lemma PosDef_traceLeft [Nonempty dA] (A : HermitianMat (dA × dB) ℂ) (hA : A.mat.PosDef) : - A.traceLeft.mat.PosDef := by - exact PosDef_traceRight (A.reindex (Equiv.prodComm _ _)) (hA.reindex _) + A.traceLeft.mat.PosDef := PosDef_traceRight (A.reindex (Equiv.prodComm _ _)) (hA.reindex _) /-- V_rho is an isometry. @@ -364,8 +363,7 @@ theorem HermitianMat.PosDef_kronecker {m n : Type*} [Fintype m] [DecidableEq m] [Fintype n] [DecidableEq n] (A : HermitianMat m ℂ) (B : HermitianMat n ℂ) (hA : A.mat.PosDef) (hB : B.mat.PosDef) : - (A ⊗ₖ B).mat.PosDef := by - exact Matrix.PosDef.kron hA hB + (A ⊗ₖ B).mat.PosDef := Matrix.PosDef.kron hA hB /- Reindex of PosDef is PosDef. -/ theorem HermitianMat.PosDef_reindex {d d₂ : Type*} [Fintype d] [DecidableEq d] diff --git a/QuantumInfo/Entropy/VonNeumann.lean b/QuantumInfo/Entropy/VonNeumann.lean index 59e5e7717..192017247 100644 --- a/QuantumInfo/Entropy/VonNeumann.lean +++ b/QuantumInfo/Entropy/VonNeumann.lean @@ -257,8 +257,7 @@ the same von Neumann entropy. private lemma Sᵥₙ_eq_of_nonzero_eigenvalues_eq (ρ₁ : MState d₁) (ρ₂ : MState d₂) (h : (Finset.univ.val.map ρ₁.spectrum.prob).filter (· ≠ 0) = (Finset.univ.val.map ρ₂.spectrum.prob).filter (· ≠ 0)) : - Sᵥₙ ρ₁ = Sᵥₙ ρ₂ := by - exact Hₛ_eq_of_nonzero_multiset_eq _ _ h + Sᵥₙ ρ₁ = Sᵥₙ ρ₂ := Hₛ_eq_of_nonzero_multiset_eq _ _ h /-- Filtering non-zero elements commutes with mapping `RCLike.ofReal` for multisets. @@ -286,8 +285,8 @@ private lemma charpoly_roots_filter_ne_zero_eq_eigenvalues_filter_ne_zero {d : T Mapping `RCLike.ofReal` over a multiset is injective. -/ private lemma multiset_map_ofReal_injective {R : Type*} [RCLike R] {M N : Multiset ℝ} : - M.map (RCLike.ofReal : ℝ → R) = N.map RCLike.ofReal ↔ M = N := by - exact ⟨fun h ↦ by simpa using congr(($h).map RCLike.re), fun h ↦ by rw [h]⟩ + M.map (RCLike.ofReal : ℝ → R) = N.map RCLike.ofReal ↔ M = N := + ⟨fun h ↦ by simpa using congr(($h).map RCLike.re), fun h ↦ by rw [h]⟩ /-- If the non-zero roots of the characteristic polynomials of two states are equal, From c58344ef6a08e020a17ef6860f0abf6118b8e735 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:16:13 -0700 Subject: [PATCH 138/498] refactor: golf small exact proofs Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/SpectralTheory/Basic.lean | 4 ++-- Physlib/SpaceAndTime/Space/Derivatives/Curl.lean | 4 ++-- .../TraceInequality/JensenOperatorInequalityIVtoV.lean | 4 ++-- QuantumInfo/ForMathlib/Majorization.lean | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean index 4106c2cdd..07678450e 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean @@ -226,8 +226,8 @@ lemma regularityDomain_isOpen (T : H →ₗ.[ℂ] H) : IsOpen T.regularityDomain /-- `T` and `T.closure` have the same regularity domain. -/ lemma regularityDomain_closure (T : H →ₗ.[ℂ] H) : - T.closure.regularityDomain = T.regularityDomain := by - exact eq_of_le_of_ge (regularityDomain_antitone T.le_closure) + T.closure.regularityDomain = T.regularityDomain := + eq_of_le_of_ge (regularityDomain_antitone T.le_closure) fun _ ⟨c, hc, h⟩ ↦ ⟨c, hc, isLowerBound_closure h⟩ lemma IsClosable.closure_range_sub_eq_range_closure_sub [CompleteSpace H] diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean b/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean index 86b89156b..40fca4c7a 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean @@ -454,8 +454,8 @@ private lemma deriv_intervalIntegral_homotopyOperatorIntegrand_sub have F'_continuous : Continuous (Function.uncurry F') := continuous_uncurry_fderiv_homotopyOperatorIntegrand (hf) have hfderiv (x₀ : Space) : HasFDerivAt (fun (x : Space) => ∫ (t : ℝ) in 0..1, F x t ∂(volume)) - (∫ (t : ℝ) in 0..1, F' x₀ t ∂(volume)) x₀ := by - exact hasFDerivAt_intervalIntegral_homotopyOperatorIntegrand (hf) x₀ + (∫ (t : ℝ) in 0..1, F' x₀ t ∂(volume)) x₀ := + hasFDerivAt_intervalIntegral_homotopyOperatorIntegrand (hf) x₀ have F'_apply_apply (x₀ : Space) (y : Space) (i : Fin 3) : ((∫ (t : ℝ) in 0..1, F' x₀ t) y).ofLp i = (∫ (t : ℝ) in 0..1, F' x₀ t y i) := by diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean index df78c42bb..467e3df2f 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean @@ -231,8 +231,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) · intro z simp [sub_eq_add_neg] have hblock : - blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by - exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) + blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := + sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index bdab08ba2..a4194a01a 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -102,8 +102,8 @@ lemma singularValuesSorted_antitone (A : Matrix d d ℂ) : lemma antitone_mul_of_antitone_nonneg {n : ℕ} {f g : Fin n → ℝ} (hf : Antitone f) (hg : Antitone g) (hf_nn : ∀ i, 0 ≤ f i) (hg_nn : ∀ i, 0 ≤ g i) : - Antitone (fun i => f i * g i) := by - exact fun i j hij => mul_le_mul (hf hij) (hg hij) (hg_nn _) (hf_nn _) + Antitone (fun i => f i * g i) := + fun _ _ hij => mul_le_mul (hf hij) (hg hij) (hg_nn _) (hf_nn _) /-! ### Compound matrices and auxiliary lemmas for Horn's inequality @@ -812,8 +812,8 @@ lemma horn_weak_log_majorization (A B : Matrix d d ℂ) (k : ℕ) lemma rpow_antitone_of_nonneg_antitone {n : ℕ} {f : Fin n → ℝ} (hf : Antitone f) (hf_nn : ∀ i, 0 ≤ f i) {r : ℝ} (hr : 0 < r) : - Antitone (fun i => f i ^ r) := by - exact fun i j hij => Real.rpow_le_rpow (hf_nn _) (hf hij) hr.le + Antitone (fun i => f i ^ r) := + fun _ _ hij => Real.rpow_le_rpow (hf_nn _) (hf hij) hr.le /-- Weak log-majorization is preserved under positive powers. -/ lemma rpow_preserves_weak_log_maj {n : ℕ} From 8d7d3439bfc549c4613c648d14135d889050bc7f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:17:27 -0700 Subject: [PATCH 139/498] refactor: golf Lowner-Heinz exact wrappers Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 454f026c4..cf5e1db80 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -865,8 +865,8 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → C + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) AB ≤ C + ((t * (1 - u)) • cfcR (fun x : ℝ ↦ 1 / (x + t)) A - + (t * u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := by - exact add_le_add_right hscale C + + (t * u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := + add_le_add_right hscale C have hR : C + ((t * (1 - u)) • cfcR (fun x : ℝ ↦ 1 / (x + t)) A @@ -1089,12 +1089,10 @@ private lemma concaveOn_rpow_Ioo {p : ℝ} (hp : p ∈ Set.Ioo (0 : ℝ) 1) : -- reduce to the `ℝ≥0` exponent case let q : NNReal := ⟨p, le_of_lt hp.1⟩ have hq0 : (0 : NNReal) < q := by - have : (0 : ℝ) < (q : ℝ) := by - exact hp.1 + have : (0 : ℝ) < (q : ℝ) := hp.1 exact (NNReal.coe_pos).1 this have hq1 : q < (1 : NNReal) := by - have : (q : ℝ) < (1 : ℝ) := by - exact hp.2 + have : (q : ℝ) < (1 : ℝ) := hp.2 exact (NNReal.coe_lt_coe).1 (by simpa using this) have hq : q ∈ Set.Ioo (0 : NNReal) 1 := ⟨hq0, hq1⟩ -- main lemma: concavity for `a ↦ a ^ q` @@ -1647,8 +1645,8 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : have hAA' : ((1 - u) • A) * ((1 - u) • A) = ((1 - u) * (1 - u)) • (A * A) := by calc - ((1 - u) • A) * ((1 - u) • A) = (1 - u) • (A * ((1 - u) • A)) := by - exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A ((1 - u) • A) + ((1 - u) • A) * ((1 - u) • A) = (1 - u) • (A * ((1 - u) • A)) := + Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A ((1 - u) • A) _ = (1 - u) • ((1 - u) • (A * A)) := by rw [Algebra.mul_smul_comm] _ = ((1 - u) * (1 - u)) • (A * A) := by @@ -1656,8 +1654,8 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : have hAB' : ((1 - u) • A) * (u • B) = ((1 - u) * u) • (A * B) := by calc - ((1 - u) • A) * (u • B) = (1 - u) • (A * (u • B)) := by - exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A (u • B) + ((1 - u) • A) * (u • B) = (1 - u) • (A * (u • B)) := + Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A (u • B) _ = (1 - u) • (u • (A * B)) := by rw [Algebra.mul_smul_comm] _ = ((1 - u) * u) • (A * B) := by @@ -1665,8 +1663,8 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : have hBA' : (u • B) * ((1 - u) • A) = (u * (1 - u)) • (B * A) := by calc - (u • B) * ((1 - u) • A) = u • (B * ((1 - u) • A)) := by - exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B ((1 - u) • A) + (u • B) * ((1 - u) • A) = u • (B * ((1 - u) • A)) := + Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B ((1 - u) • A) _ = u • ((1 - u) • (B * A)) := by simp [Algebra.mul_smul_comm] _ = (u * (1 - u)) • (B * A) := by @@ -1674,8 +1672,8 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : have hBB' : (u • B) * (u • B) = (u * u) • (B * B) := by calc - (u • B) * (u • B) = u • (B * (u • B)) := by - exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B (u • B) + (u • B) * (u • B) = u • (B * (u • B)) := + Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B (u • B) _ = u • (u • (B * B)) := by simp [Algebra.mul_smul_comm] _ = (u * u) • (B * B) := by From f33063b2e6e64103367c7e741e2dbd6c1b3d792d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:18:44 -0700 Subject: [PATCH 140/498] refactor: golf operator mean exact wrappers Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/OperatorGeometricMean.lean | 13 +++++-------- .../ForMathlib/HermitianMat/LiebConcavity.lean | 8 ++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean index cf15c94a6..3c7883d7e 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean @@ -68,11 +68,9 @@ theorem operatorPowerMean_jointlyConcaveOn_pdSet intro K _ _ _ _ exact power_Icc_zero_one_operatorConcaveOn_Ici (ℋ := K) α hα) (hfcont := rpow_continuousOn_Ici α hα.1) - (hf0 := by - exact Real.rpow_nonneg (show (0 : ℝ) ≤ 0 by simp) α) - (hconc := by - exact operatorConcaveOn_Ioi_of_Ici (ℋ := ℋ) - (power_Icc_zero_one_operatorConcaveOn_Ici (ℋ := ℋ) β hβ)) + (hf0 := Real.rpow_nonneg (show (0 : ℝ) ≤ 0 by simp) α) + (hconc := operatorConcaveOn_Ioi_of_Ici (ℋ := ℋ) + (power_Icc_zero_one_operatorConcaveOn_Ici (ℋ := ℋ) β hβ)) (hcont := by intro x hx exact (Real.continuousAt_rpow_const x β (Or.inl (ne_of_gt hx))).continuousWithinAt) @@ -106,9 +104,8 @@ theorem operatorPowerMean_jointlyConvexOn_pdSet · have hα0 : α ≠ 0 := by linarith [hα.1] simp [Real.zero_rpow hα0] ) - (hconc := by - exact operatorConcaveOn_Ioi_of_Ici (ℋ := ℋ) - (power_Icc_zero_one_operatorConcaveOn_Ici (ℋ := ℋ) β hβ)) + (hconc := operatorConcaveOn_Ioi_of_Ici (ℋ := ℋ) + (power_Icc_zero_one_operatorConcaveOn_Ici (ℋ := ℋ) β hβ)) (hcont := by intro x hx exact (Real.continuousAt_rpow_const x β (Or.inl (ne_of_gt hx))).continuousWithinAt) diff --git a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean index e2e6c8536..25cd4b17e 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean @@ -98,8 +98,8 @@ lemma Φ_mem_pdSet [Nonempty d] (A : HermitianMat d ℂ) (hA : A.mat.PosDef) : set_option synthInstance.maxHeartbeats 80000 in /-- `Φ` commutes with CFC for Hermitian matrices. -/ lemma Φ_cfc (A : HermitianMat d ℂ) (f : ℝ → ℝ) : - Φ (cfc f A.mat) = cfc f (Φ A.mat) := by - exact StarAlgHomClass.map_cfc Φ f A.mat (hφ := Φ_continuous) + Φ (cfc f A.mat) = cfc f (Φ A.mat) := + StarAlgHomClass.map_cfc Φ f A.mat (hφ := Φ_continuous) (ha := A.H.isSelfAdjoint) set_option synthInstance.maxHeartbeats 80000 in @@ -183,8 +183,8 @@ omit [Fintype d] in /-- σ + εI → σ as ε → 0+. -/ private lemma tendsto_add_eps (σ : HermitianMat d ℂ) : Filter.Tendsto (fun ε : ℝ ↦ σ + ε • (1 : HermitianMat d ℂ)) - (nhdsWithin 0 (Set.Ioi 0)) (nhds σ) := by - exact tendsto_nhdsWithin_of_tendsto_nhds + (nhdsWithin 0 (Set.Ioi 0)) (nhds σ) := + tendsto_nhdsWithin_of_tendsto_nhds (Continuous.tendsto' (by continuity) _ _ (by simp)) /-! ### Helper lemmas for the core concavity proof -/ From 5675dc39bfe11d4a52ac38b64d03fcae1189c919 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:21:51 -0700 Subject: [PATCH 141/498] refactor: golf residual exact wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/QuantumMechanics/DDimensions/Operators/Position.lean | 4 ++-- Physlib/SpaceAndTime/Space/ConstantSliceDist.lean | 4 ++-- Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean | 4 ++-- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 4 ++-- QuantumInfo/ForMathlib/Majorization.lean | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean index b8c9df9a1..55b3f918f 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean @@ -237,8 +237,8 @@ lemma radiusPowLM_apply_memHS {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (a : rw [Real.rpow_neg hx'.le] exact (le_mul_inv_iff₀' <| Real.rpow_pos_of_pos hx' _).mpr (hC x) calc - _ ≤ (C * ‖x‖ ^ (-(⌈s⌉.toNat + d) : ℝ)) ^ 2 * ‖x‖ ^ (2 * s) := by - exact mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (norm_nonneg _) hψ 2) + _ ≤ (C * ‖x‖ ^ (-(⌈s⌉.toNat + d) : ℝ)) ^ 2 * ‖x‖ ^ (2 * s) := + mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (norm_nonneg _) hψ 2) (Real.rpow_nonneg hx'.le _) _ = C ^ 2 * ‖x‖ ^ (-2 * d : ℝ) * ‖x‖ ^ (2 * (s - ⌈s⌉.toNat) : ℝ) := by simp_rw [mul_pow, ← Real.rpow_mul_natCast hx'.le, mul_assoc, ← Real.rpow_add hx'] diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index 0cfeea911..3368f8772 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -490,8 +490,8 @@ lemma schwartzMap_mul_pow_slice_integral_iteratedFDeriv_norm_le {d : ℕ} (n m : calc _ _ ≤ ‖x‖ ^ m * ((∫ (r : ℝ), ‖iteratedFDeriv ℝ n η ((slice i).symm (r, x))‖) * ‖(slice i).symm.toContinuousLinearMap.comp - ((0 : Space d →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n) := by - exact mul_le_mul_of_nonneg (by rfl) + ((0 : Space d →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n) := + mul_le_mul_of_nonneg (by rfl) (schwartzMap_slice_integral_iteratedFDeriv_norm_le n η i x) (by positivity) (by positivity) _ ≤ (∫ (r : ℝ), ‖x‖ ^ m * ‖iteratedFDeriv ℝ n η ((slice i).symm (r, x))‖) * diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 633507ee7..412620afd 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -798,8 +798,8 @@ lemma time_integral_mul_pow_iteratedFDeriv_norm_le {d : ℕ} (n m : ℕ) : have hk' : 0 ≤ k := by rw [← hk]; positivity calc _ _ ≤ ‖x‖ ^ m * ((∫ (t : Time), ‖iteratedFDeriv ℝ n η (t, x)‖) * - ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n) := by - exact mul_le_mul_of_nonneg (by rfl) (time_integral_iteratedFDeriv_norm_le n η x) + ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n) := + mul_le_mul_of_nonneg (by rfl) (time_integral_iteratedFDeriv_norm_le n η x) (by positivity) (by positivity) _ ≤ (∫ (t : Time), ‖x‖ ^ m * ‖iteratedFDeriv ℝ n η (t, x)‖) * ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index a6f19d9eb..fac666b4b 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -964,8 +964,8 @@ private lemma lieb_thirring_le_one_posDef intro k hk calc ∏ i : Fin k, singularValuesSorted N ⟨i.val, by omega⟩ - = singularValuesSorted (compoundMatrix N k) (compoundZero k hk) := by - exact prod_singularValuesSorted_eq_compoundSV N k hk + = singularValuesSorted (compoundMatrix N k) (compoundZero k hk) := + prod_singularValuesSorted_eq_compoundSV N k hk _ ≤ singularValuesSorted (compoundMatrix M k) (compoundZero k hk) ^ r := by simpa [M, N] using compound_top_singular_le_posDef hA hB hr0 hr1 k hk _ = ∏ i : Fin k, (singularValuesSorted M ⟨i.val, by omega⟩) ^ r := by diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index a4194a01a..725c311ca 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -513,8 +513,8 @@ lemma exists_sorting_equiv (M : Matrix d d ℂ) : · norm_num [Function.Injective, Function.Surjective] exact fun i j hij => Fin.ext <| by simpa [Fin.ext_iff] using σ.injective <| Fin.ext hij · intro b - obtain ⟨a, ha⟩ : ∃ a : Fin (List.ofFn (singularValuesSorted M)).length, σ a = ⟨b, by simp⟩ := by - exact σ.surjective _ + obtain ⟨a, ha⟩ : ∃ a : Fin (List.ofFn (singularValuesSorted M)).length, σ a = ⟨b, by simp⟩ := + σ.surjective _ use ⟨a, lt_of_lt_of_le a.2 (by simp)⟩ exact Fin.ext (by simp [ha]) · intro i From d0b874ef6d7b842788dc351a30f459101074d2fb Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:24:04 -0700 Subject: [PATCH 142/498] refactor: golf remaining exact wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/InnerProductSpace/Submodule.lean | 4 ++-- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 4 ++-- QuantumInfo/ForMathlib/Majorization.lean | 4 ++-- QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Physlib/Mathematics/InnerProductSpace/Submodule.lean b/Physlib/Mathematics/InnerProductSpace/Submodule.lean index a05415384..a72f1aa6e 100644 --- a/Physlib/Mathematics/InnerProductSpace/Submodule.lean +++ b/Physlib/Mathematics/InnerProductSpace/Submodule.lean @@ -65,8 +65,8 @@ lemma submoduleToLp_closure : · intro h t ht apply mem_nhds_iff.mp at ht rcases ht with ⟨t1, ht1, ht1', hx⟩ - have : ∃ t' ∈ nhds x, (∀ y ∈ t', y.ofLp ∈ t1) := by - exact Filter.eventually_iff_exists_mem.mp + have : ∃ t' ∈ nhds x, (∀ y ∈ t', y.ofLp ∈ t1) := + Filter.eventually_iff_exists_mem.mp (ContinuousAt.eventually_mem (by fun_prop) (IsOpen.mem_nhds ht1' hx)) rcases this with ⟨t2, ht2, ht2'⟩ rcases h t2 ht2 with ⟨w, hw⟩ diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index fac666b4b..45efeb940 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -401,8 +401,8 @@ theorem rpowApprox_mono {A B : HermitianMat d ℂ} (hA : A.mat.PosDef) (hB : B.m have h_cont_tq : ContinuousOn (fun t : ℝ => t ^ q) (Set.Icc 0 T) := continuousOn_id.rpow_const fun _ _ => Or.inr hq have h_cont_const : - ContinuousOn (fun t : ℝ => (1 + t)⁻¹ • (1 : HermitianMat d ℂ)) (Set.Icc 0 T) := by - exact ((continuousOn_const.add continuousOn_id).inv₀ + ContinuousOn (fun t : ℝ => (1 + t)⁻¹ • (1 : HermitianMat d ℂ)) (Set.Icc 0 T) := + ((continuousOn_const.add continuousOn_id).inv₀ (fun t ht => by change (1 : ℝ) + t ≠ 0 linarith [ht.1])).smul continuousOn_const diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index 725c311ca..87f9619d1 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -355,8 +355,8 @@ lemma prod_le_prod_sorted {n : ℕ} {f : Fin n → ℝ} -- And the product is preserved under sorting (it's the same set of values) have h_exists_sorted : ∃ (g' : Fin k → Fin n), Function.Injective g' ∧ StrictMono g' ∧ - Finset.image g Finset.univ = Finset.image g' Finset.univ := by - exact ⟨Finset.orderEmbOfFin (Finset.image g Finset.univ) (by simp [Finset.card_image_of_injective _ hg]), + Finset.image g Finset.univ = Finset.image g' Finset.univ := + ⟨Finset.orderEmbOfFin (Finset.image g Finset.univ) (by simp [Finset.card_image_of_injective _ hg]), fun a b h => by simpa using h, fun a b h => by simpa using h, by ext x; simp⟩ diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index 7bffe61ca..af67fdd0a 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -371,12 +371,12 @@ omit [Fintype m] [RCLike R] [DecidableEq n] in theorem traceNorm_sandwich_le [DecidableEq n] {S M T : Matrix n n ℂ} (hS : ‖S‖ ≤ 1) (hT : ‖T‖ ≤ 1) : (S * M * T).traceNorm ≤ M.traceNorm := calc (S * M * T).traceNorm - ≤ (M * T).traceNorm := by - exact le_trans + ≤ (M * T).traceNorm := + le_trans (by simpa [Matrix.mul_assoc] using Matrix.traceNorm_mul_le_opNorm_traceNorm S (M * T)) (by simpa using mul_le_mul_of_nonneg_right hS (Matrix.traceNorm_nonneg (M * T))) - _ ≤ M.traceNorm := by - exact le_trans (traceNorm_mul_le_traceNorm_opNorm M T) + _ ≤ M.traceNorm := + le_trans (traceNorm_mul_le_traceNorm_opNorm M T) (by simpa using mul_le_mul_of_nonneg_left hT (Matrix.traceNorm_nonneg M)) end @@ -399,8 +399,8 @@ theorem abs_trace_le_traceNorm (A : Matrix n n ℂ) : simpa [Matrix.trace] using norm_sum_le (s := Finset.univ) (f := fun i => (C.val * D) i i) _ = ∑ i, ‖C.val i i‖ * Real.sqrt (hH.eigenvalues i) := by simp [D, Matrix.mul_apply, Matrix.diagonal, Real.norm_eq_abs, abs_of_nonneg] - _ ≤ ∑ i, Real.sqrt (hH.eigenvalues i) := by - exact Finset.sum_le_sum (fun i _ => by + _ ≤ ∑ i, Real.sqrt (hH.eigenvalues i) := + Finset.sum_le_sum (fun i _ => by simpa using mul_le_mul_of_nonneg_right (entry_norm_bound_of_unitary C.property i i) (Real.sqrt_nonneg _)) From 2595f8bfc896ff2b9a8bbbc73c1fc72bb68f25d3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:28:54 -0700 Subject: [PATCH 143/498] refactor: golf small math proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Fin.lean | 3 +-- Physlib/Mathematics/InnerProductSpace/Calculus.lean | 3 +-- Physlib/Mathematics/LinearMaps.lean | 3 +-- Physlib/Mathematics/List.lean | 4 +--- Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean | 4 +--- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index 8d4fb4752..cad4974eb 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -86,8 +86,7 @@ def finExtractOne {n : ℕ} (i : Fin (n + 1)) : Fin (n + 1) ≃ Fin 1 ⊕ Fin n @[simp] lemma finExtractOne_apply_eq {n : ℕ} (i : Fin n.succ) : finExtractOne i i = Sum.inl 0 := by - rw [Equiv.apply_eq_iff_eq_symm_apply] - rfl + exact (Equiv.apply_eq_iff_eq_symm_apply (finExtractOne i)).2 rfl lemma finExtractOne_symm_inr {n : ℕ} (i : Fin n.succ) : (finExtractOne i).symm ∘ Sum.inr = i.succAbove := by diff --git a/Physlib/Mathematics/InnerProductSpace/Calculus.lean b/Physlib/Mathematics/InnerProductSpace/Calculus.lean index e90768127..2b3b92ff0 100644 --- a/Physlib/Mathematics/InnerProductSpace/Calculus.lean +++ b/Physlib/Mathematics/InnerProductSpace/Calculus.lean @@ -35,8 +35,7 @@ lemma fderiv_inner_apply' {f g : E → F} {x : E} (hf : DifferentiableAt ℝ f x) (hg : DifferentiableAt ℝ g x) (y : E) : fderiv ℝ (fun t => ⟪f t, g t⟫) x y = ⟪f x, fderiv ℝ g x y⟫ + ⟪fderiv ℝ f x y, g x⟫ := by - rw [(hf.hasFDerivAt.inner' hg.hasFDerivAt).fderiv] - rfl + simpa [fderivInnerCLM'] using DFunLike.congr_fun (hf.hasFDerivAt.inner' hg.hasFDerivAt).fderiv y -- todo: move this lemma deriv_inner_apply' diff --git a/Physlib/Mathematics/LinearMaps.lean b/Physlib/Mathematics/LinearMaps.lean index 00cb662a5..3c5eb067e 100644 --- a/Physlib/Mathematics/LinearMaps.lean +++ b/Physlib/Mathematics/LinearMaps.lean @@ -242,8 +242,7 @@ lemma toLinear₁_apply (f : TriLinearSymm V) (S T L : V) : f S T L = f.toLinear lemma map_sum₁ {n : ℕ} (f : TriLinearSymm V) (S : Fin n → V) (T : V) (L : V) : f (∑ i, S i) T L = ∑ i, f (S i) T L := by - rw [f.toLinear₁_apply, map_sum] - rfl + simp [toLinear₁_apply, map_sum] lemma map_sum₂ {n : ℕ} (f : TriLinearSymm V) (S : Fin n → V) (T : V) (L : V) : f T (∑ i, S i) L = ∑ i, f T (S i) L := by diff --git a/Physlib/Mathematics/List.lean b/Physlib/Mathematics/List.lean index abc26fb7d..c781e9305 100644 --- a/Physlib/Mathematics/List.lean +++ b/Physlib/Mathematics/List.lean @@ -446,9 +446,7 @@ lemma orderedInsert_eraseIdx_orderedInsertEquiv_fin_succ (hr : ∀ (i j : Fin r.length), i < j → ¬le1 r0 (r.get j) → ¬le1 r0 (r.get i)) : (List.orderedInsert le1 r0 r).eraseIdx (orderedInsertEquiv le1 r r0 n.succ) = (List.orderedInsert le1 r0 (r.eraseIdx n)) := by - have hn : n.succ = ⟨n.val + 1, by omega⟩ := by - rw [Fin.ext_iff] - rfl + have hn : n.succ = ⟨n.val + 1, by omega⟩ := Fin.ext rfl rw [hn] exact orderedInsert_eraseIdx_orderedInsertEquiv_succ le1 r r0 n.val _ hr diff --git a/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean b/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean index 8395ca4e4..19d847a86 100644 --- a/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean +++ b/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean @@ -81,9 +81,7 @@ def momentumOperatorSchwartz : 𝓢(ℝ, ℂ) →L[ℂ] 𝓢(ℝ, ℂ) where cont := by fun_prop lemma momentumOperatorSchwartz_apply (ψ : 𝓢(ℝ, ℂ)) - (x : ℝ) : (momentumOperatorSchwartz ψ) x = (- Complex.I * ℏ) * (deriv ψ x) := by - rw [momentumOperatorSchwartz] - rfl + (x : ℝ) : (momentumOperatorSchwartz ψ) x = (- Complex.I * ℏ) * (deriv ψ x) := rfl /-- The unbounded momentum operator, whose domain is Schwartz maps. -/ def momentumOperatorUnbounded : UnboundedOperator schwartzIncl schwartzIncl_injective := From e8ae879ff86ae14bbf2c6c8a17bd0025d93d7690 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:30:31 -0700 Subject: [PATCH 144/498] refactor: golf MatrixMap simp proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/MatrixMap.lean | 33 ++++++++++------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index c5eea82a5..43b25bf23 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -285,37 +285,29 @@ theorem kron_def [CommSemiring R] (M₁ : MatrixMap A B R) (M₂ : MatrixMap C D section kron_lemmas variable [CommSemiring R] -theorem add_kron (ML₁ ML₂ : MatrixMap A B R) (MR : MatrixMap C D R) : (ML₁ + ML₂) ⊗ₖₘ MR = ML₁ ⊗ₖₘ MR + ML₂ ⊗ₖₘ MR := by - simp [kron, TensorProduct.map_add_left, Matrix.submatrix_add] +theorem add_kron (ML₁ ML₂ : MatrixMap A B R) (MR : MatrixMap C D R) : (ML₁ + ML₂) ⊗ₖₘ MR = ML₁ ⊗ₖₘ MR + ML₂ ⊗ₖₘ MR := by simp [kron, TensorProduct.map_add_left, Matrix.submatrix_add] -theorem kron_add (ML : MatrixMap A B R) (MR₁ MR₂ : MatrixMap C D R) : ML ⊗ₖₘ (MR₁ + MR₂) = ML ⊗ₖₘ MR₁ + ML ⊗ₖₘ MR₂ := by - simp [kron, TensorProduct.map_add_right, Matrix.submatrix_add] +theorem kron_add (ML : MatrixMap A B R) (MR₁ MR₂ : MatrixMap C D R) : ML ⊗ₖₘ (MR₁ + MR₂) = ML ⊗ₖₘ MR₁ + ML ⊗ₖₘ MR₂ := by simp [kron, TensorProduct.map_add_right, Matrix.submatrix_add] -theorem smul_kron (r : R) (ML : MatrixMap A B R) (MR : MatrixMap C D R) : (r • ML) ⊗ₖₘ MR = r • (ML ⊗ₖₘ MR) := by - simp [kron, TensorProduct.map_smul_left, Matrix.submatrix_smul] +theorem smul_kron (r : R) (ML : MatrixMap A B R) (MR : MatrixMap C D R) : (r • ML) ⊗ₖₘ MR = r • (ML ⊗ₖₘ MR) := by simp [kron, TensorProduct.map_smul_left, Matrix.submatrix_smul] -theorem kron_smul (r : R) (ML : MatrixMap A B R) (MR : MatrixMap C D R) : ML ⊗ₖₘ (r • MR) = r • (ML ⊗ₖₘ MR) := by - simp [kron, TensorProduct.map_smul_right, Matrix.submatrix_smul] +theorem kron_smul (r : R) (ML : MatrixMap A B R) (MR : MatrixMap C D R) : ML ⊗ₖₘ (r • MR) = r • (ML ⊗ₖₘ MR) := by simp [kron, TensorProduct.map_smul_right, Matrix.submatrix_smul] @[simp] -theorem zero_kron (MR : MatrixMap C D R) : (0 : MatrixMap A B R) ⊗ₖₘ MR = 0 := by - simp [kron] +theorem zero_kron (MR : MatrixMap C D R) : (0 : MatrixMap A B R) ⊗ₖₘ MR = 0 := by simp [kron] @[simp] -theorem kron_zero (ML : MatrixMap A B R) : ML ⊗ₖₘ (0 : MatrixMap C D R) = 0 := by - simp [kron] +theorem kron_zero (ML : MatrixMap A B R) : ML ⊗ₖₘ (0 : MatrixMap C D R) = 0 := by simp [kron] variable [DecidableEq B] in -theorem kron_id_id : (id A R ⊗ₖₘ id B R) = id (A × B) R := by - simp [kron] +theorem kron_id_id : (id A R ⊗ₖₘ id B R) = id (A × B) R := by simp [kron] variable {Dl₁ Dl₂ Dl₃ Dr₁ Dr₂ Dr₃ : Type*} [Fintype Dl₁] [Fintype Dl₂] [Fintype Dl₃] [Fintype Dr₁] [Fintype Dr₂] [Fintype Dr₃] [DecidableEq Dl₁] [DecidableEq Dl₂] [DecidableEq Dr₁] [DecidableEq Dr₂] in /-- For maps L₁, L₂, R₁, and R₂, the product (L₂ ∘ₗ L₁) ⊗ₖₘ (R₂ ∘ₗ R₁) = (L₂ ⊗ₖₘ R₂) ∘ₗ (L₁ ⊗ₖₘ R₁) -/ theorem kron_comp_distrib (L₁ : MatrixMap Dl₁ Dl₂ R) (L₂ : MatrixMap Dl₂ Dl₃ R) (R₁ : MatrixMap Dr₁ Dr₂ R) - (R₂ : MatrixMap Dr₂ Dr₃ R) : (L₂ ∘ₗ L₁) ⊗ₖₘ (R₂ ∘ₗ R₁) = (L₂ ⊗ₖₘ R₂) ∘ₗ (L₁ ⊗ₖₘ R₁) := by - simp [kron, TensorProduct.map_comp, ← Matrix.toLin_mul, Matrix.submatrix_mul_equiv, ← LinearMap.toMatrix_comp] + (R₂ : MatrixMap Dr₂ Dr₃ R) : (L₂ ∘ₗ L₁) ⊗ₖₘ (R₂ ∘ₗ R₁) = (L₂ ⊗ₖₘ R₂) ∘ₗ (L₁ ⊗ₖₘ R₁) := by simp [kron, TensorProduct.map_comp, ← Matrix.toLin_mul, Matrix.submatrix_mul_equiv, ← LinearMap.toMatrix_comp] end kron_lemmas @@ -394,12 +386,10 @@ theorem submatrix_kron_submatrix [CommSemiring R] (f : B → A) (g : D → C) : simp [Prod.map, Matrix.single, ite_and] theorem submatrix_kron_id [CommSemiring R] (f : B → A) : - submatrix R f ⊗ₖₘ id C R = submatrix R (Prod.map f _root_.id) := by - simp [← submatrix_kron_submatrix] + submatrix R f ⊗ₖₘ id C R = submatrix R (Prod.map f _root_.id) := by simp [← submatrix_kron_submatrix] theorem id_kron_submatrix [CommSemiring R] (f : B → A) : - id C R ⊗ₖₘ submatrix R f = submatrix R (Prod.map _root_.id f) := by - simp [← submatrix_kron_submatrix] + id C R ⊗ₖₘ submatrix R f = submatrix R (Prod.map _root_.id f) := by simp [← submatrix_kron_submatrix] end kron @@ -453,8 +443,7 @@ theorem piProd_comp [∀ i, Fintype (d₂ i)] [∀ i, DecidableEq (d₂ i)] [∀ i, Fintype (d₃ i)] [∀ i, DecidableEq (d₃ i)] (Λ₁ : ∀ i, MatrixMap (d₁ i) (d₂ i) R) (Λ₂ : ∀ i, MatrixMap (d₂ i) (d₃ i) R) : - piProd (fun i ↦ (Λ₂ i) ∘ₗ (Λ₁ i)) = (piProd Λ₂) ∘ₗ (piProd Λ₁) := by - simp [piProd, PiTensorProduct.map_comp, ← Matrix.toLin_mul, ← LinearMap.toMatrix_comp] + piProd (fun i ↦ (Λ₂ i) ∘ₗ (Λ₁ i)) = (piProd Λ₂) ∘ₗ (piProd Λ₁) := by simp [piProd, PiTensorProduct.map_comp, ← Matrix.toLin_mul, ← LinearMap.toMatrix_comp] @[simp] theorem piProd_id : From a089aa8d40a3694cdfbdf8a66d05ef4c8153178c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:31:44 -0700 Subject: [PATCH 145/498] refactor: golf ClassicalInfo simp proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ClassicalInfo/Distribution.lean | 6 ++---- QuantumInfo/ClassicalInfo/Entropy.lean | 15 +++++---------- QuantumInfo/ClassicalInfo/Prob.lean | 21 +++++++-------------- 3 files changed, 14 insertions(+), 28 deletions(-) diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 93bdf4a51..f3e7dd4be 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -192,12 +192,10 @@ def coin (p : Prob) : ProbDistribution (Fin 2) := ⟨(if · = 0 then p else 1 - p), by simp⟩ @[simp] -theorem coin_val_zero (p : Prob) : coin p 0 = p := by - simp [coin] +theorem coin_val_zero (p : Prob) : coin p 0 = p := by simp [coin] @[simp] -theorem coin_val_one (p : Prob) : coin p 1 = 1 - p := by - simp [coin] +theorem coin_val_one (p : Prob) : coin p 1 = 1 - p := by simp [coin] /-- Every distribution on two variable is some coin. -/ theorem fin_two_eq_coin (d : ProbDistribution (Fin 2)) : d = coin (d 0) := by diff --git a/QuantumInfo/ClassicalInfo/Entropy.lean b/QuantumInfo/ClassicalInfo/Entropy.lean index c7f579ad7..dc861525d 100644 --- a/QuantumInfo/ClassicalInfo/Entropy.lean +++ b/QuantumInfo/ClassicalInfo/Entropy.lean @@ -31,13 +31,11 @@ def H₁ : Prob → ℝ := /-- H₁ of 0 is zero.-/ @[simp] -def H₁_zero_eq_zero : H₁ 0 = 0 := by - simp [H₁] +def H₁_zero_eq_zero : H₁ 0 = 0 := by simp [H₁] /-- H₁ of 1 is zero.-/ @[simp] -def H₁_one_eq_zero : H₁ 1 = 0 := by - simp [H₁] +def H₁_one_eq_zero : H₁ 1 = 0 := by simp [H₁] /-- Entropy is nonnegative. -/ theorem H₁_nonneg (p : Prob) : 0 ≤ H₁ p := by @@ -112,17 +110,14 @@ theorem Hₛ_le_log_d (d : ProbDistribution α) : Hₛ d ≤ Real.log (Fintype.c /-- The shannon entropy of a constant variable is zero. -/ @[simp] -theorem Hₛ_constant_eq_zero {i : α} : Hₛ (ProbDistribution.constant i) = 0 := by - simp [Hₛ, apply_ite] +theorem Hₛ_constant_eq_zero {i : α} : Hₛ (ProbDistribution.constant i) = 0 := by simp [Hₛ, apply_ite] /-- Shannon entropy of a uniform distribution is ln d. -/ theorem Hₛ_uniform [Nonempty α] : - Hₛ (ProbDistribution.uniform (α := α)) = Real.log (Finset.univ.card (α := α)) := by - simp [Hₛ, ProbDistribution.prob, H₁, Real.negMulLog] + Hₛ (ProbDistribution.uniform (α := α)) = Real.log (Finset.univ.card (α := α)) := by simp [Hₛ, ProbDistribution.prob, H₁, Real.negMulLog] /-- Shannon entropy of two-event distribution. -/ -theorem Hₛ_coin (p : Prob) : Hₛ (ProbDistribution.coin p) = Real.binEntropy p := by - simp [Hₛ, H₁, ProbDistribution.coin, Real.binEntropy_eq_negMulLog_add_negMulLog_one_sub] +theorem Hₛ_coin (p : Prob) : Hₛ (ProbDistribution.coin p) = Real.binEntropy p := by simp [Hₛ, H₁, ProbDistribution.coin, Real.binEntropy_eq_negMulLog_add_negMulLog_one_sub] lemma Hₛ_eq_of_multiset_map_eq (d₁ : ProbDistribution α) (d₂ : ProbDistribution β) (h : Multiset.map d₁.prob Finset.univ.val = Multiset.map d₂.prob Finset.univ.val) : diff --git a/QuantumInfo/ClassicalInfo/Prob.lean b/QuantumInfo/ClassicalInfo/Prob.lean index 47b02dd15..6cc1eaa9e 100644 --- a/QuantumInfo/ClassicalInfo/Prob.lean +++ b/QuantumInfo/ClassicalInfo/Prob.lean @@ -120,8 +120,7 @@ theorem ne_iff {x y : Prob} : (x : ℝ) ≠ (y : ℝ) ↔ x ≠ y := not_congr <| Prob.ext_iff.symm @[simp, norm_cast] -theorem toReal_mul (x y : Prob) : (x * y : Prob) = (x : ℝ) * (y : ℝ) := by - simp only [coe_mul] +theorem toReal_mul (x y : Prob) : (x * y : Prob) = (x : ℝ) * (y : ℝ) := by simp only [coe_mul] /-- Coercion `Prob → ℝ≥0`. -/ @[coe] def toNNReal : Prob → ℝ≥0 := @@ -173,11 +172,9 @@ instance instSub : Sub Prob where theorem coe_sub (p q : Prob) : (p - q : Prob) = (p.val - q.val) ⊔ (0 : ℝ) := rfl @[simp, norm_cast] -theorem coe_one_minus (p : Prob) : (1 - p : Prob) = 1 - (p : ℝ) := by - simp [coe_sub] +theorem coe_one_minus (p : Prob) : (1 - p : Prob) = 1 - (p : ℝ) := by simp [coe_sub] -theorem add_one_minus (p : Prob) : p.val + (1 - p).val = 1 := by - simp +theorem add_one_minus (p : Prob) : p.val + (1 - p).val = 1 := by simp @[simp] theorem one_minus_inv (p : Prob) : 1 - (1 - p) = p := by @@ -421,20 +418,16 @@ theorem negLog_Antitone : Antitone negLog := by <;> exact lt_of_le_of_ne zero_le (unitInterval.coe_ne_zero.mpr (by assumption)).symm @[simp] -theorem negLog_zero : —log (0 : Prob) = ⊤ := by - simp [negLog] +theorem negLog_zero : —log (0 : Prob) = ⊤ := by simp [negLog] @[simp] -theorem negLog_one : —log 1 = 0 := by - simp [negLog]; rfl +theorem negLog_one : —log 1 = 0 := by simp [negLog]; rfl @[simp] -theorem negLog_eq_top_iff {p : Prob} : —log p = ⊤ ↔ p = 0 := by - simp [negLog] +theorem negLog_eq_top_iff {p : Prob} : —log p = ⊤ ↔ p = 0 := by simp [negLog] theorem negLog_pos_ENNReal {p : Prob} (hp : p ≠ 0) : —log p = .ofNNReal ⟨-Real.log p, - Left.nonneg_neg_iff.mpr (Real.log_nonpos p.2.1 p.2.2)⟩ := by - simp [negLog, hp] + Left.nonneg_neg_iff.mpr (Real.log_nonpos p.2.1 p.2.2)⟩ := by simp [negLog, hp] @[simp] theorem negLog_pos_Real {p : Prob} : (—log p).toReal = -Real.log p := by From 87fbdc8dd6033487e5a772359afde71c2d561631 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:33:26 -0700 Subject: [PATCH 146/498] refactor: golf state simp proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/States/Ensemble.lean | 3 +-- QuantumInfo/States/Mixed/MState.lean | 21 +++++++-------------- QuantumInfo/States/Pure/Braket.lean | 3 +-- QuantumInfo/States/Pure/Qubit.lean | 12 ++++-------- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/QuantumInfo/States/Ensemble.lean b/QuantumInfo/States/Ensemble.lean index bab656ee9..2fe0e9ddf 100644 --- a/QuantumInfo/States/Ensemble.lean +++ b/QuantumInfo/States/Ensemble.lean @@ -112,8 +112,7 @@ def pure_average_NNReal {d : Type _} [Fintype d] (f : Ket d → NNReal) (e : PEn is equal to averaging the restricted function over Kets `f ∘ pure : Ket d → T` on `e`. -/ theorem average_of_pure_ensemble {T : Type _} {U : Type*} [AddCommGroup U] [Module ℝ U] [inst : Mixable U T] (f : MState d → T) (e : PEnsemble d α) : - average f (toMEnsemble e) = pure_average (f ∘ pure) e := by - simp only [average, pure_average, toMEnsemble, comp_map] + average f (toMEnsemble e) = pure_average (f ∘ pure) e := by simp only [average, pure_average, toMEnsemble, comp_map] variable {ψ : Ket d} diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index ce0f34cee..2e366e0f1 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -208,12 +208,10 @@ theorem exp_val_nonneg {T : HermitianMat d ℂ} (h : 0 ≤ T) : 0 ≤ ρ.exp_val -- to write first.) @[simp] -theorem exp_val_zero : ρ.exp_val 0 = 0 := by - simp [MState.exp_val] +theorem exp_val_zero : ρ.exp_val 0 = 0 := by simp [MState.exp_val] @[simp] -theorem exp_val_one : ρ.exp_val 1 = 1 := by - simp [MState.exp_val] +theorem exp_val_one : ρ.exp_val 1 = 1 := by simp [MState.exp_val] theorem exp_val_le_one {T : HermitianMat d ℂ} (h : T ≤ 1) : ρ.exp_val T ≤ 1 := by have hmono := inner_mono ρ.nonneg h @@ -224,8 +222,7 @@ theorem exp_val_prob {T : HermitianMat d ℂ} (h : 0 ≤ T ∧ T ≤ 1) : ⟨ρ.exp_val_nonneg h.1, ρ.exp_val_le_one h.2⟩ theorem exp_val_sub (A B : HermitianMat d ℂ) : - ρ.exp_val (A - B) = ρ.exp_val A - ρ.exp_val B := by - simp [exp_val, inner_sub_right] + ρ.exp_val (A - B) = ρ.exp_val A - ρ.exp_val B := by simp [exp_val, inner_sub_right] /-- If a PSD observable `A` has expectation value of 0 on a state `ρ`, it must entirely contain the support of `ρ` in its kernel. -/ @@ -241,13 +238,11 @@ theorem exp_val_eq_one_iff {A : HermitianMat d ℂ} (hA₂ : A ≤ 1) : rw [sub_eq_zero, eq_comm] theorem exp_val_add (A B : HermitianMat d ℂ) : - ρ.exp_val (A + B) = ρ.exp_val A + ρ.exp_val B := by - simp [exp_val, inner_add_right] + ρ.exp_val (A + B) = ρ.exp_val A + ρ.exp_val B := by simp [exp_val, inner_add_right] @[simp] theorem exp_val_smul (r : ℝ) (A : HermitianMat d ℂ) : - ρ.exp_val (r • A) = r * ρ.exp_val A := by - simp [MState.exp_val] + ρ.exp_val (r • A) = r * ρ.exp_val A := by simp [MState.exp_val] @[gcongr] theorem exp_val_le_exp_val (ρ : MState d) {A B : HermitianMat d ℂ} (h : A ≤ B) : @@ -1209,13 +1204,11 @@ theorem traceLeft_assoc' (ρ : MState (d₁ × d₂ × d₃)) : @[simp] theorem traceLeft_left_assoc (ρ : MState ((d₁ × d₂) × d₃)) : - ρ.assoc.traceLeft.traceLeft = ρ.traceLeft := by - simp [← traceLeft_assoc'] + ρ.assoc.traceLeft.traceLeft = ρ.traceLeft := by simp [← traceLeft_assoc'] @[simp] theorem traceRight_right_assoc' (ρ : MState (d₁ × d₂ × d₃)) : - ρ.assoc'.traceRight.traceRight = ρ.traceRight := by - simp [assoc'] + ρ.assoc'.traceRight.traceRight = ρ.traceRight := by simp [assoc'] @[simp] theorem traceNorm_eq_one (ρ : MState d) : ρ.m.traceNorm = 1 := diff --git a/QuantumInfo/States/Pure/Braket.lean b/QuantumInfo/States/Pure/Braket.lean index 6fb11971b..949555aab 100644 --- a/QuantumInfo/States/Pure/Braket.lean +++ b/QuantumInfo/States/Pure/Braket.lean @@ -342,8 +342,7 @@ is specifically the MES with an all-positive phase. For instance on `d := Fin 2` Bell state. -/ def Ket.MES (d) [Fintype d] [Nonempty d] : Ket (d × d) where vec := fun (i,j) ↦ if i = j then 1 / Real.sqrt (Fintype.card (α := d)) else 0 - normalized' := by - simp [apply_ite, Fintype.sum_prod_type] + normalized' := by simp [apply_ite, Fintype.sum_prod_type] /-- On any space of dimension at least two, the maximally entangled state `MES` is entangled. -/ theorem Ket.MES_isEntangled [Nontrivial d] : (Ket.MES d).IsEntangled := by diff --git a/QuantumInfo/States/Pure/Qubit.lean b/QuantumInfo/States/Pure/Qubit.lean index 66666ec7c..0fb9765c6 100644 --- a/QuantumInfo/States/Pure/Qubit.lean +++ b/QuantumInfo/States/Pure/Qubit.lean @@ -132,16 +132,13 @@ theorem H_mul_Z_eq_X_mul_H : H * Z = X * H := by matrix_expand [H, X, Z] @[simp] -theorem S_Z_comm : Z * S = S * Z := by - simp [← S_sq, mul_assoc] +theorem S_Z_comm : Z * S = S * Z := by simp [← S_sq, mul_assoc] @[simp] -theorem T_Z_comm : Z * T = T * Z := by - simp [← S_sq, ← T_sq, mul_assoc] +theorem T_Z_comm : Z * T = T * Z := by simp [← S_sq, ← T_sq, mul_assoc] @[simp] -theorem S_T_comm : S * T = T * S := by - simp [← T_sq, mul_assoc] +theorem S_T_comm : S * T = T * S := by simp [← T_sq, mul_assoc] /-- Given a unitary `U` on some Hilbert space `k`, we have the controllized version that acts on `Fin 2 ⊗ k` where `U` is conditionally applied if the first qubit is `1`. -/ @@ -200,8 +197,7 @@ theorem controllize_one : C[(1 : 𝐔[k])] = 1 := by matrix_expand @[simp] -theorem controllize_mul_inv : C[g] * C[g⁻¹] = 1 := by - simp +theorem controllize_mul_inv : C[g] * C[g⁻¹] = 1 := by simp open scoped Matrix in @[simp] From 8a3f0f9a559fc81d535d13cf388377baf2b4d483 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:35:09 -0700 Subject: [PATCH 147/498] refactor: golf channel simp proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/CPTP.lean | 6 ++---- QuantumInfo/Channels/Dual.lean | 3 +-- QuantumInfo/Channels/Unbundled.lean | 6 ++---- QuantumInfo/Measurements/POVM.lean | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index b7f98006c..6a83217c2 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -440,8 +440,7 @@ def IsUnitary (Λ : CPTPMap dIn dIn) : Prop := ∃ U, Λ = ofUnitary U /-- A channel is unitary iff it can be written as conjugation by a unitary. -/ -theorem IsUnitary_iff_U_conj (Λ : CPTPMap dIn dIn) : IsUnitary Λ ↔ ∃ U, ∀ ρ, Λ ρ = ρ.U_conj U := by - simp_rw [IsUnitary, ← ofUnitary_eq_conj, CPTPMap.funext_iff] +theorem IsUnitary_iff_U_conj (Λ : CPTPMap dIn dIn) : IsUnitary Λ ↔ ∃ U, ∀ ρ, Λ ρ = ρ.U_conj U := by simp_rw [IsUnitary, ← ofUnitary_eq_conj, CPTPMap.funext_iff] theorem IsUnitary_equiv (σ : dIn ≃ dIn) : IsUnitary (ofEquiv σ) := by have h_unitary : ∃ U : Matrix dIn dIn ℂ, U * U.conjTranspose = 1 ∧ U.conjTranspose * U = 1 ∧ ∀ x : dIn, (∀ y : dIn, (U y x = 1) ↔ (y = σ x)) ∧ ∀ y : dIn, (U y x = 0) ↔ (y ≠ σ x) := by @@ -783,8 +782,7 @@ theorem prep_append_map_entry (X : Matrix dIn dIn ℂ) let prep := (id ⊗ᶜᵖ zero_prep) let append : CPTPMap dIn (dIn × Unit) := CPTPMap.ofEquiv (Equiv.prodPUnit dIn).symm (prep ∘ₘ append).map X (a₁, b₁c₁) (a₂, b₂c₂) = - X a₁ a₂ * τ.m b₁c₁ b₂c₂ := by - simp [purify_prep_append_entry] + X a₁ a₂ * τ.m b₁c₁ b₂c₂ := by simp [purify_prep_append_entry] /-- The complementary channel comes from tracing out the other half (the right half) of the purified channel `purify`. -/ def complementary (Λ : CPTPMap dIn dOut) : CPTPMap dIn (dIn × dOut) := diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index 101b48086..b04b084fb 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -429,8 +429,7 @@ def HPMap.hermDual : HPMap dOut dIn := HPMap.ofHermitianMat (LinearMapClass.linearMap f).adjoint @[simp] -theorem HPMap.hermDual_hermDual : f.hermDual.hermDual = f := by - simp [hermDual] +theorem HPMap.hermDual_hermDual : f.hermDual.hermDual = f := by simp [hermDual] open RealInnerProductSpace diff --git a/QuantumInfo/Channels/Unbundled.lean b/QuantumInfo/Channels/Unbundled.lean index 11892f2df..1630ef6c9 100644 --- a/QuantumInfo/Channels/Unbundled.lean +++ b/QuantumInfo/Channels/Unbundled.lean @@ -86,8 +86,7 @@ theorem comp (h₁ : M.IsTracePreserving) (h₂ : M₂.IsTracePreserving) : /-- The identity MatrixMap IsTracePreserving. -/ @[simp] -theorem id : (id A R).IsTracePreserving := by - simp [IsTracePreserving, MatrixMap.id] +theorem id : (id A R).IsTracePreserving := by simp [IsTracePreserving, MatrixMap.id] variable {R : Type*} [CommSemiring R] in /-- Unit linear combinations of IsTracePreserving maps are IsTracePreserving. -/ @@ -202,8 +201,7 @@ theorem map_1 (h : M.Unital) : M 1 = 1 := /-- The identity `MatrixMap` is `Unital`. -/ @[simp] -theorem id : (id A R).Unital := by - simp [Unital, MatrixMap.id] +theorem id : (id A R).Unital := by simp [Unital, MatrixMap.id] --TODO: Closed under composition, kronecker products, it's iff M.choi_matrix.traceLeft = 1... diff --git a/QuantumInfo/Measurements/POVM.lean b/QuantumInfo/Measurements/POVM.lean index 781d0e9ab..c2c7c32e0 100644 --- a/QuantumInfo/Measurements/POVM.lean +++ b/QuantumInfo/Measurements/POVM.lean @@ -161,8 +161,7 @@ noncomputable def measureDiscard (Λ : POVM X d) : CPTPMap d X := CPTPMap.traceLeft ∘ₘ Λ.measurementMap theorem measureDiscard_apply (Λ : POVM X d) (ρ : MState d) : - Λ.measureDiscard ρ = MState.ofClassical (Λ.measure ρ) := by - simp [measureDiscard, traceLeft_measurementMap_eq_measure] + Λ.measureDiscard ρ = MState.ofClassical (Λ.measure ρ) := by simp [measureDiscard, traceLeft_measurementMap_eq_measure] /-- The action of measuring a state with the POVM `Λ`, forgetting the measurement outcome, and keeping the disturbed state. -/ From a018d98f8fc88b3c90f08d6e5230a6a0010e0fbe Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:36:32 -0700 Subject: [PATCH 148/498] refactor: golf classical mechanics simp proofs Co-authored-by: Claude Opus 4.8 --- .../ClassicalMechanics/DampedHarmonicOscillator/Basic.lean | 3 +-- Physlib/ClassicalMechanics/EulerLagrange.lean | 3 +-- Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean | 3 +-- Physlib/ClassicalMechanics/Mass/MassUnit.lean | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 20c1b745e..1c89dde65 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -454,8 +454,7 @@ lemma toUndamped_equationOfMotion (S : DampedHarmonicOscillator) (hS : S.IsUndam calc S.m • ∂ₜ (∂ₜ xₜ) t = (S.toUndamped hS).m • ∂ₜ (∂ₜ xₜ) t := rfl _ = HarmonicOscillator.force (S.toUndamped hS) (xₜ t) := h t - _ = force S xₜ t := by - simp [force, HarmonicOscillator.force_eq_linear, toUndamped, hγ] + _ = force S xₜ t := by simp [force, HarmonicOscillator.force_eq_linear, toUndamped, hγ] end DampedHarmonicOscillator diff --git a/Physlib/ClassicalMechanics/EulerLagrange.lean b/Physlib/ClassicalMechanics/EulerLagrange.lean index 5e597bd7b..d57013dd1 100644 --- a/Physlib/ClassicalMechanics/EulerLagrange.lean +++ b/Physlib/ClassicalMechanics/EulerLagrange.lean @@ -37,8 +37,7 @@ lemma eulerLagrangeOp_eq (L : Time → X → X → ℝ) (q : Time → X) : rfl lemma eulerLagrangeOp_zero (q : Time → X) : - eulerLagrangeOp (fun _ _ _ => 0) q = fun _ => 0 := by - simp [eulerLagrangeOp_eq, Time.deriv_eq] + eulerLagrangeOp (fun _ _ _ => 0) q = fun _ => 0 := by simp [eulerLagrangeOp_eq, Time.deriv_eq] /- The variational derivative of `L t (q' t) (deriv q' t))` for a lagrangian `L` is equal to the `eulerLagrangeOp`. -/ diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index d561c700d..a28b8ed43 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -386,8 +386,7 @@ The trajectory for zero initial conditions is the zero function. /-- For zero initial conditions, the trajectory is zero. -/ @[simp] -lemma trajectory_zero : trajectory S 0 = fun _ => 0 := by - simp [trajectory_eq] +lemma trajectory_zero : trajectory S 0 = fun _ => 0 := by simp [trajectory_eq] /-! diff --git a/Physlib/ClassicalMechanics/Mass/MassUnit.lean b/Physlib/ClassicalMechanics/Mass/MassUnit.lean index 43db8c757..b1a3430ee 100644 --- a/Physlib/ClassicalMechanics/Mass/MassUnit.lean +++ b/Physlib/ClassicalMechanics/Mass/MassUnit.lean @@ -100,8 +100,7 @@ def scale (r : ℝ) (x : MassUnit) (hr : 0 < r := by norm_num) : MassUnit := @[simp] lemma scale_div_self (x : MassUnit) (r : ℝ) (hr : 0 < r) : - scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by - simp [scale, div_eq_val] + scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by simp [scale, div_eq_val] @[simp] lemma self_div_scale (x : MassUnit) (r : ℝ) (hr : 0 < r) : @@ -110,8 +109,7 @@ lemma self_div_scale (x : MassUnit) (r : ℝ) (hr : 0 < r) : field_simp @[simp] -lemma scale_one (x : MassUnit) : scale 1 x = x := by - simp [scale] +lemma scale_one (x : MassUnit) : scale 1 x = x := by simp [scale] @[simp] lemma scale_div_scale (x1 x2 : MassUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 < r2) : From 462fdc9d99af5a8f998561d4bf94f2358ef23b55 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:38:55 -0700 Subject: [PATCH 149/498] refactor: golf small tactic proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 6 ++---- Physlib/SpaceAndTime/Time/Basic.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean index 25be0d979..eea9dde2b 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean @@ -113,8 +113,7 @@ lemma boundary_succ {k : Fin n} (hk : Boundary S k) : S k.succ = - S (0 : Fin n. rw [opposite_signs_eq_neg hS (le_of_lt hk.left) (le_of_lt hk.right)] at hn linear_combination -(1 * hn) -lemma boundary_split (k : Fin n) : k.succ.val + (n.succ - k.succ.val) = n.succ := by - omega +lemma boundary_split (k : Fin n) : k.succ.val + (n.succ - k.succ.val) = n.succ := by omega set_option backward.isDefEq.respectTransparency false in lemma boundary_accGrav' (k : Fin n) : accGrav n.succ S = diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 7464fe53e..92b71bd2d 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -106,8 +106,7 @@ section theDeltas -/ -lemma odd_shift_eq (n : ℕ) : (1 + n) + n = 2 * n +1 := by - omega +lemma odd_shift_eq (n : ℕ) : (1 + n) + n = 2 * n +1 := by omega /-- The inclusion of `Fin n` into `Fin ((n + 1) + n)` via the first `n`. This is then casted to `Fin (2 * n + 1)`. -/ @@ -178,8 +177,7 @@ lemma sum_oddShift (S : Fin (2 * n + 1) → ℚ) : -/ -lemma odd_shift_shift_eq (n : ℕ) : ((1+n)+1) + n.succ = 2 * n.succ + 1 := by - omega +lemma odd_shift_shift_eq (n : ℕ) : ((1+n)+1) + n.succ = 2 * n.succ + 1 := by omega /-- The element representing the first `1` in `Fin (1 + n + 1 + n.succ)` casted to `Fin (2 * n.succ + 1)`. -/ diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 9d954e6d0..282cc14a6 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -127,8 +127,7 @@ lemma zero_val : val 0 = 0 := by norm_cast @[simp] -lemma eq_zero_iff (t : Time) : t = 0 ↔ t.val = 0 := by - aesop +lemma eq_zero_iff (t : Time) : t = 0 ↔ t.val = 0 := by aesop @[simp] lemma one_val : val 1 = 1 := by @@ -136,8 +135,7 @@ lemma one_val : val 1 = 1 := by norm_cast @[simp] -lemma eq_one_iff (t : Time) : t = 1 ↔ t.val = 1 := by - aesop +lemma eq_one_iff (t : Time) : t = 1 ↔ t.val = 1 := by aesop /-! From fef564cd23a1ced2042ba2eae4c708143cceddcb Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:41:06 -0700 Subject: [PATCH 150/498] refactor: golf unit simp proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Charge/ChargeUnit.lean | 6 ++---- Physlib/SpaceAndTime/Space/LengthUnit.lean | 7 ++----- Physlib/SpaceAndTime/Time/TimeUnit.lean | 6 ++---- Physlib/Thermodynamics/Temperature/TemperatureUnits.lean | 6 ++---- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/Physlib/Electromagnetism/Charge/ChargeUnit.lean b/Physlib/Electromagnetism/Charge/ChargeUnit.lean index 2a3593808..c73a4977e 100644 --- a/Physlib/Electromagnetism/Charge/ChargeUnit.lean +++ b/Physlib/Electromagnetism/Charge/ChargeUnit.lean @@ -105,8 +105,7 @@ def scale (r : ℝ) (x : ChargeUnit) (hr : 0 < r := by norm_num) : ChargeUnit := @[simp] lemma scale_div_self (x : ChargeUnit) (r : ℝ) (hr : 0 < r) : - scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by - simp [scale, div_eq_val] + scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by simp [scale, div_eq_val] @[simp] lemma self_div_scale (x : ChargeUnit) (r : ℝ) (hr : 0 < r) : @@ -115,8 +114,7 @@ lemma self_div_scale (x : ChargeUnit) (r : ℝ) (hr : 0 < r) : field_simp @[simp] -lemma scale_one (x : ChargeUnit) : scale 1 x = x := by - simp [scale] +lemma scale_one (x : ChargeUnit) : scale 1 x = x := by simp [scale] @[simp] lemma scale_div_scale (x1 x2 : ChargeUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 < r2) : diff --git a/Physlib/SpaceAndTime/Space/LengthUnit.lean b/Physlib/SpaceAndTime/Space/LengthUnit.lean index bb90e9ac5..bed428461 100644 --- a/Physlib/SpaceAndTime/Space/LengthUnit.lean +++ b/Physlib/SpaceAndTime/Space/LengthUnit.lean @@ -99,19 +99,16 @@ def scale (r : ℝ) (x : LengthUnit) (hr : 0 < r := by norm_num) : LengthUnit := @[simp] lemma scale_div_self (x : LengthUnit) (r : ℝ) (hr : 0 < r) : - scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by - simp [scale, div_eq_val] + scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by simp [scale, div_eq_val] @[simp] lemma self_div_scale (x : LengthUnit) (r : ℝ) (hr : 0 < r) : x / scale r x hr = (⟨1/r, _root_.div_nonneg (by simp) (le_of_lt hr)⟩ : ℝ≥0) := by simp [scale, div_eq_val] - field_simp @[simp] -lemma scale_one (x : LengthUnit) : scale 1 x = x := by - simp [scale] +lemma scale_one (x : LengthUnit) : scale 1 x = x := by simp [scale] @[simp] lemma scale_div_scale (x1 x2 : LengthUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 < r2) : diff --git a/Physlib/SpaceAndTime/Time/TimeUnit.lean b/Physlib/SpaceAndTime/Time/TimeUnit.lean index 6e3d7ef55..8f5ebdcca 100644 --- a/Physlib/SpaceAndTime/Time/TimeUnit.lean +++ b/Physlib/SpaceAndTime/Time/TimeUnit.lean @@ -103,12 +103,10 @@ def scale (r : ℝ) (x : TimeUnit) (hr : 0 < r := by norm_num) : TimeUnit := @[simp] lemma scale_div_self (x : TimeUnit) (r : ℝ) (hr : 0 < r) : - scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by - simp [scale, div_eq_val] + scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by simp [scale, div_eq_val] @[simp] -lemma scale_one (x : TimeUnit) : scale 1 x = x := by - simp [scale] +lemma scale_one (x : TimeUnit) : scale 1 x = x := by simp [scale] @[simp] lemma scale_div_scale (x1 x2 : TimeUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 < r2) : diff --git a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean index 4ada64e15..e99a74a05 100644 --- a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean +++ b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean @@ -101,8 +101,7 @@ def scale (r : ℝ) (x : TemperatureUnit) (hr : 0 < r := by norm_num) : Temperat @[simp] lemma scale_div_self (x : TemperatureUnit) (r : ℝ) (hr : 0 < r) : - scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by - simp [scale, div_eq_val] + scale r x hr / x = (⟨r, le_of_lt hr⟩ : ℝ≥0) := by simp [scale, div_eq_val] @[simp] lemma self_div_scale (x : TemperatureUnit) (r : ℝ) (hr : 0 < r) : @@ -112,8 +111,7 @@ lemma self_div_scale (x : TemperatureUnit) (r : ℝ) (hr : 0 < r) : field_simp @[simp] -lemma scale_one (x : TemperatureUnit) : scale 1 x = x := by - simp [scale] +lemma scale_one (x : TemperatureUnit) : scale 1 x = x := by simp [scale] @[simp] lemma scale_div_scale (x1 x2 : TemperatureUnit) {r1 r2 : ℝ} (hr1 : 0 < r1) (hr2 : 0 < r2) : From d43cbe58529d0956f19a368fd213d183f2920675 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:43:44 -0700 Subject: [PATCH 151/498] refactor: golf electromagnetism simp proofs Co-authored-by: Claude Opus 4.8 --- .../Kinematics/ScalarPotential.lean | 14 ++++++-------- .../Kinematics/VectorPotential.lean | 8 ++++---- Physlib/Electromagnetism/Vacuum/HarmonicWave.lean | 3 +-- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean index df3b3be98..1d99ed571 100644 --- a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean @@ -79,8 +79,8 @@ lemma ofScalarPotential_scalarPotential {d} (c : SpeedOfLight) @[simp] lemma ofStaticScalarPotential_scalarPotential {d} (c : SpeedOfLight) - (φ : Space d → ℝ) : (ofStaticScalarPotential c φ).scalarPotential c = fun _ => φ := by - simp [ofStaticScalarPotential] + (φ : Space d → ℝ) : (ofStaticScalarPotential c φ).scalarPotential c = + fun _ => φ := by simp [ofStaticScalarPotential] @[simp] lemma ofVectorPotential_scalarPotential {d} (c : SpeedOfLight) @@ -92,8 +92,7 @@ lemma ofVectorPotential_scalarPotential {d} (c : SpeedOfLight) @[simp] lemma ofStaticVectorPotential_scalarPotential {d} (c : SpeedOfLight) (A : Space d → EuclideanSpace ℝ (Fin d)) : - (ofStaticVectorPotential c A).scalarPotential = 0 := by - simp [ofStaticVectorPotential] + (ofStaticVectorPotential c A).scalarPotential = 0 := by simp [ofStaticVectorPotential] @[simp] lemma ofPotentials_scalarPotential {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) @@ -106,16 +105,15 @@ lemma ofPotentials_scalarPotential {d} (c : SpeedOfLight) (φ : Time → Space d @[simp] lemma ofStaticPotentials_scalarPotential {d} (c : SpeedOfLight) (φ : Space d → ℝ) (A : Space d → EuclideanSpace ℝ (Fin d)) : - (ofStaticPotentials c φ A).scalarPotential c = fun _ => φ := by - simp [ofStaticPotentials_eq_ofPotentials] + (ofStaticPotentials c φ A).scalarPotential c = + fun _ => φ := by simp [ofStaticPotentials_eq_ofPotentials] open MeasureTheory Matrix Space InnerProductSpace Time in lemma ofElectromagneticField_scalarPotential (c : SpeedOfLight) (E : Time → Space → EuclideanSpace ℝ (Fin 3)) (B : Time → Space → EuclideanSpace ℝ (Fin 3)) : (ofElectromagneticField c E B).scalarPotential c = fun t x => - - ∫ u in (0 : ℝ)..1, ⟪E t (u • x), basis.repr x⟫_ℝ ∂(volume) := by - simp [ofElectromagneticField] + - ∫ u in (0 : ℝ)..1, ⟪E t (u • x), basis.repr x⟫_ℝ ∂(volume) := by simp [ofElectromagneticField] open MeasureTheory Matrix Space InnerProductSpace Time in lemma ofElectromagneticField_scalarPotential_eq_add_vectorPotential (c : SpeedOfLight) diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index 7963a1089..9e60efa1a 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -92,8 +92,8 @@ lemma ofVectorPotential_vectorPotential {d} (c : SpeedOfLight) @[simp] lemma ofStaticVectorPotential_vectorPotential {d} (c : SpeedOfLight) (A : Space d → EuclideanSpace ℝ (Fin d)) : - (ofStaticVectorPotential c A).vectorPotential c = fun _ => A := by - simp [ofStaticVectorPotential] + (ofStaticVectorPotential c A).vectorPotential c = + fun _ => A := by simp [ofStaticVectorPotential] @[simp] lemma ofPotentials_vectorPotential {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) @@ -105,8 +105,8 @@ lemma ofPotentials_vectorPotential {d} (c : SpeedOfLight) (φ : Time → Space d @[simp] lemma ofStaticPotentials_vectorPotential {d} (c : SpeedOfLight) (φ : Space d → ℝ) (A : Space d → EuclideanSpace ℝ (Fin d)) : - (ofStaticPotentials c φ A).vectorPotential c = fun _ => A := by - simp [ofStaticPotentials_eq_ofPotentials] + (ofStaticPotentials c φ A).vectorPotential c = + fun _ => A := by simp [ofStaticPotentials_eq_ofPotentials] /-! diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index 9dc5394fc..261749666 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -86,8 +86,7 @@ noncomputable def harmonicWaveX (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → @[simp] lemma harmonicWaveX_inl_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) (x : SpaceTime d.succ) : - harmonicWaveX 𝓕 k E₀ φ x (Sum.inl 0) = 0 := by - simp [harmonicWaveX] + harmonicWaveX 𝓕 k E₀ φ x (Sum.inl 0) = 0 := by simp [harmonicWaveX] @[simp] lemma harmonicWaveX_inr_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) From eb17e78b0c732d3fd8b3bdf6ce9272b4351893b0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:46:32 -0700 Subject: [PATCH 152/498] refactor: golf small simp proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/KroneckerDelta.lean | 9 +++------ Physlib/Mathematics/LinearPMap.lean | 3 +-- Physlib/SpaceAndTime/Space/Origin.lean | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/Mathematics/KroneckerDelta.lean b/Physlib/Mathematics/KroneckerDelta.lean index 36d2933db..2ddde0146 100644 --- a/Physlib/Mathematics/KroneckerDelta.lean +++ b/Physlib/Mathematics/KroneckerDelta.lean @@ -109,20 +109,17 @@ open Finset variable [AddCommMonoid M] @[simp] -lemma sum_mul [Fintype α] (i j : α) : ∑ k : α, δ[i,k] * δ[k,j] = δ[i,j] := by - simp [kroneckerDelta] +lemma sum_mul [Fintype α] (i j : α) : ∑ k : α, δ[i,k] * δ[k,j] = δ[i,j] := by simp [kroneckerDelta] @[simp] lemma sum_smul [Fintype α] (i : α) (f : α → M) : ∑ j : α, δ[i,j] • f j = f i := by simp [kroneckerDelta] lemma sum_sum_smul_eq_zero [Fintype α] {f : α → α → M} (hf : ∀ i : α, f i i = 0) : - ∑ i : α, ∑ j : α, δ[i,j] • f i j = 0 := by - simp [sum_smul, hf, sum_const_zero] + ∑ i : α, ∑ j : α, δ[i,j] • f i j = 0 := by simp [sum_smul, hf, sum_const_zero] lemma finset_sum_smul (s : Finset α) (i : α) (f : α → M) : - ∑ j ∈ s, δ[i,j] • f j = if i ∈ s then f i else 0 := by - simp [kroneckerDelta] + ∑ j ∈ s, δ[i,j] • f j = if i ∈ s then f i else 0 := by simp [kroneckerDelta] lemma finset_sum_sum_smul_eq_zero {s s' : Finset α} {f : α → α → M} (hf : ∀ i ∈ s ∩ s', f i i = 0) : ∑ i ∈ s, ∑ j ∈ s', δ[i,j] • f i j = 0 := by diff --git a/Physlib/Mathematics/LinearPMap.lean b/Physlib/Mathematics/LinearPMap.lean index 5c7bf3ee0..bc4879fd7 100644 --- a/Physlib/Mathematics/LinearPMap.lean +++ b/Physlib/Mathematics/LinearPMap.lean @@ -198,8 +198,7 @@ lemma compRestricted_domain : (g ∘ᵣ f).domain = (g.domain.comap f.toFun).map exact h.choose lemma mem_compRestricted_domain_iff {x : E} : - x ∈ (v ∘ᵣ u).domain ↔ ∃ h : x ∈ u.domain, u ⟨x, h⟩ ∈ v.domain := by - simp [compRestricted_domain] + x ∈ (v ∘ᵣ u).domain ↔ ∃ h : x ∈ u.domain, u ⟨x, h⟩ ∈ v.domain := by simp [compRestricted_domain] lemma mem_compRestricted_domain_iff' {x : E} : x ∈ (v ∘ᵣ u).domain ↔ ∃ y : u.domain, x = y ∧ ∃ y' : v.domain, u y = y' := by diff --git a/Physlib/SpaceAndTime/Space/Origin.lean b/Physlib/SpaceAndTime/Space/Origin.lean index 5f236d8d2..c50edaec0 100644 --- a/Physlib/SpaceAndTime/Space/Origin.lean +++ b/Physlib/SpaceAndTime/Space/Origin.lean @@ -41,13 +41,11 @@ noncomputable def vectorToSpace {d : ℕ} (v : EuclideanSpace ℝ (Fin d)) : Spa @[simp] lemma vectorToSpace_apply {d : ℕ} (v : EuclideanSpace ℝ (Fin d)) (i : Fin d) : - vectorToSpace v i = v i := by - simp [vectorToSpace] + vectorToSpace v i = v i := by simp [vectorToSpace] @[simp] lemma vectorToSpace_vsub_zero {d : ℕ} (v : EuclideanSpace ℝ (Fin d)) : - vectorToSpace v -ᵥ (0 : Space d) = v := by - simp [vectorToSpace] + vectorToSpace v -ᵥ (0 : Space d) = v := by simp [vectorToSpace] /-- The standard chart `Space d ≃ᵃⁱ[ℝ] EuclideanSpace ℝ (Fin d)`, `p ↦ p -ᵥ 0`, identifying a point with its coordinate vector relative to the origin (the vector-space zero `(0 : Space d)`). -/ From cd3d27974e2e388db2f96eae10657882d11683d8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:48:51 -0700 Subject: [PATCH 153/498] refactor: golf multi-index simp proofs Co-authored-by: Claude Opus 4.8 --- .../SpaceAndTime/Space/Derivatives/MultiIndex.lean | 12 ++++-------- Physlib/SpaceAndTime/Space/Module.lean | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean b/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean index 92c1cfac3..e6d000336 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean @@ -97,17 +97,14 @@ lemma add_apply (I J : MultiIndex d) (i : Fin d) : (I + J) i = I i + J i := rfl @[simp] lemma increment_apply_same (I : MultiIndex d) (i : Fin d) : - increment I i i = I i + 1 := by - simp [increment] + increment I i i = I i + 1 := by simp [increment] @[simp] lemma increment_apply_ne (I : MultiIndex d) {i j : Fin d} (h : j ≠ i) : - increment I i j = I j := by - simp [increment, Pi.single_eq_of_ne h] + increment I i j = I j := by simp [increment, Pi.single_eq_of_ne h] @[simp] -lemma order_zero : order (0 : MultiIndex d) = 0 := by - simp [order] +lemma order_zero : order (0 : MultiIndex d) = 0 := by simp [order] lemma order_add (I J : MultiIndex d) : order (I + J) = order I + order J := by simp [order, Finset.sum_add_distrib] @@ -125,8 +122,7 @@ lemma order_single (i : Fin d) : order (⟨Pi.single i 1⟩ : MultiIndex d) = 1 @[simp] lemma order_increment (I : MultiIndex d) (i : Fin d) : - order (increment I i) = order I + 1 := by - simp [increment, order, Finset.sum_add_distrib] + order (increment I i) = order I + 1 := by simp [increment, order, Finset.sum_add_distrib] /-! ### A.3. Canonical ordered lists of directions diff --git a/Physlib/SpaceAndTime/Space/Module.lean b/Physlib/SpaceAndTime/Space/Module.lean index 482d37a64..5ae376bbb 100644 --- a/Physlib/SpaceAndTime/Space/Module.lean +++ b/Physlib/SpaceAndTime/Space/Module.lean @@ -350,18 +350,15 @@ lemma basis_apply {d} (i j : Fin d) : exact Lean.Grind.eq_congr' rfl rfl @[simp] -lemma basis_self {d} (i : Fin d) : basis i i = 1 := by - simp [basis_apply] +lemma basis_self {d} (i : Fin d) : basis i i = 1 := by simp [basis_apply] @[simp high] lemma inner_basis {d} (p : Space d) (i : Fin d) : - inner ℝ p (basis i) = p i := by - simp [inner_eq_sum, basis_apply] + inner ℝ p (basis i) = p i := by simp [inner_eq_sum, basis_apply] @[simp high] lemma basis_inner {d} (i : Fin d) (p : Space d) : - inner ℝ (basis i) p = p i := by - simp [inner_eq_sum, basis_apply] + inner ℝ (basis i) p = p i := by simp [inner_eq_sum, basis_apply] open InnerProductSpace @@ -427,8 +424,7 @@ noncomputable def coord (μ : Fin d) (p : Space d) : ℝ := inner ℝ p (basis μ) lemma coord_apply (μ : Fin d) (p : Space d) : - coord μ p = p μ := by - simp [coord] + coord μ p = p μ := by simp [coord] /-- The standard coordinate functions of Space based on `Fin d`, as a continuous linear map. -/ noncomputable def coordCLM {d} (μ : Fin d) : Space d →L[ℝ] ℝ where From c6a92fd8aed7b3b7d9556ce451743eb233859b74 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:51:17 -0700 Subject: [PATCH 154/498] refactor: golf canonical ensemble simp proofs Co-authored-by: Claude Opus 4.8 --- .../CanonicalEnsemble/Basic.lean | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 7c0e6599c..b7ebb32ef 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -468,8 +468,7 @@ lemma mathematicalPartitionFunction_comp_ofβ_apply (β : ℝ≥0) : measure is non-zero and the Boltzmann measure is finite. -/ lemma mathematicalPartitionFunction_pos (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] [NeZero 𝓒.μ] : - 0 < 𝓒.mathematicalPartitionFunction T := by - simp [mathematicalPartitionFunction] + 0 < 𝓒.mathematicalPartitionFunction T := by simp [mathematicalPartitionFunction] open NNReal Constants @@ -492,8 +491,7 @@ lemma probability_add {T : Temperature} (i : ι × ι1) : @[simp] lemma probability_congr (e : ι1 ≃ᵐ ι) (T : Temperature) (i : ι1) : - (𝓒.congr e).probability T i = 𝓒.probability T (e i) := by - simp [probability] + (𝓒.congr e).probability T i = 𝓒.probability T (e i) := by simp [probability] lemma probability_nsmul (n : ℕ) (T : Temperature) (f : Fin n → ι) : (nsmul n 𝓒).probability T f = ∏ i, 𝓒.probability T (f i) := by @@ -770,8 +768,7 @@ lemma partitionFunction_pos lemma partitionFunction_congr (𝓒 : CanonicalEnsemble ι) (e : ι1 ≃ᵐ ι) (T : Temperature) : - (𝓒.congr e).partitionFunction T = 𝓒.partitionFunction T := by - simp [partitionFunction] + (𝓒.congr e).partitionFunction T = 𝓒.partitionFunction T := by simp [partitionFunction] lemma partitionFunction_add (𝓒 : CanonicalEnsemble ι) (𝓒1 : CanonicalEnsemble ι1) @@ -996,18 +993,15 @@ lemma integral_physicalProbability_base lemma physicalProbability_dof_zero (T : Temperature) (h : 𝓒.dof = 0) (i : ι) : - 𝓒.physicalProbability T i = 𝓒.probability T i := by - simp [physicalProbability, h] + 𝓒.physicalProbability T i = 𝓒.probability T i := by simp [physicalProbability, h] lemma physicalProbability_phase_space_unit_one (T : Temperature) (h : 𝓒.phaseSpaceunit = 1) (i : ι) : - 𝓒.physicalProbability T i = 𝓒.probability T i := by - simp [physicalProbability, h] + 𝓒.physicalProbability T i = 𝓒.probability T i := by simp [physicalProbability, h] lemma physicalProbability_congr (e : ι1 ≃ᵐ ι) (T : Temperature) (i : ι1) : (𝓒.congr e).physicalProbability T i - = 𝓒.physicalProbability T (e i) := by - simp [physicalProbability, probability] + = 𝓒.physicalProbability T (e i) := by simp [physicalProbability, probability] lemma physicalProbability_add {ι1} [MeasurableSpace ι1] From f9bb0f736110a1ece073147c06b51bdc550afe57 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:52:32 -0700 Subject: [PATCH 155/498] refactor: golf Minkowski matrix simp proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/MinkowskiMatrix.lean | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Physlib/Relativity/MinkowskiMatrix.lean b/Physlib/Relativity/MinkowskiMatrix.lean index 13d8a485a..ae81cac22 100644 --- a/Physlib/Relativity/MinkowskiMatrix.lean +++ b/Physlib/Relativity/MinkowskiMatrix.lean @@ -140,8 +140,7 @@ as well as other properties related to squaring the Minkowski matrix. /-- The Minkowski matrix is self-inverting. -/ @[simp] -lemma sq : @minkowskiMatrix d * minkowskiMatrix = 1 := by - simp [as_block, fromBlocks_multiply] +lemma sq : @minkowskiMatrix d * minkowskiMatrix = 1 := by simp [as_block, fromBlocks_multiply] /-- Multiplying any element on the diagonal of the Minkowski matrix by itself gives `1`. -/ @[simp] @@ -162,8 +161,7 @@ The Minkowski matrix is symmetric, due to it being diagonal. /-- The Minkowski matrix is symmetric. -/ @[simp] -lemma eq_transpose : minkowskiMatrixᵀ = @minkowskiMatrix d := by - simp [as_diagonal] +lemma eq_transpose : minkowskiMatrixᵀ = @minkowskiMatrix d := by simp [as_diagonal] /-! @@ -177,8 +175,7 @@ We show the determinant of the Minkowski matrix is equal to `(-1)^d` where /-- The determinant of the Minkowski matrix is equal to `-1` to the power of the number of spatial dimensions. -/ @[simp] -lemma det_eq_neg_one_pow_d : (@minkowskiMatrix d).det = (- 1) ^ d := by - simp [as_diagonal] +lemma det_eq_neg_one_pow_d : (@minkowskiMatrix d).det = (- 1) ^ d := by simp [as_diagonal] /-! @@ -285,8 +282,7 @@ lemma dual_dual : Function.Involutive (@dual d) := by /-- The Minkowski dual commutes with the transpose. -/ @[simp] -lemma dual_transpose : dual Λᵀ = (dual Λ)ᵀ := by - simp [dual, mul_assoc] +lemma dual_transpose : dual Λᵀ = (dual Λ)ᵀ := by simp [dual, mul_assoc] /-! @@ -296,8 +292,7 @@ lemma dual_transpose : dual Λᵀ = (dual Λ)ᵀ := by /-- The Minkowski dual preserves the Minkowski matrix. -/ @[simp] -lemma dual_eta : @dual d η = η := by - simp [dual] +lemma dual_eta : @dual d η = η := by simp [dual] /-! @@ -324,13 +319,11 @@ We show a number of properties related to the components of the duals. /-- Expansion of the components of the Minkowski dual in terms of the components of the original matrix. -/ lemma dual_apply (μ ν : Fin 1 ⊕ Fin d) : - dual Λ μ ν = η μ μ * Λ ν μ * η ν ν := by - simp [dual, as_diagonal] + dual Λ μ ν = η μ μ * Λ ν μ * η ν ν := by simp [dual, as_diagonal] /-- The components of the Minkowski dual of a matrix multiplied by the Minkowski matrix in terms of the original matrix. -/ lemma dual_apply_minkowskiMatrix (μ ν : Fin 1 ⊕ Fin d) : - dual Λ μ ν * η ν ν = η μ μ * Λ ν μ := by - simp [dual_apply, mul_assoc] + dual Λ μ ν * η ν ν = η μ μ * Λ ν μ := by simp [dual_apply, mul_assoc] end minkowskiMatrix From bb72111e025fafc58a552fd8d4f430d3beb90db7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:53:30 -0700 Subject: [PATCH 156/498] refactor: golf Hermitian inner simp proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/Inner.lean | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean index ec7c9b135..7c22da3ed 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean @@ -63,12 +63,10 @@ protected theorem inner_add_left : ⟪A + B, C⟫_R = ⟪A, C⟫_R + ⟪B, C⟫_ simp [inner_def, right_distrib] @[simp] -protected theorem inner_zero_right : ⟪A, 0⟫_R = 0 := by - simp [inner_def] +protected theorem inner_zero_right : ⟪A, 0⟫_R = 0 := by simp [inner_def] @[simp] -protected theorem inner_zero_left : ⟪0, A⟫_R = 0 := by - simp [inner_def] +protected theorem inner_zero_left : ⟪0, A⟫_R = 0 := by simp [inner_def] end semiring section ring @@ -77,12 +75,10 @@ variable [CommRing R] [Ring α] [StarAddMonoid α] [Algebra R α] [IsMaximalSelf variable (A B C : HermitianMat n α) @[simp] -protected theorem inner_neg_left : ⟪-A, B⟫_R = -⟪A, B⟫_R := by - simp [inner_def] +protected theorem inner_neg_left : ⟪-A, B⟫_R = -⟪A, B⟫_R := by simp [inner_def] @[simp] -protected theorem inner_neg_right : ⟪A, -B⟫_R = -⟪A, B⟫_R := by - simp [inner_def] +protected theorem inner_neg_right : ⟪A, -B⟫_R = -⟪A, B⟫_R := by simp [inner_def] protected theorem inner_sub_left : ⟪A, B - C⟫_R = ⟪A, B⟫_R - ⟪A, C⟫_R := by simp [inner_def, mul_sub] @@ -118,12 +114,10 @@ variable [CommSemiring R] [Ring α] [StarRing α] [Algebra R α] [IsMaximalSelfA variable (A B : HermitianMat n α) @[simp] -theorem inner_one : ⟪A, 1⟫_R = A.trace := by - simp only [inner_def, mat_one, mul_one, trace] +theorem inner_one : ⟪A, 1⟫_R = A.trace := by simp only [inner_def, mat_one, mul_one, trace] @[simp] -theorem one_inner : ⟪1, A⟫_R = A.trace := by - simp only [inner_def, one_mul, mat_one, trace] +theorem one_inner : ⟪1, A⟫_R = A.trace := by simp only [inner_def, one_mul, mat_one, trace] end starring section commring From ad08cfa9c41069e7e355b2284d2bcd1a7ddded4e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:54:19 -0700 Subject: [PATCH 157/498] refactor: golf Hermitian basic simp proofs Co-authored-by: Claude Opus 4.8 --- .../ForMathlib/HermitianMat/Basic.lean | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean index 79f7cdd5b..b26ef7faf 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean @@ -365,12 +365,10 @@ theorem conj_conj {m l} [Fintype m] (B : Matrix m n α) (C : Matrix l m α) : variable (B : HermitianMat n α) @[simp] -theorem conj_zero [DecidableEq n] : A.conj (0 : Matrix m n α) = 0 := by - simp [conj_apply] +theorem conj_zero [DecidableEq n] : A.conj (0 : Matrix m n α) = 0 := by simp [conj_apply] @[simp] -theorem conj_one [DecidableEq n] : A.conj 1 = A := by - simp [conj_apply] +theorem conj_one [DecidableEq n] : A.conj 1 = A := by simp [conj_apply] @[simp] lemma conj_one_unitary [DecidableEq n] (U : Matrix.unitaryGroup n α) : @@ -416,12 +414,10 @@ theorem isSymmetric : A.lin.IsSymmetric := Matrix.isSymmetric_toEuclideanLin_iff.symm.mp A.H @[simp] -theorem lin_zero : (0 : HermitianMat n 𝕜).lin = 0 := by - simp [lin]; rfl +theorem lin_zero : (0 : HermitianMat n 𝕜).lin = 0 := by simp [lin]; rfl @[simp] -theorem lin_one : (1 : HermitianMat n 𝕜).lin = 1 := by - simp [lin]; rfl +theorem lin_one : (1 : HermitianMat n 𝕜).lin = 1 := by simp [lin]; rfl noncomputable def eigenspace (μ : 𝕜) : Submodule 𝕜 (EuclideanSpace 𝕜 n) := Module.End.eigenspace A.lin μ @@ -440,12 +436,10 @@ theorem ker_eq_eigenspace_zero : A.ker = A.eigenspace 0 := by simp [ker, eigenspace] @[simp] -theorem ker_zero : (0 : HermitianMat n 𝕜).ker = ⊤ := by - simp [ker] +theorem ker_zero : (0 : HermitianMat n 𝕜).ker = ⊤ := by simp [ker] @[simp] -theorem ker_one : (1 : HermitianMat n 𝕜).ker = ⊥ := by - simp [ker]; rfl +theorem ker_one : (1 : HermitianMat n 𝕜).ker = ⊥ := by simp [ker]; rfl theorem ker_pos_smul {c : ℝ} (hc : c ≠ 0) : (c • A).ker = A.ker := by ext x @@ -461,8 +455,7 @@ theorem support_eq_sup_eigenspace_nonzero : A.support = ⨆ μ ≠ 0, A.eigenspa A.lin.support_eq_sup_eigenspace_nonzero A.isSymmetric @[simp] -theorem support_zero : (0 : HermitianMat n 𝕜).support = ⊥ := by - simp [support] +theorem support_zero : (0 : HermitianMat n 𝕜).support = ⊥ := by simp [support] @[simp] theorem support_one : (1 : HermitianMat n 𝕜).support = ⊤ := by From 3d41dbe74f46930a5956d3ec6805770b1377d1c8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:55:28 -0700 Subject: [PATCH 158/498] refactor: golf Hermitian trace simp proofs Co-authored-by: Claude Opus 4.8 --- .../ForMathlib/HermitianMat/Trace.lean | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean index ca5cca95d..7172e4a18 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean @@ -57,24 +57,20 @@ section semiring variable [CommSemiring R] [Ring α] [StarAddMonoid α] [Algebra R α] [IsMaximalSelfAdjoint R α] @[simp] -theorem trace_zero : (0 : HermitianMat n α).trace = 0 := by - simp [trace] +theorem trace_zero : (0 : HermitianMat n α).trace = 0 := by simp [trace] @[simp] -theorem trace_add (A B : HermitianMat n α) : (A + B).trace = A.trace + B.trace := by - simp [trace] +theorem trace_add (A B : HermitianMat n α) : (A + B).trace = A.trace + B.trace := by simp [trace] end semiring section ring variable [CommRing R] [Ring α] [StarAddMonoid α] [Algebra R α] [IsMaximalSelfAdjoint R α] @[simp] -theorem trace_neg (A : HermitianMat n α) : (-A).trace = -A.trace := by - simp [trace] +theorem trace_neg (A : HermitianMat n α) : (-A).trace = -A.trace := by simp [trace] @[simp] -theorem trace_sub (A B : HermitianMat n α) : (A - B).trace = A.trace - B.trace := by - simp [trace] +theorem trace_sub (A B : HermitianMat n α) : (A - B).trace = A.trace - B.trace := by simp [trace] end ring section starring @@ -151,8 +147,7 @@ theorem trace_eq_one_iff (A : HermitianMat n 𝕜) : A.trace = 1 ↔ A.mat.trace @[simp] theorem trace_reindex (A : HermitianMat n ℂ) (e : n ≃ m) : - (A.reindex e).trace = A.trace := by - simp [reindex, trace_eq_re_trace] + (A.reindex e).trace = A.trace := by simp [reindex, trace_eq_re_trace] end RCLike section partialTrace @@ -219,12 +214,10 @@ theorem traceRight_smul (r : ℝ) : (r • A).traceRight = r • A.traceRight := ext1; simp @[simp] -theorem traceLeft_trace : A.traceLeft.trace = A.trace := by - simp [trace_eq_re_trace] +theorem traceLeft_trace : A.traceLeft.trace = A.trace := by simp [trace_eq_re_trace] @[simp] -theorem traceRight_trace : A.traceRight.trace = A.trace := by - simp [trace_eq_re_trace] +theorem traceRight_trace : A.traceRight.trace = A.trace := by simp [trace_eq_re_trace] end rcLike section kron From 791911b4f1a2e59a745202ab3bc5945cfc99d923 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:56:27 -0700 Subject: [PATCH 159/498] refactor: golf boost component simp proofs Co-authored-by: Claude Opus 4.8 --- .../Relativity/LorentzGroup/Boosts/Basic.lean | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean index b8ebdf947..4be53b43d 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean @@ -209,43 +209,34 @@ lemma boost_inverse (i : Fin d) {β : ℝ} (hβ : |β| < 1) : @[simp] lemma boost_inl_0_inl_0 (i : Fin d) {β : ℝ} (hβ : |β| < 1) : - (boost i β hβ).1 (Sum.inl 0) (Sum.inl 0) = γ β := by - simp [boost] + (boost i β hβ).1 (Sum.inl 0) (Sum.inl 0) = γ β := by simp [boost] @[simp] lemma boost_inr_self_inr_self (i : Fin d) {β : ℝ} (hβ : |β| < 1) : - (boost i β hβ).1 (Sum.inr i) (Sum.inr i) = γ β := by - simp [boost] + (boost i β hβ).1 (Sum.inr i) (Sum.inr i) = γ β := by simp [boost] @[simp] lemma boost_inl_0_inr_self (i : Fin d) {β : ℝ} (hβ : |β| < 1) : - (boost i β hβ).1 (Sum.inl 0) (Sum.inr i) = - γ β * β := by - simp [boost] + (boost i β hβ).1 (Sum.inl 0) (Sum.inr i) = - γ β * β := by simp [boost] @[simp] lemma boost_inr_self_inl_0 (i : Fin d) {β : ℝ} (hβ : |β| < 1) : - (boost i β hβ).1 (Sum.inr i) (Sum.inl 0) = - γ β * β := by - simp [boost] + (boost i β hβ).1 (Sum.inr i) (Sum.inl 0) = - γ β * β := by simp [boost] lemma boost_inl_0_inr_other {i j : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j ≠ i) : - (boost i β hβ).1 (Sum.inl 0) (Sum.inr j) = 0 := by - simp [boost, hij] + (boost i β hβ).1 (Sum.inl 0) (Sum.inr j) = 0 := by simp [boost, hij] lemma boost_inr_other_inl_0 {i j : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j ≠ i) : - (boost i β hβ).1 (Sum.inr j) (Sum.inl 0) = 0 := by - simp [boost, hij] + (boost i β hβ).1 (Sum.inr j) (Sum.inl 0) = 0 := by simp [boost, hij] lemma boost_inr_self_inr_other {i j : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j ≠ i) : - (boost i β hβ).1 (Sum.inr i) (Sum.inr j) = 0 := by - simp [boost, hij, Ne.symm hij] + (boost i β hβ).1 (Sum.inr i) (Sum.inr j) = 0 := by simp [boost, hij, Ne.symm hij] lemma boost_inr_other_inr_self {i j : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j ≠ i) : - (boost i β hβ).1 (Sum.inr j) (Sum.inr i) = 0 := by - simp [boost, hij] + (boost i β hβ).1 (Sum.inr j) (Sum.inr i) = 0 := by simp [boost, hij] lemma boost_inr_other_inr {i j k : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j ≠ i) : - (boost i β hβ).1 (Sum.inr j) (Sum.inr k) = if j = k then 1 else 0:= by - simp [boost, hij] + (boost i β hβ).1 (Sum.inr j) (Sum.inr k) = if j = k then 1 else 0:= by simp [boost, hij] lemma boost_inr_inr_other {i j k : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j ≠ i) : (boost i β hβ).1 (Sum.inr k) (Sum.inr j) = if j = k then 1 else 0:= by From 3aef7ac365ad15b36bf28cd91d1fb08038df465b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:57:19 -0700 Subject: [PATCH 160/498] refactor: golf charge spectrum simp proofs Co-authored-by: Claude Opus 4.8 --- .../SU5/ChargeSpectrum/Basic.lean | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean index cbe11a7fb..69d205ad0 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean @@ -207,8 +207,7 @@ instance emptyInst : EmptyCollection (ChargeSpectrum 𝓩) where lemma empty_eq : (∅ : ChargeSpectrum 𝓩) = ⟨none, none, {}, {}⟩ := rfl @[simp] -lemma empty_subset (x : ChargeSpectrum 𝓩) : ∅ ⊆ x := by - simp [Subset, empty_eq] +lemma empty_subset (x : ChargeSpectrum 𝓩) : ∅ ⊆ x := by simp [Subset, empty_eq] @[simp] lemma subset_of_empty_iff_empty {x : ChargeSpectrum 𝓩} : @@ -218,20 +217,16 @@ lemma subset_of_empty_iff_empty {x : ChargeSpectrum 𝓩} : simp @[simp] -lemma empty_qHd : (∅ : ChargeSpectrum 𝓩).qHd = none := by - simp [empty_eq] +lemma empty_qHd : (∅ : ChargeSpectrum 𝓩).qHd = none := by simp [empty_eq] @[simp] -lemma empty_qHu : (∅ : ChargeSpectrum 𝓩).qHu = none := by - simp [empty_eq] +lemma empty_qHu : (∅ : ChargeSpectrum 𝓩).qHu = none := by simp [empty_eq] @[simp] -lemma empty_Q5 : (∅ : ChargeSpectrum 𝓩).Q5 = ∅ := by - simp [empty_eq] +lemma empty_Q5 : (∅ : ChargeSpectrum 𝓩).Q5 = ∅ := by simp [empty_eq] @[simp] -lemma empty_Q10 : (∅ : ChargeSpectrum 𝓩).Q10 = ∅ := by - simp [empty_eq] +lemma empty_Q10 : (∅ : ChargeSpectrum 𝓩).Q10 = ∅ := by simp [empty_eq] /-! @@ -245,8 +240,7 @@ def card (x : ChargeSpectrum 𝓩) : Nat := x.qHu.toFinset.card + x.qHd.toFinset.card + x.Q5.card + x.Q10.card @[simp] -lemma card_empty : card (∅ : ChargeSpectrum 𝓩) = 0 := by - simp [card, empty_eq] +lemma card_empty : card (∅ : ChargeSpectrum 𝓩) = 0 := by simp [card, empty_eq] lemma card_mono {x y : ChargeSpectrum 𝓩} (h : x ⊆ y) : card x ≤ card y := by have h1 := Finset.card_le_card h.1 @@ -299,13 +293,11 @@ lemma mem_powerset_iff {x y : ChargeSpectrum 𝓩} : x.qHd ∈ y.qHd.powerset ∧ x.qHu ∈ y.qHu.powerset ∧ x.Q5 ∈ y.Q5.powerset ∧ - x.Q10 ∈ y.Q10.powerset := by - simp [powerset, Finset.mem_product, toProd] + x.Q10 ∈ y.Q10.powerset := by simp [powerset, Finset.mem_product, toProd] @[simp] lemma mem_powerset_iff_subset {x y : ChargeSpectrum 𝓩} : - x ∈ powerset y ↔ x ⊆ y := by - simp [mem_powerset_iff, subset_def] + x ∈ powerset y ↔ x ⊆ y := by simp [mem_powerset_iff, subset_def] lemma self_mem_powerset (x : ChargeSpectrum 𝓩) : x ∈ powerset x := by simp From 2e36ddc7cf215cca2e2f1ecf21514523a5435f6f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 15:58:49 -0700 Subject: [PATCH 161/498] refactor: golf Wick algebra simp proofs Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/WickAlgebra/Basic.lean | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean index 813ef0739..7d0eb7ac8 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean @@ -380,8 +380,7 @@ lemma ofFieldOpList_append (φs ψs : List 𝓕.FieldOp) : simp lemma ofFieldOpList_cons (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : - ofFieldOpList (φ :: φs) = ofFieldOp φ * ofFieldOpList φs := by - aesop + ofFieldOpList (φ :: φs) = ofFieldOp φ * ofFieldOpList φs := by aesop lemma ofFieldOpList_singleton (φ : 𝓕.FieldOp) : ofFieldOpList [φ] = ofFieldOp φ := by @@ -418,8 +417,7 @@ lemma ofCrAnList_append (φs ψs : List 𝓕.CrAnFieldOp) : simp lemma ofCrAnList_singleton (φ : 𝓕.CrAnFieldOp) : - ofCrAnList [φ] = ofCrAnOp φ := by - simp only [ofCrAnList, ofCrAnOp, ofCrAnListF_singleton] + ofCrAnList [φ] = ofCrAnOp φ := by simp only [ofCrAnList, ofCrAnOp, ofCrAnListF_singleton] lemma ofFieldOpList_eq_sum (φs : List 𝓕.FieldOp) : ofFieldOpList φs = ∑ s : CrAnSection φs, ofCrAnList s.1 := by @@ -438,14 +436,12 @@ lemma anPart_eq_ι_anPartF (φ : 𝓕.FieldOp) : anPart φ = ι (anPartF φ) := @[simp] lemma anPart_inAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : - anPart (FieldOp.inAsymp φ) = 0 := by - simp [anPart, anPartF] + anPart (FieldOp.inAsymp φ) = 0 := by simp [anPart, anPartF] @[simp] lemma anPart_position (φ : (Σ f, 𝓕.PositionLabel f) × SpaceTime) : anPart (FieldOp.position φ) = - ofCrAnOp ⟨FieldOp.position φ, CreateAnnihilate.annihilate⟩ := by - simp [anPart, ofCrAnOp] + ofCrAnOp ⟨FieldOp.position φ, CreateAnnihilate.annihilate⟩ := by simp [anPart, ofCrAnOp] @[simp] lemma anPart_outAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : @@ -470,13 +466,11 @@ lemma crPart_inAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : @[simp] lemma crPart_position (φ : (Σ f, 𝓕.PositionLabel f) × SpaceTime) : crPart (FieldOp.position φ) = - ofCrAnOp ⟨FieldOp.position φ, CreateAnnihilate.create⟩ := by - simp [crPart, ofCrAnOp] + ofCrAnOp ⟨FieldOp.position φ, CreateAnnihilate.create⟩ := by simp [crPart, ofCrAnOp] @[simp] lemma crPart_outAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : - crPart (FieldOp.outAsymp φ) = 0 := by - simp [crPart] + crPart (FieldOp.outAsymp φ) = 0 := by simp [crPart] /-- For field specification `𝓕`, and an element `φ` of `𝓕.FieldOp` the following relation holds: From 80c64b9a3ff75a2465a862bbdcf5064261a7153e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:00:27 -0700 Subject: [PATCH 162/498] refactor: golf uncontracted list simp proofs Co-authored-by: Claude Opus 4.8 --- .../WickContraction/UncontractedList.lean | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index a7b3b882b..48768795a 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -191,15 +191,14 @@ lemma orderedInsert_eq_insertIdx_of_fin_list_sorted (l : List (Fin n)) (hl : l.P 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 - simp [uncontractedList] + i ∈ c.uncontractedList ↔ i ∈ c.uncontracted := by simp [uncontractedList] @[simp] -lemma uncontractedList_empty : (empty (n := n)).uncontractedList = List.finRange n := by - simp [uncontractedList] +lemma uncontractedList_empty : + (empty (n := n)).uncontractedList = List.finRange n := by simp [uncontractedList] -lemma nil_zero_uncontractedList : (empty (n := 0)).uncontractedList = [] := by - simp [empty, uncontractedList] +lemma nil_zero_uncontractedList : + (empty (n := 0)).uncontractedList = [] := by simp [empty, uncontractedList] lemma congr_uncontractedList {n m : ℕ} (h : n = m) (c : WickContraction n) : ((congr h) c).uncontractedList = List.map (finCongr h) c.uncontractedList := by @@ -228,8 +227,7 @@ lemma uncontractedList_nodup : c.uncontractedList.Nodup := by exact List.Nodup.filter (fun x => decide (x ∈ c.uncontracted)) (List.nodup_finRange n) lemma uncontractedList_toFinset (c : WickContraction n) : - c.uncontractedList.toFinset = c.uncontracted := by - simp [uncontractedList] + c.uncontractedList.toFinset = c.uncontracted := by simp [uncontractedList] lemma uncontractedList_eq_sort (c : WickContraction n) : c.uncontractedList = c.uncontracted.sort (· ≤ ·) := by @@ -323,8 +321,7 @@ scoped[WickContraction] notation "[" φsΛ "]ᵘᶜ" => uncontractedListGet φs @[simp] lemma uncontractedListGet_empty {φs : List 𝓕.FieldOp} : - (empty (n := φs.length)).uncontractedListGet = φs := by - simp [uncontractedListGet] + (empty (n := φs.length)).uncontractedListGet = φs := by simp [uncontractedListGet] /-! @@ -342,8 +339,7 @@ def uncontractedFieldOpEquiv (φs : List 𝓕.FieldOp) (φsΛ : WickContraction @[simp] lemma uncontractedFieldOpEquiv_none (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) : - (uncontractedFieldOpEquiv φs φsΛ).toFun none = none := by - simp [uncontractedFieldOpEquiv] + (uncontractedFieldOpEquiv φs φsΛ).toFun none = none := by simp [uncontractedFieldOpEquiv] lemma uncontractedFieldOpEquiv_list_sum [AddCommMonoid α] (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) (f : Option (Fin [φsΛ]ᵘᶜ.length) → α) : From feda9b41799674faba29e1e5de4ef2ec0c227d81 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:02:40 -0700 Subject: [PATCH 163/498] refactor: golf tensor simp proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/Basic.lean | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index 422df53d5..5d47abd1b 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -135,8 +135,7 @@ lemma update_eq_function_update {n : ℕ} {c : Fin n → C} [inst : DecidableEq @[simp] lemma update_same {n : ℕ} {c : Fin n → C} [inst : DecidableEq (Fin n)] (p : Pure S c) (i : Fin n) - (x : V (c i)) : (update p i x) i = x := by - simp [update] + (x : V (c i)) : (update p i x) i = x := by simp [update] lemma update_diff {n : ℕ} {c : Fin n → C} [inst : DecidableEq (Fin n)] (p : Pure S c) (i j : Fin n) (x : V (c i)) (hij : i ≠ j) : (update p i x) j = p j := by @@ -154,14 +153,13 @@ lemma update_succAbove_apply {n : ℕ} {c : Fin (n + 1) → C} [inst : Decidable @[simp] lemma toTensor_update_add {n : ℕ} {c : Fin n → C} [inst : DecidableEq (Fin n)] (p : Pure S c) (i : Fin n) (x y : V (c i)) : - (update p i (x + y)).toTensor = (update p i x).toTensor + (update p i y).toTensor := by - simp [toTensor, update] + (update p i (x + y)).toTensor = + (update p i x).toTensor + (update p i y).toTensor := by simp [toTensor, update] @[simp] lemma toTensor_update_smul {n : ℕ} {c : Fin n → C} [inst : DecidableEq (Fin n)] (p : Pure S c) (i : Fin n) (r : k) (y : V (c i)) : - (update p i (r • y)).toTensor = r • (update p i y).toTensor := by - simp [toTensor, update] + (update p i (r • y)).toTensor = r • (update p i y).toTensor := by simp [toTensor, update] /-- Given a list of indices `c` of length `n + 1`, a pure tensor `p` and an `i : Fin (n + 1)`, then `drop p i` is the tensor `p` with it's `i`th part dropped. @@ -328,8 +326,7 @@ def ofComponents {n : ℕ} (c : Fin n → C) : toFun f := ∑ b, f b • (Pure.basisVector c b).toTensor map_add' fb gb := by simp [add_smul, Finset.sum_add_distrib] - map_smul' fb r := by - simp [smul_smul, Finset.smul_sum] + map_smul' fb r := by simp [smul_smul, Finset.smul_sum] @[simp] lemma componentMap_ofComponents {n : ℕ} (c : Fin n → C) (f : ComponentIdx c → k) : @@ -530,8 +527,7 @@ lemma actionT_smul {g : G} {r : k} {t : S.Tensor c} : rw [actionT_eq, actionT_eq (S := S)] simp -lemma actionT_zero {g : G} : g • (0 : S.Tensor c) = 0 := by - simp [actionT_eq] +lemma actionT_zero {g : G} : g • (0 : S.Tensor c) = 0 := by simp [actionT_eq] lemma actionT_neg {g : G} {t : S.Tensor c} : g • (-t) = -(g • t) := by @@ -774,8 +770,7 @@ noncomputable def toField {c : Fin 0 → C} : S.Tensor c →ₗ[k] k := (PiTensorProduct.isEmptyEquiv (Fin 0)).toLinearMap lemma toField_default {c : Fin 0 → C} : - toField (Pure.toTensor default : S.Tensor c) = 1 := by - simp [toField, Pure.toTensor] + toField (Pure.toTensor default : S.Tensor c) = 1 := by simp [toField, Pure.toTensor] lemma toField_injective {c : Fin 0 → C} : Function.Injective (toField : S.Tensor c → k) := @@ -804,8 +799,7 @@ lemma toField_basis_default {c : Fin 0 → C} : simp [basis_apply] lemma toField_basis {c : Fin 0 → C} (b : ComponentIdx (S := S) c) : - toField (basis c b) = 1 := by - simp [basis_apply] + toField (basis c b) = 1 := by simp [basis_apply] lemma toField_eq_repr {c : Fin 0 → C} (t : Tensor S c) : t.toField = (basis c).repr t (fun j => Fin.elim0 j) := by From dc544e1671a11c29b9cbf0e4226a6a05999055a4 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:03:48 -0700 Subject: [PATCH 164/498] refactor: golf field op free algebra simp proofs Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/Basic.lean | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Basic.lean index 169c50c34..99576211c 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Basic.lean @@ -85,8 +85,8 @@ lemma ofCrAnListF_cons (φ : 𝓕.CrAnFieldOp) (φs : List 𝓕.CrAnFieldOp) : ofCrAnListF (φ :: φs) = ofCrAnOpF φ * ofCrAnListF φs := rfl lemma ofCrAnListF_append (φs φs' : List 𝓕.CrAnFieldOp) : - ofCrAnListF (φs ++ φs') = ofCrAnListF φs * ofCrAnListF φs' := by - simp [ofCrAnListF, List.map_append] + ofCrAnListF (φs ++ φs') = + ofCrAnListF φs * ofCrAnListF φs' := by simp [ofCrAnListF, List.map_append] lemma ofCrAnListF_singleton (φ : 𝓕.CrAnFieldOp) : ofCrAnListF [φ] = ofCrAnOpF φ := by simp [ofCrAnListF] @@ -155,19 +155,16 @@ def crPartF : 𝓕.FieldOp → 𝓕.FieldOpFreeAlgebra := fun φ => @[simp] lemma crPartF_negAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : - crPartF (FieldOp.inAsymp φ) = ofCrAnOpF ⟨FieldOp.inAsymp φ, ()⟩ := by - simp [crPartF] + crPartF (FieldOp.inAsymp φ) = ofCrAnOpF ⟨FieldOp.inAsymp φ, ()⟩ := by simp [crPartF] @[simp] lemma crPartF_position (φ : (Σ f, 𝓕.PositionLabel f) × SpaceTime) : crPartF (FieldOp.position φ) = - ofCrAnOpF ⟨FieldOp.position φ, CreateAnnihilate.create⟩ := by - simp [crPartF] + ofCrAnOpF ⟨FieldOp.position φ, CreateAnnihilate.create⟩ := by simp [crPartF] @[simp] lemma crPartF_posAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : - crPartF (FieldOp.outAsymp φ) = 0 := by - simp [crPartF] + crPartF (FieldOp.outAsymp φ) = 0 := by simp [crPartF] /-- The algebra map taking an element of the free-state algebra to the part of it in the creation and annihilation free algebra @@ -180,19 +177,16 @@ def anPartF : 𝓕.FieldOp → 𝓕.FieldOpFreeAlgebra := fun φ => @[simp] lemma anPartF_negAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : - anPartF (FieldOp.inAsymp φ) = 0 := by - simp [anPartF] + anPartF (FieldOp.inAsymp φ) = 0 := by simp [anPartF] @[simp] lemma anPartF_position (φ : (Σ f, 𝓕.PositionLabel f) × SpaceTime) : anPartF (FieldOp.position φ) = - ofCrAnOpF ⟨FieldOp.position φ, CreateAnnihilate.annihilate⟩ := by - simp [anPartF] + ofCrAnOpF ⟨FieldOp.position φ, CreateAnnihilate.annihilate⟩ := by simp [anPartF] @[simp] lemma anPartF_posAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : - anPartF (FieldOp.outAsymp φ) = ofCrAnOpF ⟨FieldOp.outAsymp φ, ()⟩ := by - simp [anPartF] + anPartF (FieldOp.outAsymp φ) = ofCrAnOpF ⟨FieldOp.outAsymp φ, ()⟩ := by simp [anPartF] lemma ofFieldOpF_eq_crPartF_add_anPartF (φ : 𝓕.FieldOp) : ofFieldOpF φ = crPartF φ + anPartF φ := by From bf3060e18e294785e693aebda1ad4660a1dab06c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:05:57 -0700 Subject: [PATCH 165/498] refactor: golf spacetime derivative simp proofs Co-authored-by: Claude Opus 4.8 --- .../Space/Derivatives/Iterated.lean | 7 +++---- Physlib/SpaceAndTime/TimeAndSpace/Basic.lean | 18 ++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean b/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean index af9506c20..f2ec5d3fe 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean @@ -91,8 +91,7 @@ private lemma iteratedDerivList_const_smul (L : List (Fin d)) (c : ℝ) {f : Spa @[simp] lemma iteratedDeriv_zero [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] - (f : Space d → M) : ∂^[0] f = f := by - simp [iteratedDeriv, Physlib.MultiIndex.toList_zero] + (f : Space d → M) : ∂^[0] f = f := by simp [iteratedDeriv, Physlib.MultiIndex.toList_zero] @[simp] lemma iteratedDeriv_increment_zero [NeZero d] [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] @@ -104,8 +103,8 @@ lemma iteratedDeriv_increment_zero [NeZero d] [AddCommGroup M] [Module ℝ M] [T @[simp] lemma iteratedDeriv_single [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (i : Fin d) (f : Space d → M) : - ∂^[MultiIndex.increment 0 i] f = ∂[i] f := by - simp [iteratedDeriv, Physlib.MultiIndex.toList_single] + ∂^[MultiIndex.increment 0 i] f = + ∂[i] f := by simp [iteratedDeriv, Physlib.MultiIndex.toList_single] lemma iteratedDeriv_add (I : MultiIndex d) {f g : Space d → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) : diff --git a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean index a6a237617..ab2b368cc 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean @@ -379,13 +379,11 @@ noncomputable def distTimeDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] ev.comp (Distribution.fderivD ℝ f) map_add' _ _ := by simp - map_smul' _ _ := by - simp + map_smul' _ _ := by simp lemma distTimeDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : - (distTimeDeriv f) ε = fderivD ℝ f ε (1, 0) := by - simp [distTimeDeriv] + (distTimeDeriv f) ε = fderivD ℝ f ε (1, 0) := by simp [distTimeDeriv] lemma distTimeDeriv_apply' {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : @@ -397,8 +395,7 @@ lemma distTimeDeriv_apply' {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] lemma apply_fderiv_eq_distTimeDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : f (SchwartzMap.evalCLM ℝ (Time × Space d) ℝ (1, 0) ((fderivCLM ℝ (Time × Space d) ℝ) ε)) = - - (distTimeDeriv f) ε := by - simp [distTimeDeriv_apply'] + - (distTimeDeriv f) ε := by simp [distTimeDeriv_apply'] /-! @@ -430,13 +427,11 @@ noncomputable def distSpaceDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M ev.comp (Distribution.fderivD ℝ f) map_add' _ _ := by simp - map_smul' _ _ := by - simp + map_smul' _ _ := by simp lemma distSpaceDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (i : Fin d) (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : - (distSpaceDeriv i f) ε = fderivD ℝ f ε (0, basis i) := by - simp [distSpaceDeriv] + (distSpaceDeriv i f) ε = fderivD ℝ f ε (0, basis i) := by simp [distSpaceDeriv] lemma distSpaceDeriv_apply' {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (i : Fin d) (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : @@ -449,8 +444,7 @@ lemma apply_fderiv_eq_distSpaceDeriv {M d} [NormedAddCommGroup M] [NormedSpace (i : Fin d) (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : f ((SchwartzMap.evalCLM ℝ (Time × Space d) ℝ (0, basis i)) ((fderivCLM ℝ (Time × Space d) ℝ) ε)) = - - (distSpaceDeriv i f) ε := by - simp [distSpaceDeriv_apply'] + - (distSpaceDeriv i f) ε := by simp [distSpaceDeriv_apply'] /-! From 257fe4289c18137ee818b2294966e9a64efa49df Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:08:13 -0700 Subject: [PATCH 166/498] refactor: golf nonsingular and Hermite simp proofs Co-authored-by: Claude Opus 4.8 --- .../SpecialFunctions/PhysHermite.lean | 16 ++++++++-------- .../ForMathlib/HermitianMat/NonSingular.lean | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean index 7661d8600..8ca5752d5 100644 --- a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean +++ b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean @@ -35,8 +35,8 @@ noncomputable def physHermite : ℕ → Polynomial ℤ | n + 1 => 2 • X * physHermite n - derivative (physHermite n) lemma physHermite_succ (n : ℕ) : - physHermite (n + 1) = 2 • X * physHermite n - derivative (physHermite n) := by - simp [physHermite] + physHermite (n + 1) = + 2 • X * physHermite n - derivative (physHermite n) := by simp [physHermite] lemma physHermite_eq_iterate (n : ℕ) : physHermite n = (fun p => 2 * X * p - derivative p)^[n] 1 := by @@ -73,8 +73,8 @@ lemma physHermite_succ' (n : ℕ) : rw [physHermite_succ, derivative_physHermite] lemma coeff_physHhermite_succ_zero (n : ℕ) : - coeff (physHermite (n + 1)) 0 = - coeff (physHermite n) 1 := by - simp [physHermite_succ, coeff_derivative] + coeff (physHermite (n + 1)) 0 = + - coeff (physHermite n) 1 := by simp [physHermite_succ, coeff_derivative] lemma coeff_physHermite_succ_succ (n k : ℕ) : coeff (physHermite (n + 1)) (k + 1) = 2 * coeff (physHermite n) k - (k + 2) * coeff (physHermite n) (k + 2) := by @@ -135,8 +135,8 @@ lemma iterate_derivative_physHermite_self {n : ℕ} : rfl @[simp] -lemma physHermite_leadingCoeff {n : ℕ} : (physHermite n).leadingCoeff = 2 ^ n := by - simp [leadingCoeff] +lemma physHermite_leadingCoeff {n : ℕ} : + (physHermite n).leadingCoeff = 2 ^ n := by simp [leadingCoeff] @[simp] lemma physHermite_ne_zero {n : ℕ} : physHermite n ≠ 0 := by @@ -151,8 +151,8 @@ lemma physHermite_eq_aeval (n : ℕ) (x : ℝ) : lemma physHermite_zero_apply (x : ℝ) : physHermite 0 x = 1 := by simp -lemma physHermite_pow (n m : ℕ) (x : ℝ) : physHermite n x ^ m = aeval x (physHermite n ^ m) := by - simp +lemma physHermite_pow (n m : ℕ) (x : ℝ) : + physHermite n x ^ m = aeval x (physHermite n ^ m) := by simp lemma physHermite_succ_fun (n : ℕ) : (physHermite (n + 1) : ℝ → ℝ) = 2 • (fun x => x) * diff --git a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean index 1aa5a2529..c33ea17fb 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean @@ -187,8 +187,7 @@ theorem nonSingular_conj (hC : IsUnit C) : NonSingular (A.conj C) := by rwa [nonSingular_iff_conj hC] instance nonSingular_conj_isometry {B : HermitianMat n 𝕜} [NonSingular B] : - NonSingular (A.conj B.mat) := by - simpa [nonSingular_iff_conj] + NonSingular (A.conj B.mat) := by simpa [nonSingular_iff_conj] theorem nonSingular_zero_notMem_spectrum : 0 ∉ spectrum ℝ A.mat := by rwa [← nonSingular_iff_zero_notMem_spectrum] From 85dfd5d66920b1292ed4559b17ed62b6f6bf10de Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:09:25 -0700 Subject: [PATCH 167/498] refactor: golf normal order simp proofs Co-authored-by: Claude Opus 4.8 --- .../FieldSpecification/NormalOrder.lean | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index 3d85ad38b..e3f2756b4 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -56,8 +56,8 @@ def normalOrderSign (φs : List 𝓕.CrAnFieldOp) : ℂ := @[simp] lemma normalOrderSign_mul_self (φs : List 𝓕.CrAnFieldOp) : - normalOrderSign φs * normalOrderSign φs = 1 := by - simp [normalOrderSign, Wick.koszulSign_mul_self] + normalOrderSign φs * normalOrderSign φs = + 1 := by simp [normalOrderSign, Wick.koszulSign_mul_self] lemma koszulSignInsert_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) : (φs : List 𝓕.CrAnFieldOp) → @@ -73,12 +73,13 @@ lemma koszulSignInsert_create (φ : 𝓕.CrAnFieldOp) lemma normalOrderSign_cons_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) (φs : List 𝓕.CrAnFieldOp) : - normalOrderSign (φ :: φs) = normalOrderSign φs := by - simp [normalOrderSign, Wick.koszulSign, koszulSignInsert_create φ hφ φs] + normalOrderSign (φ :: φs) = + normalOrderSign φs := by simp [normalOrderSign, Wick.koszulSign, + koszulSignInsert_create φ hφ φs] @[simp] -lemma normalOrderSign_singleton (φ : 𝓕.CrAnFieldOp) : normalOrderSign [φ] = 1 := by - simp [normalOrderSign] +lemma normalOrderSign_singleton (φ : 𝓕.CrAnFieldOp) : + normalOrderSign [φ] = 1 := by simp [normalOrderSign] @[simp] lemma normalOrderSign_nil : normalOrderSign (𝓕 := 𝓕) [] = 1 := rfl @@ -236,13 +237,11 @@ def normalOrderList (φs : List 𝓕.CrAnFieldOp) : List 𝓕.CrAnFieldOp := List.insertionSort 𝓕.normalOrderRel φs @[simp] -lemma normalOrderList_nil : normalOrderList (𝓕 := 𝓕) [] = [] := by - simp [normalOrderList] +lemma normalOrderList_nil : normalOrderList (𝓕 := 𝓕) [] = [] := by simp [normalOrderList] @[simp] lemma normalOrderList_statistics (φs : List 𝓕.CrAnFieldOp) : - (𝓕 |>ₛ (normalOrderList φs)) = 𝓕 |>ₛ φs := by - simp [normalOrderList] + (𝓕 |>ₛ (normalOrderList φs)) = 𝓕 |>ₛ φs := by simp [normalOrderList] lemma orderedInsert_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) : From e3952e9b0eef6834cc5991f55f40e483fec2f7bd Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:10:22 -0700 Subject: [PATCH 168/498] refactor: golf uncontracted simp proofs Co-authored-by: Claude Opus 4.8 --- .../WickContraction/Uncontracted.lean | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean index 5f4a8ebf1..f9d90820c 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean @@ -30,8 +30,7 @@ lemma congr_uncontracted {n m : ℕ} (c : WickContraction n) (h : n = m) : simp lemma getDual?_eq_none_iff_mem_uncontracted (i : Fin n) : - c.getDual? i = none ↔ i ∈ c.uncontracted := by - simp [uncontracted] + c.getDual? i = none ↔ i ∈ c.uncontracted := by simp [uncontracted] /-- The equivalence of `Option c.uncontracted` for two propositionally equal Wick contractions. -/ def uncontractedCongr {c c': WickContraction n} (h : c = c') : @@ -40,13 +39,12 @@ def uncontractedCongr {c c': WickContraction n} (h : c = c') : @[simp] lemma uncontractedCongr_none {c c': WickContraction n} (h : c = c') : - (uncontractedCongr h) none = none := by - simp [uncontractedCongr] + (uncontractedCongr h) none = none := by simp [uncontractedCongr] @[simp] lemma uncontractedCongr_some {c c': WickContraction n} (h : c = c') (i : c.uncontracted) : - (uncontractedCongr h) (some i) = some (Equiv.subtypeEquivRight (by rw [h]; simp) i) := by - simp [uncontractedCongr] + (uncontractedCongr h) (some i) = + some (Equiv.subtypeEquivRight (by rw [h]; simp) i) := by simp [uncontractedCongr] lemma mem_uncontracted_iff_not_contracted (i : Fin n) : i ∈ c.uncontracted ↔ ∀ p ∈ c.1, i ∉ p := by @@ -81,12 +79,11 @@ lemma mem_uncontracted_empty (i : Fin n) : i ∈ empty.uncontracted := by simp [empty] at hp @[simp] -lemma getDual?_empty_eq_none (i : Fin n) : empty.getDual? i = none := by - simpa [uncontracted] using mem_uncontracted_empty i +lemma getDual?_empty_eq_none (i : Fin n) : + empty.getDual? i = none := by simpa [uncontracted] using mem_uncontracted_empty i @[simp] -lemma uncontracted_empty {n : ℕ} : (@empty n).uncontracted = Finset.univ := by - simp [uncontracted] +lemma uncontracted_empty {n : ℕ} : (@empty n).uncontracted = Finset.univ := by simp [uncontracted] lemma uncontracted_card_le (c : WickContraction n) : c.uncontracted.card ≤ n := by simp only [uncontracted] From 257f8b3dbb5f814ebf93bb5f6af2b7af6350bdc6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:11:10 -0700 Subject: [PATCH 169/498] refactor: golf component contraction simp proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComponentIdx/Contraction.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComponentIdx/Contraction.lean b/Physlib/Relativity/Tensors/ComponentIdx/Contraction.lean index b09c2f539..0b4ebea8f 100644 --- a/Physlib/Relativity/Tensors/ComponentIdx/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComponentIdx/Contraction.lean @@ -98,8 +98,7 @@ lemma mem_iff_apply_succSuccAbove_eq {n : ℕ} {c : Fin (n + 1 + 1) → C} lemma mem_self_of_dropPair {n : ℕ} {c : Fin (n + 1 + 1) → C} {i j : Fin (n + 1 + 1)} (b : ComponentIdx (c)) : - b ∈ DropPairSection (S := S) (b.dropPair i j) := by - simp [DropPairSection] + b ∈ DropPairSection (S := S) (b.dropPair i j) := by simp [DropPairSection] /-- Given a `b` in `ComponentIdx (c ∘ Fin.succSuccAbove i j))` and an `x` in `Fin (S.repDim (c i)) × Fin (S.repDim (c j))`, the corresponding @@ -118,8 +117,7 @@ def ofFin {n : ℕ} {c : Fin (n + 1 + 1) → C} lemma ofFin_apply_fst {n : ℕ} {c : Fin (n + 1 + 1) → C} {i j : Fin (n + 1 + 1)} (hij : i ≠ j) (b : ComponentIdx (c ∘ Fin.succSuccAbove i j)) (x : basisIdx (c i) × basisIdx (c j)) : - ofFin (S := S) hij b x i = x.1 := by - simp [ofFin] + ofFin (S := S) hij b x i = x.1 := by simp [ofFin] @[simp] lemma ofFin_apply_snd {n : ℕ} {c : Fin (n + 1 + 1) → C} @@ -163,22 +161,19 @@ def ofFinEquiv {n : ℕ} {c : Fin n.succ.succ → C} symm apply ComponentIdx.congr_right simp - left_inv x := by - simp + left_inv x := by simp @[simp] lemma ofFinEquiv_apply_fst {n : ℕ} {c : Fin (n + 1 + 1) → C} {i j : Fin (n + 1 + 1)} (hij : i ≠ j) (b : ComponentIdx (c ∘ Fin.succSuccAbove i j)) (x : basisIdx (c i) × basisIdx (c j)) : - (ofFinEquiv (S := S) hij b x).1 i = x.1 := by - simp [ofFinEquiv] + (ofFinEquiv (S := S) hij b x).1 i = x.1 := by simp [ofFinEquiv] @[simp] lemma ofFinEquiv_apply_snd {n : ℕ} {c : Fin (n + 1 + 1) → C} {i j : Fin (n + 1 + 1)} (hij : i ≠ j) (b : ComponentIdx (c ∘ Fin.succSuccAbove i j)) (x : basisIdx (c i) × basisIdx (c j)) : - (ofFinEquiv (S := S) hij b x).1 j = x.2 := by - simp [ofFinEquiv] + (ofFinEquiv (S := S) hij b x).1 j = x.2 := by simp [ofFinEquiv] end DropPairSection From 9da5044f7f5d12480cfcc7753b0b474b79fbdc7a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:12:17 -0700 Subject: [PATCH 170/498] refactor: golf finite ensemble simp proofs Co-authored-by: Claude Opus 4.8 --- .../CanonicalEnsemble/Finite.lean | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index 8388081fd..ba2c3355c 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -83,8 +83,7 @@ instance [IsFinite 𝓒] [IsFinite 𝓒1] : IsFinite (𝓒 + 𝓒1) where · exact MeasurableSet.prod hs ht dof_eq_zero := by simp [IsFinite.dof_eq_zero (𝓒:=𝓒), IsFinite.dof_eq_zero (𝓒:=𝓒1)] - phase_space_unit_eq_one := by - simp [IsFinite.phase_space_unit_eq_one (𝓒:=𝓒)] + phase_space_unit_eq_one := by simp [IsFinite.phase_space_unit_eq_one (𝓒:=𝓒)] instance [IsFinite 𝓒] (e : ι1 ≃ᵐ ι) : IsFinite (congr 𝓒 e) where μ_eq_count := by @@ -106,8 +105,7 @@ instance [IsFinite 𝓒] (e : ι1 ≃ᵐ ι) : IsFinite (congr 𝓒 e) where · exact (MeasurableEquiv.measurableSet_preimage e.symm).mpr hs dof_eq_zero := by simp [IsFinite.dof_eq_zero (𝓒:=𝓒)] - phase_space_unit_eq_one := by - simp [IsFinite.phase_space_unit_eq_one (𝓒:=𝓒)] + phase_space_unit_eq_one := by simp [IsFinite.phase_space_unit_eq_one (𝓒:=𝓒)] instance [IsFinite 𝓒] (n : ℕ) : IsFinite (nsmul n 𝓒) where μ_eq_count := by @@ -217,8 +215,8 @@ variable {ι1 : Type} [Fintype ι1] [MeasurableSpace ι1] open Constants lemma entropy_of_fintype (T : Temperature) : - 𝓒.shannonEntropy T = - kB * ∑ i, 𝓒.probability T i * log (𝓒.probability T i) := by - simp [shannonEntropy] + 𝓒.shannonEntropy T = + - kB * ∑ i, 𝓒.probability T i * log (𝓒.probability T i) := by simp [shannonEntropy] lemma probability_le_one [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] (T : Temperature) (i : ι) : @@ -234,8 +232,8 @@ lemma probability_le_one /-- Finite specialization: strict positivity of the mathematical partition function. -/ lemma mathematicalPartitionFunction_pos_finite [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] (T : Temperature) : - 0 < 𝓒.mathematicalPartitionFunction T := by - simpa using (CanonicalEnsemble.mathematicalPartitionFunction_pos (𝓒:=𝓒) T) + 0 < 𝓒.mathematicalPartitionFunction T := by simpa using + (CanonicalEnsemble.mathematicalPartitionFunction_pos (𝓒:=𝓒) T) /-- Finite specialization: strict positivity of the (physical) partition function. -/ lemma partitionFunction_pos_finite @@ -274,8 +272,9 @@ lemma entropy_nonneg [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] lemma shannonEntropy_eq_differentialEntropy [MeasurableSingletonClass ι] [IsFinite 𝓒] (T : Temperature) : - 𝓒.shannonEntropy T = 𝓒.differentialEntropy T := by - simp [shannonEntropy, differentialEntropy, integral_fintype, μProd_of_fintype] + 𝓒.shannonEntropy T = + 𝓒.differentialEntropy T := by simp [shannonEntropy, differentialEntropy, + integral_fintype, μProd_of_fintype] /-- In the finite, nonempty case the thermodynamic and Shannon entropies coincide. All semi-classical correction factors vanish (`dof = 0`, `phaseSpaceUnit = 1`), From 2b7f99b86acd72102adb991db4da27835ee2404b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:17:50 -0700 Subject: [PATCH 171/498] refactor: golf complex unit proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Units/Basic.lean | 12 ++++-------- .../Tensors/ComplexTensor/Units/Symm.lean | 18 ++++++------------ 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index d91c2b6b1..09f99f86d 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -173,26 +173,22 @@ lemma contrCoUnit_eq_complexContrBasisFin4_complexCoBasisFin4 : δ = open Fermion in lemma dualLeftLeftUnit_eq_dualLeftBasis_leftBasis : δL' = ∑ i, fromPairT (dualLeftBasis i ⊗ₜ[ℂ] leftBasis i) := by - rw [dualLeftLeftUnit_eq_fromPairT, dualLeftLeftUnitVal_expand_tmul] - rfl + simp [dualLeftLeftUnit_eq_fromPairT, dualLeftLeftUnitVal_expand_tmul] open Fermion in lemma leftDualLeftUnit_eq_leftBasis_dualLeftBasis : δL = ∑ i, fromPairT (leftBasis i ⊗ₜ[ℂ] dualLeftBasis i) := by - rw [leftDualLeftUnit_eq_fromPairT, leftDualLeftUnitVal_expand_tmul] - rfl + simp [leftDualLeftUnit_eq_fromPairT, leftDualLeftUnitVal_expand_tmul] open Fermion in lemma dualRightRightUnit_eq_dualRightBasis_rightBasis : δR' = ∑ i, fromPairT (dualRightBasis i ⊗ₜ[ℂ] rightBasis i) := by - rw [dualRightRightUnit_eq_fromPairT, dualRightRightUnitVal_expand_tmul] - rfl + simp [dualRightRightUnit_eq_fromPairT, dualRightRightUnitVal_expand_tmul] open Fermion in lemma rightDualRightUnit_eq_rightBasis_dualRightBasis : δR = ∑ i, fromPairT (rightBasis i ⊗ₜ[ℂ] dualRightBasis i) := by - rw [rightDualRightUnit_eq_fromPairT, rightDualRightUnitVal_expand_tmul] - rfl + simp [rightDualRightUnit_eq_fromPairT, rightDualRightUnitVal_expand_tmul] /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean index a7f32eae1..b3b8dc6ce 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean @@ -28,38 +28,32 @@ open Tensor /-- Swapping indices of `coContrUnit` returns `contrCoUnit`: `{δ' | μ ν = δ | ν μ}ᵀ`. -/ lemma coContrUnit_symm : {δ' | μ ν = δ | ν μ}ᵀ := by - rw [coContrUnit, unitTensor_eq_permT_dual] - rfl + exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.up /-- Swapping indices of `contrCoUnit` returns `coContrUnit`: `{δ | μ ν = δ' | ν μ}ᵀ`. -/ lemma contrCoUnit_symm : {δ | μ ν = δ' | ν μ}ᵀ := by - rw [contrCoUnit, unitTensor_eq_permT_dual] - rfl + exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.down /-- Swapping indices of `dualLeftLeftUnit` returns `leftDualLeftUnit`: `{δL' | α α' = δL | α' α}ᵀ`. -/ lemma dualLeftLeftUnit_symm : {δL' | α α' = δL | α' α}ᵀ := by - rw [dualLeftLeftUnit, unitTensor_eq_permT_dual] - rfl + exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.upL /-- Swapping indices of `leftDualLeftUnit` returns `dualLeftLeftUnit`: `{δL | α α' = δL' | α' α}ᵀ`. -/ lemma leftDualLeftUnit_symm : {δL | α α' = δL' | α' α}ᵀ := by - rw [leftDualLeftUnit, unitTensor_eq_permT_dual] - rfl + exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.downL /-- Swapping indices of `dualRightRightUnit` returns `rightDualRightUnit`: `{δR' | β β' = δR | β' β}ᵀ`. -/ lemma dualRightRightUnit_symm : {δR' | β β' = δR | β' β}ᵀ := by - rw [dualRightRightUnit, unitTensor_eq_permT_dual] - rfl + exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.upR /-- Swapping indices of `rightDualRightUnit` returns `dualRightRightUnit`: `{δR | β β' = δR' | β' β}ᵀ`. -/ lemma rightDualRightUnit_symm : {δR | β β' = δR' | β' β}ᵀ := by - rw [rightDualRightUnit, unitTensor_eq_permT_dual] - rfl + exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.downR end complexLorentzTensor From 973b5418c387f43d8a6e5db2ad2e7fe639e61055 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:22:11 -0700 Subject: [PATCH 172/498] refactor: golf QFT filter and basis proofs Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/FieldSpecification/Filters.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 6 ++---- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/Filters.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/Filters.lean index 9af522575..4f8d7caa2 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/Filters.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/Filters.lean @@ -40,8 +40,7 @@ lemma createFilter_cons_annihilate {φ : 𝓕.CrAnFieldOp} lemma createFilter_append (φs φs' : List 𝓕.CrAnFieldOp) : createFilter (φs ++ φs') = createFilter φs ++ createFilter φs' := by - rw [createFilter, List.filter_append] - rfl + simp [createFilter, List.filter_append] lemma createFilter_singleton_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) : @@ -76,8 +75,7 @@ lemma annihilateFilter_cons_annihilate {φ : 𝓕.CrAnFieldOp} lemma annihilateFilter_append (φs φs' : List 𝓕.CrAnFieldOp) : annihilateFilter (φs ++ φs') = annihilateFilter φs ++ annihilateFilter φs' := by - rw [annihilateFilter, List.filter_append] - rfl + simp [annihilateFilter, List.filter_append] lemma annihilateFilter_singleton_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) : diff --git a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean index 4b9f954ae..400e78c19 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean @@ -73,8 +73,7 @@ noncomputable def coordinateMap : (PureU1 n.succ).LinSols ≃ₗ[ℚ] Fin n →₀ ℚ where toFun S := (Finsupp.linearEquivFunOnFinite ℚ ℚ (Fin n)).symm (S.1 ∘ Fin.castSucc) map_add' S T := by - rw [← map_add] - rfl + exact map_add _ _ _ map_smul' a S := by rw [← map_smul] rfl diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index 938c956ce..af16adc78 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -298,8 +298,7 @@ lemma basis_on_evenSnd_self (j : Fin n.succ) : basisAsCharges j (evenSnd j) = - rw [basis_evenSnd_eq_neg_evenFst, basis_on_evenFst_self] lemma basis_on_evenSnd_other {k j : Fin n.succ} (h : k ≠ j) : basisAsCharges k (evenSnd j) = 0 := by - rw [basis_evenSnd_eq_neg_evenFst, basis_on_evenFst_other h] - rfl + simp [basis_evenSnd_eq_neg_evenFst, basis_on_evenFst_other h] /-! @@ -550,8 +549,7 @@ lemma basis!_on_evenShiftSnd_self (j : Fin n) : basis!AsCharges j (evenShiftSnd lemma basis!_on_evenShiftSnd_other {k j : Fin n} (h : k ≠ j) : basis!AsCharges k (evenShiftSnd j) = 0 := by - rw [basis!_evenShftSnd_eq_neg_evenShiftFst, basis!_on_evenShiftFst_other h] - rfl + simp [basis!_evenShftSnd_eq_neg_evenShiftFst, basis!_on_evenShiftFst_other h] set_option backward.isDefEq.respectTransparency false in lemma basis!_on_evenShiftZero (j : Fin n) : basis!AsCharges j evenShiftZero = 0 := by diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 92b71bd2d..b40214bfe 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -345,8 +345,7 @@ lemma basis_on_oddSnd_self (j : Fin n) : basisAsCharges j (oddSnd j) = - 1 := by rw [basis_oddSnd_eq_minus_oddFst, basis_on_oddFst_self] lemma basis_on_oddSnd_other {k j : Fin n} (h : k ≠ j) : basisAsCharges k (oddSnd j) = 0 := by - rw [basis_oddSnd_eq_minus_oddFst, basis_on_oddFst_other h] - rfl + simp [basis_oddSnd_eq_minus_oddFst, basis_on_oddFst_other h] set_option backward.isDefEq.respectTransparency false in lemma basis_on_oddMid (j : Fin n) : basisAsCharges j oddMid = 0 := by @@ -569,8 +568,7 @@ lemma basis!_on_oddShiftSnd_self (j : Fin n) : basis!AsCharges j (oddShiftSnd j) lemma basis!_on_oddShiftSnd_other {k j : Fin n} (h : k ≠ j) : basis!AsCharges k (oddShiftSnd j) = 0 := by - rw [basis!_oddShiftSnd_eq_minus_oddShiftFst, basis!_on_oddShiftFst_other h] - rfl + simp [basis!_oddShiftSnd_eq_minus_oddShiftFst, basis!_on_oddShiftFst_other h] set_option backward.isDefEq.respectTransparency false in lemma basis!_on_oddShiftZero (j : Fin n) : basis!AsCharges j oddShiftZero = 0 := by From a731dbbcc7a92a96f2fc74fb1b6ebba49d4a55cb Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:25:46 -0700 Subject: [PATCH 173/498] refactor: golf QFT sum transport proofs Co-authored-by: Claude Opus 4.8 --- .../FieldSpecification/CrAnSection.lean | 15 ++++++--------- .../WickContraction/ExtractEquiv.lean | 4 +--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index fc0f4d208..518d101b9 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -194,21 +194,18 @@ lemma card_perm_eq {φs φs' : List 𝓕.FieldOp} (h : φs.Perm φs') : @[simp] lemma sum_nil (f : CrAnSection (𝓕 := 𝓕) [] → M) [AddCommMonoid M] : ∑ (s : CrAnSection []), f s = f ⟨[], rfl⟩ := by - rw [← nilEquiv.symm.sum_comp] - simp only [Finset.univ_unique, PUnit.default_eq_unit, Finset.sum_singleton] - rfl + simpa [nilEquiv] using Eq.symm (Equiv.sum_comp nilEquiv.symm f) lemma sum_cons (f : CrAnSection (φ :: φs) → M) [AddCommMonoid M] : ∑ (s : CrAnSection (φ :: φs)), f s = ∑ (a : 𝓕.fieldOpToCrAnType φ), ∑ (s : CrAnSection φs), f (cons a s) := by - rw [← consEquiv.symm.sum_comp, Fintype.sum_prod_type] - rfl + simpa [Fintype.sum_prod_type, consEquiv] using + Eq.symm (Equiv.sum_comp consEquiv.symm f) lemma sum_over_length {s : CrAnSection φs} (f : Fin s.1.length → M) [AddCommMonoid M] : ∑ (n : Fin s.1.length), f n = ∑ (n : Fin φs.length), f (Fin.cast (length_eq s).symm n) := by - rw [← (finCongr (length_eq s)).sum_comp] - rfl + exact Eq.symm (Equiv.sum_comp (finCongr (length_eq s)).symm f) /-- The equivalence between `CrAnSection φs` and `CrAnSection φs'` induced by an equality `φs = φs'`. -/ @@ -421,8 +418,8 @@ lemma sum_eraseIdxEquiv (n : ℕ) (φs : List 𝓕.FieldOp) (hn : n < φs.length (f : CrAnSection φs → M) [AddCommMonoid M] : ∑ (s : CrAnSection φs), f s = ∑ (a : 𝓕.fieldOpToCrAnType φs[n]), ∑ (s : CrAnSection (φs.eraseIdx n)), f ((eraseIdxEquiv n φs hn).symm ⟨a, s⟩) := by - rw [← (eraseIdxEquiv n φs hn).symm.sum_comp] - rw [Fintype.sum_prod_type] + simpa [Fintype.sum_prod_type] using + Eq.symm (Equiv.sum_comp (eraseIdxEquiv n φs hn).symm f) end CrAnSection diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean b/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean index 987530659..b791c770d 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean @@ -108,9 +108,7 @@ lemma sum_extractEquiv_congr [AddCommMonoid M] {n m : ℕ} (i : Fin n) (f : Wick ∑ c, f c = ∑ (c : WickContraction m), ∑ (k : Option c.uncontracted), f (congr h.symm ((extractEquiv (finCongr h i)).symm ⟨c, k⟩)) := by subst h - simp only [finCongr_refl, Equiv.refl_apply, congr_refl] - rw [← (extractEquiv i).symm.sum_comp] - rw [Finset.sum_sigma'] + rw [← (extractEquiv i).symm.sum_comp, Finset.sum_sigma'] rfl /-- For `n = 3` there are `4` possible Wick contractions: From d92933ca06e693d1c11a85d559ec5da4c71ca5e1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:30:26 -0700 Subject: [PATCH 174/498] refactor: golf relativity wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean | 3 +-- .../Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean | 3 +-- Physlib/Relativity/Tensors/Tensorial.lean | 2 -- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean index 98e285566..583fe605e 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean @@ -743,8 +743,7 @@ lemma leftRightToMatrix_ρ_symm_selfAdjoint (v : Matrix (Fin 2) (Fin 2) ℂ) (hv : IsSelfAdjoint v) (M : SL(2,ℂ)) : TensorProduct.map (leftHandedRep M) (rightHandedRep M) (leftRightToMatrix.symm v) = leftRightToMatrix.symm (SL2C.toSelfAdjointMap M ⟨v, hv⟩) := by - rw [leftRightToMatrix_ρ_symm] - rfl + exact leftRightToMatrix_ρ_symm v M end end Fermion diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean index ed5224500..8e4ac1e2a 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean @@ -128,8 +128,7 @@ lemma minkowskiProduct_apply {d : ℕ} (p q : Vector d) : lemma minkowskiProduct_symm {d : ℕ} (p q : Vector d) : ⟪p, q⟫ₘ = ⟪q, p⟫ₘ := by - rw [minkowskiProduct_apply, minkowskiProductMap_symm] - rfl + exact minkowskiProductMap_symm p q lemma minkowskiProduct_toCoord {d : ℕ} (p q : Vector d) : ⟪p, q⟫ₘ = p (Sum.inl 0) * q (Sum.inl 0) - ∑ i, p (Sum.inr i) * q (Sum.inr i) := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index 635b8dcaf..e9b50bbba 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -240,8 +240,7 @@ lemma toSelfAdjoint_apply_coe (x : ContrMod 3) : (toSelfAdjoint x).1 = - x.toFin1dℝ (Sum.inr 0) • PauliMatrix.pauliMatrix (Sum.inr 0) - x.toFin1dℝ (Sum.inr 1) • PauliMatrix.pauliMatrix (Sum.inr 1) - x.toFin1dℝ (Sum.inr 2) • PauliMatrix.pauliMatrix (Sum.inr 2) := by - rw [toSelfAdjoint_apply] - rfl + exact congrArg Subtype.val (toSelfAdjoint_apply x) lemma toSelfAdjoint_stdBasis (i : Fin 1 ⊕ Fin 3) : toSelfAdjoint (stdBasis i) = PauliMatrix.pauliBasis' i := by diff --git a/Physlib/Relativity/Tensors/Tensorial.lean b/Physlib/Relativity/Tensors/Tensorial.lean index c301054f1..8df05a360 100644 --- a/Physlib/Relativity/Tensors/Tensorial.lean +++ b/Physlib/Relativity/Tensors/Tensorial.lean @@ -109,7 +109,6 @@ noncomputable instance self {n : ℕ} (S : TensorSpecies k C G V basisIdx rep b) lemma self_toTensor_apply {n : ℕ} (S : TensorSpecies k C G V basisIdx rep b) (c : Fin n → C) (t : S.Tensor c) : Tensorial.toTensor t = t := by - rw [Tensorial.toTensor] rfl /-! @@ -152,7 +151,6 @@ noncomputable instance mulAction [Tensorial S c M] : MulAction G M where lemma smul_eq {g : G} {t : M} [Tensorial S c M] : g • t = toTensor.symm (g • toTensor t) := by - rw [Tensorial.toTensor] rfl lemma toTensor_smul {g : G} {t : M} [Tensorial S c M] : From 0296e78d940f578dd179aaa9ef538b667d94ca90 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:38:30 -0700 Subject: [PATCH 175/498] refactor: golf vector coordinate proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 1 - .../Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean | 6 ++---- Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean | 6 ++---- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index b40214bfe..fad015394 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -233,7 +233,6 @@ lemma oddShiftShiftSnd_eq_oddSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddSnd exact Nat.add_comm 1 n lemma oddShiftShiftSnd_eq_oddShiftSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddShiftSnd j := by - rw [Fin.ext_iff] rfl lemma oddSnd_eq_oddShiftSnd (j : Fin n) : oddSnd j = oddShiftSnd j := by diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index 4555daac9..faa5029f6 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -32,8 +32,7 @@ def complexContrBasis : Basis (Fin 1 ⊕ Fin 3) ℂ ContrℂModule := @[simp] lemma complexContrBasis_toFin13ℂ (i :Fin 1 ⊕ Fin 3) : (complexContrBasis i).toFin13ℂ = Pi.single i 1 := by - simp only [complexContrBasis, Basis.coe_ofEquivFun] - rfl + simp [complexContrBasis] @[simp] lemma complexContrBasis_ρ_apply (M : SL(2,ℂ)) (i j : Fin 1 ⊕ Fin 3) : @@ -97,8 +96,7 @@ def complexCoBasis : Basis (Fin 1 ⊕ Fin 3) ℂ CoℂModule := @[simp] lemma complexCoBasis_toFin13ℂ (i :Fin 1 ⊕ Fin 3) : (complexCoBasis i).toFin13ℂ = Pi.single i 1 := by - simp only [complexCoBasis, Basis.coe_ofEquivFun] - rfl + simp [complexCoBasis] @[simp] lemma complexCoBasis_ρ_apply (M : SL(2,ℂ)) (i j : Fin 1 ⊕ Fin 3) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index 3f807fa42..f4bc80206 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -46,8 +46,7 @@ lemma contrBasis_ρ_apply {d : ℕ} (M : LorentzGroup d) (i j : Fin 1 ⊕ Fin d) @[simp] lemma contrBasis_toFin1dℝ {d : ℕ} (i : Fin 1 ⊕ Fin d) : (contrBasis d i).toFin1dℝ = Pi.single i 1 := by - simp only [ContrMod.toFin1dℝ, contrBasis, Basis.coe_ofEquivFun] - rfl + simp [ContrMod.toFin1dℝ, contrBasis] lemma contrBasis_repr_apply {d : ℕ} (p : Contr d) (i : Fin 1 ⊕ Fin d) : (contrBasis d).repr p i = p.val i := by @@ -109,8 +108,7 @@ lemma coBasis_repr_apply {d : ℕ} (p : Co d) (i : Fin 1 ⊕ Fin d) : @[simp] lemma coBasis_toFin1dℝ {d : ℕ} (i : Fin 1 ⊕ Fin d) : (coBasis d i).toFin1dℝ = Pi.single i 1 := by - simp only [coBasis, Basis.coe_ofEquivFun] - rfl + simp [coBasis] /-- The standard basis of covariant Lorentz vectors indexed by `Fin (1 + d)`. -/ def coBasisFin (d : ℕ := 3) : Basis (Fin (1 + d)) ℝ (CoMod d) := From a144533d5e01fe9eb947c81c00761c66ee29cc98 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:43:45 -0700 Subject: [PATCH 176/498] refactor: golf grading parity proofs Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/FieldOpFreeAlgebra/Grading.lean | 4 ---- .../FieldOpFreeAlgebra/SuperCommute.lean | 10 ---------- Physlib/Relativity/Tensors/OfInt.lean | 3 +-- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean index 229a9cd29..4461e5354 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean @@ -349,7 +349,6 @@ lemma bosonicProjF_mul (a b : 𝓕.FieldOpFreeAlgebra) : rw [bosonicProjF_of_mem_bosonic _ (by have h1 : bosonic = fermionic + fermionic := by - simp only [add_eq_mul, mul_self] rfl conv_lhs => rw [h1] apply fieldOpFreeAlgebraGrade.mul_mem @@ -357,7 +356,6 @@ lemma bosonicProjF_mul (a b : 𝓕.FieldOpFreeAlgebra) : simp)] simp only [ZeroMemClass.coe_zero, add_zero, zero_add] · have h1 : bosonic = bosonic + bosonic := by - simp only [add_eq_mul, mul_self] rfl conv_lhs => rw [h1] apply fieldOpFreeAlgebraGrade.mul_mem @@ -377,7 +375,6 @@ lemma fermionicProjF_mul (a b : 𝓕.FieldOpFreeAlgebra) : rw [fermionicProjF_of_mem_bosonic _ (by have h1 : bosonic = bosonic + bosonic := by - simp only [add_eq_mul, mul_self] rfl conv_lhs => rw [h1] apply fieldOpFreeAlgebraGrade.mul_mem @@ -409,7 +406,6 @@ lemma fermionicProjF_mul (a b : 𝓕.FieldOpFreeAlgebra) : rw [fermionicProjF_of_mem_bosonic _ (by have h1 : bosonic = fermionic + fermionic := by - simp only [add_eq_mul, mul_self] rfl conv_lhs => rw [h1] apply fieldOpFreeAlgebraGrade.mul_mem diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 84da10d1b..2d65a8d2b 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -732,7 +732,6 @@ lemma superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic (φs φs' : Lis by_cases h1 : (𝓕 |>ₛ φs) = bosonic <;> by_cases h2 : (𝓕 |>ₛ φs') = bosonic · left have h : bosonic = bosonic + bosonic := by - simp only [add_eq_mul, mul_self] rfl rw [h] apply superCommuteF_grade @@ -740,7 +739,6 @@ lemma superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic (φs φs' : Lis apply ofCrAnListF_mem_statisticSubmodule_of _ _ h2 · right have h : fermionic = bosonic + fermionic := by - simp only [add_eq_mul] rfl rw [h] apply superCommuteF_grade @@ -748,7 +746,6 @@ lemma superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic (φs φs' : Lis apply ofCrAnListF_mem_statisticSubmodule_of _ _ (by simpa using h2) · right have h : fermionic = fermionic + bosonic := by - simp only [add_eq_mul] rfl rw [h] apply superCommuteF_grade @@ -756,7 +753,6 @@ lemma superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic (φs φs' : Lis apply ofCrAnListF_mem_statisticSubmodule_of _ _ h2 · left have h : bosonic = fermionic + fermionic := by - simp only [add_eq_mul, mul_self] rfl rw [h] apply superCommuteF_grade @@ -776,25 +772,21 @@ lemma superCommuteF_superCommuteF_ofCrAnOpF_bosonic_or_fermionic (φ1 φ2 φ3 : <;> rcases ofCrAnOpF_bosonic_or_fermionic φ1 with h1 | h1 · left have h : bosonic = bosonic + bosonic := by - simp only [add_eq_mul, mul_self] rfl rw [h] apply superCommuteF_grade h1 hs · right have h : fermionic = fermionic + bosonic := by - simp only [add_eq_mul] rfl rw [h] apply superCommuteF_grade h1 hs · right have h : fermionic = bosonic + fermionic := by - simp only [add_eq_mul] rfl rw [h] apply superCommuteF_grade h1 hs · left have h : bosonic = fermionic + fermionic := by - simp only [add_eq_mul, mul_self] rfl rw [h] apply superCommuteF_grade h1 hs @@ -872,7 +864,6 @@ lemma statistic_ne_of_superCommuteF_fermionic {φs φs' : List 𝓕.CrAnFieldOp} refine h0 (eq_zero_of_bosonic_and_fermionic ?_ h) by_cases hc : (𝓕 |>ₛ φs) = bosonic · have h1 : bosonic = bosonic + bosonic := by - simp only [add_eq_mul, mul_self] rfl rw [h1] apply superCommuteF_grade @@ -880,7 +871,6 @@ lemma statistic_ne_of_superCommuteF_fermionic {φs φs' : List 𝓕.CrAnFieldOp} apply ofCrAnListF_mem_statisticSubmodule_of _ _ rw [← hn, hc] · have h1 : bosonic = fermionic + fermionic := by - simp only [add_eq_mul, mul_self] rfl rw [h1] apply superCommuteF_grade diff --git a/Physlib/Relativity/Tensors/OfInt.lean b/Physlib/Relativity/Tensors/OfInt.lean index b50bf4139..4182cdede 100644 --- a/Physlib/Relativity/Tensors/OfInt.lean +++ b/Physlib/Relativity/Tensors/OfInt.lean @@ -42,8 +42,7 @@ noncomputable def toTensor {n : ℕ} {c : Fin n → C} (f : TensorInt S c) : lemma basis_repr_apply {n : ℕ} {c : Fin n → C} (f : TensorInt S c) (b : ComponentIdx c) : (Tensor.basis c).repr (toTensor f) b = Int.cast (f b) := by - simp only [toTensor, Basis.repr_symm_apply, Basis.repr_linearCombination] - rfl + simp [toTensor] end TensorInt From 42038427c24447efa5433d24e8fedede6b2bec80 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:51:08 -0700 Subject: [PATCH 177/498] refactor: golf Wick wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean | 3 +-- .../WickAlgebra/NormalOrder/Lemmas.lean | 4 ++-- .../QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean | 4 ++-- .../PerturbationTheory/WickContraction/Sign/Join.lean | 9 +++------ 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean index 7d0eb7ac8..5b015c681 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean @@ -73,8 +73,7 @@ instance : Setoid (FieldOpFreeAlgebra 𝓕) := (TwoSidedIdeal.span 𝓕.fieldOpI lemma equiv_iff_sub_mem_ideal (x y : FieldOpFreeAlgebra 𝓕) : x ≈ y ↔ x - y ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet := by - rw [← TwoSidedIdeal.rel_iff] - rfl + exact (TwoSidedIdeal.span 𝓕.fieldOpIdealSet).rel_iff x y lemma equiv_iff_exists_add (x y : FieldOpFreeAlgebra 𝓕) : x ≈ y ↔ ∃ a, x = y + a ∧ a ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet := by diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index c7d41c4c1..2b09191a2 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -34,8 +34,8 @@ lemma normalOrder_eq_ι_normalOrderF (a : 𝓕.FieldOpFreeAlgebra) : lemma normalOrder_ofCrAnList (φs : List 𝓕.CrAnFieldOp) : 𝓝(ofCrAnList φs) = normalOrderSign φs • ofCrAnList (normalOrderList φs) := by - rw [ofCrAnList, normalOrder_eq_ι_normalOrderF, normalOrderF_ofCrAnListF] - rfl + simpa [ofCrAnList, normalOrder_eq_ι_normalOrderF] using + congrArg ι (normalOrderF_ofCrAnListF φs) @[simp] lemma normalOrder_one_eq_one : normalOrder (𝓕 := 𝓕) 1 = 1 := by diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 4185b92a5..27d02f823 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -488,8 +488,8 @@ lemma timeOrder_eq_maxTimeField_mul_finset (φ : 𝓕.FieldOp) (φs : List 𝓕. (Finset.univ.filter (fun x => (maxTimeFieldPosFin φ φs).succAbove x < maxTimeFieldPosFin φ φs))⟩) • ofFieldOp (maxTimeField φ φs) * 𝓣(ofFieldOpList (eraseMaxTimeField φ φs)) := by - rw [ofFieldOpList, timeOrder_eq_ι_timeOrderF, timeOrderF_eq_maxTimeField_mul_finset] - rfl + simpa [ofFieldOpList, ofFieldOp, timeOrder_eq_ι_timeOrderF] using + congrArg ι (timeOrderF_eq_maxTimeField_mul_finset φ φs) lemma timeOrder_superCommute_eq_time_mid {φ ψ : 𝓕.CrAnFieldOp} (hφψ : crAnTimeOrderRel φ ψ) (hψφ : crAnTimeOrderRel ψ φ) (a b : 𝓕.WickAlgebra) : diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean index 8fb183a2b..f48bfd8cc 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean @@ -193,10 +193,8 @@ lemma join_singleton_sign_left {φs : List 𝓕.FieldOp} (φsucΛ : WickContraction [singleton h]ᵘᶜ.length) : (singleton h).sign = 𝓢(𝓕 |>ₛ φs[j], (𝓕 |>ₛ ⟨φs.get, (join (singleton h) φsucΛ).signFinset i j⟩)) * (joinSignLeftExtra h φsucΛ) := by - rw [singleton_sign_expand] - rw [join_singleton_left_signFinset_eq_filter h φsucΛ] - rw [map_mul] - rfl + simpa [joinSignLeftExtra, join_singleton_left_signFinset_eq_filter h φsucΛ, map_mul] using + singleton_sign_expand h lemma join_singleton_sign_right {φs : List 𝓕.FieldOp} {i j : Fin φs.length} (h : i < j) @@ -206,8 +204,7 @@ lemma join_singleton_sign_right {φs : List 𝓕.FieldOp} (∏ a, 𝓢(𝓕|>ₛ [singleton h]ᵘᶜ[φsucΛ.sndFieldOfContract a], 𝓕|>ₛ ⟨φs.get, ((join (singleton h) φsucΛ).signFinset (uncontractedListEmd (φsucΛ.fstFieldOfContract a)) (uncontractedListEmd (φsucΛ.sndFieldOfContract a)))⟩)) := by - rw [sign_right_eq_prod_mul_prod] - rfl + exact sign_right_eq_prod_mul_prod (singleton h) φsucΛ lemma joinSignRightExtra_eq_i_j_finset_eq_if {φs : List 𝓕.FieldOp} {i j : Fin φs.length} (h : i < j) (φsucΛ : WickContraction [singleton h]ᵘᶜ.length) : From f1c0067332f6df79bf4d21831cb103eab1f60eb3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 16:58:01 -0700 Subject: [PATCH 178/498] refactor: golf normal and time order proofs Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/NormalOrder/Lemmas.lean | 33 ++++--------------- .../WickAlgebra/TimeOrder.lean | 2 +- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index 2b09191a2..3d86f23ca 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -39,24 +39,17 @@ lemma normalOrder_ofCrAnList (φs : List 𝓕.CrAnFieldOp) : @[simp] lemma normalOrder_one_eq_one : normalOrder (𝓕 := 𝓕) 1 = 1 := by - have h1 : 1 = ofCrAnList (𝓕 := 𝓕) [] := by simp [ofCrAnList] - rw [h1] - rw [normalOrder_ofCrAnList] - simp + simpa [ofCrAnList, normalOrderSign_nil, normalOrderList_nil, one_smul] using + normalOrder_ofCrAnList (𝓕 := 𝓕) [] @[simp] lemma normalOrder_ofFieldOpList_nil : normalOrder (𝓕 := 𝓕) (ofFieldOpList []) = 1 := by - rw [ofFieldOpList] - rw [normalOrder_eq_ι_normalOrderF] - simp only [ofFieldOpListF_nil] - change normalOrder (𝓕 := 𝓕) 1 = _ - simp + simp [ofFieldOpList, ofFieldOpListF_nil] @[simp] lemma normalOrder_ofCrAnList_nil : normalOrder (𝓕 := 𝓕) (ofCrAnList []) = 1 := by - rw [normalOrder_ofCrAnList] - simp only [normalOrderSign_nil, normalOrderList_nil, ofCrAnList_nil] - module + simpa only [normalOrderSign_nil, normalOrderList_nil, ofCrAnList_nil, one_smul] using + normalOrder_ofCrAnList (𝓕 := 𝓕) [] lemma ofCrAnList_eq_normalOrder (φs : List 𝓕.CrAnFieldOp) : ofCrAnList (normalOrderList φs) = normalOrderSign φs • 𝓝(ofCrAnList φs) := by @@ -76,23 +69,11 @@ lemma normalOrder_normalOrder_mid (a b c : 𝓕.WickAlgebra) : lemma normalOrder_normalOrder_left (a b : 𝓕.WickAlgebra) : 𝓝(a * b) = 𝓝(𝓝(a) * b) := by - obtain ⟨a, rfl⟩ := ι_surjective a - obtain ⟨b, rfl⟩ := ι_surjective b - rw [normalOrder_eq_ι_normalOrderF] - simp only [← map_mul] - rw [normalOrder_eq_ι_normalOrderF] - rw [normalOrderF_normalOrderF_left] - rfl + simpa using normalOrder_normalOrder_mid (1 : 𝓕.WickAlgebra) a b lemma normalOrder_normalOrder_right (a b : 𝓕.WickAlgebra) : 𝓝(a * b) = 𝓝(a * 𝓝(b)) := by - obtain ⟨a, rfl⟩ := ι_surjective a - obtain ⟨b, rfl⟩ := ι_surjective b - rw [normalOrder_eq_ι_normalOrderF] - simp only [← map_mul] - rw [normalOrder_eq_ι_normalOrderF] - rw [normalOrderF_normalOrderF_right] - rfl + simpa using normalOrder_normalOrder_mid a b (1 : 𝓕.WickAlgebra) lemma normalOrder_normalOrder (a : 𝓕.WickAlgebra) : 𝓝(𝓝(a)) = 𝓝(a) := by trans 𝓝(𝓝(a) * 1) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 27d02f823..7a84d3dc8 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -475,7 +475,7 @@ lemma timeOrder_ofFieldOpList_nil : 𝓣(ofFieldOpList (𝓕 := 𝓕) []) = 1 := @[simp] lemma timeOrder_ofFieldOpList_singleton (φ : 𝓕.FieldOp) : 𝓣(ofFieldOpList [φ]) = ofFieldOpList [φ] := by - rw [ofFieldOpList, timeOrder_eq_ι_timeOrderF, timeOrderF_ofFieldOpListF_singleton] + simp [ofFieldOpList, timeOrder_eq_ι_timeOrderF, timeOrderF_ofFieldOpListF_singleton] /-- For a field specification `𝓕`, the time order operator acting on a list of `𝓕.FieldOp`, `𝓣(φ₀…φₙ)`, is equal to From b2657f77948d181aadf15c7dd5db8688e575362a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:01:45 -0700 Subject: [PATCH 179/498] refactor: golf order projection proofs Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/NormalOrder.lean | 10 ++-------- .../FieldOpFreeAlgebra/TimeOrder.lean | 10 ++-------- .../WickAlgebra/NormalOrder/Lemmas.lean | 5 +---- .../PerturbationTheory/WickAlgebra/TimeOrder.lean | 15 +++------------ 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean index 3cb794dd1..f7c0ba5b8 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean @@ -115,17 +115,11 @@ lemma normalOrderF_normalOrderF_mid (a b c : 𝓕.FieldOpFreeAlgebra) : lemma normalOrderF_normalOrderF_right (a b : 𝓕.FieldOpFreeAlgebra) : 𝓝ᶠ(a * b) = 𝓝ᶠ(a * 𝓝ᶠ(b)) := by - trans 𝓝ᶠ(a * b * 1) - · simp - · rw [normalOrderF_normalOrderF_mid] - simp + simpa using normalOrderF_normalOrderF_mid a b (1 : 𝓕.FieldOpFreeAlgebra) lemma normalOrderF_normalOrderF_left (a b : 𝓕.FieldOpFreeAlgebra) : 𝓝ᶠ(a * b) = 𝓝ᶠ(𝓝ᶠ(a) * b) := by - trans 𝓝ᶠ(1 * a * b) - · simp - · rw [normalOrderF_normalOrderF_mid] - simp + simpa using normalOrderF_normalOrderF_mid (1 : 𝓕.FieldOpFreeAlgebra) a b /-! diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean index 1a2430219..ff992d504 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean @@ -105,16 +105,10 @@ lemma timeOrderF_timeOrderF_mid (a b c : 𝓕.FieldOpFreeAlgebra) : simp_all [pc] lemma timeOrderF_timeOrderF_right (a b : 𝓕.FieldOpFreeAlgebra) : 𝓣ᶠ(a * b) = 𝓣ᶠ(a * 𝓣ᶠ(b)) := by - trans 𝓣ᶠ(a * b * 1) - · simp - · rw [timeOrderF_timeOrderF_mid] - simp + simpa using timeOrderF_timeOrderF_mid a b (1 : 𝓕.FieldOpFreeAlgebra) lemma timeOrderF_timeOrderF_left (a b : 𝓕.FieldOpFreeAlgebra) : 𝓣ᶠ(a * b) = 𝓣ᶠ(𝓣ᶠ(a) * b) := by - trans 𝓣ᶠ(1 * a * b) - · simp - · rw [timeOrderF_timeOrderF_mid] - simp + simpa using timeOrderF_timeOrderF_mid (1 : 𝓕.FieldOpFreeAlgebra) a b lemma timeOrderF_ofFieldOpListF (φs : List 𝓕.FieldOp) : 𝓣ᶠ(ofFieldOpListF φs) = timeOrderSign φs • ofFieldOpListF (timeOrderList φs) := by diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index 3d86f23ca..1cd0babf9 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -76,10 +76,7 @@ lemma normalOrder_normalOrder_right (a b : 𝓕.WickAlgebra) : simpa using normalOrder_normalOrder_mid a b (1 : 𝓕.WickAlgebra) lemma normalOrder_normalOrder (a : 𝓕.WickAlgebra) : 𝓝(𝓝(a)) = 𝓝(a) := by - trans 𝓝(𝓝(a) * 1) - · simp - · rw [← normalOrder_normalOrder_left] - simp + simpa using (normalOrder_normalOrder_left a (1 : 𝓕.WickAlgebra)).symm /-! diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 7a84d3dc8..4cca33b7a 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -556,25 +556,16 @@ lemma timeOrder_timeOrder_mid (a b c : 𝓕.WickAlgebra) : lemma timeOrder_timeOrder_left (b c : 𝓕.WickAlgebra) : 𝓣(b * c) = 𝓣(𝓣(b) * c) := by - trans 𝓣(1 * b * c) - simp only [one_mul] - rw [timeOrder_timeOrder_mid] - simp + simpa using timeOrder_timeOrder_mid (1 : 𝓕.WickAlgebra) b c lemma timeOrder_timeOrder_right (a b : 𝓕.WickAlgebra) : 𝓣(a * b) = 𝓣(a * 𝓣(b)) := by - trans 𝓣(a * b * 1) - simp only [mul_one] - rw [timeOrder_timeOrder_mid] - simp + simpa using timeOrder_timeOrder_mid a b (1 : 𝓕.WickAlgebra) /-- Time ordering is a projection. -/ lemma timeOrder_timeOrder (a : 𝓕.WickAlgebra) : 𝓣(𝓣(a)) = 𝓣(a) := by - trans 𝓣(𝓣(a) * 1) - · simp - · rw [← timeOrder_timeOrder_left] - simp + simpa using (timeOrder_timeOrder_left a (1 : 𝓕.WickAlgebra)).symm end WickAlgebra end FieldSpecification From 4045621e746f94b4401f524541638828a123e6bf Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:05:13 -0700 Subject: [PATCH 180/498] refactor: golf super commute wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/SuperCommute.lean | 28 ++++++------------- .../WickAlgebra/TimeContraction.lean | 5 +--- .../WickContraction/TimeCond.lean | 6 ++-- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 2c26bca6b..01b312f00 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -362,60 +362,50 @@ lemma ofCrAnList_mul_ofCrAnList_eq_superCommute (φs φs' : List 𝓕.CrAnFieldO ofCrAnList φs * ofCrAnList φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofCrAnList φs' * ofCrAnList φs + [ofCrAnList φs, ofCrAnList φs']ₛ := by - rw [superCommute_ofCrAnList_ofCrAnList] - simp [ofCrAnList_append] + simp [superCommute_ofCrAnList_ofCrAnList, ofCrAnList_append] lemma ofCrAnOp_mul_ofCrAnList_eq_superCommute (φ : 𝓕.CrAnFieldOp) (φs' : List 𝓕.CrAnFieldOp) : ofCrAnOp φ * ofCrAnList φs' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs') • ofCrAnList φs' * ofCrAnOp φ + [ofCrAnOp φ, ofCrAnList φs']ₛ := by - rw [← ofCrAnList_singleton, ofCrAnList_mul_ofCrAnList_eq_superCommute] - simp + simpa [ofCrAnList_singleton] using ofCrAnList_mul_ofCrAnList_eq_superCommute [φ] φs' lemma ofFieldOpList_mul_ofFieldOpList_eq_superCommute (φs φs' : List 𝓕.FieldOp) : ofFieldOpList φs * ofFieldOpList φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofFieldOpList φs' * ofFieldOpList φs + [ofFieldOpList φs, ofFieldOpList φs']ₛ := by - rw [superCommute_ofFieldOpList_ofFieldOpList] - simp + simp [superCommute_ofFieldOpList_ofFieldOpList] lemma ofFieldOp_mul_ofFieldOpList_eq_superCommute (φ : 𝓕.FieldOp) (φs' : List 𝓕.FieldOp) : ofFieldOp φ * ofFieldOpList φs' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs') • ofFieldOpList φs' * ofFieldOp φ + [ofFieldOp φ, ofFieldOpList φs']ₛ := by - rw [superCommute_ofFieldOp_ofFieldOpList] - simp + simpa [ofFieldOpList_singleton] using ofFieldOpList_mul_ofFieldOpList_eq_superCommute [φ] φs' lemma ofFieldOp_mul_ofFieldOp_eq_superCommute (φ φ' : 𝓕.FieldOp) : ofFieldOp φ * ofFieldOp φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • ofFieldOp φ' * ofFieldOp φ + [ofFieldOp φ, ofFieldOp φ']ₛ := by - rw [← ofFieldOpList_singleton, ← ofFieldOpList_singleton] - rw [ofFieldOpList_mul_ofFieldOpList_eq_superCommute, ofFieldOpList_singleton] - simp + simpa [ofFieldOpList_singleton] using ofFieldOpList_mul_ofFieldOpList_eq_superCommute [φ] [φ'] lemma ofFieldOpList_mul_ofFieldOp_eq_superCommute (φs : List 𝓕.FieldOp) (φ : 𝓕.FieldOp) : ofFieldOpList φs * ofFieldOp φ = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φ) • ofFieldOp φ * ofFieldOpList φs + [ofFieldOpList φs, ofFieldOp φ]ₛ := by - rw [superCommute_ofFieldOpList_ofFieldOp] - simp + simpa [ofFieldOpList_singleton] using ofFieldOpList_mul_ofFieldOpList_eq_superCommute φs [φ] lemma ofCrAnList_mul_ofFieldOpList_eq_superCommute (φs : List 𝓕.CrAnFieldOp) (φs' : List 𝓕.FieldOp) : ofCrAnList φs * ofFieldOpList φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofFieldOpList φs' * ofCrAnList φs + [ofCrAnList φs, ofFieldOpList φs']ₛ := by - rw [superCommute_ofCrAnList_ofFieldOpList] - simp + simp [superCommute_ofCrAnList_ofFieldOpList] lemma crPart_mul_anPart_eq_superCommute (φ φ' : 𝓕.FieldOp) : crPart φ * anPart φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • anPart φ' * crPart φ + [crPart φ, anPart φ']ₛ := by - rw [superCommute_crPart_anPart] - simp + simp [superCommute_crPart_anPart] lemma anPart_mul_crPart_eq_superCommute (φ φ' : 𝓕.FieldOp) : anPart φ * crPart φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPart φ' * anPart φ + [anPart φ, crPart φ']ₛ := by - rw [superCommute_anPart_crPart] - simp + simp [superCommute_anPart_crPart] lemma crPart_mul_crPart_swap (φ φ' : 𝓕.FieldOp) : crPart φ * crPart φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPart φ' * crPart φ := by diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean index f5bf701c0..3a119ef29 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean @@ -147,10 +147,7 @@ lemma timeOrder_timeContract_eq_time_mid {φ ψ : 𝓕.FieldOp} lemma timeOrder_timeContract_eq_time_left {φ ψ : 𝓕.FieldOp} (h1 : timeOrderRel φ ψ) (h2 : timeOrderRel ψ φ) (b : 𝓕.WickAlgebra) : 𝓣(timeContract φ ψ * b) = timeContract φ ψ * 𝓣(b) := by - trans 𝓣(1 * timeContract φ ψ * b) - simp only [one_mul] - rw [timeOrder_timeContract_eq_time_mid h1 h2] - simp + simpa using timeOrder_timeContract_eq_time_mid h1 h2 (1 : 𝓕.WickAlgebra) b lemma timeOrder_timeContract_ne_time {φ ψ : 𝓕.FieldOp} (h1 : ¬ (timeOrderRel φ ψ ∧ timeOrderRel ψ φ)) : diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean index 12c3ca4f0..5494d8320 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean @@ -205,10 +205,8 @@ lemma timeOrder_timeContract_mul_of_eqTimeOnly_left {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) (hl : φsΛ.EqTimeOnly) (b : 𝓕.WickAlgebra) : 𝓣(φsΛ.timeContract.1 * b) = φsΛ.timeContract.1 * 𝓣(b) := by - trans 𝓣(1 * φsΛ.timeContract.1 * b) - simp only [one_mul] - rw [timeOrder_timeContract_mul_of_eqTimeOnly_mid φsΛ hl] - simp + simpa using + timeOrder_timeContract_mul_of_eqTimeOnly_mid φsΛ hl (1 : 𝓕.WickAlgebra) b set_option maxHeartbeats 400000 in lemma exists_join_singleton_of_not_eqTimeOnly {φs : List 𝓕.FieldOp} From 3deaaf5716362e0598b041cfd787b78c8831f255 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:07:46 -0700 Subject: [PATCH 181/498] refactor: golf normal order specialization proofs Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/NormalOrder.lean | 22 +++++++------------ .../WickAlgebra/NormalOrder/Basic.lean | 14 +++++------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean index f7c0ba5b8..df0cc243e 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean @@ -342,38 +342,32 @@ lemma normalOrderF_crPartF_mul_crPartF (φ φ' : 𝓕.FieldOp) : 𝓝ᶠ(crPartF φ * crPartF φ') = crPartF φ * crPartF φ' := by rw [normalOrderF_crPartF_mul] - conv_lhs => rw [← mul_one (crPartF φ')] - rw [normalOrderF_crPartF_mul, normalOrderF_one] - simp + simpa [normalOrderF_one] using congrArg (fun x => crPartF φ * x) + (normalOrderF_crPartF_mul φ' (1 : 𝓕.FieldOpFreeAlgebra)) @[simp] lemma normalOrderF_anPartF_mul_anPartF (φ φ' : 𝓕.FieldOp) : 𝓝ᶠ(anPartF φ * anPartF φ') = anPartF φ * anPartF φ' := by rw [normalOrderF_mul_anPartF] - conv_lhs => rw [← one_mul (anPartF φ)] - rw [normalOrderF_mul_anPartF, normalOrderF_one] - simp + simpa [normalOrderF_one] using congrArg (fun x => x * anPartF φ') + (normalOrderF_mul_anPartF φ (1 : 𝓕.FieldOpFreeAlgebra)) @[simp] lemma normalOrderF_crPartF_mul_anPartF (φ φ' : 𝓕.FieldOp) : 𝓝ᶠ(crPartF φ * anPartF φ') = crPartF φ * anPartF φ' := by rw [normalOrderF_crPartF_mul] - conv_lhs => rw [← one_mul (anPartF φ')] - rw [normalOrderF_mul_anPartF, normalOrderF_one] - simp + simpa [normalOrderF_one] using congrArg (fun x => crPartF φ * x) + (normalOrderF_mul_anPartF φ' (1 : 𝓕.FieldOpFreeAlgebra)) @[simp] lemma normalOrderF_anPartF_mul_crPartF (φ φ' : 𝓕.FieldOp) : 𝓝ᶠ(anPartF φ * crPartF φ') = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • (crPartF φ' * anPartF φ) := by - conv_lhs => rw [← one_mul (anPartF φ * crPartF φ')] - conv_lhs => rw [← mul_one (1 * (anPartF φ * - crPartF φ'))] - rw [← mul_assoc, normalOrderF_swap_anPartF_crPartF] - simp + simpa using normalOrderF_swap_anPartF_crPartF φ φ' + (1 : 𝓕.FieldOpFreeAlgebra) (1 : 𝓕.FieldOpFreeAlgebra) lemma normalOrderF_ofFieldOpF_mul_ofFieldOpF (φ φ' : 𝓕.FieldOp) : 𝓝ᶠ(ofFieldOpF φ * ofFieldOpF φ') = diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean index 81412c81b..9634831a6 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean @@ -156,26 +156,22 @@ lemma ι_normalOrderF_superCommuteF_eq_zero_mul @[simp] lemma ι_normalOrder_superCommuteF_eq_zero_mul_right (b c d : 𝓕.FieldOpFreeAlgebra) : ι 𝓝ᶠ([d, c]ₛF * b) = 0 := by - rw [← ι_normalOrderF_superCommuteF_eq_zero_mul 1 b c d] - simp + simpa using ι_normalOrderF_superCommuteF_eq_zero_mul (1 : 𝓕.FieldOpFreeAlgebra) b c d @[simp] lemma ι_normalOrderF_superCommuteF_eq_zero_mul_left (a c d : 𝓕.FieldOpFreeAlgebra) : ι 𝓝ᶠ(a * [d, c]ₛF) = 0 := by - rw [← ι_normalOrderF_superCommuteF_eq_zero_mul a 1 c d] - simp + simpa using ι_normalOrderF_superCommuteF_eq_zero_mul a (1 : 𝓕.FieldOpFreeAlgebra) c d @[simp] lemma ι_normalOrderF_superCommuteF_eq_zero_mul_mul_right (a b1 b2 c d: 𝓕.FieldOpFreeAlgebra) : ι 𝓝ᶠ(a * [d, c]ₛF * b1 * b2) = 0 := by - rw [← ι_normalOrderF_superCommuteF_eq_zero_mul a (b1 * b2) c d] - congr 2 - noncomm_ring + simpa [mul_assoc] using ι_normalOrderF_superCommuteF_eq_zero_mul a (b1 * b2) c d @[simp] lemma ι_normalOrderF_superCommuteF_eq_zero (c d : 𝓕.FieldOpFreeAlgebra) : ι 𝓝ᶠ([d, c]ₛF) = 0 := by - rw [← ι_normalOrderF_superCommuteF_eq_zero_mul 1 1 c d] - simp + simpa using ι_normalOrderF_superCommuteF_eq_zero_mul + (1 : 𝓕.FieldOpFreeAlgebra) (1 : 𝓕.FieldOpFreeAlgebra) c d /-! From 43537717600c5ac701182b876fcc249660cd18e0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:11:16 -0700 Subject: [PATCH 182/498] refactor: golf super commute transport proofs Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/SuperCommute.lean | 77 ++++++++----------- 1 file changed, 30 insertions(+), 47 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 01b312f00..210cd6206 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -182,15 +182,13 @@ lemma superCommute_anPart_ofFieldOpF_diff_grade_zero (φ ψ : 𝓕.FieldOp) lemma superCommute_ofCrAnOp_ofCrAnOp_mem_center (φ φ' : 𝓕.CrAnFieldOp) : [ofCrAnOp φ, ofCrAnOp φ']ₛ ∈ Subalgebra.center ℂ (WickAlgebra 𝓕) := by - rw [ofCrAnOp, ofCrAnOp, superCommute_eq_ι_superCommuteF] - exact ι_superCommuteF_ofCrAnOpF_ofCrAnOpF_mem_center φ φ' + simpa [ofCrAnOp, superCommute_eq_ι_superCommuteF] using + ι_superCommuteF_ofCrAnOpF_ofCrAnOpF_mem_center φ φ' lemma superCommute_ofCrAnOp_ofCrAnOp_commute (φ φ' : 𝓕.CrAnFieldOp) (a : WickAlgebra 𝓕) : a * [ofCrAnOp φ, ofCrAnOp φ']ₛ = [ofCrAnOp φ, ofCrAnOp φ']ₛ * a := by - have h1 := superCommute_ofCrAnOp_ofCrAnOp_mem_center φ φ' - rw [@Subalgebra.mem_center_iff] at h1 - exact h1 a + exact (Subalgebra.mem_center_iff.mp (superCommute_ofCrAnOp_ofCrAnOp_mem_center φ φ')) a lemma superCommute_ofCrAnOp_ofFieldOp_mem_center (φ : 𝓕.CrAnFieldOp) (φ' : 𝓕.FieldOp) : [ofCrAnOp φ, ofFieldOp φ']ₛ ∈ Subalgebra.center ℂ (WickAlgebra 𝓕) := by @@ -203,9 +201,7 @@ lemma superCommute_ofCrAnOp_ofFieldOp_mem_center (φ : 𝓕.CrAnFieldOp) (φ' : lemma superCommute_ofCrAnOp_ofFieldOp_commute (φ : 𝓕.CrAnFieldOp) (φ' : 𝓕.FieldOp) (a : WickAlgebra 𝓕) : a * [ofCrAnOp φ, ofFieldOp φ']ₛ = [ofCrAnOp φ, ofFieldOp φ']ₛ * a := by - have h1 := superCommute_ofCrAnOp_ofFieldOp_mem_center φ φ' - rw [@Subalgebra.mem_center_iff] at h1 - exact h1 a + exact (Subalgebra.mem_center_iff.mp (superCommute_ofCrAnOp_ofFieldOp_mem_center φ φ')) a lemma superCommute_anPart_ofFieldOp_mem_center (φ φ' : 𝓕.FieldOp) : [anPart φ, ofFieldOp φ']ₛ ∈ Subalgebra.center ℂ (WickAlgebra 𝓕) := by @@ -227,59 +223,51 @@ lemma superCommute_anPart_ofFieldOp_mem_center (φ φ' : 𝓕.FieldOp) : lemma superCommute_ofCrAnList_ofCrAnList (φs φs' : List 𝓕.CrAnFieldOp) : [ofCrAnList φs, ofCrAnList φs']ₛ = ofCrAnList (φs ++ φs') - 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofCrAnList (φs' ++ φs) := by - rw [ofCrAnList_eq_ι_ofCrAnListF, ofCrAnList_eq_ι_ofCrAnListF] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_ofCrAnListF_ofCrAnListF] - rfl + simp [ofCrAnList_eq_ι_ofCrAnListF, superCommute_eq_ι_superCommuteF, + superCommuteF_ofCrAnListF_ofCrAnListF] lemma superCommute_ofCrAnOp_ofCrAnOp (φ φ' : 𝓕.CrAnFieldOp) : [ofCrAnOp φ, ofCrAnOp φ']ₛ = ofCrAnOp φ * ofCrAnOp φ' - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • ofCrAnOp φ' * ofCrAnOp φ := by - rw [ofCrAnOp, ofCrAnOp] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_ofCrAnOpF_ofCrAnOpF] - rfl + simp [ofCrAnOp, superCommute_eq_ι_superCommuteF, + superCommuteF_ofCrAnOpF_ofCrAnOpF] lemma superCommute_ofCrAnList_ofFieldOpList (φcas : List 𝓕.CrAnFieldOp) (φs : List 𝓕.FieldOp) : [ofCrAnList φcas, ofFieldOpList φs]ₛ = ofCrAnList φcas * ofFieldOpList φs - 𝓢(𝓕 |>ₛ φcas, 𝓕 |>ₛ φs) • ofFieldOpList φs * ofCrAnList φcas := by - rw [ofCrAnList, ofFieldOpList] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_ofCrAnListF_ofFieldOpFsList] - rfl + simp [ofCrAnList, ofFieldOpList, superCommute_eq_ι_superCommuteF, + superCommuteF_ofCrAnListF_ofFieldOpFsList] lemma superCommute_ofFieldOpList_ofFieldOpList (φs φs' : List 𝓕.FieldOp) : [ofFieldOpList φs, ofFieldOpList φs']ₛ = ofFieldOpList φs * ofFieldOpList φs' - 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofFieldOpList φs' * ofFieldOpList φs := by - rw [ofFieldOpList, ofFieldOpList] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_ofFieldOpListF_ofFieldOpFsList] - rfl + simp [ofFieldOpList, superCommute_eq_ι_superCommuteF, + superCommuteF_ofFieldOpListF_ofFieldOpFsList] lemma superCommute_ofFieldOp_ofFieldOpList (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : [ofFieldOp φ, ofFieldOpList φs]ₛ = ofFieldOp φ * ofFieldOpList φs - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs) • ofFieldOpList φs * ofFieldOp φ := by - rw [ofFieldOp, ofFieldOpList] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_ofFieldOpF_ofFieldOpFsList] - rfl + simpa [ofFieldOpList_singleton] using + superCommute_ofFieldOpList_ofFieldOpList (𝓕 := 𝓕) [φ] φs lemma superCommute_ofFieldOpList_ofFieldOp (φs : List 𝓕.FieldOp) (φ : 𝓕.FieldOp) : [ofFieldOpList φs, ofFieldOp φ]ₛ = ofFieldOpList φs * ofFieldOp φ - 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φ) • ofFieldOp φ * ofFieldOpList φs := by - rw [ofFieldOpList, ofFieldOp] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_ofFieldOpListF_ofFieldOpF] - rfl + simpa [ofFieldOpList_singleton] using + superCommute_ofFieldOpList_ofFieldOpList (𝓕 := 𝓕) φs [φ] lemma superCommute_anPart_crPart (φ φ' : 𝓕.FieldOp) : [anPart φ, crPart φ']ₛ = anPart φ * crPart φ' - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPart φ' * anPart φ := by - rw [anPart, crPart] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_anPartF_crPartF] - rfl + simp [anPart, crPart, superCommute_eq_ι_superCommuteF, + superCommuteF_anPartF_crPartF] lemma superCommute_crPart_anPart (φ φ' : 𝓕.FieldOp) : [crPart φ, anPart φ']ₛ = crPart φ * anPart φ' - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • anPart φ' * crPart φ := by - rw [anPart, crPart] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_crPartF_anPartF] - rfl + simp [anPart, crPart, superCommute_eq_ι_superCommuteF, + superCommuteF_crPartF_anPartF] @[simp] lemma superCommute_crPart_crPart (φ φ' : 𝓕.FieldOp) : [crPart φ, crPart φ']ₛ = 0 := by @@ -324,30 +312,26 @@ lemma superCommute_anPart_anPart (φ φ' : 𝓕.FieldOp) : [anPart φ, anPart φ lemma superCommute_crPart_ofFieldOpList (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : [crPart φ, ofFieldOpList φs]ₛ = crPart φ * ofFieldOpList φs - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs) • ofFieldOpList φs * crPart φ := by - rw [crPart, ofFieldOpList] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_crPartF_ofFieldOpListF] - rfl + simp [crPart, ofFieldOpList, superCommute_eq_ι_superCommuteF, + superCommuteF_crPartF_ofFieldOpListF] lemma superCommute_anPart_ofFieldOpList (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : [anPart φ, ofFieldOpList φs]ₛ = anPart φ * ofFieldOpList φs - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs) • ofFieldOpList φs * anPart φ := by - rw [anPart, ofFieldOpList] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_anPartF_ofFieldOpListF] - rfl + simp [anPart, ofFieldOpList, superCommute_eq_ι_superCommuteF, + superCommuteF_anPartF_ofFieldOpListF] lemma superCommute_crPart_ofFieldOp (φ φ' : 𝓕.FieldOp) : [crPart φ, ofFieldOp φ']ₛ = crPart φ * ofFieldOp φ' - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • ofFieldOp φ' * crPart φ := by - rw [crPart, ofFieldOp] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_crPartF_ofFieldOpF] - rfl + simp [crPart, ofFieldOp, superCommute_eq_ι_superCommuteF, + superCommuteF_crPartF_ofFieldOpF] lemma superCommute_anPart_ofFieldOp (φ φ' : 𝓕.FieldOp) : [anPart φ, ofFieldOp φ']ₛ = anPart φ * ofFieldOp φ' - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • ofFieldOp φ' * anPart φ := by - rw [anPart, ofFieldOp] - rw [superCommute_eq_ι_superCommuteF, superCommuteF_anPartF_ofFieldOpF] - rfl + simp [anPart, ofFieldOp, superCommute_eq_ι_superCommuteF, + superCommuteF_anPartF_ofFieldOpF] /-! @@ -437,9 +421,8 @@ lemma superCommute_ofCrAnList_ofCrAnList_symm (φs φs' : List 𝓕.CrAnFieldOp) lemma superCommute_ofCrAnOp_ofCrAnOp_symm (φ φ' : 𝓕.CrAnFieldOp) : [ofCrAnOp φ, ofCrAnOp φ']ₛ = (- 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ')) • [ofCrAnOp φ', ofCrAnOp φ]ₛ := by - rw [ofCrAnOp, ofCrAnOp, superCommute_eq_ι_superCommuteF, - superCommuteF_ofCrAnOpF_ofCrAnOpF_symm] - rfl + simpa [ofCrAnList_singleton] using + superCommute_ofCrAnList_ofCrAnList_symm (𝓕 := 𝓕) [φ] [φ'] /-! From fbe519e40765d83c8915485428b1a68c00bd1341 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:14:42 -0700 Subject: [PATCH 183/498] refactor: golf tensor unit symmetry proofs Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/NormalOrder/Lemmas.lean | 5 ++--- .../Tensors/ComplexTensor/Units/Pre.lean | 10 ++++------ .../Tensors/ComplexTensor/Weyl/Unit.lean | 20 ++++++++----------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index 1cd0babf9..d8c45ac56 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -422,9 +422,8 @@ lemma normalOrder_anPart_mul_crPart (φ φ' : 𝓕.FieldOp) : lemma normalOrder_ofFieldOp_mul_ofFieldOp (φ φ' : 𝓕.FieldOp) : 𝓝(ofFieldOp φ * ofFieldOp φ') = crPart φ * crPart φ' + 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • (crPart φ' * anPart φ) + crPart φ * anPart φ' + anPart φ * anPart φ' := by - rw [ofFieldOp, ofFieldOp, ← map_mul, normalOrder_eq_ι_normalOrderF, - normalOrderF_ofFieldOpF_mul_ofFieldOpF] - rfl + rw [ofFieldOp, ofFieldOp, ← map_mul, normalOrder_eq_ι_normalOrderF] + simp [normalOrderF_ofFieldOpF_mul_ofFieldOpF, crPart, anPart] end WickAlgebra end FieldSpecification diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean index b766a96ff..ff2cdb12c 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean @@ -168,16 +168,14 @@ open CategoryTheory lemma contrCoUnit_symm : contrCoUnit (1 : ℂ) = LinearMap.lTensor _ (LinearEquiv.refl _ _).toLinearMap (TensorProduct.comm ℂ _ _ (coContrUnit (1 : ℂ))) := by - rw [contrCoUnit_apply_one, contrCoUnitVal_expand_tmul] - rw [coContrUnit_apply_one, coContrUnitVal_expand_tmul] - rfl + simp [contrCoUnit_apply_one, contrCoUnitVal_expand_tmul, + coContrUnit_apply_one, coContrUnitVal_expand_tmul] lemma coContrUnit_symm : (coContrUnit (1 : ℂ)) = LinearMap.lTensor _ (LinearEquiv.refl _ _).toLinearMap (TensorProduct.comm ℂ _ _ (contrCoUnit (1 : ℂ))) := by - rw [coContrUnit_apply_one, coContrUnitVal_expand_tmul] - rw [contrCoUnit_apply_one, contrCoUnitVal_expand_tmul] - rfl + simp [coContrUnit_apply_one, coContrUnitVal_expand_tmul, + contrCoUnit_apply_one, contrCoUnitVal_expand_tmul] end Lorentz end diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean index 244f4e7d2..87d7c225b 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean @@ -259,30 +259,26 @@ open CategoryTheory lemma dualLeftLeftUnit_symm : dualLeftLeftUnit (1 : ℂ) = LinearMap.lTensor _ (LinearEquiv.refl _ _).toLinearMap (TensorProduct.comm ℂ _ _ (leftDualLeftUnit (1 : ℂ))) := by - rw [dualLeftLeftUnit_apply_one, dualLeftLeftUnitVal_expand_tmul] - rw [leftDualLeftUnit_apply_one, leftDualLeftUnitVal_expand_tmul] - rfl + simp [dualLeftLeftUnit_apply_one, dualLeftLeftUnitVal_expand_tmul, + leftDualLeftUnit_apply_one, leftDualLeftUnitVal_expand_tmul] lemma leftDualLeftUnit_symm : leftDualLeftUnit (1 : ℂ) = LinearMap.lTensor _ (LinearEquiv.refl _ _).toLinearMap (TensorProduct.comm ℂ _ _ (dualLeftLeftUnit (1 : ℂ))) := by - rw [dualLeftLeftUnit_apply_one, dualLeftLeftUnitVal_expand_tmul] - rw [leftDualLeftUnit_apply_one, leftDualLeftUnitVal_expand_tmul] - rfl + simp [dualLeftLeftUnit_apply_one, dualLeftLeftUnitVal_expand_tmul, + leftDualLeftUnit_apply_one, leftDualLeftUnitVal_expand_tmul] lemma dualRightRightUnit_symm : dualRightRightUnit (1 : ℂ) = LinearMap.lTensor _ (LinearEquiv.refl _ _).toLinearMap (TensorProduct.comm ℂ _ _ (rightDualRightUnit (1 : ℂ))) := by - rw [dualRightRightUnit_apply_one, dualRightRightUnitVal_expand_tmul] - rw [rightDualRightUnit_apply_one, rightDualRightUnitVal_expand_tmul] - rfl + simp [dualRightRightUnit_apply_one, dualRightRightUnitVal_expand_tmul, + rightDualRightUnit_apply_one, rightDualRightUnitVal_expand_tmul] lemma rightDualRightUnit_symm : rightDualRightUnit (1 : ℂ) = LinearMap.lTensor _ (LinearEquiv.refl _ _).toLinearMap (TensorProduct.comm ℂ _ _ (dualRightRightUnit (1 : ℂ))) := by - rw [dualRightRightUnit_apply_one, dualRightRightUnitVal_expand_tmul] - rw [rightDualRightUnit_apply_one, rightDualRightUnitVal_expand_tmul] - rfl + simp [dualRightRightUnit_apply_one, dualRightRightUnitVal_expand_tmul, + rightDualRightUnit_apply_one, rightDualRightUnitVal_expand_tmul] end end Fermion From 727d2d6ad839edaad176eaabaa51970461ddce02 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:17:18 -0700 Subject: [PATCH 184/498] refactor: golf free algebra super commute wrappers Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/SuperCommute.lean | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 2d65a8d2b..0230893f4 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -244,15 +244,13 @@ lemma superCommuteF_crPartF_ofFieldOpF (φ φ' : 𝓕.FieldOp) : [crPartF φ, ofFieldOpF φ']ₛF = crPartF φ * ofFieldOpF φ' - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • ofFieldOpF φ' * crPartF φ := by - rw [← ofFieldOpListF_singleton, superCommuteF_crPartF_ofFieldOpListF] - simp + simpa [ofFieldOpListF_singleton] using superCommuteF_crPartF_ofFieldOpListF φ [φ'] lemma superCommuteF_anPartF_ofFieldOpF (φ φ' : 𝓕.FieldOp) : [anPartF φ, ofFieldOpF φ']ₛF = anPartF φ * ofFieldOpF φ' - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • ofFieldOpF φ' * anPartF φ := by - rw [← ofFieldOpListF_singleton, superCommuteF_anPartF_ofFieldOpListF] - simp + simpa [ofFieldOpListF_singleton] using superCommuteF_anPartF_ofFieldOpListF φ [φ'] /-! @@ -265,68 +263,61 @@ multiplication with a sign plus the super commutator. lemma ofCrAnListF_mul_ofCrAnListF_eq_superCommuteF (φs φs' : List 𝓕.CrAnFieldOp) : ofCrAnListF φs * ofCrAnListF φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofCrAnListF φs' * ofCrAnListF φs + [ofCrAnListF φs, ofCrAnListF φs']ₛF := by - rw [superCommuteF_ofCrAnListF_ofCrAnListF] - simp [ofCrAnListF_append] + simp [superCommuteF_ofCrAnListF_ofCrAnListF, ofCrAnListF_append] lemma ofCrAnOpF_mul_ofCrAnListF_eq_superCommuteF (φ : 𝓕.CrAnFieldOp) (φs' : List 𝓕.CrAnFieldOp) : ofCrAnOpF φ * ofCrAnListF φs' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs') • ofCrAnListF φs' * ofCrAnOpF φ + [ofCrAnOpF φ, ofCrAnListF φs']ₛF := by - rw [← ofCrAnListF_singleton, ofCrAnListF_mul_ofCrAnListF_eq_superCommuteF] - simp + simpa [ofCrAnListF_singleton] using + ofCrAnListF_mul_ofCrAnListF_eq_superCommuteF [φ] φs' lemma ofFieldOpListF_mul_ofFieldOpListF_eq_superCommuteF (φs φs' : List 𝓕.FieldOp) : ofFieldOpListF φs * ofFieldOpListF φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofFieldOpListF φs' * ofFieldOpListF φs + [ofFieldOpListF φs, ofFieldOpListF φs']ₛF := by - rw [superCommuteF_ofFieldOpListF_ofFieldOpFsList] - simp + simp [superCommuteF_ofFieldOpListF_ofFieldOpFsList] lemma ofFieldOpF_mul_ofFieldOpListF_eq_superCommuteF (φ : 𝓕.FieldOp) (φs' : List 𝓕.FieldOp) : ofFieldOpF φ * ofFieldOpListF φs' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs') • ofFieldOpListF φs' * ofFieldOpF φ + [ofFieldOpF φ, ofFieldOpListF φs']ₛF := by - rw [superCommuteF_ofFieldOpF_ofFieldOpFsList] - simp + simpa [ofFieldOpListF_singleton] using + ofFieldOpListF_mul_ofFieldOpListF_eq_superCommuteF [φ] φs' lemma ofFieldOpListF_mul_ofFieldOpF_eq_superCommuteF (φs : List 𝓕.FieldOp) (φ : 𝓕.FieldOp) : ofFieldOpListF φs * ofFieldOpF φ = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φ) • ofFieldOpF φ * ofFieldOpListF φs + [ofFieldOpListF φs, ofFieldOpF φ]ₛF := by - rw [superCommuteF_ofFieldOpListF_ofFieldOpF] - simp + simpa [ofFieldOpListF_singleton] using + ofFieldOpListF_mul_ofFieldOpListF_eq_superCommuteF φs [φ] lemma crPartF_mul_anPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : crPartF φ * anPartF φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • anPartF φ' * crPartF φ + [crPartF φ, anPartF φ']ₛF := by - rw [superCommuteF_crPartF_anPartF] - simp + simp [superCommuteF_crPartF_anPartF] lemma anPartF_mul_crPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : anPartF φ * crPartF φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPartF φ' * anPartF φ + [anPartF φ, crPartF φ']ₛF := by - rw [superCommuteF_anPartF_crPartF] - simp + simp [superCommuteF_anPartF_crPartF] lemma crPartF_mul_crPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : crPartF φ * crPartF φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPartF φ' * crPartF φ + [crPartF φ, crPartF φ']ₛF := by - rw [superCommuteF_crPartF_crPartF] - simp + simp [superCommuteF_crPartF_crPartF] lemma anPartF_mul_anPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : anPartF φ * anPartF φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • anPartF φ' * anPartF φ + [anPartF φ, anPartF φ']ₛF := by - rw [superCommuteF_anPartF_anPartF] - simp + simp [superCommuteF_anPartF_anPartF] lemma ofCrAnListF_mul_ofFieldOpListF_eq_superCommuteF (φs : List 𝓕.CrAnFieldOp) (φs' : List 𝓕.FieldOp) : ofCrAnListF φs * ofFieldOpListF φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofFieldOpListF φs' * ofCrAnListF φs + [ofCrAnListF φs, ofFieldOpListF φs']ₛF := by - rw [superCommuteF_ofCrAnListF_ofFieldOpFsList] - simp + simp [superCommuteF_ofCrAnListF_ofFieldOpFsList] /-! From 3d6c651fd0845b7e61867d452371e2d94e40c321 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:19:11 -0700 Subject: [PATCH 185/498] refactor: golf free algebra super commute symmetry proofs Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/SuperCommute.lean | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 0230893f4..6728e7289 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -92,16 +92,14 @@ lemma superCommuteF_ofFieldOpListF_ofFieldOpFsList (φ : List 𝓕.FieldOp) (φs lemma superCommuteF_ofFieldOpF_ofFieldOpFsList (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : [ofFieldOpF φ, ofFieldOpListF φs]ₛF = ofFieldOpF φ * ofFieldOpListF φs - 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs) • ofFieldOpListF φs * ofFieldOpF φ := by - rw [← ofFieldOpListF_singleton, superCommuteF_ofFieldOpListF_ofFieldOpFsList, - ofFieldOpListF_singleton] - simp + simpa [ofFieldOpListF_singleton] using + superCommuteF_ofFieldOpListF_ofFieldOpFsList [φ] φs lemma superCommuteF_ofFieldOpListF_ofFieldOpF (φs : List 𝓕.FieldOp) (φ : 𝓕.FieldOp) : [ofFieldOpListF φs, ofFieldOpF φ]ₛF = ofFieldOpListF φs * ofFieldOpF φ - 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φ) • ofFieldOpF φ * ofFieldOpListF φs := by - rw [← ofFieldOpListF_singleton, superCommuteF_ofFieldOpListF_ofFieldOpFsList, - ofFieldOpListF_singleton] - simp + simpa [ofFieldOpListF_singleton] using + superCommuteF_ofFieldOpListF_ofFieldOpFsList φs [φ] lemma superCommuteF_anPartF_crPartF (φ φ' : 𝓕.FieldOp) : [anPartF φ, crPartF φ']ₛF = anPartF φ * crPartF φ' - @@ -655,14 +653,12 @@ lemma bosonic_superCommuteF {a b : 𝓕.FieldOpFreeAlgebra} (ha : a ∈ statisti lemma superCommuteF_bonsonic_symm {a b : 𝓕.FieldOpFreeAlgebra} (hb : b ∈ statisticSubmodule bosonic) : [a, b]ₛF = - [b, a]ₛF := by - rw [bosonic_superCommuteF hb, superCommuteF_bonsonic hb] - simp + simp [bosonic_superCommuteF hb, superCommuteF_bonsonic hb] lemma bonsonic_superCommuteF_symm {a b : 𝓕.FieldOpFreeAlgebra} (ha : a ∈ statisticSubmodule bosonic) : [a, b]ₛF = - [b, a]ₛF := by - rw [bosonic_superCommuteF ha, superCommuteF_bonsonic ha] - simp + simp [bosonic_superCommuteF ha, superCommuteF_bonsonic ha] lemma superCommuteF_fermionic_fermionic {a b : 𝓕.FieldOpFreeAlgebra} (ha : a ∈ statisticSubmodule fermionic) (hb : b ∈ statisticSubmodule fermionic) : @@ -700,8 +696,7 @@ lemma superCommuteF_fermionic_fermionic {a b : 𝓕.FieldOpFreeAlgebra} lemma superCommuteF_fermionic_fermionic_symm {a b : 𝓕.FieldOpFreeAlgebra} (ha : a ∈ statisticSubmodule fermionic) (hb : b ∈ statisticSubmodule fermionic) : [a, b]ₛF = [b, a]ₛF := by - rw [superCommuteF_fermionic_fermionic ha hb] - rw [superCommuteF_fermionic_fermionic hb ha] + rw [superCommuteF_fermionic_fermionic ha hb, superCommuteF_fermionic_fermionic hb ha] abel lemma superCommuteF_expand_bosonicProjF_fermionicProjF (a b : 𝓕.FieldOpFreeAlgebra) : From 688ca0864acfac0683cce58ff901771022f5fd82 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:22:24 -0700 Subject: [PATCH 186/498] refactor: golf Wick algebra wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean | 9 +++------ .../WickAlgebra/NormalOrder/Lemmas.lean | 4 +--- .../PerturbationTheory/WickAlgebra/TimeContraction.lean | 6 ++---- .../WickAlgebra/WicksTheoremNormal.lean | 4 ++-- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean index 5b015c681..b91e23ea7 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean @@ -479,18 +479,15 @@ That is, every field operator splits into its creation part plus its annihilatio -/ lemma ofFieldOp_eq_crPart_add_anPart (φ : 𝓕.FieldOp) : ofFieldOp φ = crPart φ + anPart φ := by - rw [ofFieldOp, crPart, anPart, ofFieldOpF_eq_crPartF_add_anPartF] - simp [map_add] + simp [ofFieldOp, crPart, anPart, ofFieldOpF_eq_crPartF_add_anPartF, map_add] lemma anPart_outAsymp_eq_ofFieldOp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : anPart (FieldOp.outAsymp φ) = ofFieldOp (FieldOp.outAsymp φ) := by - rw [ofFieldOp_eq_crPart_add_anPart] - simp + simp [ofFieldOp_eq_crPart_add_anPart] lemma crPart_inAsymp_eq_ofFieldOp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : crPart (FieldOp.inAsymp φ) = ofFieldOp (FieldOp.inAsymp φ) := by - rw [ofFieldOp_eq_crPart_add_anPart] - simp + simp [ofFieldOp_eq_crPart_add_anPart] end WickAlgebra end FieldSpecification diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index d8c45ac56..882971453 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -308,9 +308,7 @@ Within a proto-operator algebra we have that lemma anPart_mul_normalOrder_ofFieldOpList_eq_superCommute_reorder (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : anPart φ * 𝓝(ofFieldOpList φs) = 𝓝(anPart φ * ofFieldOpList φs) + [anPart φ, 𝓝(ofFieldOpList φs)]ₛ := by - rw [anPart_mul_normalOrder_ofFieldOpList_eq_superCommute] - simp only [add_left_inj] - rw [normalOrder_anPart_ofFieldOpList_swap] + rw [anPart_mul_normalOrder_ofFieldOpList_eq_superCommute, normalOrder_anPart_ofFieldOpList_swap] /-- Within a proto-operator algebra we have that diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean index 3a119ef29..27ff3a54d 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean @@ -196,8 +196,7 @@ lemma timeOrder_timeContract_ne_time {φ ψ : 𝓕.FieldOp} connected to incoming vertices. -/ lemma timeContract_inAsymp_inAsymp (φ ψ : ((f : Field 𝓕) × AsymptoticLabel 𝓕 f) × Momentum) : timeContract (.inAsymp φ) (.inAsymp ψ) = 0 := by - rw [timeContract_eq_superCommute] - simp + simp [timeContract_eq_superCommute] /-- The time contraction of an outgoing asymptotic field with another outgoing asymptotic field is zero. @@ -206,8 +205,7 @@ lemma timeContract_inAsymp_inAsymp (φ ψ : ((f : Field 𝓕) × AsymptoticLabel connected to outgoing vertices. -/ lemma timeContract_outAsymp_outAsymp (φ ψ : ((f : Field 𝓕) × AsymptoticLabel 𝓕 f) × Momentum) : timeContract (.outAsymp φ) (.outAsymp ψ) = 0 := by - rw [timeContract_eq_superCommute, ← anPart_outAsymp_eq_ofFieldOp, ← anPart_outAsymp_eq_ofFieldOp] - simp [- anPart_outAsymp] + simp [timeContract_eq_superCommute, ← anPart_outAsymp_eq_ofFieldOp, - anPart_outAsymp] end WickAlgebra diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean index 5d2dec371..59b29cf81 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean @@ -109,8 +109,8 @@ lemma normalOrder_timeOrder_ofFieldOpList_eq_eqTimeOnly_empty (φs : List 𝓕.F 𝓣(𝓝(ofFieldOpList φs)) = 𝓣(ofFieldOpList φs) - ∑ (φsΛ : {φsΛ // φsΛ.EqTimeOnly (φs := φs) ∧ φsΛ ≠ empty}), φsΛ.1.sign • φsΛ.1.timeContract.1 * 𝓣(𝓝(ofFieldOpList [φsΛ.1]ᵘᶜ)) := by - rw [timeOrder_ofFieldOpList_eq_eqTimeOnly_empty] - simp + simpa [eq_sub_iff_add_eq] using + (timeOrder_ofFieldOpList_eq_eqTimeOnly_empty (𝓕 := 𝓕) φs).symm /-- For a list `φs` of `𝓕.FieldOp`, then `𝓣(φs)` is equal to the sum of From 4b2c4c423ec6df8a9cf7a831a4fb41c073e0f283 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:25:39 -0700 Subject: [PATCH 187/498] refactor: golf empty contraction proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean | 3 +-- .../QFT/PerturbationTheory/WickContraction/Sign/Basic.lean | 3 +-- .../QFT/PerturbationTheory/WickContraction/TimeCond.lean | 6 ++---- .../PerturbationTheory/WickContraction/TimeContract.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean index 947fd32ec..137f7b358 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean @@ -41,8 +41,7 @@ def wickTerm {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) : @[simp] lemma wickTerm_empty_nil : wickTerm (empty (n := ([] : List 𝓕.FieldOp).length)) = 1 := by - rw [wickTerm] - simp [sign_empty] + simp [wickTerm, sign_empty] /-- For a list `φs = φ₀…φₙ` of `𝓕.FieldOp`, a Wick contraction `φsΛ` of `φs`, an element `φ` of diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean index c128c5c08..b082ba49d 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean @@ -52,8 +52,7 @@ def sign (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) : ℂ := lemma sign_empty (φs : List 𝓕.FieldOp) : sign φs empty = 1 := by - rw [sign] - simp [empty] + simp [sign, empty] lemma sign_congr {φs φs' : List 𝓕.FieldOp} (h : φs = φs') (φsΛ : WickContraction φs.length) : sign φs' (congr (by simp [h]) φsΛ) = sign φs φsΛ := by diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean index 5494d8320..d8950b581 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean @@ -95,8 +95,7 @@ lemma eqTimeOnly_iff_forall_finset {φs : List 𝓕.FieldOp} (φsΛ : WickContra @[simp] lemma empty_mem {φs : List 𝓕.FieldOp} : empty (n := φs.length).EqTimeOnly := by - rw [eqTimeOnly_iff_forall_finset] - simp [empty] + simp [eqTimeOnly_iff_forall_finset, empty] /-- Let `φs` be a list of `𝓕.FieldOp` and `φsΛ` a `WickContraction` of `φs` within which every contraction involves two `𝓕.FieldOp`s that have the same time, then @@ -312,8 +311,7 @@ lemma haveEqTime_iff_finset {φs : List 𝓕.FieldOp} (φsΛ : WickContraction @[simp] lemma empty_not_haveEqTime {φs : List 𝓕.FieldOp} : ¬ HaveEqTime (empty : WickContraction φs.length) := by - rw [haveEqTime_iff_finset] - simp [empty] + simp [haveEqTime_iff_finset, empty] /-- Given a Wick contraction the subset of contracted pairs between equal time fields. -/ def eqTimeContractSet {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) : diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean index ec014fd96..4dcc3a848 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean @@ -78,8 +78,7 @@ lemma timeContract_insertAndContract_some @[simp] lemma timeContract_empty (φs : List 𝓕.FieldOp) : (@empty φs.length).timeContract = 1 := by - rw [timeContract, empty] - simp + simp [timeContract, empty] open FieldStatistic From eea438cd3ec954c7bbca8210023cf51859d6b348 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:29:21 -0700 Subject: [PATCH 188/498] refactor: golf time contraction rewrite proofs Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean | 7 +++---- .../PerturbationTheory/WickAlgebra/TimeContraction.lean | 9 +++------ .../PerturbationTheory/WickContraction/Singleton.lean | 3 +-- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean index ff992d504..91ae0dd6f 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean @@ -150,8 +150,7 @@ lemma timeOrderF_ofFieldOpF_ofFieldOpF_not_ordered {φ ψ : 𝓕.FieldOp} (h : lemma timeOrderF_ofFieldOpF_ofFieldOpF_not_ordered_eq_timeOrderF {φ ψ : 𝓕.FieldOp} (h : ¬ timeOrderRel φ ψ) : 𝓣ᶠ(ofFieldOpF φ * ofFieldOpF ψ) = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ ψ) • 𝓣ᶠ(ofFieldOpF ψ * ofFieldOpF φ) := by - rw [timeOrderF_ofFieldOpF_ofFieldOpF_not_ordered h] - rw [timeOrderF_ofFieldOpF_ofFieldOpF_ordered] + rw [timeOrderF_ofFieldOpF_ofFieldOpF_not_ordered h, timeOrderF_ofFieldOpF_ofFieldOpF_ordered] simp only [Algebra.smul_mul_assoc] have hx := Std.Total.total (r := timeOrderRel) ψ φ simp_all @@ -310,8 +309,8 @@ lemma timeOrderF_eq_maxTimeField_mul (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldO 𝓣ᶠ(ofFieldOpListF (φ :: φs)) = 𝓢(𝓕 |>ₛ maxTimeField φ φs, 𝓕 |>ₛ (φ :: φs).take (maxTimeFieldPos φ φs)) • ofFieldOpF (maxTimeField φ φs) * 𝓣ᶠ(ofFieldOpListF (eraseMaxTimeField φ φs)) := by - rw [timeOrderF_ofFieldOpListF, timeOrderList_eq_maxTimeField_timeOrderList] - rw [ofFieldOpListF_cons, timeOrderF_ofFieldOpListF] + rw [timeOrderF_ofFieldOpListF, timeOrderList_eq_maxTimeField_timeOrderList, + ofFieldOpListF_cons, timeOrderF_ofFieldOpListF] simp only [Algebra.mul_smul_comm, Algebra.smul_mul_assoc, smul_smul] congr rw [timerOrderSign_of_eraseMaxTimeField, mul_assoc] diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean index 27ff3a54d..f789e8f50 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean @@ -54,10 +54,8 @@ lemma timeContract_of_timeOrderRel (φ ψ : 𝓕.FieldOp) (h : timeOrderRel φ lemma timeContract_of_not_timeOrderRel (φ ψ : 𝓕.FieldOp) (h : ¬ timeOrderRel φ ψ) : timeContract φ ψ = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ ψ) • timeContract ψ φ := by - rw [timeContract_eq_smul] - rw [normalOrder_ofFieldOp_ofFieldOp_swap] - rw [timeOrder_ofFieldOp_ofFieldOp_not_ordered_eq_timeOrder h] - rw [timeContract_eq_smul] + rw [timeContract_eq_smul, normalOrder_ofFieldOp_ofFieldOp_swap, + timeOrder_ofFieldOp_ofFieldOp_not_ordered_eq_timeOrder h, timeContract_eq_smul] simp only [smul_add] rw [smul_smul, smul_smul, mul_comm] @@ -67,8 +65,7 @@ lemma timeContract_of_not_timeOrderRel (φ ψ : 𝓕.FieldOp) (h : ¬ timeOrderR `timeContract φ ψ = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ ψ) • [anPart ψ, ofFieldOp φ]ₛ`. -/ lemma timeContract_of_not_timeOrderRel_expand (φ ψ : 𝓕.FieldOp) (h : ¬ timeOrderRel φ ψ) : timeContract φ ψ = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ ψ) • [anPart ψ, ofFieldOp φ]ₛ := by - rw [timeContract_of_not_timeOrderRel _ _ h] - rw [timeContract_of_timeOrderRel _ _ _] + rw [timeContract_of_not_timeOrderRel _ _ h, timeContract_of_timeOrderRel _ _ _] have h1 := Std.Total.total (r := 𝓕.timeOrderRel) φ ψ simp_all diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Singleton.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Singleton.lean index 103fd57af..6a294112a 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Singleton.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Singleton.lean @@ -81,8 +81,7 @@ lemma singleton_sign_expand {φs : List 𝓕.FieldOp} {i j : Fin φs.length} (hi lemma singleton_getDual?_eq_none_iff_neq {i j : Fin n} (hij : i < j) (a : Fin n) : (singleton hij).getDual? a = none ↔ (i ≠ a ∧ j ≠ a) := by - rw [getDual?_eq_none_iff_mem_uncontracted] - rw [mem_uncontracted_iff_not_contracted] + rw [getDual?_eq_none_iff_mem_uncontracted, mem_uncontracted_iff_not_contracted] simp only [singleton, Finset.mem_singleton, forall_eq, Finset.mem_insert, not_or, ne_eq] omega From e7722d5d378b11fc9fe347362c7a96c02b5c2710 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:31:27 -0700 Subject: [PATCH 189/498] refactor: golf contraction getDual proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickContraction/Card.lean | 6 ++---- .../WickContraction/InsertAndContract.lean | 4 +--- .../WickContraction/InsertAndContractNat.lean | 6 ++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean index 16adb3620..a0707f20e 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean @@ -111,14 +111,12 @@ def consAddContract (i : Fin n.succ) (c : WickContraction n) : @[simp] lemma consAddContract_getDual?_zero (i : Fin n.succ) (c : WickContraction n) : (consAddContract i c).getDual? 0 = some i.succ := by - rw [getDual?_eq_some_iff_mem] - simp [consAddContract] + simp [getDual?_eq_some_iff_mem, consAddContract] @[simp] lemma consAddContract_getDual?_self_succ (i : Fin n.succ) (c : WickContraction n) : (consAddContract i c).getDual? i.succ = some 0 := by - rw [getDual?_eq_some_iff_mem] - simp [consAddContract, Finset.pair_comm] + simp [getDual?_eq_some_iff_mem, consAddContract, Finset.pair_comm] lemma mem_consAddContract_of_mem_iff (i : Fin n.succ) (c : WickContraction n) (a : Finset (Fin n)) : a ∈ c.1 ↔ (a.map i.succAboveEmb).map (Fin.succEmb n.succ) ∈ (consAddContract i c).1 := by diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean index 4b75e3b11..400ec8459 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean @@ -140,9 +140,7 @@ lemma insertAndContract_some_getDual?_some_eq (φ : 𝓕.FieldOp) (φs : List ((φsΛ ↩Λ φ i (some j)).getDual? (Fin.cast (insertIdx_length_fin φ φs i).symm (i.succAbove j))) = some (Fin.cast (insertIdx_length_fin φ φs i).symm i) := by - rw [getDual?_eq_some_iff_mem] - rw [@Finset.pair_comm] - rw [← getDual?_eq_some_iff_mem] + rw [getDual?_eq_some_iff_mem, @Finset.pair_comm, ← getDual?_eq_some_iff_mem] simp @[simp] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean index 39705a04b..3e732f9cf 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean @@ -161,8 +161,7 @@ lemma self_mem_uncontracted_of_insertAndContractNat_none (c : WickContraction n) lemma self_not_mem_uncontracted_of_insertAndContractNat_some (c : WickContraction n) (i : Fin n.succ) (j : c.uncontracted) : i ∉ (insertAndContractNat c i (some j)).uncontracted := by - rw [mem_uncontracted_iff_not_contracted] - simp [insertAndContractNat] + simp [mem_uncontracted_iff_not_contracted, insertAndContractNat] lemma insertAndContractNat_succAbove_mem_uncontracted_iff (c : WickContraction n) (i : Fin n.succ) (j : Fin n) : @@ -392,8 +391,7 @@ lemma insertAndContractNat_succAbove_getDual?_get (c : WickContraction n) (i : F lemma insertAndContractNat_some_getDual?_eq (c : WickContraction n) (i : Fin n.succ) (j : c.uncontracted) : (insertAndContractNat c i (some j)).getDual? i = some (i.succAbove j) := by - rw [getDual?_eq_some_iff_mem] - simp [insertAndContractNat] + simp [getDual?_eq_some_iff_mem, insertAndContractNat] lemma insertAndContractNat_some_getDual?_ne_none (c : WickContraction n) (i : Fin n.succ) (j : c.uncontracted) (k : Fin n) (hkj : k ≠ j.1) : From 4948e819d878d06ccfac3e1a63f2015c372d4298 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:34:22 -0700 Subject: [PATCH 190/498] refactor: golf join contraction membership proofs Co-authored-by: Claude Opus 4.8 --- .../WickContraction/Join.lean | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean index 6fce2aacc..c19efdc34 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean @@ -355,8 +355,7 @@ lemma exists_mem_left_uncontracted_of_mem_join_uncontracted {φs : List 𝓕.Fie (φsucΛ : WickContraction [φsΛ]ᵘᶜ.length) (i : Fin φs.length) (ha : i ∈ (join φsΛ φsucΛ).uncontracted) : i ∈ φsΛ.uncontracted := by - rw [@mem_uncontracted_iff_not_contracted] - rw [@mem_uncontracted_iff_not_contracted] at ha + rw [@mem_uncontracted_iff_not_contracted] at ha ⊢ simp only [join, Finset.le_eq_subset, Finset.mem_union, Finset.mem_map, RelEmbedding.coe_toEmbedding] at ha intro p hp @@ -371,8 +370,7 @@ lemma exists_mem_right_uncontracted_of_mem_join_uncontracted {φs : List 𝓕.Fi obtain ⟨j, rfl⟩ := uncontractedListEmd_surjective_mem_uncontracted i hi' use j simp only [true_and] - rw [mem_uncontracted_iff_not_contracted] at hi - rw [mem_uncontracted_iff_not_contracted] + rw [mem_uncontracted_iff_not_contracted] at hi ⊢ intro p hp have hip := hi (p.map uncontractedListEmd) (by simp only [join, Finset.le_eq_subset, Finset.mem_union, Finset.mem_map, @@ -386,8 +384,7 @@ lemma exists_mem_right_uncontracted_of_mem_join_uncontracted {φs : List 𝓕.Fi lemma join_uncontractedList {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) (φsucΛ : WickContraction [φsΛ]ᵘᶜ.length) : (join φsΛ φsucΛ).uncontractedList = List.map uncontractedListEmd φsucΛ.uncontractedList := by - rw [uncontractedList_eq_sort] - rw [uncontractedList_eq_sort] + rw [uncontractedList_eq_sort, uncontractedList_eq_sort] rw [fin_finset_sort_map_monotone] congr ext a @@ -592,19 +589,14 @@ lemma join_singleton_getDual?_left {φs : List 𝓕.FieldOp} {i j : Fin φs.length} (h : i < j) (φsucΛ : WickContraction [singleton h]ᵘᶜ.length) : (join (singleton h) φsucΛ).getDual? i = some j := by - rw [@getDual?_eq_some_iff_mem] - simp [singleton, join] + simp [getDual?_eq_some_iff_mem, singleton, join] @[simp] lemma join_singleton_getDual?_right {φs : List 𝓕.FieldOp} {i j : Fin φs.length} (h : i < j) (φsucΛ : WickContraction [singleton h]ᵘᶜ.length) : (join (singleton h) φsucΛ).getDual? j = some i := by - rw [@getDual?_eq_some_iff_mem] - simp only [join, singleton, Finset.le_eq_subset, Finset.mem_union, Finset.mem_singleton, - Finset.mem_map, RelEmbedding.coe_toEmbedding] - left - exact Finset.pair_comm j i + simp [getDual?_eq_some_iff_mem, join, singleton, Finset.pair_comm] lemma exists_contraction_pair_of_card_ge_zero {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) (h : 0 < φsΛ.1.card) : From 4cc9562d261fd8b57de4f5b76e018f3765cdc5d1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:41:54 -0700 Subject: [PATCH 191/498] refactor: golf Lorentz membership proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Basic.lean | 9 +++------ Physlib/Relativity/LorentzGroup/Boosts/Basic.lean | 3 +-- Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 50258a325..78c0e0005 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -80,8 +80,7 @@ lemma mem_iff_transpose : Λ ∈ LorentzGroup d ↔ Λᵀ ∈ LorentzGroup d := noncomm_ring lemma mem_iff_neg_mem : Λ ∈ LorentzGroup d ↔ -Λ ∈ LorentzGroup d := by - rw [mem_iff_self_mul_dual, mem_iff_self_mul_dual] - simp [dual] + simp [mem_iff_self_mul_dual, dual] lemma mem_mul (hΛ : Λ ∈ LorentzGroup d) (hΛ' : Λ' ∈ LorentzGroup d) : Λ * Λ' ∈ LorentzGroup d := by rw [mem_iff_dual_mul_self, dual_mul] @@ -91,8 +90,7 @@ lemma mem_mul (hΛ : Λ ∈ LorentzGroup d) (hΛ' : Λ' ∈ LorentzGroup d) : Λ simp [(mem_iff_dual_mul_self).mp hΛ'] lemma one_mem : 1 ∈ LorentzGroup d := by - rw [mem_iff_dual_mul_self] - simp + simp [mem_iff_dual_mul_self] lemma dual_mem (h : Λ ∈ LorentzGroup d) : dual Λ ∈ LorentzGroup d := by rw [mem_iff_dual_mul_self, dual_dual] @@ -104,8 +102,7 @@ A matrix `Λ` is in the Lorentz group if and only if it satisfies `Λᵀ * η * lemma mem_iff_transpose_mul_minkowskiMatrix_mul_self (Λ : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) : Λ ∈ LorentzGroup d ↔ Λᵀ * η * Λ = η := by - rw [mem_iff_dual_mul_self] - rw [dual] + rw [mem_iff_dual_mul_self, dual] constructor · intro h have h' : η * ((η * Λᵀ * η) * Λ) = η * 1 := congr_arg (η * ·) h diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean index 4be53b43d..2baefb0f6 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean @@ -293,8 +293,7 @@ lemma boost_zero_inr_nat_succ_inr_0 {d : ℕ} {β : ℝ} (hβ : |β| < 1) (i : lemma boost_zero_inr_succ_inr_succ {d : ℕ} {β : ℝ} (hβ : |β| < 1) (i1 i2 : Fin d) : (boost (0 : Fin d.succ) β hβ).1 (Sum.inr i1.succ) (Sum.inr i2.succ) = if i1 = i2 then 1 else 0 := by - rw [boost_inr_inr_other hβ (Fin.succ_ne_zero i2)] - simp [Fin.succ_inj, eq_comm] + simp [boost_inr_inr_other hβ (Fin.succ_ne_zero i2), Fin.succ_inj, eq_comm] end LorentzGroup diff --git a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean index 37a336150..b02447db5 100644 --- a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean @@ -96,8 +96,7 @@ lemma not_isOrthochronous_iff_le_zero : ¬ IsOrthochronous Λ ↔ Λ.1 (Sum.inl lemma not_isOrthochronous_iff_toVector_timeComponet_nonpos : ¬ IsOrthochronous Λ ↔ (toVector Λ).timeComponent ≤ 0:= by - rw [not_isOrthochronous_iff_le_zero] - simp + simp [not_isOrthochronous_iff_le_zero] /-- The identity Lorentz transformation is orthochronous. -/ lemma id_isOrthochronous : @IsOrthochronous d 1 := by From 981a4602b549f939ac55b0ec6bae54a5fcc9b6db Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:46:14 -0700 Subject: [PATCH 192/498] refactor: golf Lorentz vector wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean | 6 ++---- Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean | 1 - .../Tensors/RealTensor/Vector/MinkowskiProduct.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean | 3 +-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean index df444f58d..47ac256ed 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean @@ -105,8 +105,7 @@ lemma genBoostAux₂_basis_minkowskiProduct (u v : Velocity d) (μ ν : Fin 1 ⟪genBoostAux₂ u v (Vector.basis μ), genBoostAux₂ u v (Vector.basis ν)⟫ₘ = 2 * η μ μ * η ν ν * (u.1 μ + v.1 μ) * (u.1 ν + v.1 ν) * (1 + ⟪u, v.1⟫ₘ)⁻¹ := by - rw [genBoostAux₂_apply_basis, genBoostAux₂_apply_basis] - rw [map_smul, map_smul] + rw [genBoostAux₂_apply_basis, genBoostAux₂_apply_basis, map_smul, map_smul] have h1 : ⟪u.1 + v.1, u.1 + v.1⟫ₘ = 2 * (1 + ⟪u.1, v.1⟫ₘ) := by simp only [map_add, add_apply, Velocity.minkowskiProduct_self_eq_one] rw [minkowskiProduct_symm] @@ -124,8 +123,7 @@ lemma genBoostAux₂_basis_minkowskiProduct (u v : Velocity d) (μ ν : Fin 1 lemma genBoostAux₁_basis_genBoostAux₂_minkowskiProduct (u v : Velocity d) (μ ν : Fin 1 ⊕ Fin d) : ⟪genBoostAux₁ u v (Vector.basis μ), genBoostAux₂ u v (Vector.basis ν)⟫ₘ = - 2 * η μ μ * η ν ν * u.1 μ * (u.1 ν + v.1 ν) := by - rw [genBoostAux₁_apply_basis, genBoostAux₂_apply_basis] - rw [map_smul, map_smul] + rw [genBoostAux₁_apply_basis, genBoostAux₂_apply_basis, map_smul, map_smul] have h1 : ⟪v.1, u.1 + v.1⟫ₘ = (1 + ⟪u.1, v.1⟫ₘ) := by simp only [map_add, Velocity.minkowskiProduct_self_eq_one] rw [minkowskiProduct_symm] diff --git a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean index b02447db5..316a6c58e 100644 --- a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean @@ -231,7 +231,6 @@ to the same element via the homomorphism from `LorentzGroup` to `ℤ₂`. -/ lemma isOrthochronous_iff_of_orthchroMap_eq {Λ Λ' : LorentzGroup d} (h : orthchroMap Λ = orthchroMap Λ') : IsOrthochronous Λ ↔ IsOrthochronous Λ' := by rw [IsOrthochronous.iff_in_orthchroRep_ker, IsOrthochronous.iff_in_orthchroRep_ker] - rw [MonoidHom.mem_ker, MonoidHom.mem_ker] change orthchroMap Λ = 1 ↔ orthchroMap Λ' = 1 rw [h] diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean index 8e4ac1e2a..fcd54f638 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean @@ -76,8 +76,7 @@ lemma minkowskiProductMap_add_fst {d : ℕ} (p q r : Vector d) : @[simp] lemma minkowskiProductMap_add_snd {d : ℕ} (p q r : Vector d) : minkowskiProductMap p (q + r) = minkowskiProductMap p q + minkowskiProductMap p r := by - rw [minkowskiProductMap_symm, minkowskiProductMap_add_fst] - rw [minkowskiProductMap_symm q p, minkowskiProductMap_symm r p] + simpa [minkowskiProductMap_symm] using minkowskiProductMap_add_fst q r p @[simp] lemma minkowskiProductMap_smul_fst {d : ℕ} (c : ℝ) (p q : Vector d) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index c5c6984b0..1fa115ef6 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -68,8 +68,7 @@ lemma norm_spatialPart_le_timeComponent (v : Velocity d) : lemma norm_spatialPart_sq_eq (v : Velocity d) : ‖v.1.spatialPart‖ ^ 2 = (v.1 (Sum.inl 0))^2 - 1 := by - rw [← minkowskiProduct_self_eq_one v] - rw [minkowskiProduct_self_eq_timeComponent_spatialPart] + rw [← minkowskiProduct_self_eq_one v, minkowskiProduct_self_eq_timeComponent_spatialPart] simp [timeComponent] lemma zero_le_minkowskiProduct (u v : Velocity d) : From dd69c23ce490fdeb9298255c31b7e06825fa595d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:48:09 -0700 Subject: [PATCH 193/498] refactor: golf metric unit tensor proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/MetricTensor.lean | 11 ++++------- Physlib/Relativity/Tensors/UnitTensor.lean | 6 ++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Physlib/Relativity/Tensors/MetricTensor.lean b/Physlib/Relativity/Tensors/MetricTensor.lean index e9e1a9678..d4c685995 100644 --- a/Physlib/Relativity/Tensors/MetricTensor.lean +++ b/Physlib/Relativity/Tensors/MetricTensor.lean @@ -53,8 +53,7 @@ lemma fromPairTContr_metric_metric_eq_permT_unit {c : C} : ((S.metric (S.τ c)) (1 : k)) = permT ![1, 0] (And.intro (by decide) (fun i => by fin_cases i <;> rfl)) (unitTensor c) := by - rw [← permT_fromPairTContr_metric_metric] - rw [permT_permT] + rw [← permT_fromPairTContr_metric_metric, permT_permT] symm apply permT_congr_eq_id decide @@ -66,8 +65,8 @@ lemma contrT_metricTensor_metricTensor {c : C} : contrT 2 1 2 (by simp; rfl) (prodT (metricTensor c) (metricTensor (S.τ c))) = permT ![1, 0] (And.intro (by decide) (fun i => by fin_cases i <;> rfl)) (unitTensor (S := S) c) := by - rw [metricTensor, metricTensor, fromConstPair, fromConstPair] - rw [fromPairT_contr_fromPairT_eq_fromPairTContr] + rw [metricTensor, metricTensor, fromConstPair, fromConstPair, + fromPairT_contr_fromPairT_eq_fromPairTContr] erw [fromPairTContr_metric_metric_eq_permT_unit] rw [permT_permT] rfl @@ -80,9 +79,7 @@ lemma contrT_metricTensor_metricTensor_eq_dual_unit {c : C} : simp · rfl)) (unitTensor (S := S) (S.τ c)) := by - rw [contrT_metricTensor_metricTensor] - rw [unitTensor_eq_permT_dual] - rw [permT_permT] + rw [contrT_metricTensor_metricTensor, unitTensor_eq_permT_dual, permT_permT] apply permT_congr · decide · rfl diff --git a/Physlib/Relativity/Tensors/UnitTensor.lean b/Physlib/Relativity/Tensors/UnitTensor.lean index 106246b89..fa9a5e9c7 100644 --- a/Physlib/Relativity/Tensors/UnitTensor.lean +++ b/Physlib/Relativity/Tensors/UnitTensor.lean @@ -38,8 +38,7 @@ lemma unitTensor_congr {c c1 : C} (h : c = c1) : lemma unitTensor_eq_permT_dual (c : C) : S.unitTensor c = permT ![1, 0] (And.intro (by decide) (fun i => by fin_cases i <;> simp)) (unitTensor (S.τ c)) := by - rw [unitTensor, fromConstPair, S.unit_symm] - rw [unitTensor, fromConstPair] + rw [unitTensor, fromConstPair, S.unit_symm, unitTensor, fromConstPair] simp [fromPairT] generalize (S.unit (S.τ c)) 1 = u at * induction' u using TensorProduct.induction_on with x y @@ -65,8 +64,7 @@ lemma unitTensor_eq_permT_dual (c : C) : lemma dual_unitTensor_eq_permT_unitTensor (c : C) : S.unitTensor (S.τ c) = permT ![1, 0] (And.intro (by decide) (fun i => by fin_cases i <;> simp)) (unitTensor c) := by - rw [unitTensor_eq_permT_dual] - rw [unitTensor_congr (by simp : c = S.τ (S.τ c))] + rw [unitTensor_eq_permT_dual, unitTensor_congr (by simp : c = S.τ (S.τ c))] simp lemma unit_fromSingleTContrFromPairT_eq_fromSingleT {c : C} (x : V c) : From 17c76e1beb7bd88aedacc0329090c0913a5d25d9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:50:47 -0700 Subject: [PATCH 194/498] refactor: golf tensor unit transport proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/Dual.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean | 10 ++++------ .../Tensors/RealTensor/Vector/MinkowskiProduct.lean | 3 +-- Physlib/Relativity/Tensors/UnitTensor.lean | 8 ++------ 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/Relativity/Tensors/Dual.lean b/Physlib/Relativity/Tensors/Dual.lean index 0bef5962e..a0bdb7de3 100644 --- a/Physlib/Relativity/Tensors/Dual.lean +++ b/Physlib/Relativity/Tensors/Dual.lean @@ -107,8 +107,7 @@ lemma fromDualMap_eq_permT_toDualMap {c : C} (t : S.Tensor ![S.τ c]) : lemma toDualMap_eq_permT_fromDualMap {c : C} (t : S.Tensor ![c]) : toDualMap t = (fromDualMap (permT id (by simp) t)) := by - rw [fromDualMap_eq_permT_toDualMap] - rw [toDualMap_apply, toDualMap_apply] + rw [fromDualMap_eq_permT_toDualMap, toDualMap_apply, toDualMap_apply] conv_rhs => enter [2, 2] rw [prodT_permT_right] diff --git a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean index fc510c0bb..9798fa1f4 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean @@ -209,16 +209,14 @@ lemma contr_preCoContrUnit {d : ℕ} (x : ContrMod d) : lemma preContrCoUnit_symm {d : ℕ} : (preContrCoUnit d) (1 : ℝ) = LinearMap.lTensor _ (LinearEquiv.cast (by rfl)).toLinearMap (TensorProduct.comm ℝ _ _ ((preCoContrUnit d) (1 : ℝ))) := by - rw [preContrCoUnit_apply_one, preContrCoUnitVal_expand_tmul] - rw [preCoContrUnit_apply_one, preCoContrUnitVal_expand_tmul] - simp + simp [preContrCoUnit_apply_one, preContrCoUnitVal_expand_tmul, preCoContrUnit_apply_one, + preCoContrUnitVal_expand_tmul] lemma preCoContrUnit_symm {d : ℕ} : (preCoContrUnit d) (1 : ℝ) = LinearMap.lTensor _ (LinearEquiv.cast (by simp)).toLinearMap (TensorProduct.comm ℝ _ _ ((preContrCoUnit d) (1 : ℝ))) := by - rw [preContrCoUnit_apply_one, preContrCoUnitVal_expand_tmul] - rw [preCoContrUnit_apply_one, preCoContrUnitVal_expand_tmul] - simp + simp [preContrCoUnit_apply_one, preContrCoUnitVal_expand_tmul, preCoContrUnit_apply_one, + preCoContrUnitVal_expand_tmul] end Lorentz end diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean index fcd54f638..a699c33fc 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean @@ -279,8 +279,7 @@ lemma isLorentz_iff_comp_adjoint_eq_id {d : ℕ} (f : Vector d →ₗ[ℝ] Vecto lemma isLorentz_iff_toMatrix_mem_lorentzGroup {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : IsLorentz f ↔ LinearMap.toMatrix Vector.basis Vector.basis f ∈ LorentzGroup d := by - rw [isLorentz_iff_comp_adjoint_eq_id] - rw [LorentzGroup.mem_iff_dual_mul_self] + rw [isLorentz_iff_comp_adjoint_eq_id, LorentzGroup.mem_iff_dual_mul_self] trans LinearMap.toMatrix Vector.basis Vector.basis (adjoint f ∘ₗ f) = LinearMap.toMatrix Vector.basis Vector.basis (LinearMap.id : Vector d →ₗ[ℝ] Vector d) · exact Iff.symm (EmbeddingLike.apply_eq_iff_eq (LinearMap.toMatrix basis basis)) diff --git a/Physlib/Relativity/Tensors/UnitTensor.lean b/Physlib/Relativity/Tensors/UnitTensor.lean index fa9a5e9c7..fa197d681 100644 --- a/Physlib/Relativity/Tensors/UnitTensor.lean +++ b/Physlib/Relativity/Tensors/UnitTensor.lean @@ -87,12 +87,8 @@ set_option backward.isDefEq.respectTransparency false in lemma contrT_unitTensor_dual_single {c : C} (x : Tensor S ![S.τ c]) : contrT 1 1 2 (by simp; rfl) (prodT (unitTensor c) x) = permT id (by simp; rfl) x := by - rw [unitTensor_eq_permT_dual] - rw [prodT_permT_left] - rw [contrT_permT] - rw [prodT_swap] - rw [contrT_permT] - rw [permT_permT] + rw [unitTensor_eq_permT_dual, prodT_permT_left, contrT_permT, prodT_swap, contrT_permT, + permT_permT] conv_lhs => enter [2] change contrT 1 1 0 _ _ From 0752c4c65efb2b315b1f19c3323ddb82393aee72 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:52:17 -0700 Subject: [PATCH 195/498] refactor: golf Weyl metric rewrite proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Weyl/Metric.lean | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean index 60f8174b6..c80c3966a 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean @@ -33,8 +33,7 @@ def metricRaw : Matrix (Fin 2) (Fin 2) ℂ := !![0, 1; -1, 0] /-- Multiplying an element of `SL(2, ℂ)` on the left with the metric `𝓔` is equivalent to multiplying the inverse-transpose of that element on the right with the metric. -/ lemma comm_metricRaw (M : SL(2,ℂ)) : M.1 * metricRaw = metricRaw * (M.1⁻¹)ᵀ := by - rw [metricRaw] - rw [Lorentz.SL2C.inverse_coe, eta_fin_two M.1] + rw [metricRaw, Lorentz.SL2C.inverse_coe, eta_fin_two M.1] rw [SpecialLinearGroup.coe_inv, Matrix.adjugate_fin_two, Matrix.mul_fin_two, eta_fin_two !![M.1 1 1, -M.1 0 1; -M.1 1 0, M.1 0 0]ᵀ] simp only [Fin.isValue, mul_zero, mul_neg, mul_one, zero_add, add_zero, transpose_apply, of_apply, @@ -43,8 +42,7 @@ lemma comm_metricRaw (M : SL(2,ℂ)) : M.1 * metricRaw = metricRaw * (M.1⁻¹) empty_vecMul, neg_smul, neg_cons, neg_neg, neg_empty, empty_mul, Equiv.symm_apply_apply] lemma metricRaw_comm (M : SL(2,ℂ)) : metricRaw * M.1 = (M.1⁻¹)ᵀ * metricRaw := by - rw [metricRaw] - rw [Lorentz.SL2C.inverse_coe, eta_fin_two M.1] + rw [metricRaw, Lorentz.SL2C.inverse_coe, eta_fin_two M.1] rw [SpecialLinearGroup.coe_inv, Matrix.adjugate_fin_two, Matrix.mul_fin_two, eta_fin_two !![M.1 1 1, -M.1 0 1; -M.1 1 0, M.1 0 0]ᵀ] simp only [Fin.isValue, zero_mul, one_mul, zero_add, neg_mul, add_zero, transpose_apply, of_apply, @@ -54,16 +52,14 @@ lemma metricRaw_comm (M : SL(2,ℂ)) : metricRaw * M.1 = (M.1⁻¹)ᵀ * metricR empty_vecMul, add_cons, empty_add_empty, empty_mul, Equiv.symm_apply_apply] lemma star_comm_metricRaw (M : SL(2,ℂ)) : M.1.map star * metricRaw = metricRaw * ((M.1)⁻¹)ᴴ := by - rw [metricRaw] - rw [Lorentz.SL2C.inverse_coe, eta_fin_two M.1] + rw [metricRaw, Lorentz.SL2C.inverse_coe, eta_fin_two M.1] rw [SpecialLinearGroup.coe_inv, Matrix.adjugate_fin_two, eta_fin_two !![M.1 1 1, -M.1 0 1; -M.1 1 0, M.1 0 0]ᴴ] rw [eta_fin_two (!![M.1 0 0, M.1 0 1; M.1 1 0, M.1 1 1].map star)] simp lemma metricRaw_comm_star (M : SL(2,ℂ)) : metricRaw * M.1.map star = ((M.1)⁻¹)ᴴ * metricRaw := by - rw [metricRaw] - rw [Lorentz.SL2C.inverse_coe, eta_fin_two M.1] + rw [metricRaw, Lorentz.SL2C.inverse_coe, eta_fin_two M.1] rw [SpecialLinearGroup.coe_inv, Matrix.adjugate_fin_two, eta_fin_two !![M.1 1 1, -M.1 0 1; -M.1 1 0, M.1 0 0]ᴴ] rw [eta_fin_two (!![M.1 0 0, M.1 0 1; M.1 1 0, M.1 1 1].map star)] @@ -280,8 +276,8 @@ lemma leftDualContraction_apply_metric : (TensorProduct.assoc ℂ _ _ _).symm.toLinearMap.lTensor _<| TensorProduct.assoc ℂ _ _ (_ ⊗[ℂ] _) <| (leftMetric 1) ⊗ₜ[ℂ] (dualLeftMetric 1)) = dualLeftLeftUnit (1 : ℂ) := by - rw [leftMetric_apply_one, dualLeftMetric_apply_one] - rw [leftMetricVal_expand_tmul', dualLeftMetricVal_expand_tmul] + rw [leftMetric_apply_one, dualLeftMetric_apply_one, leftMetricVal_expand_tmul', + dualLeftMetricVal_expand_tmul] simp only [Fin.isValue, tmul_sub, sub_tmul, map_sub, assoc_tmul, LinearMap.lTensor_tmul, LinearEquiv.coe_coe, assoc_symm_tmul, LinearMap.rTensor_tmul, Representation.IntertwiningMap.coe_toLinearMap, LinearEquiv.lTensor_tmul, lid_tmul, tmul_smul, From 01061fd1830a65d3b477a9436be89c608f08523e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 17:57:07 -0700 Subject: [PATCH 196/498] refactor: golf complex tensor rewrite proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean | 8 ++++---- Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean | 6 ++---- .../Tensors/ComplexTensor/Vector/Pre/Basic.lean | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean index 0be7cec11..e281fcf3f 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean @@ -138,8 +138,8 @@ lemma contrCoContraction_apply_metric : (TensorProduct.assoc ℂ _ _ _).symm.toLinearMap.lTensor _<| TensorProduct.assoc ℂ _ _ (_ ⊗[ℂ] _) <| (contrMetric 1) ⊗ₜ[ℂ] (coMetric 1)) = coContrUnit (1 : ℝ) := by - rw [contrMetric_apply_one, coMetric_apply_one] - rw [contrMetricVal_expand_tmul, coMetricVal_expand_tmul] + rw [contrMetric_apply_one, coMetric_apply_one, contrMetricVal_expand_tmul, + coMetricVal_expand_tmul] simp [Fin.isValue, tmul_sub, sub_tmul, map_sub] simp only [← Representation.IntertwiningMap.toLinearMap_apply] repeat erw [contrCoContraction_basis'] @@ -154,8 +154,8 @@ lemma coContrContraction_apply_metric : (TensorProduct.assoc ℂ _ _ _).symm.toLinearMap.lTensor _<| TensorProduct.assoc ℂ _ _ (_ ⊗[ℂ] _) <| (coMetric 1) ⊗ₜ[ℂ] (contrMetric 1)) = contrCoUnit (1 : ℝ) := by - rw [coMetric_apply_one, contrMetric_apply_one] - rw [coMetricVal_expand_tmul, contrMetricVal_expand_tmul] + rw [coMetric_apply_one, contrMetric_apply_one, coMetricVal_expand_tmul, + contrMetricVal_expand_tmul] simp [Fin.isValue, tmul_sub, sub_tmul, map_sub] simp only [← Representation.IntertwiningMap.toLinearMap_apply] repeat erw [coContrContraction_basis'] diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index 09f99f86d..42b82c094 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -153,8 +153,7 @@ lemma coContrUnit_eq_complexCoBasis_complexContrBasis : δ' = open Lorentz in lemma coContrUnit_eq_complexCoBasisFin4_complexContrBasisFin4 : δ' = ∑ i, fromPairT (complexCoBasisFin4 i ⊗ₜ[ℂ] complexContrBasisFin4 i) := by - rw [coContrUnit_eq_complexCoBasis_complexContrBasis] - rw [← finSumFinEquiv.symm.sum_comp] + rw [coContrUnit_eq_complexCoBasis_complexContrBasis, ← finSumFinEquiv.symm.sum_comp] simp [complexCoBasisFin4, complexContrBasisFin4] open Lorentz in @@ -166,8 +165,7 @@ lemma contrCoUnit_eq_complexContrBasis_complexCoBasis : δ = open Lorentz in lemma contrCoUnit_eq_complexContrBasisFin4_complexCoBasisFin4 : δ = ∑ i, fromPairT (complexContrBasisFin4 i ⊗ₜ[ℂ] complexCoBasisFin4 i) := by - rw [contrCoUnit_eq_complexContrBasis_complexCoBasis] - rw [← finSumFinEquiv.symm.sum_comp] + rw [contrCoUnit_eq_complexContrBasis_complexCoBasis, ← finSumFinEquiv.symm.sum_comp] simp [complexContrBasisFin4, complexCoBasisFin4] open Fermion in diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index faa5029f6..caddd4ebf 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -200,8 +200,7 @@ lemma SL2CRep_ρ_basis (M : SL(2, ℂ)) (i : Fin 1 ⊕ Fin 3) : (ContrℂModule.SL2CRep M) (complexContrBasis i) = ∑ j, (SL2C.toLorentzGroup M).1 j i • complexContrBasis j := by - rw [complexContrBasis_of_real, inclCongrRealLorentz_ρ] - rw [Contr.ρ_stdBasis, map_sum] + rw [complexContrBasis_of_real, inclCongrRealLorentz_ρ, Contr.ρ_stdBasis, map_sum] apply congrArg funext j simp only [LinearMap.map_smulₛₗ, ofRealHom_eq_coe, coe_smul] From 33f73ff31592321e4ff775e2a3ea6a1968a5c70d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:00:45 -0700 Subject: [PATCH 197/498] refactor: golf electromagnetic tensor basis proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Distributional/Basic.lean | 3 +-- Physlib/Electromagnetism/Distributional/FieldStrength.lean | 3 +-- Physlib/Electromagnetism/Kinematics/EMPotential.lean | 6 ++---- Physlib/Electromagnetism/Kinematics/FieldStrength.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Basic.lean b/Physlib/Electromagnetism/Distributional/Basic.lean index 2c3004bf6..49c214689 100644 --- a/Physlib/Electromagnetism/Distributional/Basic.lean +++ b/Physlib/Electromagnetism/Distributional/Basic.lean @@ -188,8 +188,7 @@ lemma toTensor_distTensorDeriv_basis_repr_apply {d} (A : DistElectromagneticPote (Fin.append ![Color.down] ![Color.up])) : (Tensor.basis _).repr (Tensorial.toTensor (distTensorDeriv A ε)) b = distDeriv (b 0) A ε (b 1) := by - rw [Tensorial.basis_toTensor_apply] - rw [Tensorial.basis_map_prod] + rw [Tensorial.basis_toTensor_apply, Tensorial.basis_map_prod] simp only [Nat.reduceSucc, Nat.reduceAdd, Basis.repr_reindex, Finsupp.mapDomain_equiv_apply, Equiv.symm_symm, Fin.isValue] rw [Lorentz.Vector.tensor_basis_map_eq_basis_reindex, diff --git a/Physlib/Electromagnetism/Distributional/FieldStrength.lean b/Physlib/Electromagnetism/Distributional/FieldStrength.lean index 5af7cfc75..952474218 100644 --- a/Physlib/Electromagnetism/Distributional/FieldStrength.lean +++ b/Physlib/Electromagnetism/Distributional/FieldStrength.lean @@ -129,8 +129,7 @@ lemma fieldStrengthAux_tensor_basis_eq_basis {d} (A : DistElectromagneticPotenti (Tensor.basis _).repr (Tensorial.toTensor (A.fieldStrengthAux ε)) b = (Lorentz.Vector.basis.tensorProduct Lorentz.Vector.basis).repr (A.fieldStrengthAux ε) (b 0, b 1) := by - rw [Tensorial.basis_toTensor_apply] - rw [Tensorial.basis_map_prod] + rw [Tensorial.basis_toTensor_apply, Tensorial.basis_map_prod] simp only [Nat.reduceSucc, Nat.reduceAdd, Basis.repr_reindex, Finsupp.mapDomain_equiv_apply, Equiv.symm_symm, Fin.isValue] rw [Lorentz.Vector.tensor_basis_map_eq_basis_reindex] diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index 855271a5c..4916f5ab4 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -561,8 +561,7 @@ as taking the derivative and then applying the Lorentz transformation to the res lemma deriv_equivariant {d} {x : SpaceTime d} (A : ElectromagneticPotential d) (Λ : LorentzGroup d) (hf : Differentiable ℝ A) : deriv (Λ • A) x = Λ • (deriv A (Λ⁻¹ • x)) := by - rw [deriv_eq_tensorDeriv, deriv_eq_tensorDeriv] - rw [action_val, tensorDeriv_equivariant] + rw [deriv_eq_tensorDeriv, deriv_eq_tensorDeriv, action_val, tensorDeriv_equivariant] all_goals fun_prop /-! @@ -619,8 +618,7 @@ lemma toTensor_deriv_basis_repr_apply {d} (A : ElectromagneticPotential d) (Fin.append ![Color.down] ![Color.up])) : (Tensor.basis _).repr (Tensorial.toTensor (deriv A x)) b = ∂_ (b 0) A x (b 1) := by - rw [Tensorial.basis_toTensor_apply] - rw [Tensorial.basis_map_prod] + rw [Tensorial.basis_toTensor_apply, Tensorial.basis_map_prod] simp only [Nat.reduceSucc, Nat.reduceAdd, Basis.repr_reindex, Finsupp.mapDomain_equiv_apply, Equiv.symm_symm, Fin.isValue] rw [Lorentz.Vector.tensor_basis_map_eq_basis_reindex, diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index 32cd59d00..5d1b48f19 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -317,8 +317,7 @@ lemma toFieldStrength_tensor_basis_eq_basis {d} (A : ElectromagneticPotential d) (Tensor.basis _).repr (Tensorial.toTensor (toFieldStrength A x)) b = (Lorentz.Vector.basis.tensorProduct Lorentz.Vector.basis).repr (toFieldStrength A x) (b 0, b 1) := by - rw [Tensorial.basis_toTensor_apply] - rw [Tensorial.basis_map_prod] + rw [Tensorial.basis_toTensor_apply, Tensorial.basis_map_prod] simp only [Nat.reduceSucc, Nat.reduceAdd, Basis.repr_reindex, Finsupp.mapDomain_equiv_apply, Equiv.symm_symm, Fin.isValue] rw [Lorentz.Vector.tensor_basis_map_eq_basis_reindex] From 6d66ca2e854b4c7455bf7c6820e1be44ac763179 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:04:00 -0700 Subject: [PATCH 198/498] refactor: golf space derivative wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 9 +++------ Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean | 3 +-- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index 5f611bdf5..b379d46a7 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -289,8 +289,7 @@ lemma deriv_component (μ ν : Fin d) (x : Space d) : lemma deriv_component_sq {d : ℕ} {ν μ : Fin d} (x : Space d) : (deriv ν (fun x => (x μ) ^ 2) x) = if ν = μ then 2 * x μ else 0:= by - rw [deriv_eq_fderiv_basis] - rw [fderiv_fun_pow] + rw [deriv_eq_fderiv_basis, fderiv_fun_pow] simp only [Nat.add_one_sub_one, pow_one, nsmul_eq_mul, Nat.cast_ofNat, FunLike.coe_smul, Pi.smul_apply, smul_eq_mul] rw [← deriv_eq_fderiv_basis, deriv_component] @@ -435,8 +434,7 @@ lemma deriv_eq_inner_self (x : Space d) (i : Fin d) : @[simp] lemma deriv_inner_left {d} (x1 x2 : Space d) (i : Fin d) : deriv i (fun x => ⟪x, x2⟫_ℝ) x1 = x2 i := by - rw [deriv_eq_fderiv_basis] - rw [fderiv_inner_apply] + rw [deriv_eq_fderiv_basis, fderiv_inner_apply] simp only [fderiv_fun_const, Pi.zero_apply, _root_.zero_apply, inner_zero_right, fderiv_fun_id, ContinuousLinearMap.coe_id', id_eq, basis_inner, zero_add] · fun_prop @@ -445,8 +443,7 @@ lemma deriv_inner_left {d} (x1 x2 : Space d) (i : Fin d) : @[simp] lemma deriv_inner_right {d} (x1 x2 : Space d) (i : Fin d) : deriv i (fun x => ⟪x1, x⟫_ℝ) x2 = x1 i := by - rw [deriv_eq_fderiv_basis] - rw [fderiv_inner_apply] + rw [deriv_eq_fderiv_basis, fderiv_inner_apply] simp only [fderiv_fun_id, ContinuousLinearMap.coe_id', id_eq, inner_basis, fderiv_fun_const, Pi.ofNat_apply, _root_.zero_apply, inner_zero_left, add_zero] · fun_prop diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean index 15950e40a..c37458412 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean @@ -135,8 +135,7 @@ transport of `toAffineIsometryMulEquiv` acting on `EuclideanSpace`: `chart (g • p) = (toAffineIsometryMulEquiv g) (chart p)`. -/ lemma chartEuclidean_smul (g : EuclideanGroup d) (p : Space d) : Space.chartEuclidean d (g • p) = toAffineIsometryMulEquiv g (Space.chartEuclidean d p) := by - rw [Space.chartEuclidean_apply] - rw [toAffineIsometryMulEquiv_apply, toAffineIsometryHom_apply] + rw [Space.chartEuclidean_apply, toAffineIsometryMulEquiv_apply, toAffineIsometryHom_apply] have h_left : g • p -ᵥ (0 : Space d) = g.linear • (p -ᵥ (0 : Space d)) + g.translation := by exact (eq_vadd_iff_vsub_eq (g • p) (g.linear • (p -ᵥ (0 : Space d)) + g.translation) diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index dde4947a9..9ceffe498 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -159,8 +159,7 @@ open Space lemma deriv_normPowerSeries {d} (n : ℕ) (x : Space d) (i : Fin d) : ∂[i] (normPowerSeries n) x = x i * (normPowerSeries n x)⁻¹ := by - rw [deriv_eq_fderiv_basis] - rw [normPowerSeries_eq] + rw [deriv_eq_fderiv_basis, normPowerSeries_eq] rw [fderiv_sqrt] simp only [one_div, mul_inv_rev, fderiv_add_const, FunLike.coe_smul, Pi.smul_apply, smul_eq_mul] From 9b243d32773398359931eaa024d33f6201923067 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:06:19 -0700 Subject: [PATCH 199/498] refactor: golf field statistic sign proofs Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/FieldStatistics/OfFinset.lean | 6 ++---- .../WickContraction/Sign/InsertNone.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean index 76d572ecd..97f9ce2e2 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean @@ -83,8 +83,7 @@ lemma ofFinset_erase (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a : Finset lemma ofFinset_eq_prod (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a : Finset (Fin φs.length)) : ofFinset q φs.get a = ∏ (i : Fin φs.length), if i ∈ a then (q φs[i]) else 1 := by - rw [ofFinset] - rw [ofList_map_eq_finset_prod] + rw [ofFinset, ofList_map_eq_finset_prod] congr funext i simp only [Finset.mem_sort, Fin.getElem_fin] @@ -92,8 +91,7 @@ lemma ofFinset_eq_prod (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a : Fins lemma ofFinset_union (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a b : Finset (Fin φs.length)) : ofFinset q φs.get a * ofFinset q φs.get b = ofFinset q φs.get ((a ∪ b) \ (a ∩ b)) := by - rw [ofFinset_eq_prod, ofFinset_eq_prod, ofFinset_eq_prod] - rw [← Finset.prod_mul_distrib] + rw [ofFinset_eq_prod, ofFinset_eq_prod, ofFinset_eq_prod, ← Finset.prod_mul_distrib] congr funext x simp only [Fin.getElem_fin, mul_ite, ite_mul, mul_self, one_mul, mul_one, diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean index 71a8131b8..4da8ebd33 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean @@ -94,8 +94,7 @@ def signInsertNone (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) (φsΛ : WickCo lemma sign_insert_none_eq_signInsertNone_mul_sign (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) (i : Fin φs.length.succ) : (φsΛ ↩Λ φ i none).sign = (φsΛ.signInsertNone φ φs i) * φsΛ.sign := by - rw [sign] - rw [signInsertNone, sign, ← Finset.prod_mul_distrib] + rw [sign, signInsertNone, sign, ← Finset.prod_mul_distrib] rw [insertAndContract_none_prod_contractions] congr funext a @@ -192,8 +191,7 @@ lemma signInsertNone_eq_filter_map (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) φsΛ.signInsertNone φ φs i = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ ((List.filter (fun x => (φsΛ.getDual? x).isSome ∧ i.succAbove x < i) (List.finRange φs.length)).map φs.get)) := by - rw [signInsertNone_eq_prod_getDual?_Some] - rw [FieldStatistic.ofList_map_eq_finset_prod] + rw [signInsertNone_eq_prod_getDual?_Some, FieldStatistic.ofList_map_eq_finset_prod] rw [map_prod] congr funext a @@ -252,8 +250,7 @@ lemma sign_insert_none (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) (i : Fin φs.length.succ) (hG : GradingCompliant φs φsΛ) : (φsΛ ↩Λ φ i none).sign = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ ⟨φs.get, Finset.univ.filter (fun x => (φsΛ.getDual? x).isSome ∧ i.succAbove x < i)⟩) * φsΛ.sign := by - rw [sign_insert_none_eq_signInsertNone_mul_sign] - rw [signInsertNone_eq_filterset] + rw [sign_insert_none_eq_signInsertNone_mul_sign, signInsertNone_eq_filterset] exact hG /-- For a list `φs = φ₀…φₙ` of `𝓕.FieldOp`, a graded compliant Wick contraction `φsΛ` of `φs`, From 0a9e2e6c6ea0543d4a54ff5d39c52540f8a4493b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:11:38 -0700 Subject: [PATCH 200/498] refactor: golf Wick contraction sign proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickContraction/Join.lean | 3 +-- .../WickContraction/Sign/InsertSome.lean | 9 +++------ .../WickContraction/UncontractedList.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean index c19efdc34..d7a6864f6 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean @@ -384,8 +384,7 @@ lemma exists_mem_right_uncontracted_of_mem_join_uncontracted {φs : List 𝓕.Fi lemma join_uncontractedList {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) (φsucΛ : WickContraction [φsΛ]ᵘᶜ.length) : (join φsΛ φsucΛ).uncontractedList = List.map uncontractedListEmd φsucΛ.uncontractedList := by - rw [uncontractedList_eq_sort, uncontractedList_eq_sort] - rw [fin_finset_sort_map_monotone] + rw [uncontractedList_eq_sort, uncontractedList_eq_sort, fin_finset_sort_map_monotone] congr ext a simp only [Finset.mem_map] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean index 7cf174f70..d1c9f38d9 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean @@ -365,8 +365,7 @@ lemma signInsertSomeProd_eq_prod_fin (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldO then 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs[x.1]) else 1 else 1 := by - rw [signInsertSomeProd_eq_prod_prod] - rw [Finset.prod_sigma'] + rw [signInsertSomeProd_eq_prod_prod, Finset.prod_sigma'] erw [← φsΛ.sigmaContractedEquiv.symm.prod_comp] let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm @@ -395,8 +394,7 @@ lemma signInsertSomeProd_eq_finset (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) ∀ (h : (φsΛ.getDual? x).isSome), x < j ∧ (i.succAbove x < i ∧ i < i.succAbove ((φsΛ.getDual? x).get h) ∨ j < ((φsΛ.getDual? x).get h) ∧ ¬ i.succAbove x < i)))⟩) := by - rw [signInsertSomeProd_eq_prod_fin] - rw [ofFinset_eq_prod] + rw [signInsertSomeProd_eq_prod_fin, ofFinset_eq_prod] rw [map_prod] congr funext x @@ -442,8 +440,7 @@ lemma stat_signFinset_insert_some_self_fst 𝓕 |>ₛ ⟨φs.get, (Finset.univ.filter (fun x => i < i.succAbove x ∧ x < j ∧ ((φsΛ.getDual? x = none) ∨ ∀ (h : (φsΛ.getDual? x).isSome), i < i.succAbove ((φsΛ.getDual? x).get h))))⟩ := by - rw [get_eq_insertIdx_succAbove φ _ i] - rw [ofFinset_finset_map] + rw [get_eq_insertIdx_succAbove φ _ i, ofFinset_finset_map] swap refine (Equiv.comp_injective i.succAbove (finCongr (Eq.symm (insertIdx_length_fin φ φs i)))).mpr ?hi.a diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index 48768795a..953ab88dd 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -544,8 +544,7 @@ lemma uncontractedList_succAboveEmb_eraseIdx_eq_sort (c : WickContraction n) (i 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 - rw [uncontractedList_eq_sort] - rw [uncontractedList_succAboveEmb_eraseIdx_eq_sort] + rw [uncontractedList_eq_sort, uncontractedList_succAboveEmb_eraseIdx_eq_sort] swap simp only [Fin.is_lt] congr From 9d100aba1975f51ed6d3fbd3c7bc48cf4bb83c7b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:14:29 -0700 Subject: [PATCH 201/498] refactor: golf MSSM projection proofs Co-authored-by: Claude Opus 4.8 --- .../AnomalyCancellation/OrthogY3B3/Basic.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean index 1a74d38e3..8662b312b 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean @@ -65,15 +65,13 @@ lemma Y₃_plus_B₃_plus_proj (T : MSSMACC.LinSols) (a b c : ℚ) : (a + c * (dot B₃.val T.val - dot Y₃.val T.val)) • Y₃.val + (b + c * (dot Y₃.val T.val - 2 * dot B₃.val T.val)) • B₃.val + (dot Y₃.val B₃.val * c) • T.val:= by - rw [proj_val] - rw [DistribMulAction.smul_add, DistribMulAction.smul_add] + rw [proj_val, DistribMulAction.smul_add, DistribMulAction.smul_add] module set_option backward.isDefEq.respectTransparency false in lemma quad_Y₃_proj (T : MSSMACC.LinSols) : quadBiLin Y₃.val (proj T).val = dot Y₃.val B₃.val * quadBiLin Y₃.val T.val := by - rw [proj_val] - rw [quadBiLin.map_add₂, quadBiLin.map_add₂] + rw [proj_val, quadBiLin.map_add₂, quadBiLin.map_add₂] rw [quadBiLin.map_smul₂, quadBiLin.map_smul₂, quadBiLin.map_smul₂] rw [show quadBiLin Y₃.val B₃.val = 0 by with_unfolding_all rfl] rw [show quadBiLin Y₃.val Y₃.val = 0 by with_unfolding_all rfl] @@ -82,8 +80,7 @@ lemma quad_Y₃_proj (T : MSSMACC.LinSols) : set_option backward.isDefEq.respectTransparency false in lemma quad_B₃_proj (T : MSSMACC.LinSols) : quadBiLin B₃.val (proj T).val = dot Y₃.val B₃.val * quadBiLin B₃.val T.val := by - rw [proj_val] - rw [quadBiLin.map_add₂, quadBiLin.map_add₂] + rw [proj_val, quadBiLin.map_add₂, quadBiLin.map_add₂] rw [quadBiLin.map_smul₂, quadBiLin.map_smul₂, quadBiLin.map_smul₂] rw [show quadBiLin B₃.val Y₃.val = 0 by with_unfolding_all rfl] rw [show quadBiLin B₃.val B₃.val = 0 by with_unfolding_all rfl] @@ -94,8 +91,7 @@ lemma quad_self_proj (T : MSSMACC.Sols) : quadBiLin T.val (proj T.1.1).val = (dot B₃.val T.val - dot Y₃.val T.val) * quadBiLin Y₃.val T.val + (dot Y₃.val T.val - 2 * dot B₃.val T.val) * quadBiLin B₃.val T.val := by - rw [proj_val] - rw [quadBiLin.map_add₂, quadBiLin.map_add₂] + rw [proj_val, quadBiLin.map_add₂, quadBiLin.map_add₂] rw [quadBiLin.map_smul₂, quadBiLin.map_smul₂, quadBiLin.map_smul₂] rw [← quadBiLin.toHomogeneousQuad_apply] rw [← accQuad] @@ -118,8 +114,7 @@ set_option backward.isDefEq.respectTransparency false in lemma cube_proj_proj_Y₃ (T : MSSMACC.LinSols) : cubeTriLin (proj T).val (proj T).val Y₃.val = (dot Y₃.val B₃.val)^2 * cubeTriLin T.val T.val Y₃.val := by - rw [proj_val] - rw [cubeTriLin.map_add₁, cubeTriLin.map_add₂] + rw [proj_val, cubeTriLin.map_add₁, cubeTriLin.map_add₂] conv_lhs => enter [1, 1] change ((cubeTriLin (lineY₃B₃ _ _).val) (lineY₃B₃ _ _).val) _ From 269347fe8a29f42e45c5a12e7a6b2ab54b0e2c32 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:17:17 -0700 Subject: [PATCH 202/498] refactor: golf MSSM cube projection proofs Co-authored-by: Claude Opus 4.8 --- .../MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean | 6 ++---- .../AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean | 3 +-- .../MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean index 8662b312b..475c8ce0b 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/Basic.lean @@ -139,8 +139,7 @@ set_option backward.isDefEq.respectTransparency false in lemma cube_proj_proj_B₃ (T : MSSMACC.LinSols) : cubeTriLin (proj T).val (proj T).val B₃.val = (dot Y₃.val B₃.val)^2 * cubeTriLin T.val T.val B₃.val := by - rw [proj_val] - rw [cubeTriLin.map_add₁, cubeTriLin.map_add₂] + rw [proj_val, cubeTriLin.map_add₁, cubeTriLin.map_add₂] rw [← lineY₃B₃_val, lineY₃B₃_doublePoint, lineY₃B₃_val] rw [cubeTriLin.map_add₂, cubeTriLin.swap₂, cubeTriLin.map_add₁, cubeTriLin.map_smul₁, cubeTriLin.map_smul₃, doublePoint_Y₃_B₃] @@ -158,8 +157,7 @@ lemma cube_proj_proj_self (T : MSSMACC.Sols) : 2 * dot Y₃.val B₃.val * ((dot B₃.val T.val - dot Y₃.val T.val) * cubeTriLin T.val T.val Y₃.val + (dot Y₃.val T.val - 2 * dot B₃.val T.val) * cubeTriLin T.val T.val B₃.val) := by - rw [proj_val] - rw [cubeTriLin.map_add₁, cubeTriLin.map_add₂] + rw [proj_val, cubeTriLin.map_add₁, cubeTriLin.map_add₂] rw [← lineY₃B₃_val, lineY₃B₃_doublePoint, lineY₃B₃_val] repeat rw [cubeTriLin.map_add₁] repeat rw [cubeTriLin.map_smul₁] diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean index f546a7a66..37c173052 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean @@ -66,8 +66,7 @@ set_option backward.isDefEq.respectTransparency false in lemma planeY₃B₃_quad (R : MSSMACC.AnomalyFreePerp) (a b c : ℚ) : accQuad (planeY₃B₃ R a b c).val = c * (2 * a * quadBiLin Y₃.val R.val + 2 * b * quadBiLin B₃.val R.val + c * quadBiLin R.val R.val) := by - rw [planeY₃B₃_val] - rw [accQuad, BiLinearSymm.toHomogeneousQuad_add] + rw [planeY₃B₃_val, accQuad, BiLinearSymm.toHomogeneousQuad_add] rw [← lineY₃B₃Charges_val, ← accQuad] rw [lineY₃B₃Charges_quad] rw [lineY₃B₃Charges_val, accQuad] diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean index f1d2b3469..d424426b1 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean @@ -152,8 +152,7 @@ lemma inCubeSolProp_iff_cubicCoeff_zero (T : MSSMACC.Sols) : lemma inCubeSolProp_iff_proj_inCubeProp (R : MSSMACC.Sols) : InCubeSolProp R ↔ InCubeProp (proj R.1.1) := by - rw [InCubeSolProp, InCubeProp] - rw [cube_proj, cube_proj_proj_Y₃, cube_proj_proj_B₃] + rw [InCubeSolProp, InCubeProp, cube_proj, cube_proj_proj_Y₃, cube_proj_proj_B₃] refine Iff.intro (fun h => ?_) (fun h => ?_) · rw [h.1, h.2] simp only [mul_zero, add_zero, and_self] @@ -199,8 +198,7 @@ def toSolNSQuad (R : MSSMACC.AnomalyFreePerp) : MSSMACC.QuadSols := lemma toSolNSQuad_cube (R : MSSMACC.AnomalyFreePerp) : accCube (toSolNSQuad R).val = 0 := by - rw [toSolNSQuad] - rw [lineQuad_val] + rw [toSolNSQuad, lineQuad_val] rw [planeY₃B₃_cubic] ring From 881309c75a8369bfb3ca1b94e014bf8b44443a0c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:20:03 -0700 Subject: [PATCH 203/498] refactor: golf supersymmetry map proofs Co-authored-by: Claude Opus 4.8 --- .../OrthogY3B3/PlaneWithY3B3.lean | 12 ++++-------- .../SuperSymmetry/SU5/ChargeSpectrum/Map.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean index 37c173052..9a57d775d 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean @@ -81,8 +81,7 @@ lemma planeY₃B₃_cubic (R : MSSMACC.AnomalyFreePerp) (a b c : ℚ) : accCube (planeY₃B₃ R a b c).val = c ^ 2 * (3 * a * cubeTriLin R.val R.val Y₃.val + 3 * b * cubeTriLin R.val R.val B₃.val + c * cubeTriLin R.val R.val R.val) := by - rw [planeY₃B₃_val] - rw [accCube, TriLinearSymm.toCubic_add, ← accCube] + rw [planeY₃B₃_val, accCube, TriLinearSymm.toCubic_add, ← accCube] rw [← lineY₃B₃Charges_val] rw [lineY₃B₃Charges_cubic] rw [TriLinearSymm.map_smul₃, lineY₃B₃Charges_val, ← lineY₃B₃_val] @@ -103,8 +102,7 @@ def lineQuadAFL (R : MSSMACC.AnomalyFreePerp) (c1 c2 c3 : ℚ) : MSSMACC.LinSols lemma lineQuadAFL_quad (R : MSSMACC.AnomalyFreePerp) (c1 c2 c3 : ℚ) : accQuad (lineQuadAFL R c1 c2 c3).val = 0 := by - rw [lineQuadAFL, planeY₃B₃_quad] - rw [mul_eq_zero] + rw [lineQuadAFL, planeY₃B₃_quad, mul_eq_zero] apply Or.inr ring @@ -145,8 +143,7 @@ lemma lineQuad_cube (R : MSSMACC.AnomalyFreePerp) (c₁ c₂ c₃ : ℚ) : accCube (lineQuad R c₁ c₂ c₃).val = - 4 * (c₁ * quadBiLin B₃.val R.val - c₂ * quadBiLin Y₃.val R.val) ^ 2 * (α₁ R * c₁ + α₂ R * c₂ + α₃ R * c₃) := by - rw [lineQuad_val] - rw [planeY₃B₃_cubic, α₁, α₂, α₃] + rw [lineQuad_val, planeY₃B₃_cubic, α₁, α₂, α₃] ring /-- The line in the plane spanned by `Y₃`, `B₃` and `R` which is in the cubic. -/ @@ -193,8 +190,7 @@ lemma α₂_proj (T : MSSMACC.Sols) : α₂ (proj T.1.1) = lemma α₁_proj (T : MSSMACC.Sols) : α₁ (proj T.1.1) = - α₃ (proj T.1.1) * (dot B₃.val T.val - dot Y₃.val T.val) := by - rw [α₃_proj, α₁] - rw [cube_proj_proj_B₃, quad_B₃_proj, quad_proj, cube_proj] + rw [α₃_proj, α₁, cube_proj_proj_B₃, quad_B₃_proj, quad_proj, cube_proj] ring lemma α₁_proj_zero (T : MSSMACC.Sols) (h1 : α₃ (proj T.1.1) = 0) : diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean index c38e78973..526bbcec0 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean @@ -222,8 +222,7 @@ lemma mem_map_ofPotentialTerm_iff [DecidableEq 𝓩] lemma mem_map_ofPotentialTerm'_iff[DecidableEq 𝓩] (f : 𝓩 →+ 𝓩1) (x : ChargeSpectrum 𝓩) (T : PotentialTerm) : i ∈ (ofPotentialTerm' (map f x) T) ↔ i ∈ (ofPotentialTerm' x T).map f := by - rw [← mem_ofPotentialTerm_iff_mem_ofPotentialTerm] - rw [mem_map_ofPotentialTerm_iff] + rw [← mem_ofPotentialTerm_iff_mem_ofPotentialTerm, mem_map_ofPotentialTerm_iff] simp only [Multiset.mem_map] constructor · intro ⟨a, h, h1⟩ From 9e0110650a826e86b4669aa3c70760f58e2e4804 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:23:22 -0700 Subject: [PATCH 204/498] refactor: golf foundational rewrite proofs Co-authored-by: Claude Opus 4.8 --- .../Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean | 6 ++---- Physlib/Mathematics/InnerProductSpace/Adjoint.lean | 3 +-- Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean | 3 +-- Physlib/Units/WithDim/Basic.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean index 271c8c3de..977e3f461 100644 --- a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean @@ -486,16 +486,14 @@ lemma sharp_flat_apply lemma apply_sharp_sharp (g : PseudoRiemannianMetric E H M n I) (x : M) (ω₁ ω₂ : TangentSpace I x →L[ℝ] ℝ) : g.val x (g.sharpL x ω₁) (g.sharpL x ω₂) = ω₁ (g.sharpL x ω₂) := by - rw [← flatL_apply g x (g.sharpL x ω₁)] - rw [flatL_apply_sharpL g x ω₁] + rw [← flatL_apply g x (g.sharpL x ω₁), flatL_apply_sharpL g x ω₁] /-- The metric evaluated at `v` and `sharp ω`. -/ lemma apply_vec_sharp (g : PseudoRiemannianMetric E H M n I) (x : M) (v : TangentSpace I x) (ω : TangentSpace I x →L[ℝ] ℝ) : g.val x v (g.sharpL x ω) = ω v := by - rw [g.symm x v (g.sharpL x ω)] - rw [← flatL_apply g x (g.sharpL x ω)] + rw [g.symm x v (g.sharpL x ω), ← flatL_apply g x (g.sharpL x ω)] rw [flatL_apply_sharpL g x ω] end Sharp diff --git a/Physlib/Mathematics/InnerProductSpace/Adjoint.lean b/Physlib/Mathematics/InnerProductSpace/Adjoint.lean index 9161b1fb2..28c70c14d 100644 --- a/Physlib/Mathematics/InnerProductSpace/Adjoint.lean +++ b/Physlib/Mathematics/InnerProductSpace/Adjoint.lean @@ -49,8 +49,7 @@ def adjoint (f : E → F) := lemma HasAdjoint.adjoint_inner_right {f : E → F} (hf : HasAdjoint 𝕜 f f') : ⟪x, f' y⟫ = ⟪f x, y⟫ := by - rw [← inner_conj_symm'] - rw [hf.adjoint_inner_left] + rw [← inner_conj_symm', hf.adjoint_inner_left] rw [inner_conj_symm'] open InnerProductSpace' in diff --git a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean index 66ce46b51..d1eccdbd0 100644 --- a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean +++ b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean @@ -69,8 +69,7 @@ set_option backward.isDefEq.respectTransparency false in The exponential of an element of the Lorentz algebra is a member of the Lorentz group. -/ theorem exp_mem_lorentzGroup (A : lorentzAlgebra) : NormedSpace.exp A.1 ∈ LorentzGroup 3 := by - rw [LorentzGroup.mem_iff_transpose_mul_minkowskiMatrix_mul_self] - rw [← Matrix.exp_transpose] + rw [LorentzGroup.mem_iff_transpose_mul_minkowskiMatrix_mul_self, ← Matrix.exp_transpose] rw [exp_transpose_of_mem_algebra A] calc (η * NormedSpace.exp (-A.1) * η) * η * NormedSpace.exp A.1 diff --git a/Physlib/Units/WithDim/Basic.lean b/Physlib/Units/WithDim/Basic.lean index 8d7dcf78e..d24934bff 100644 --- a/Physlib/Units/WithDim/Basic.lean +++ b/Physlib/Units/WithDim/Basic.lean @@ -170,8 +170,7 @@ lemma val_pow_two_eq_mul {d1 : Dimension} (m1 : WithDim d1 ℝ) : lemma scaleUnit_val_eq_scaleUnit_val {d : Dimension} (M : Type) [MulAction ℝ≥0 M] (u1 u2 : UnitChoices) (m1 m2 : WithDim d M) : (scaleUnit u1 u2 m1).val = (scaleUnit u1 u2 m2).val ↔ m1.val = m2.val := by - rw [← WithDim.ext_iff] - rw [scaleUnit_injective] + rw [← WithDim.ext_iff, scaleUnit_injective] exact WithDim.ext_iff lemma scaleUnit_val_eq_scaleUnit_val_of_dim_eq {d1 d2 : Dimension} {M : Type} [MulAction ℝ≥0 M] From 1a15fcfe3b4b32fcd6454d8cd17f653aa69f5a28 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:27:15 -0700 Subject: [PATCH 205/498] refactor: golf anomaly explicit proofs Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/Basic.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean index 9a3d6d45c..9ec3f3678 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean @@ -257,8 +257,7 @@ def quadBiLin : BiLinearSymm (SMνCharges n).Charges := BiLinearSymm.mk₂ lemma quadBiLin_decomp (S T : (SMνCharges n).Charges) : quadBiLin S T = ∑ i, Q S i * Q T i - 2 * ∑ i, U S i * U T i + ∑ i, D S i * D T i - ∑ i, L S i * L T i + ∑ i, E S i * E T i := by - rw [quadBiLin] - rw [BiLinearSymm.mk₂_toFun_apply] + rw [quadBiLin, BiLinearSymm.mk₂_toFun_apply] repeat rw [Finset.sum_add_distrib] repeat rw [← Finset.mul_sum] simp only [toSpecies_apply, Fin.isValue, neg_mul, one_mul, add_left_inj] @@ -324,8 +323,7 @@ lemma cubeTriLin_decomp (S T R : (SMνCharges n).Charges) : cubeTriLin S T R = 6 * ∑ i, (Q S i * Q T i * Q R i) + 3 * ∑ i, (U S i * U T i * U R i) + 3 * ∑ i, (D S i * D T i * D R i) + 2 * ∑ i, (L S i * L T i * L R i) + ∑ i, (E S i * E T i * E R i) + ∑ i, (N S i * N T i * N R i) := by - rw [cubeTriLin] - rw [TriLinearSymm.mk₃_toFun_apply_apply] + rw [cubeTriLin, TriLinearSymm.mk₃_toFun_apply_apply] repeat rw [Finset.sum_add_distrib] repeat rw [← Finset.mul_sum] diff --git a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean index eea9dde2b..537837d68 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean @@ -128,8 +128,7 @@ set_option backward.isDefEq.respectTransparency false in include hS in lemma boundary_accGrav'' (k : Fin n) (hk : Boundary S k) : accGrav n.succ S = (2 * ↑↑k + 1 - ↑n) * S (0 : Fin n.succ) := by - rw [boundary_accGrav' k] - rw [Fin.sum_univ_add] + rw [boundary_accGrav' k, Fin.sum_univ_add] have hfst (i : Fin k.succ.val) : S (Fin.cast (boundary_split k) (Fin.castAdd (n.succ - k.succ.val) i)) = S k.castSucc := by apply lt_eq hS (le_of_lt hk.left) (Fin.is_le i) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index af16adc78..80ff7bac3 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -599,8 +599,7 @@ lemma basis!_linearACC (j : Fin n) : (accGrav (2 * n.succ)) (basis!AsCharges j) lemma basis!_accCube (j : Fin n) : accCube (2 * n.succ) (basis!AsCharges j) = 0 := by - rw [accCube_explicit, sum_evenShift] - rw [basis!_on_evenShiftLast, basis!_on_evenShiftZero] + rw [accCube_explicit, sum_evenShift, basis!_on_evenShiftLast, basis!_on_evenShiftZero] simp only [ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow, add_zero, Function.comp_apply, zero_add] apply Finset.sum_eq_zero diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index fad015394..7cf007d86 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -935,8 +935,7 @@ lemma Pa'_elim_eq_iff (g g' : Fin n.succ → ℚ) (f f' : Fin n.succ → ℚ) : lemma Pa_eq (g g' : Fin n.succ → ℚ) (f f' : Fin n.succ → ℚ) : Pa g f = Pa g' f' ↔ g = g' ∧ f = f' := by - rw [← Pa'_elim_eq_iff] - rw [← Sum.elim_eq_iff] + rw [← Pa'_elim_eq_iff, ← Sum.elim_eq_iff] exact Pa'_eq _ _ /-! From 89961e0796e880656c3f3b54712512d1985e9653 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:31:49 -0700 Subject: [PATCH 206/498] refactor: golf electromagnetic wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Dynamics/IsExtrema.lean | 3 +-- Physlib/Electromagnetism/Dynamics/KineticTerm.lean | 3 +-- Physlib/Electromagnetism/Kinematics/GaugeTransformation.lean | 3 +-- Physlib/Electromagnetism/Kinematics/VectorPotential.lean | 3 +-- Physlib/Electromagnetism/Vacuum/Constant.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean index 9e2502a51..8c329e9d3 100644 --- a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean @@ -233,8 +233,7 @@ lemma isExtrema_iff_gauss_ampere_magneticFieldMatrix {d} {𝓕 : FreeSpace} IsExtrema 𝓕 A J ↔ ∀ t, ∀ x, (∇ ⬝ (A.electricField 𝓕.c t)) x = J.chargeDensity 𝓕.c t x / 𝓕.ε₀ ∧ ∀ i, 𝓕.μ₀ * 𝓕.ε₀ * ∂ₜ (fun t => A.electricField 𝓕.c t x) t i = ∑ j, ∂[j] (A.magneticFieldMatrix 𝓕.c t · (j, i)) x - 𝓕.μ₀ * J.currentDensity 𝓕.c t x i := by - rw [isExtrema_iff_gradLagrangian] - rw [funext_iff] + rw [isExtrema_iff_gradLagrangian, funext_iff] conv_lhs => enter [x] rw [gradLagrangian_eq_electricField_magneticField (𝓕 := 𝓕) A hA J hJ] diff --git a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean index b168c38e7..73f98f4f7 100644 --- a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean @@ -121,8 +121,7 @@ lemma kineticTerm_eq_sum {d} {𝓕 : FreeSpace} (A : ElectromagneticPotential d) (Lorentz.CoVector.basis.tensorProduct Lorentz.Vector.basis).repr (A.toFieldStrength x) (μ, ν) * (Lorentz.CoVector.basis.tensorProduct Lorentz.Vector.basis).repr (A.toFieldStrength x) (μ', ν') := by - rw [kineticTerm] - rw [toField_eq_repr] + rw [kineticTerm, toField_eq_repr] rw [contrT_basis_repr_apply_eq_fin] conv_lhs => enter [2, 2, μ] diff --git a/Physlib/Electromagnetism/Kinematics/GaugeTransformation.lean b/Physlib/Electromagnetism/Kinematics/GaugeTransformation.lean index c3c1cc631..bd75d39ed 100644 --- a/Physlib/Electromagnetism/Kinematics/GaugeTransformation.lean +++ b/Physlib/Electromagnetism/Kinematics/GaugeTransformation.lean @@ -104,8 +104,7 @@ lemma ofGradient_apply_sum {d} (χ : SpaceTime d → ℝ) (x : SpaceTime d) (μ only the `κ = μ` term survives. -/ lemma ofGradient_apply {d} (χ : SpaceTime d → ℝ) (x : SpaceTime d) (μ : Fin 1 ⊕ Fin d) : ofGradient χ x μ = η μ μ * ∂_ μ χ x := by - rw [ofGradient_apply_sum] - rw [Finset.sum_eq_single μ] + rw [ofGradient_apply_sum, Finset.sum_eq_single μ] · intro κ _ hκ rw [minkowskiMatrix.off_diag_zero (Ne.symm hκ)] simp diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index 9e60efa1a..a68244ddf 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -197,8 +197,7 @@ lemma vectorPotential_inner_radial_eq_zero_ofElectromagneticField {c : SpeedOfLight} {E B : Time → Space 3 → EuclideanSpace ℝ (Fin 3)} {t : Time} {x : Space 3} {a : ℝ} (hB : Continuous ↿B) : ⟪(ofElectromagneticField c E B).vectorPotential c t (a • x), Space.basis.repr x⟫_ℝ = 0 := by - rw [real_inner_comm] - rw [PiLp.inner_apply] + rw [real_inner_comm, PiLp.inner_apply] have h1 (a b : ℝ) : ⟪a, b⟫_ℝ = b * a := rfl simp only [Space.basis_repr_apply, ofElectromagneticField_vectorPotential_apply_eq_expand hB, Fin.isValue, Space.smul_apply, h1, Fin.sum_univ_three, zero_add, Fin.reduceAdd] diff --git a/Physlib/Electromagnetism/Vacuum/Constant.lean b/Physlib/Electromagnetism/Vacuum/Constant.lean index 9ba469e90..4a83b75c6 100644 --- a/Physlib/Electromagnetism/Vacuum/Constant.lean +++ b/Physlib/Electromagnetism/Vacuum/Constant.lean @@ -166,8 +166,7 @@ lemma constantEB_vectorPotential_space_deriv {c : SpeedOfLight} {B₀_antisymm : ∀ i j, B₀ (i, j) = - B₀ (j, i)} (t : Time) (x : Space d) (i j : Fin d) : Space.deriv i ((constantEB c E₀ B₀ B₀_antisymm).vectorPotential c t · j) x = (1 / 2) * B₀ (j, i) := by - rw [constantEB_vectorPotential] - rw [Space.deriv_eq] + rw [constantEB_vectorPotential, Space.deriv_eq] rw [fderiv_const_mul (by fun_prop)] rw [fderiv_fun_sum (by fun_prop)] simp only [one_div, FunLike.coe_smul, FunLike.coe_sum, Pi.smul_apply, From 07d13c1a649fcbc8c7ad0bb5fa65b4c00c487ab3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:36:53 -0700 Subject: [PATCH 207/498] refactor: golf particle mechanics wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean | 3 +-- Physlib/Particles/FlavorPhysics/CKMMatrix/PhaseFreedom.lean | 3 +-- Physlib/Particles/StandardModel/HiggsBoson/Basic.lean | 3 +-- Physlib/Particles/SuperSymmetry/N1/Basic.lean | 3 +-- .../OneDimension/HarmonicOscillator/Completeness.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 1c89dde65..9945afe1e 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -166,8 +166,7 @@ decreasing at that time. -/ lemma energy_not_conserved (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (t : Time) (h1 : S.EquationOfMotion xₜ) (hx : ContDiff ℝ ∞ xₜ) (hdx : ∂ₜ xₜ t ≠ 0) (hγ : 0 < S.γ) : ∂ₜ (S.energy xₜ) t < 0 := by - rw [energy_dissipation_rate S xₜ t h1 hx] - rw [neg_mul] + rw [energy_dissipation_rate S xₜ t h1 hx, neg_mul] exact neg_neg_of_pos (mul_pos hγ (real_inner_self_pos.mpr hdx)) /-! diff --git a/Physlib/Particles/FlavorPhysics/CKMMatrix/PhaseFreedom.lean b/Physlib/Particles/FlavorPhysics/CKMMatrix/PhaseFreedom.lean index 36dba588d..a454c85b4 100644 --- a/Physlib/Particles/FlavorPhysics/CKMMatrix/PhaseFreedom.lean +++ b/Physlib/Particles/FlavorPhysics/CKMMatrix/PhaseFreedom.lean @@ -97,8 +97,7 @@ lemma shift_tb_phase_zero {V : CKMMatrix} (h1 : t + b = - arg [V]tb) : lemma shift_cd_phase_pi {V : CKMMatrix} (h1 : c + d = Real.pi - arg [V]cd) : [phaseShiftApply V u c t d s b]cd = - VcdAbs ⟦V⟧ := by - rw [phaseShiftApply.cd] - rw [← norm_mul_exp_arg_mul_I [V]cd] + rw [phaseShiftApply.cd, ← norm_mul_exp_arg_mul_I [V]cd] rw [mul_comm, mul_assoc, ← exp_add] have h2 : ↑(arg [V]cd) * I + (↑c * I + ↑d * I) = ↑(arg [V]cd + (c + d)) * I := by simp only [Fin.isValue, ofReal_add] diff --git a/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean b/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean index 5a647eab3..a455bc03d 100644 --- a/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean +++ b/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean @@ -176,8 +176,7 @@ lemma gaugeGroupI_smul_eq_U1_mul_SU2 (g : StandardModel.GaugeGroupI) (φ : Higgs lemma gaugeGroupI_smul_eq_U1_smul_SU2 (g : StandardModel.GaugeGroupI) (φ : HiggsVec) : g • φ = (WithLp.toLp 2 <| (g.toU1 ^ 3 • g.toSU2.1) *ᵥ φ.ofLp) := by - rw [gaugeGroupI_smul_eq] - rw [Matrix.smul_mulVec] + rw [gaugeGroupI_smul_eq, Matrix.smul_mulVec] instance : MulAction StandardModel.GaugeGroupI HiggsVec where one_smul φ := by simp [gaugeGroupI_smul_eq] diff --git a/Physlib/Particles/SuperSymmetry/N1/Basic.lean b/Physlib/Particles/SuperSymmetry/N1/Basic.lean index 30c27e517..f7cd6350b 100644 --- a/Physlib/Particles/SuperSymmetry/N1/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/N1/Basic.lean @@ -413,8 +413,7 @@ def conjChiralCovector `toField`. -/ lemma toField_conjScalar (t : (chiralTensor (ι := ι)).Tensor ![]) : (conjScalar t).toField = star t.toField := by - rw [conjScalar, toField_permT] - rw [toField_eq_repr, toField_eq_repr] + rw [conjScalar, toField_permT, toField_eq_repr, toField_eq_repr] change componentMap (S := (chiralTensor (ι := ι)).toTensorSpecies) ((chiralTensor (ι := ι)).bar ∘ ![]) ((chiralTensor (ι := ι)).conjT t) (fun j => Fin.elim0 j) = star ((basis (S := (chiralTensor (ι := ι)).toTensorSpecies) ![]).repr t (fun j => Fin.elim0 j)) diff --git a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean index 4501e523e..8009ddc91 100644 --- a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean +++ b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean @@ -142,8 +142,7 @@ lemma mul_power_integrable (f : ℝ → ℂ) (hf : MemHS f) (r : ℕ) : lemma orthogonal_eigenfunction_of_mem_orthogonal (f : ℝ → ℂ) (hf : MemHS f) (hOrth : ∀ n : ℕ, ⟪HilbertSpace.mk (Q.eigenfunction_memHS n), HilbertSpace.mk hf⟫_ℂ = 0) (n : ℕ) : ∫ (x : ℝ), Q.eigenfunction n x * f x = 0 := by - rw [← hOrth n] - rw [inner_mk_mk] + rw [← hOrth n, inner_mk_mk] simp local notation "m" => Q.m From 406097e9279dbddac9a95c5188a924624f74331b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:50:44 -0700 Subject: [PATCH 208/498] refactor: golf relative entropy projection proof Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 30aa67418..9d50c7581 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -283,10 +283,8 @@ lemma HermitianMat.supportProj_mul_self (A : HermitianMat d ℂ) : have h_supportProj_mul_A : ∀ (v : EuclideanSpace ℂ d), v ∈ LinearMap.range A.val.toEuclideanLin → (A.supportProj.val.toEuclideanLin v) = v := by intro v hv have h_supportProj_mul_A : (A.supportProj.val.toEuclideanLin v) = (Submodule.orthogonalProjectionOnto (LinearMap.range A.val.toEuclideanLin) v) := by - simp only [val_eq_coe, Submodule.coe_orthogonalProjectionOnto_apply] + simp only [val_eq_coe] simp [supportProj, projector] - simp only [Submodule.starProjection] - simp have key : ∀ (f : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d), Matrix.toEuclideanLin ((LinearMap.toMatrix (EuclideanSpace.basisFun d ℂ).toBasis (EuclideanSpace.basisFun d ℂ).toBasis) f) = f := by From 90316edc8b9494a1922b7e16429e7c7d35ab5cda Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 18:55:27 -0700 Subject: [PATCH 209/498] refactor: golf pinching channel unfold proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Pinching.lean | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 4dfe03eca..8d529f9ed 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -44,7 +44,7 @@ theorem pinching_kraus_commutes (ρ : MState d) (i : spectrum ℝ ρ.m) : theorem pinching_kraus_mul_self (ρ : MState d) (i : spectrum ℝ ρ.m) : (pinching_kraus ρ i).mat * ρ.m = i.val • pinching_kraus ρ i := by - dsimp [MState.m] + unfold MState.m nth_rw 1 [← ρ.M.cfc_id] rw [pinching_kraus] rw [← ρ.M.mat_cfc_mul, ← HermitianMat.mat_smul] @@ -123,7 +123,8 @@ theorem pinching_commutes_kraus (σ ρ : MState d) (i : spectrum ℝ σ.m) : theorem pinching_commutes (ρ σ : MState d) : Commute (pinching_map σ ρ).m σ.m := by - dsimp [MState.m, Commute, SemiconjBy] + rw [commute_iff_eq] + change (pinching_map σ ρ).M.mat * σ.M.mat = σ.M.mat * (pinching_map σ ρ).M.mat rw [pinchingMap_apply_M] simp only [MatrixMap.of_kraus, Function.comp_apply] simp only [HermitianMat.conjTranspose_mat, MState.mat_M, LinearMap.coe_sum, @@ -190,7 +191,7 @@ theorem pinching_bound (ρ σ : MState d) : ρ.M ≤ (↑(Fintype.card (spectrum simp only [HermitianMat.mat_finset_sum] simp only [Matrix.mul_sum, Matrix.sum_mul, Matrix.sum_mulVec, dotProduct_sum] simp only [MState.pure] - dsimp [MState.m] + unfold MState.m --This out to be Cauchy-Schwarz. have hschwarz := inner_mul_inner_self_le (𝕜 := ℂ) (E := EuclideanSpace ℂ (↑(spectrum ℝ σ.m))) (x := .toLp 2 fun i ↦ 1) (y := .toLp 2 fun k ↦ ( From 0562c92a3f174e1de8cee348d8aa1eceab56b2a9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:02:19 -0700 Subject: [PATCH 210/498] refactor: golf Steins lemma rewrite proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ResourceTheory/SteinsLemma.lean | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/QuantumInfo/ResourceTheory/SteinsLemma.lean b/QuantumInfo/ResourceTheory/SteinsLemma.lean index f16c81b09..96d273d3b 100644 --- a/QuantumInfo/ResourceTheory/SteinsLemma.lean +++ b/QuantumInfo/ResourceTheory/SteinsLemma.lean @@ -456,8 +456,8 @@ private lemma rexp_mul_smul_proj_lt_mul_sub_le_mul_sub {n : ℕ} {x : ℝ} dsimp gcongr apply Matrix.PosSemidef.trace_mono - rw [one_div, HermitianMat.mat_smul, smul_mul_assoc, mul_smul_comm] - rw [inv_smul_le_iff_of_pos (mod_cast hn), HermitianMat.mat_smul] + rw [one_div, smul_mul_assoc, mul_smul_comm] + rw [inv_smul_le_iff_of_pos (mod_cast hn)] rw [mul_smul_comm] obtain ⟨C, ⟨f, hf⟩, ⟨g, hg⟩⟩ := hℰσ.exists_HermitianMat_cfc rw [hf, hg] at hE ⊢ @@ -855,7 +855,7 @@ private theorem hσ₁_le_σ' : (1 / 3 : ℝ) • ((σ₁ i) ⊗ᵣ^[n]).M ≤ ( positivity private theorem σ''_unnormalized_PosDef : Matrix.PosDef (σ''_unnormalized ρ ε m σ n).mat := by - dsimp [σ''_unnormalized] + change Matrix.PosDef (((σ' ρ ε m σ n).M.cfc fun e ↦ Real.exp (f_map i n e)).mat) rw [HermitianMat.cfc_posDef] intro positivity @@ -1237,7 +1237,7 @@ private theorem EquationS62 dsimp [σ₁_mineig, iInf] rw [← Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues] rw [← Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues] - rw [MState.mat_M, sInf_spectrum_spacePow (σ₁ i) n, MState.mat_M, smul_smul] + rw [sInf_spectrum_spacePow (σ₁ i) n, smul_smul] _ = Real.exp (- n * (σ₁_c i n + (σ₁_c i n) / n)) • 1 := by rw [σ₁_c_identity i hn] _ ≥ Real.exp (-n * c' ε2 n) • 1 := by @@ -1856,10 +1856,12 @@ theorem Lemma7 (ρ : MState (H i)) {ε : Prob} (hε : 0 < ε ∧ ε < 1) (σ : ( dsimp [σ₁_mineig, iInf] rw [← Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues] rw [← Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues] - rw [HermitianMat.val_eq_coe, HermitianMat.mat_smul] - rw [spectrum.smul_eq_smul _ _ (ContinuousFunctionalCalculus.spectrum_nonempty _ ((σ₁ i) ⊗ᵣ^[n]).M.H)] + change sInf (spectrum ℝ (σ₁ i).m) ^ n / 3 ≤ + sInf (spectrum ℝ ((1 / 3 : ℝ) • ((σ₁ i) ⊗ᵣ^[n]).m)) + rw [spectrum.smul_eq_smul _ _ + (ContinuousFunctionalCalculus.spectrum_nonempty _ ((σ₁ i) ⊗ᵣ^[n]).Hermitian)] rw [Real.sInf_smul_of_nonneg (by norm_num)] - simp [MState.mat_M, div_eq_inv_mul, sInf_spectrum_spacePow] + simp [div_eq_inv_mul, sInf_spectrum_spacePow] have hdpos n : 0 < Fintype.card (spectrum ℝ (σ'' ρ ε m σ n).m) := by rw [Fintype.card_pos_iff, Set.nonempty_coe_sort] From c5a6a0b1bb53e180ea32c7a4eda17ccf2afd4696 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:07:51 -0700 Subject: [PATCH 211/498] refactor: golf field op statistic witnesses Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/SuperCommute.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 6728e7289..6fde2f861 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -717,29 +717,25 @@ lemma superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic (φs φs' : Lis [ofCrAnListF φs, ofCrAnListF φs']ₛF ∈ statisticSubmodule fermionic := by by_cases h1 : (𝓕 |>ₛ φs) = bosonic <;> by_cases h2 : (𝓕 |>ₛ φs') = bosonic · left - have h : bosonic = bosonic + bosonic := by - rfl + have h : bosonic = bosonic + bosonic := rfl rw [h] apply superCommuteF_grade apply ofCrAnListF_mem_statisticSubmodule_of _ _ h1 apply ofCrAnListF_mem_statisticSubmodule_of _ _ h2 · right - have h : fermionic = bosonic + fermionic := by - rfl + have h : fermionic = bosonic + fermionic := rfl rw [h] apply superCommuteF_grade apply ofCrAnListF_mem_statisticSubmodule_of _ _ h1 apply ofCrAnListF_mem_statisticSubmodule_of _ _ (by simpa using h2) · right - have h : fermionic = fermionic + bosonic := by - rfl + have h : fermionic = fermionic + bosonic := rfl rw [h] apply superCommuteF_grade apply ofCrAnListF_mem_statisticSubmodule_of _ _ (by simpa using h1) apply ofCrAnListF_mem_statisticSubmodule_of _ _ h2 · left - have h : bosonic = fermionic + fermionic := by - rfl + have h : bosonic = fermionic + fermionic := rfl rw [h] apply superCommuteF_grade apply ofCrAnListF_mem_statisticSubmodule_of _ _ (by simpa using h1) @@ -757,8 +753,7 @@ lemma superCommuteF_superCommuteF_ofCrAnOpF_bosonic_or_fermionic (φ1 φ2 φ3 : rcases superCommuteF_ofCrAnOpF_ofCrAnOpF_bosonic_or_fermionic φ2 φ3 with hs | hs <;> rcases ofCrAnOpF_bosonic_or_fermionic φ1 with h1 | h1 · left - have h : bosonic = bosonic + bosonic := by - rfl + have h : bosonic = bosonic + bosonic := rfl rw [h] apply superCommuteF_grade h1 hs · right From 181ccb736eb3c02564ef44ed217cf8972da186f4 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:08:58 -0700 Subject: [PATCH 212/498] refactor: golf field op grading witnesses Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/FieldOpFreeAlgebra/Grading.lean | 6 ++---- .../FieldOpFreeAlgebra/SuperCommute.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean index 4461e5354..90883aec7 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean @@ -348,15 +348,13 @@ lemma bosonicProjF_mul (a b : 𝓕.FieldOpFreeAlgebra) : right rw [bosonicProjF_of_mem_bosonic _ (by - have h1 : bosonic = fermionic + fermionic := by - rfl + have h1 : bosonic = fermionic + fermionic := rfl conv_lhs => rw [h1] apply fieldOpFreeAlgebraGrade.mul_mem simp only [SetLike.coe_mem] simp)] simp only [ZeroMemClass.coe_zero, add_zero, zero_add] - · have h1 : bosonic = bosonic + bosonic := by - rfl + · have h1 : bosonic = bosonic + bosonic := rfl conv_lhs => rw [h1] apply fieldOpFreeAlgebraGrade.mul_mem simp only [SetLike.coe_mem] diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 6fde2f861..577203c67 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -757,18 +757,15 @@ lemma superCommuteF_superCommuteF_ofCrAnOpF_bosonic_or_fermionic (φ1 φ2 φ3 : rw [h] apply superCommuteF_grade h1 hs · right - have h : fermionic = fermionic + bosonic := by - rfl + have h : fermionic = fermionic + bosonic := rfl rw [h] apply superCommuteF_grade h1 hs · right - have h : fermionic = bosonic + fermionic := by - rfl + have h : fermionic = bosonic + fermionic := rfl rw [h] apply superCommuteF_grade h1 hs · left - have h : bosonic = fermionic + fermionic := by - rfl + have h : bosonic = fermionic + fermionic := rfl rw [h] apply superCommuteF_grade h1 hs From 365c69d3de4739490fc56316c387bee1437a43a8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:10:02 -0700 Subject: [PATCH 213/498] refactor: golf field op and matrix order proofs Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean | 6 ++---- .../PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean | 6 ++---- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean index 90883aec7..4d13b02f6 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean @@ -372,8 +372,7 @@ lemma fermionicProjF_mul (a b : 𝓕.FieldOpFreeAlgebra) : left rw [fermionicProjF_of_mem_bosonic _ (by - have h1 : bosonic = bosonic + bosonic := by - rfl + have h1 : bosonic = bosonic + bosonic := rfl conv_lhs => rw [h1] apply fieldOpFreeAlgebraGrade.mul_mem simp only [SetLike.coe_mem] @@ -403,8 +402,7 @@ lemma fermionicProjF_mul (a b : 𝓕.FieldOpFreeAlgebra) : right rw [fermionicProjF_of_mem_bosonic _ (by - have h1 : bosonic = fermionic + fermionic := by - rfl + have h1 : bosonic = fermionic + fermionic := rfl conv_lhs => rw [h1] apply fieldOpFreeAlgebraGrade.mul_mem simp only [SetLike.coe_mem] diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 577203c67..9dfdf870b 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -841,15 +841,13 @@ lemma statistic_ne_of_superCommuteF_fermionic {φs φs' : List 𝓕.CrAnFieldOp} by_contra hn refine h0 (eq_zero_of_bosonic_and_fermionic ?_ h) by_cases hc : (𝓕 |>ₛ φs) = bosonic - · have h1 : bosonic = bosonic + bosonic := by - rfl + · have h1 : bosonic = bosonic + bosonic := rfl rw [h1] apply superCommuteF_grade apply ofCrAnListF_mem_statisticSubmodule_of _ _ hc apply ofCrAnListF_mem_statisticSubmodule_of _ _ rw [← hn, hc] - · have h1 : bosonic = fermionic + fermionic := by - rfl + · have h1 : bosonic = fermionic + fermionic := rfl rw [h1] apply superCommuteF_grade apply ofCrAnListF_mem_statisticSubmodule_of _ _ diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 22ec226eb..0d9c7cbe7 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -31,8 +31,7 @@ instance : IsOrderedAddMonoid (HermitianMat n 𝕜) := inferInstanceAs (IsOrderedAddMonoid (selfAdjoint _)) omit [Fintype n] in -theorem le_iff : A ≤ B ↔ (B - A).mat.PosSemidef := by - rfl +theorem le_iff : A ≤ B ↔ (B - A).mat.PosSemidef := Iff.rfl omit [Fintype n] in theorem zero_le_iff : 0 ≤ A ↔ A.mat.PosSemidef := by From 449dc643211e8739d8db22203d5bf5f41677a6e8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:11:08 -0700 Subject: [PATCH 214/498] refactor: golf complex tensor unit symmetry proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Units/Symm.lean | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean index b3b8dc6ce..e0710f798 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean @@ -27,28 +27,28 @@ open TensorSpecies open Tensor /-- Swapping indices of `coContrUnit` returns `contrCoUnit`: `{δ' | μ ν = δ | ν μ}ᵀ`. -/ -lemma coContrUnit_symm : {δ' | μ ν = δ | ν μ}ᵀ := by - exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.up +lemma coContrUnit_symm : {δ' | μ ν = δ | ν μ}ᵀ := + unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.up /-- Swapping indices of `contrCoUnit` returns `coContrUnit`: `{δ | μ ν = δ' | ν μ}ᵀ`. -/ -lemma contrCoUnit_symm : {δ | μ ν = δ' | ν μ}ᵀ := by - exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.down +lemma contrCoUnit_symm : {δ | μ ν = δ' | ν μ}ᵀ := + unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.down /-- Swapping indices of `dualLeftLeftUnit` returns `leftDualLeftUnit`: `{δL' | α α' = δL | α' α}ᵀ`. -/ -lemma dualLeftLeftUnit_symm : {δL' | α α' = δL | α' α}ᵀ := by - exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.upL +lemma dualLeftLeftUnit_symm : {δL' | α α' = δL | α' α}ᵀ := + unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.upL /-- Swapping indices of `leftDualLeftUnit` returns `dualLeftLeftUnit`: `{δL | α α' = δL' | α' α}ᵀ`. -/ -lemma leftDualLeftUnit_symm : {δL | α α' = δL' | α' α}ᵀ := by - exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.downL +lemma leftDualLeftUnit_symm : {δL | α α' = δL' | α' α}ᵀ := + unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.downL /-- Swapping indices of `dualRightRightUnit` returns `rightDualRightUnit`: `{δR' | β β' = δR | β' β}ᵀ`. -/ -lemma dualRightRightUnit_symm : {δR' | β β' = δR | β' β}ᵀ := by - exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.upR +lemma dualRightRightUnit_symm : {δR' | β β' = δR | β' β}ᵀ := + unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.upR /-- Swapping indices of `rightDualRightUnit` returns `dualRightRightUnit`: `{δR | β β' = δR' | β' β}ᵀ`. From ab925f96b520e62f86e8ae17913108a8f81ebb96 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:13:49 -0700 Subject: [PATCH 215/498] refactor: golf Wick and tensor wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean | 4 ++-- .../QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean | 8 ++++---- Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean | 4 ++-- .../Tensors/RealTensor/Vector/MinkowskiProduct.lean | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean index b91e23ea7..1c4599fd0 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean @@ -72,8 +72,8 @@ instance : Coe (𝓕.FieldOpFreeAlgebra) (𝓕.WickAlgebra) := instance : Setoid (FieldOpFreeAlgebra 𝓕) := (TwoSidedIdeal.span 𝓕.fieldOpIdealSet).ringCon.toSetoid lemma equiv_iff_sub_mem_ideal (x y : FieldOpFreeAlgebra 𝓕) : - x ≈ y ↔ x - y ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet := by - exact (TwoSidedIdeal.span 𝓕.fieldOpIdealSet).rel_iff x y + x ≈ y ↔ x - y ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet := + (TwoSidedIdeal.span 𝓕.fieldOpIdealSet).rel_iff x y lemma equiv_iff_exists_add (x y : FieldOpFreeAlgebra 𝓕) : x ≈ y ↔ ∃ a, x = y + a ∧ a ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet := by diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 210cd6206..6d443ed25 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -187,8 +187,8 @@ lemma superCommute_ofCrAnOp_ofCrAnOp_mem_center (φ φ' : 𝓕.CrAnFieldOp) : lemma superCommute_ofCrAnOp_ofCrAnOp_commute (φ φ' : 𝓕.CrAnFieldOp) (a : WickAlgebra 𝓕) : - a * [ofCrAnOp φ, ofCrAnOp φ']ₛ = [ofCrAnOp φ, ofCrAnOp φ']ₛ * a := by - exact (Subalgebra.mem_center_iff.mp (superCommute_ofCrAnOp_ofCrAnOp_mem_center φ φ')) a + a * [ofCrAnOp φ, ofCrAnOp φ']ₛ = [ofCrAnOp φ, ofCrAnOp φ']ₛ * a := + (Subalgebra.mem_center_iff.mp (superCommute_ofCrAnOp_ofCrAnOp_mem_center φ φ')) a lemma superCommute_ofCrAnOp_ofFieldOp_mem_center (φ : 𝓕.CrAnFieldOp) (φ' : 𝓕.FieldOp) : [ofCrAnOp φ, ofFieldOp φ']ₛ ∈ Subalgebra.center ℂ (WickAlgebra 𝓕) := by @@ -200,8 +200,8 @@ lemma superCommute_ofCrAnOp_ofFieldOp_mem_center (φ : 𝓕.CrAnFieldOp) (φ' : lemma superCommute_ofCrAnOp_ofFieldOp_commute (φ : 𝓕.CrAnFieldOp) (φ' : 𝓕.FieldOp) (a : WickAlgebra 𝓕) : a * [ofCrAnOp φ, ofFieldOp φ']ₛ = - [ofCrAnOp φ, ofFieldOp φ']ₛ * a := by - exact (Subalgebra.mem_center_iff.mp (superCommute_ofCrAnOp_ofFieldOp_mem_center φ φ')) a + [ofCrAnOp φ, ofFieldOp φ']ₛ * a := + (Subalgebra.mem_center_iff.mp (superCommute_ofCrAnOp_ofFieldOp_mem_center φ φ')) a lemma superCommute_anPart_ofFieldOp_mem_center (φ φ' : 𝓕.FieldOp) : [anPart φ, ofFieldOp φ']ₛ ∈ Subalgebra.center ℂ (WickAlgebra 𝓕) := by diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean index e0710f798..c8eca1e95 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Symm.lean @@ -53,7 +53,7 @@ lemma dualRightRightUnit_symm : {δR' | β β' = δR | β' β}ᵀ := /-- Swapping indices of `rightDualRightUnit` returns `dualRightRightUnit`: `{δR | β β' = δR' | β' β}ᵀ`. -/ -lemma rightDualRightUnit_symm : {δR | β β' = δR' | β' β}ᵀ := by - exact unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.downR +lemma rightDualRightUnit_symm : {δR | β β' = δR' | β' β}ᵀ := + unitTensor_eq_permT_dual (S := complexLorentzTensor) Color.downR end complexLorentzTensor diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean index a699c33fc..1c96f0e77 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean @@ -126,8 +126,8 @@ lemma minkowskiProduct_apply {d : ℕ} (p q : Vector d) : ⟪p, q⟫ₘ = minkowskiProductMap p q := rfl lemma minkowskiProduct_symm {d : ℕ} (p q : Vector d) : - ⟪p, q⟫ₘ = ⟪q, p⟫ₘ := by - exact minkowskiProductMap_symm p q + ⟪p, q⟫ₘ = ⟪q, p⟫ₘ := + minkowskiProductMap_symm p q lemma minkowskiProduct_toCoord {d : ℕ} (p q : Vector d) : ⟪p, q⟫ₘ = p (Sum.inl 0) * q (Sum.inl 0) - ∑ i, p (Sum.inr i) * q (Sum.inr i) := by From 916a97a06226b5aa81e7db7b20a55f104700992c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:15:11 -0700 Subject: [PATCH 216/498] refactor: golf tensor and Wick wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Fin.lean | 4 ++-- .../PerturbationTheory/FieldSpecification/CrAnSection.lean | 4 ++-- Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean | 4 ++-- Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean | 4 ++-- Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index cad4974eb..cc621c151 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -85,8 +85,8 @@ def finExtractOne {n : ℕ} (i : Fin (n + 1)) : Fin (n + 1) ≃ Fin 1 ⊕ Fin n @[simp] lemma finExtractOne_apply_eq {n : ℕ} (i : Fin n.succ) : - finExtractOne i i = Sum.inl 0 := by - exact (Equiv.apply_eq_iff_eq_symm_apply (finExtractOne i)).2 rfl + finExtractOne i i = Sum.inl 0 := + (Equiv.apply_eq_iff_eq_symm_apply (finExtractOne i)).2 rfl lemma finExtractOne_symm_inr {n : ℕ} (i : Fin n.succ) : (finExtractOne i).symm ∘ Sum.inr = i.succAbove := by diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 518d101b9..fa6fb2a83 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -204,8 +204,8 @@ lemma sum_cons (f : CrAnSection (φ :: φs) → M) [AddCommMonoid M] : lemma sum_over_length {s : CrAnSection φs} (f : Fin s.1.length → M) [AddCommMonoid M] : ∑ (n : Fin s.1.length), f n = - ∑ (n : Fin φs.length), f (Fin.cast (length_eq s).symm n) := by - exact Eq.symm (Equiv.sum_comp (finCongr (length_eq s)).symm f) + ∑ (n : Fin φs.length), f (Fin.cast (length_eq s).symm n) := + Eq.symm (Equiv.sum_comp (finCongr (length_eq s)).symm f) /-- The equivalence between `CrAnSection φs` and `CrAnSection φs'` induced by an equality `φs = φs'`. -/ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean index f48bfd8cc..0ff3bacfd 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean @@ -203,8 +203,8 @@ lemma join_singleton_sign_right {φs : List 𝓕.FieldOp} (joinSignRightExtra h φsucΛ) * (∏ a, 𝓢(𝓕|>ₛ [singleton h]ᵘᶜ[φsucΛ.sndFieldOfContract a], 𝓕|>ₛ ⟨φs.get, ((join (singleton h) φsucΛ).signFinset (uncontractedListEmd (φsucΛ.fstFieldOfContract a)) - (uncontractedListEmd (φsucΛ.sndFieldOfContract a)))⟩)) := by - exact sign_right_eq_prod_mul_prod (singleton h) φsucΛ + (uncontractedListEmd (φsucΛ.sndFieldOfContract a)))⟩)) := + sign_right_eq_prod_mul_prod (singleton h) φsucΛ lemma joinSignRightExtra_eq_i_j_finset_eq_if {φs : List 𝓕.FieldOp} {i j : Fin φs.length} (h : i < j) (φsucΛ : WickContraction [singleton h]ᵘᶜ.length) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean index 583fe605e..e7e2ff315 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean @@ -742,8 +742,8 @@ lemma dualLeftDualRightToMatrix_ρ_symm_selfAdjoint (v : Matrix (Fin 2) (Fin 2) lemma leftRightToMatrix_ρ_symm_selfAdjoint (v : Matrix (Fin 2) (Fin 2) ℂ) (hv : IsSelfAdjoint v) (M : SL(2,ℂ)) : TensorProduct.map (leftHandedRep M) (rightHandedRep M) (leftRightToMatrix.symm v) = - leftRightToMatrix.symm (SL2C.toSelfAdjointMap M ⟨v, hv⟩) := by - exact leftRightToMatrix_ρ_symm v M + leftRightToMatrix.symm (SL2C.toSelfAdjointMap M ⟨v, hv⟩) := + leftRightToMatrix_ρ_symm v M end end Fermion diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index e9b50bbba..ae6b139d0 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -239,8 +239,8 @@ lemma toSelfAdjoint_apply_coe (x : ContrMod 3) : (toSelfAdjoint x).1 = x.toFin1dℝ (Sum.inl 0) • PauliMatrix.pauliMatrix (Sum.inl 0) - x.toFin1dℝ (Sum.inr 0) • PauliMatrix.pauliMatrix (Sum.inr 0) - x.toFin1dℝ (Sum.inr 1) • PauliMatrix.pauliMatrix (Sum.inr 1) - - x.toFin1dℝ (Sum.inr 2) • PauliMatrix.pauliMatrix (Sum.inr 2) := by - exact congrArg Subtype.val (toSelfAdjoint_apply x) + - x.toFin1dℝ (Sum.inr 2) • PauliMatrix.pauliMatrix (Sum.inr 2) := + congrArg Subtype.val (toSelfAdjoint_apply x) lemma toSelfAdjoint_stdBasis (i : Fin 1 ⊕ Fin 3) : toSelfAdjoint (stdBasis i) = PauliMatrix.pauliBasis' i := by From 18289dd794490603bfe1ed7dab60df64d20a1e1a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:16:39 -0700 Subject: [PATCH 217/498] refactor: golf tensorial and linear map proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/LinearMaps.lean | 10 ++++------ .../QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 2 +- Physlib/Relativity/Tensors/Tensorial.lean | 6 ++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Physlib/Mathematics/LinearMaps.lean b/Physlib/Mathematics/LinearMaps.lean index 3c5eb067e..118c410c5 100644 --- a/Physlib/Mathematics/LinearMaps.lean +++ b/Physlib/Mathematics/LinearMaps.lean @@ -207,9 +207,8 @@ lemma swap₃ (f : TriLinearSymm V) (S T L : V) : f S T L = f L T S := by rw [f.swap₁, f.swap₂, f.swap₁] lemma map_smul₁ (f : TriLinearSymm V) (a : ℚ) (S T L : V) : - f (a • S) T L = a * f S T L := by - exact - (congrArg (fun g : V →ₗ[ℚ] V →ₗ[ℚ] ℚ => g T L) (f.map_smul a S)).trans (by rfl) + f (a • S) T L = a * f S T L := + (congrArg (fun g : V →ₗ[ℚ] V →ₗ[ℚ] ℚ => g T L) (f.map_smul a S)).trans rfl lemma map_smul₂ (f : TriLinearSymm V) (S : V) (a : ℚ) (T L : V) : f S (a • T) L = a * f S T L := by @@ -220,9 +219,8 @@ lemma map_smul₃ (f : TriLinearSymm V) (S T : V) (a : ℚ) (L : V) : rw [f.swap₃, f.map_smul₁, f.swap₃] lemma map_add₁ (f : TriLinearSymm V) (S1 S2 T L : V) : - f (S1 + S2) T L = f S1 T L + f S2 T L := by - exact - (congrArg (fun g : V →ₗ[ℚ] V →ₗ[ℚ] ℚ => g T L) (f.map_add S1 S2)).trans (by rfl) + f (S1 + S2) T L = f S1 T L + f S2 T L := + (congrArg (fun g : V →ₗ[ℚ] V →ₗ[ℚ] ℚ => g T L) (f.map_add S1 S2)).trans rfl lemma map_add₂ (f : TriLinearSymm V) (S T1 T2 L : V) : f S (T1 + T2) L = f S T1 L + f S T2 L := by diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 7cf007d86..1ab47f5d2 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -232,7 +232,7 @@ lemma oddShiftShiftSnd_eq_oddSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddSnd simp only [succ_eq_add_one, oddShiftShiftSnd, Fin.val_cast, Fin.val_natAdd, oddSnd, add_left_inj] exact Nat.add_comm 1 n -lemma oddShiftShiftSnd_eq_oddShiftSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddShiftSnd j := by +lemma oddShiftShiftSnd_eq_oddShiftSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddShiftSnd j := rfl lemma oddSnd_eq_oddShiftSnd (j : Fin n) : oddSnd j = oddShiftSnd j := by diff --git a/Physlib/Relativity/Tensors/Tensorial.lean b/Physlib/Relativity/Tensors/Tensorial.lean index 8df05a360..1f83952f8 100644 --- a/Physlib/Relativity/Tensors/Tensorial.lean +++ b/Physlib/Relativity/Tensors/Tensorial.lean @@ -108,8 +108,7 @@ noncomputable instance self {n : ℕ} (S : TensorSpecies k C G V basisIdx rep b) @[simp] lemma self_toTensor_apply {n : ℕ} (S : TensorSpecies k C G V basisIdx rep b) (c : Fin n → C) (t : S.Tensor c) : - Tensorial.toTensor t = t := by - rfl + Tensorial.toTensor t = t := rfl /-! @@ -150,8 +149,7 @@ noncomputable instance mulAction [Tensorial S c M] : MulAction G M where -/ lemma smul_eq {g : G} {t : M} [Tensorial S c M] : - g • t = toTensor.symm (g • toTensor t) := by - rfl + g • t = toTensor.symm (g • toTensor t) := rfl lemma toTensor_smul {g : G} {t : M} [Tensorial S c M] : toTensor (g • t) = g • toTensor t := by From 199764dcdd8c0d1d48bf6d885dc9b368951d9542 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:19:29 -0700 Subject: [PATCH 218/498] refactor: golf linear and spectrum wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean | 3 +-- Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean | 8 +++----- .../TraceInequality/JensenOperatorInequality.lean | 7 +++---- .../TraceInequality/JensenOperatorInequalityIImpIV.lean | 7 +++---- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 5 ++--- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean index 400e78c19..be9572a62 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean @@ -72,8 +72,7 @@ lemma sum_of_vectors {n : ℕ} (f : Fin k → (PureU1 n).LinSols) (j : Fin n) : noncomputable def coordinateMap : (PureU1 n.succ).LinSols ≃ₗ[ℚ] Fin n →₀ ℚ where toFun S := (Finsupp.linearEquivFunOnFinite ℚ ℚ (Fin n)).symm (S.1 ∘ Fin.castSucc) - map_add' S T := by - exact map_add _ _ _ + map_add' S T := map_add _ _ _ map_smul' a S := by rw [← map_smul] rfl diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean index c37458412..d1a5600c9 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Action.lean @@ -136,11 +136,9 @@ transport of `toAffineIsometryMulEquiv` acting on `EuclideanSpace`: lemma chartEuclidean_smul (g : EuclideanGroup d) (p : Space d) : Space.chartEuclidean d (g • p) = toAffineIsometryMulEquiv g (Space.chartEuclidean d p) := by rw [Space.chartEuclidean_apply, toAffineIsometryMulEquiv_apply, toAffineIsometryHom_apply] - have h_left : g • p -ᵥ (0 : Space d) = g.linear • (p -ᵥ (0 : Space d)) + g.translation := by - exact - (eq_vadd_iff_vsub_eq (g • p) (g.linear • (p -ᵥ (0 : Space d)) + g.translation) - ((0 : Space d))).mp - rfl + have h_left : g • p -ᵥ (0 : Space d) = g.linear • (p -ᵥ (0 : Space d)) + g.translation := + (eq_vadd_iff_vsub_eq (g • p) (g.linear • (p -ᵥ (0 : Space d)) + g.translation) + ((0 : Space d))).mp rfl simp [h_left] exact add_comm' (g.linear • (p -ᵥ (0 : Space d))) g.translation end EuclideanGroup diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean index 2d42e4e41..8d50f6eca 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean @@ -150,10 +150,9 @@ private lemma continuousOn_union_of_subset_Ici_wrap {f : ℝ → ℝ} · exact ht hx private lemma spectrum_Ici_of_nonneg_wrap {A : L ℋ} (hA0 : (0 : L ℋ) ≤ A) : - spectrum ℝ A ⊆ Set.Ici (0 : ℝ) := by - exact - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A - (ha := IsSelfAdjoint.of_nonneg hA0)).1 hA0 + spectrum ℝ A ⊆ Set.Ici (0 : ℝ) := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A + (ha := IsSelfAdjoint.of_nonneg hA0)).1 hA0 variable [Nontrivial ℋ] diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean index c2765c3ca..2acc5cdac 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean @@ -520,10 +520,9 @@ private lemma continuousOn_union_of_subset_Ici {f : ℝ → ℝ} · exact ht hx private lemma spectrum_Ici_of_nonneg {A : L ℋ} (hA0 : (0 : L ℋ) ≤ A) : - spectrum ℝ A ⊆ Set.Ici (0 : ℝ) := by - exact - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A - (ha := IsSelfAdjoint.of_nonneg hA0)).1 hA0 + spectrum ℝ A ⊆ Set.Ici (0 : ℝ) := + (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A + (ha := IsSelfAdjoint.of_nonneg hA0)).1 hA0 variable [Nontrivial ℋ] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 0d9c7cbe7..aa31c0d08 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -524,9 +524,8 @@ open MatrixOrder in /-- If all eigenvalues of a Hermitian matrix are at most `M`, then it is bounded by `M * I`. -/ theorem eigenvalues_le_imp_le_smul_one [DecidableEq n] (A : HermitianMat n ℂ) (M : ℝ) (h : ∀ i, A.H.eigenvalues i ≤ M) : - A ≤ M • (1 : HermitianMat n ℂ) := by - exact - (Matrix.PosSemidef.le_smul_one_of_eigenvalues_iff A.H M).mp h + A ≤ M • (1 : HermitianMat n ℂ) := + (Matrix.PosSemidef.le_smul_one_of_eigenvalues_iff A.H M).mp h --TODO: Positivity extensions for traceLeft, traceRight, rpow, nat powers, inverse function, -- the various `proj` function (in Proj.lean), and the inner product. From 33e7b5f3e020205f926b9ec79e939883ed1477d5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:21:30 -0700 Subject: [PATCH 219/498] refactor: golf QuantumInfo witness proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Dual.lean | 4 ++-- QuantumInfo/Entropy/Relative.lean | 8 ++++---- QuantumInfo/States/Mixed/MState.lean | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index b04b084fb..78f19b63c 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -300,8 +300,8 @@ lemma Module.Basis.toDualEquiv_symm_comp_dualMap_toDualEquiv {ι R M : Type*} [F b.toDualEquiv.symm.toLinearMap ∘ₗ b.toDualEquiv.toLinearMap.dualMap = (Module.evalEquiv R M).symm.toLinearMap := by simp [ LinearMap.ext_iff ]; intro x - obtain ⟨y, hy⟩ : ∃ y, x = (Module.evalEquiv R M).toLinearMap y := by - exact ⟨ _, Eq.symm <| LinearEquiv.apply_symm_apply ( Module.evalEquiv R M ) x ⟩; + obtain ⟨y, hy⟩ : ∃ y, x = (Module.evalEquiv R M).toLinearMap y := + ⟨_, Eq.symm <| LinearEquiv.apply_symm_apply (Module.evalEquiv R M) x⟩ rw [ hy ]; simp [ Module.evalEquiv, LinearEquiv.symm_apply_eq ]; ext; simp [ Module.Dual.eval ] ; diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 9d50c7581..53dc40be0 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -343,8 +343,8 @@ lemma HermitianMat.mul_supportProj_of_ker_le {A B : HermitianMat d ℂ} -- Since $B.supportProj$ is the projection onto $range B$, and $range A \subseteq range B$, we have $B.supportProj * A = A$. have h_supportProj_mul_A : ∀ (v : EuclideanSpace ℂ d), B.supportProj.mat.mulVec (A.mat.mulVec v) = A.mat.mulVec v := by intro v - obtain ⟨w, hw⟩ : WithLp.toLp 2 (A.mat.mulVec v) ∈ LinearMap.range B.lin.toLinearMap := by - exact h_range_A_subset_range_B ( Set.mem_range_self v ); + obtain ⟨w, hw⟩ : WithLp.toLp 2 (A.mat.mulVec v) ∈ LinearMap.range B.lin.toLinearMap := + h_range_A_subset_range_B (Set.mem_range_self v) replace h_supportProj_mul_B := congr(Matrix.mulVec $h_supportProj_mul_B w) replace hw := congr(WithLp.ofLp $hw) simp only [ContinuousLinearMap.coe_coe] at hw @@ -1982,8 +1982,8 @@ private lemma ker_le_iff_eigenWeight_zero (ρ x : MState d) : constructor · exact fun h i ↦ eigenWeight_zero_of_eigenvalue_zero h · intro h v hv - obtain ⟨w, hw⟩ : ∃ w : d → ℂ, v = ∑ i, w i • x.M.H.eigenvectorBasis i := by - exact ⟨ _, Eq.symm ( x.M.H.eigenvectorBasis.sum_repr v ) ⟩; + obtain ⟨w, hw⟩ : ∃ w : d → ℂ, v = ∑ i, w i • x.M.H.eigenvectorBasis i := + ⟨_, Eq.symm (x.M.H.eigenvectorBasis.sum_repr v)⟩ -- Since $v \in \ker(x.M)$, we have $x.M(v) = 0$. Using the eigenvector basis, this implies that for each $i$, if the eigenvalue is non-zero, then $w i = 0$. have h_w_zero : ∀ i, x.M.H.eigenvalues i ≠ 0 → w i = 0 := by intro i hi diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 2e366e0f1..186913a5e 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -727,8 +727,7 @@ theorem pure_eq_pure_iff {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) intro i j; replace h := congr_arg ( fun ρ => ρ.M.mat i j ) h ; aesop; -- Let $k$ be such that $\varphi_k \neq 0$. - obtain ⟨k, hk⟩ : ∃ k, φ.vec k ≠ 0 := by - exact φ.exists_ne_zero; + obtain ⟨k, hk⟩ : ∃ k, φ.vec k ≠ 0 := φ.exists_ne_zero -- Let $z = \frac{\psi_k}{\varphi_k}$. Then $|z| = 1$. obtain ⟨z, hz⟩ : ∃ z : ℂ, ψ.vec k = z * φ.vec k ∧ ‖z‖ = 1 := by specialize h_eq k k @@ -886,8 +885,8 @@ theorem pure_iff_rank_eq_one {d : Type*} [Fintype d] [DecidableEq d] (ρ : MStat rw [ Matrix.rank_diagonal ] at h_diag; simp [ Finset.sum_ite ]; rw [ Fintype.card_subtype ] at h_diag ; exact h_diag; - obtain ⟨i, hi⟩ : ∃ i : d, h_herm.eigenvalues i ≠ 0 := by - exact not_forall.mp fun h => by simp [ h ] at h_diag; + obtain ⟨i, hi⟩ : ∃ i : d, h_herm.eigenvalues i ≠ 0 := + not_forall.mp fun h => by simp [h] at h_diag rw [ Finset.sum_eq_add_sum_sdiff_singleton i _ (by simp) ] at h_diag; exact ⟨i, hi, fun j hj => Classical.not_not.1 fun hj' => absurd h_diag ( by rw [ if_neg hi ] ; exact ne_of_gt ( lt_add_of_pos_right _ ( lt_of_lt_of_le ( by simp [ hj' ] ) ( Finset.single_le_sum ( fun x _ => by positivity ) ( Finset.mem_sdiff.2 ⟨ Finset.mem_univ j, by simp [ hj ] ⟩ ) ) ) ) ) ⟩; From 76dc12bf533430f005c7f99f50028754f5320402 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:23:20 -0700 Subject: [PATCH 220/498] refactor: golf QuantumInfo compactness witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 5 +++-- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 9 +++++---- QuantumInfo/ForMathlib/Minimax.lean | 4 ++-- QuantumInfo/ForMathlib/Misc.lean | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 53dc40be0..e91ff2b82 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -771,8 +771,9 @@ private lemma scalar_rpow_cross_term_of_continuous_zero {b : ℝ → ℝ} intro ε hε_pos obtain ⟨δ₁, hδ₁_pos, hδ₁⟩ : ∃ δ₁ > 0, ∀ α, abs (α - 1) < δ₁ → Real.sqrt (|b α|) * |Real.log (|b α|)| < ε := by simpa using Metric.tendsto_nhds_nhds.mp h_sqrt_log ε hε_pos |> fun ⟨ δ₁, hδ₁₁, hδ₁₂ ⟩ => ⟨ δ₁, hδ₁₁, fun α hα => lt_of_abs_lt <| by simpa using hδ₁₂ hα ⟩; - obtain ⟨δ₂, hδ₂_pos, hδ₂⟩ : ∃ δ₂ > 0, ∀ α, abs (α - 1) < δ₂ → |b α ^ α - b α| ≤ |α - 1| * Real.sqrt (|b α|) * |Real.log (|b α|)| := by - exact Metric.mem_nhds_iff.mp h_bound |> fun ⟨ δ₂, hδ₂_pos, hδ₂ ⟩ => ⟨ δ₂, hδ₂_pos, fun α hα => hδ₂ hα ⟩; + obtain ⟨δ₂, hδ₂_pos, hδ₂⟩ : ∃ δ₂ > 0, ∀ α, abs (α - 1) < δ₂ → |b α ^ α - b α| ≤ |α - 1| * Real.sqrt (|b α|) * |Real.log (|b α|)| := + Metric.mem_nhds_iff.mp h_bound |> fun ⟨δ₂, hδ₂_pos, hδ₂⟩ => + ⟨δ₂, hδ₂_pos, fun α hα => hδ₂ hα⟩ exact ⟨ Min.min δ₁ δ₂, lt_min hδ₁_pos hδ₂_pos, fun α hα => le_trans ( hδ₂ α ( lt_of_lt_of_le hα ( min_le_right _ _ ) ) ) ( by nlinarith [ hδ₁ α ( lt_of_lt_of_le hα ( min_le_left _ _ ) ), abs_nonneg ( α - 1 ) ] ) ⟩; rw [ hasDerivAt_iff_isLittleO_nhds_zero ]; rw [ Asymptotics.isLittleO_iff ]; diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 456664a9b..a6c89e7f7 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -521,8 +521,9 @@ lemma continuousOn_cfc_of_compact {K : Set ℝ} {g : ℝ → ℝ} (hK : IsCompac obtain ⟨p_n, hp_n⟩ : ∃ p_n : ℕ → Polynomial ℝ, (∀ n, ∀ x ∈ K, |(p_n n).eval x - g x| ≤ 1 / (n + 1)) := by have h_stone_weierstrass : ∀ ε > 0, ∃ p : Polynomial ℝ, ∀ x ∈ K, |p.eval x - g x| < ε := by have := @exists_polynomial_near_of_continuousOn; - obtain ⟨a, b, hab⟩ : ∃ a b : ℝ, K ⊆ Set.Icc a b := by - exact ⟨ hK.bddBelow.some, hK.bddAbove.some, fun x hx => ⟨ hK.bddBelow.choose_spec hx, hK.bddAbove.choose_spec hx ⟩ ⟩; + obtain ⟨a, b, hab⟩ : ∃ a b : ℝ, K ⊆ Set.Icc a b := + ⟨hK.bddBelow.some, hK.bddAbove.some, + fun x hx => ⟨hK.bddBelow.choose_spec hx, hK.bddAbove.choose_spec hx⟩⟩ -- Extend $g$ to a continuous function on $[a, b]$. obtain ⟨f, hf⟩ : ∃ f : ℝ → ℝ, ContinuousOn f (Set.Icc a b) ∧ ∀ x ∈ K, f x = g x := by have := @ContinuousMap.exists_restrict_eq; @@ -905,8 +906,8 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] fun y hy => hU'.2 y ⟨hy.1.1, hy.2⟩ |> Set.Subset.trans <| by simp [hW_def] have hU_cont : ∀ y ∈ U ∩ S, ∀ t ∈ spectrum ℝ (A y).mat, ‖f y t - f x₀ t‖ < ε := by intro y hy t ht - obtain ⟨i, hi⟩ : ∃ i, t ∈ V_i i := by - exact Set.mem_iUnion.mp ( hU_subset y hy ht ) |> Exists.imp fun i => by tauto; + obtain ⟨i, hi⟩ : ∃ i, t ∈ V_i i := + Set.mem_iUnion.mp (hU_subset y hy ht) |> Exists.imp fun i => by tauto have h_cont_i : ‖f y t - f x₀ t‖ < ε := h_cont.2.2 i y ⟨hU''.2 i (by aesop), hy.2⟩ t ⟨hi, hA₁ y hy.2 ht⟩ |> fun h => by simpa using h diff --git a/QuantumInfo/ForMathlib/Minimax.lean b/QuantumInfo/ForMathlib/Minimax.lean index 9a7b2891c..6663c2c13 100644 --- a/QuantumInfo/ForMathlib/Minimax.lean +++ b/QuantumInfo/ForMathlib/Minimax.lean @@ -48,8 +48,8 @@ theorem _root_.IsCompact.exists_isMinOn_lowerSemicontinuousOn {α β : Type*} -- Since $s$ is compact, the open cover $\{U_x \cap s \mid x \in s\}$ has a finite subcover. obtain ⟨t, ht⟩ : ∃ t : Finset β, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x ∩ s := by -- Since $s$ is compact, the open cover $\{U_x \mid x \in s\}$ has a finite subcover. - obtain ⟨t, ht⟩ : ∃ t : Finset β, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := by - exact hs.elim_nhds_subcover U fun x hx => IsOpen.mem_nhds ( hU x hx |>.1 ) ( hU x hx |>.2.1 ); + obtain ⟨t, ht⟩ : ∃ t : Finset β, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := + hs.elim_nhds_subcover U fun x hx => IsOpen.mem_nhds (hU x hx |>.1) (hU x hx |>.2.1) exact ⟨ t, ht.1, fun x hx => by rcases Set.mem_iUnion₂.1 ( ht.2 hx ) with ⟨ y, hy, hy' ⟩ ; exact Set.mem_iUnion₂.2 ⟨ y, hy, ⟨ hy', hx ⟩ ⟩ ⟩; -- Since $t$ is finite, there exists $x \in t$ such that $f(g(x))$ is minimal. obtain ⟨x, hx⟩ : ∃ x ∈ t, ∀ y ∈ t, f (g x) ≤ f (g y) := by diff --git a/QuantumInfo/ForMathlib/Misc.lean b/QuantumInfo/ForMathlib/Misc.lean index edb49e2d6..1ca8e10bf 100644 --- a/QuantumInfo/ForMathlib/Misc.lean +++ b/QuantumInfo/ForMathlib/Misc.lean @@ -181,6 +181,6 @@ lemma exists_equiv_of_multiset_map_eq {α β γ : Type*} [Fintype α] [Fintype rw [ Multiset.map_map ] exact h.trans h_multiset_eq; -- By `Multiset.map_univ_eq_iff`, there exists `e' : α ≃ α` such that `f = (g ∘ σ) ∘ e'`. - obtain ⟨e', he'⟩ : ∃ e' : α ≃ α, f = (g ∘ σ) ∘ e' := by - exact (Multiset.map_univ_eq_iff f (g ∘ ⇑σ)).mp hσ; + obtain ⟨e', he'⟩ : ∃ e' : α ≃ α, f = (g ∘ σ) ∘ e' := + (Multiset.map_univ_eq_iff f (g ∘ ⇑σ)).mp hσ exact ⟨ e'.trans σ, by simp_all [ Function.comp ]; grind⟩ From fc328570072e92dba294b761079287630275b8bf Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:37:14 -0700 Subject: [PATCH 221/498] refactor: golf tensor and QuantumInfo witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/PauliMatrices/ToTensor.lean | 4 +++- .../HilbertSchmidtOperatorSpace.lean | 15 ++++++--------- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 8 ++++++-- QuantumInfo/States/Mixed/MState.lean | 6 ++++-- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Physlib/Relativity/PauliMatrices/ToTensor.lean b/Physlib/Relativity/PauliMatrices/ToTensor.lean index f7d34fc34..6f6cb5438 100644 --- a/Physlib/Relativity/PauliMatrices/ToTensor.lean +++ b/Physlib/Relativity/PauliMatrices/ToTensor.lean @@ -372,7 +372,9 @@ set_option backward.isDefEq.respectTransparency false in lemma smul_pauliContrDown (g : SL(2,ℂ)) : g • pauliContrDown = pauliContrDown := by rw [← permT_equivariant, ← contrT_equivariant, ← prodT_equivariant, ← contrT_equivariant, ← prodT_equivariant] - simp only [Tensorial.self_toTensor_apply] + rw [show toTensor (toTensor σ) = toTensor σ from rfl, + show toTensor εR' = εR' from rfl, + show toTensor εL' = εL' from rfl] rw [toTensor_smul_eq_self, actionT_dualLeftMetric, actionT_dualRightMetric] rfl diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean index 69b259294..a772a8cc2 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean @@ -603,9 +603,8 @@ lemma cfc_op_eq_op_cfc [ContinuousFunctionalCalculus ℝ (L ℋ) IsSelfAdjoint] cfc (R := ℝ) (A := (L ℋ)ᵐᵒᵖ) (p := IsSelfAdjoint) f (MulOpposite.op A) = MulOpposite.op (cfcR f A) := by let φ : L ℋ →⋆ₐ[ℝ] (L ℋ)ᵐᵒᵖ := opStarHSStarAlgHom (ℋ := ℋ) - have hφ : Continuous φ := by - exact - (LinearMap.continuous_of_finiteDimensional (opStarHSLinearMap (ℋ := ℋ))) + have hφ : Continuous φ := + LinearMap.continuous_of_finiteDimensional (opStarHSLinearMap (ℋ := ℋ)) have hopA : IsSelfAdjoint (MulOpposite.op A : (L ℋ)ᵐᵒᵖ) := op_isSelfAdjoint (A := A) hA have hφA : IsSelfAdjoint (φ A) := hA.map φ have hcfcA : @@ -626,9 +625,8 @@ lemma leftMulHS_cfcR [ContinuousFunctionalCalculus ℝ (L ℋ) IsSelfAdjoint] [N leftMulHS (ℋ := ℋ) (cfcR f A) = cfcR (ℋ := HSOp ℋ) f (leftMulHS (ℋ := ℋ) A) := by let φ : L ℋ →⋆ₐ[ℝ] L (HSOp ℋ) := leftMulHSStarAlgHom (ℋ := ℋ) - have hφ : Continuous φ := by - exact - (LinearMap.continuous_of_finiteDimensional (leftMulHSLinearMap (ℋ := ℋ))) + have hφ : Continuous φ := + LinearMap.continuous_of_finiteDimensional (leftMulHSLinearMap (ℋ := ℋ)) have hφA : IsSelfAdjoint (φ A) := hA.map φ have hmap := StarAlgHom.map_cfc (φ := φ) (f := f) (a := A) (hf := hf) (hφ := hφ) (ha := hA) (hφa := hφA) @@ -641,9 +639,8 @@ lemma rightMulHS_cfcR [ContinuousFunctionalCalculus ℝ (L ℋ) IsSelfAdjoint] rightMulHS (ℋ := ℋ) (cfcR f A) = cfcR (ℋ := HSOp ℋ) f (rightMulHS (ℋ := ℋ) A) := by let φ : (L ℋ)ᵐᵒᵖ →⋆ₐ[ℝ] L (HSOp ℋ) := rightMulHSStarAlgHom (ℋ := ℋ) - have hφ : Continuous φ := by - exact - (LinearMap.continuous_of_finiteDimensional (rightMulHSLinearMap (ℋ := ℋ))) + have hφ : Continuous φ := + LinearMap.continuous_of_finiteDimensional (rightMulHSLinearMap (ℋ := ℋ)) have hopA : IsSelfAdjoint (MulOpposite.op A : (L ℋ)ᵐᵒᵖ) := op_isSelfAdjoint (A := A) hA have hφA : IsSelfAdjoint (φ (MulOpposite.op A)) := hopA.map φ have hmap := StarAlgHom.map_cfc (φ := φ) (f := f) (a := MulOpposite.op A) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index a6c89e7f7..467c4b535 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -897,8 +897,12 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] fun _ hy => hy obtain ⟨U', hU'⟩ : ∃ U' ∈ nhds x₀, ∀ y ∈ U' ∩ S, spectrum ℝ (A y).mat ⊆ W := by obtain ⟨ U', hU' ⟩ := mem_nhdsWithin_iff_exists_mem_nhds_inter.mp hW_subset_S; use U'; aesop; - obtain ⟨U'', hU''⟩ : ∃ U'' ∈ nhds x₀, ∀ i, U'' ⊆ U_i i := by - exact ⟨ ⋂ i, U_i i, Filter.mem_of_superset ( Filter.iInter_mem.mpr fun i => IsOpen.mem_nhds ( hU_i i ) ( h_cont.1 i ) ) fun x hx => by aesop, fun i => Set.iInter_subset _ i ⟩ + obtain ⟨U'', hU''⟩ : ∃ U'' ∈ nhds x₀, ∀ i, U'' ⊆ U_i i := + ⟨⋂ i, U_i i, + Filter.mem_of_superset + (Filter.iInter_mem.mpr fun i => IsOpen.mem_nhds (hU_i i) (h_cont.1 i)) + fun x hx => by aesop, + fun i => Set.iInter_subset _ i⟩ set U := U' ∩ U'' with hU_def have hU_mem : U ∈ nhds x₀ := Filter.inter_mem hU'.1 hU''.1 diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 186913a5e..e447c0b4e 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -778,8 +778,10 @@ theorem pure_separable_imp_IsProd {d₁ d₂ : Type*} [Fintype d₁] [Fintype d obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) ∧ (MState.pure ψ).M = (k.val.1).M ⊗ₖ (k.val.2).M := by have h_pure : (MState.pure ψ).purity = 1 := ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; - obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) := by - exact ⟨ Classical.choose ( show ∃ k : ρLRs, 0 < ( ps k : ℝ ) from by exact not_forall_not.mp fun h => by have := ps.2; simp_all ), Classical.choose_spec ( show ∃ k : ρLRs, 0 < ( ps k : ℝ ) from by exact not_forall_not.mp fun h => by have := ps.2; simp_all) ⟩; + obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) := + not_forall_not.mp fun h => by + have := ps.2 + simp_all refine' ⟨ k, hk, _ ⟩; convert MState.eq_of_sum_eq_pure h_pure _ _ _ k _ _; rotate_left; From 50a815a76ec34583bbc1356a778c67a9d392d59d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:40:18 -0700 Subject: [PATCH 222/498] refactor: target Pauli tensor rewrites Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/PauliMatrices/Relations.lean | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Physlib/Relativity/PauliMatrices/Relations.lean b/Physlib/Relativity/PauliMatrices/Relations.lean index 98dcfc360..18c334032 100644 --- a/Physlib/Relativity/PauliMatrices/Relations.lean +++ b/Physlib/Relativity/PauliMatrices/Relations.lean @@ -105,7 +105,10 @@ lemma pauliCo_trace_pauliCoDown: {σ_^^ | μ α β ⊗ σ___ | ν β α = 2 • lemma pauliContr_mul_pauliContrDown_add : {((σ^^^ | μ α β ⊗ σ^__ | ν β α') + (σ^^^ | ν α β ⊗ σ^__ | μ β α')) = 2 •ₜ η | μ ν ⊗ δL | α α'}ᵀ := by - simp only [Tensorial.self_toTensor_apply] + rw [show Tensorial.toTensor (Tensorial.toTensor σ) = Tensorial.toTensor σ from rfl, + show Tensorial.toTensor σ^__ = σ^__ from rfl, + show Tensorial.toTensor η = η from rfl, + show Tensorial.toTensor δL = δL from rfl] conv_lhs => rw [pauliContrDown_ofRat, toTensor_eq_ofRat, prodT_ofRat_ofRat, contrT_ofRat, permT_ofRat, ← map_add] @@ -121,7 +124,10 @@ lemma pauliContr_mul_pauliContrDown_add : lemma auliContrDown_pauliContr_mul_add : {((σ^__ | μ β α ⊗ σ^^^ | ν α β') + (σ^__ | ν β α ⊗ σ^^^ | μ α β')) = 2 •ₜ η | μ ν ⊗ δR' | β β'}ᵀ := by - simp only [Tensorial.self_toTensor_apply] + rw [show Tensorial.toTensor σ^__ = σ^__ from rfl, + show Tensorial.toTensor (Tensorial.toTensor σ) = Tensorial.toTensor σ from rfl, + show Tensorial.toTensor η = η from rfl, + show Tensorial.toTensor δR' = δR' from rfl] conv_lhs => rw [pauliContrDown_ofRat, toTensor_eq_ofRat, prodT_ofRat_ofRat, contrT_ofRat, permT_ofRat, ← map_add] From b1e16d4196942f5159d6f48f2c19893cdb5aa4ca Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:48:48 -0700 Subject: [PATCH 223/498] refactor: golf list and normal-order witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List.lean | 3 +-- Physlib/Mathematics/SpecialFunctions/PhysHermite.lean | 3 +-- .../PerturbationTheory/FieldSpecification/NormalOrder.lean | 6 ++---- QuantumInfo/ForMathlib/Majorization.lean | 6 ++++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/List.lean b/Physlib/Mathematics/List.lean index c781e9305..f642c8e32 100644 --- a/Physlib/Mathematics/List.lean +++ b/Physlib/Mathematics/List.lean @@ -23,8 +23,7 @@ variable {n : Nat} lemma takeWile_eraseIdx {I : Type} (P : I → Prop) [DecidablePred P] : (l : List I) → (i : ℕ) → (hi : ∀ (i j : Fin l.length), i < j → P (l.get j) → P (l.get i)) → List.takeWhile P (List.eraseIdx l i) = (List.takeWhile P l).eraseIdx i - | [], _, h => by - rfl + | [], _, h => rfl | a :: [], 0, h => by simp only [List.takeWhile, List.eraseIdx_zero] split <;> rfl diff --git a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean index 8ca5752d5..dc6a9ff7b 100644 --- a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean +++ b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean @@ -325,8 +325,7 @@ lemma integral_physHermite_mul_physHermite_eq_integral_deriv_inductive (n m : ∫ x : ℝ, (physHermite n x * physHermite m x) * Real.exp (- x ^ 2) = (-1 : ℝ) ^ (m - p) * ∫ x : ℝ, (deriv^[p] (physHermite n) x * (deriv^[m - p] fun x => Real.exp (-x ^ 2)) x) - | 0, h => by - exact integral_physHermite_mul_physHermite_eq_integral_deriv_exp n m + | 0, h => integral_physHermite_mul_physHermite_eq_integral_deriv_exp n m | p + 1, h => by rw [integral_physHermite_mul_physHermite_eq_integral_deriv_inductive n m p (by omega)] have h1 : m - p = m - (p + 1) + 1 := by omega diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index e3f2756b4..616ddd608 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -172,8 +172,7 @@ lemma normalOrderSign_swap_create_create (φc φc' : 𝓕.CrAnFieldOp) (hφc : 𝓕 |>ᶜ φc = CreateAnnihilate.create) (hφc' : 𝓕 |>ᶜ φc' = CreateAnnihilate.create) : (φs φs' : List 𝓕.CrAnFieldOp) → normalOrderSign (φs ++ φc :: φc' :: φs') = normalOrderSign (φs ++ φc' :: φc :: φs') - | [], φs' => by - exact normalOrderSign_swap_create_create_fst φc φc' hφc hφc' φs' + | [], φs' => normalOrderSign_swap_create_create_fst φc φc' hφc hφc' φs' | φ :: φs, φs' => by rw [normalOrderSign] dsimp only [List.cons_append, Wick.koszulSign] @@ -206,8 +205,7 @@ lemma normalOrderSign_swap_annihilate_annihilate (φa φa' : 𝓕.CrAnFieldOp) (hφa : 𝓕 |>ᶜ φa = CreateAnnihilate.annihilate) (hφa' : 𝓕 |>ᶜ φa' = CreateAnnihilate.annihilate) : (φs φs' : List 𝓕.CrAnFieldOp) → normalOrderSign (φs ++ φa :: φa' :: φs') = normalOrderSign (φs ++ φa' :: φa :: φs') - | [], φs' => by - exact normalOrderSign_swap_annihilate_annihilate_fst φa φa' hφa hφa' φs' + | [], φs' => normalOrderSign_swap_annihilate_annihilate_fst φa φa' hφa hφa' φs' | φ :: φs, φs' => by rw [normalOrderSign] dsimp only [List.cons_append, Wick.koszulSign] diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index 87f9619d1..9824b9bc0 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -606,8 +606,10 @@ lemma exists_subset_prod_eq_sorted_prod (M : Matrix d d ℂ) (k : ℕ) obtain ⟨a, ha⟩ := σ.surjective ⟨i, by simp⟩ exact ⟨⟨a, by simpa using a.2⟩, Fin.ext <| by simpa [Fin.ext_iff] using congr_arg Fin.val ha⟩⟩, fun i => by simpa [Fin.ext_iff] using congr_arg (fun l => l[i]!) hσ⟩) obtain ⟨σ, hσ⟩ := h_perm - use Equiv.ofBijective (fun i => (Fintype.equivFin d).symm (σ i)) ⟨fun i j hij => by simpa [Fin.ext_iff] using σ.injective (by simpa [Fin.ext_iff] using hij), fun i => by - exact ⟨σ.symm (Fintype.equivFin d i), by simp⟩;⟩ + use Equiv.ofBijective (fun i => (Fintype.equivFin d).symm (σ i)) + ⟨fun i j hij => by + simpa [Fin.ext_iff] using σ.injective (by simpa [Fin.ext_iff] using hij), + fun i => ⟨σ.symm (Fintype.equivFin d i), by simp⟩⟩ intro i replace hσ := congr_arg (fun l => l[i]!) hσ simp_all From 758e6a7eb4d2d42f097f67e6140a653f6bfa2199 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:53:01 -0700 Subject: [PATCH 224/498] refactor: golf channel positivity proofs Co-authored-by: Claude Opus 4.8 --- .../Koszul/KoszulSignInsert.lean | 3 +-- QuantumInfo/Channels/Bundled.lean | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean index 5dbed34d4..3d369bf8f 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean @@ -103,8 +103,7 @@ lemma koszulSignInsert_eq_filter (φ : 𝓕) : (φs : List 𝓕) → lemma koszulSignInsert_eq_cons [Std.Total le] (φ : 𝓕) (φs : List 𝓕) : koszulSignInsert q le φ φs = koszulSignInsert q le φ (φ :: φs) := by simp only [koszulSignInsert, and_self] - have h1 : le φ φ := by - simpa only [or_self] using Std.Total.total (r := le) φ φ + have h1 : le φ φ := (Std.Total.total (r := le) φ φ).elim id id simp [h1] lemma koszulSignInsert_eq_grade (φ : 𝓕) (φs : List 𝓕) : diff --git a/QuantumInfo/Channels/Bundled.lean b/QuantumInfo/Channels/Bundled.lean index aa54a6938..a30c1f75a 100644 --- a/QuantumInfo/Channels/Bundled.lean +++ b/QuantumInfo/Channels/Bundled.lean @@ -206,8 +206,8 @@ instance instContinuousOrderHomClass : ContinuousOrderHomClass (PMap dIn dOut /-- Positive-presering maps also preserve positivity on, specifically, Hermitian matrices. -/ @[simp] -theorem pos_Hermitian (M : PMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := by - simpa only [map_zero] using ContinuousOrderHomClass.map_monotone M h +theorem pos_Hermitian (M : PMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := + map_nonneg M h end PMap @@ -259,8 +259,8 @@ instance instHContinuousOrderHomClass : ContinuousOrderHomClass (PTPMap dIn dOut /-- PTP maps also preserve positivity on Hermitian matrices. -/ @[simp] -theorem pos_Hermitian (M : PTPMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := by - simpa only [map_zero] using ContinuousOrderHomClass.map_monotone M h +theorem pos_Hermitian (M : PTPMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := + map_nonneg M h /-- `PTPMap`s are functions from `MState`s to `MState`s. -/ noncomputable instance instMFunLike [DecidableEq dIn] [DecidableEq dOut] : @@ -408,8 +408,8 @@ instance instOneHomClass : OneHomClass (PUMap dIn dOut ℂ) /-- CPTP maps also preserve positivity on Hermitian matrices. -/ @[simp] -theorem pos_Hermitian (M : PUMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := by - simpa only [map_zero] using ContinuousOrderHomClass.map_monotone M h +theorem pos_Hermitian (M : PUMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := + map_nonneg M h end PUMap @@ -451,8 +451,8 @@ instance instOneHomClass : OneHomClass (CPUMap dIn dOut ℂ) /-- CPTP maps also preserve positivity on Hermitian matrices. -/ @[simp] -theorem pos_Hermitian (M : CPUMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := by - simpa only [map_zero] using ContinuousOrderHomClass.map_monotone M h +theorem pos_Hermitian (M : CPUMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := + map_nonneg M h end CPUMap From f4d7f60e46a2769c7db2a3e16153e72fe176f972 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 19:56:53 -0700 Subject: [PATCH 225/498] refactor: golf SU5 and rpow wrappers Co-authored-by: Claude Opus 4.8 --- .../SU5/ChargeSpectrum/OfPotentialTerm.lean | 7 +++---- .../FTheory/SU5/Fluxes/NoExotics/Completeness.lean | 14 ++++++-------- .../StringTheory/FTheory/SU5/Quanta/TenQuanta.lean | 7 +++---- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 5 ++--- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean index 49658a0a8..c16ffa53b 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean @@ -381,10 +381,9 @@ which is not important for us. -/ lemma mem_ofPotentialTerm_iff_mem_ofPotentialTerm [DecidableEq 𝓩] {T : PotentialTerm} {n : 𝓩} {y : ChargeSpectrum 𝓩} : - n ∈ y.ofPotentialTerm T ↔ n ∈ y.ofPotentialTerm' T := by - constructor - · exact fun h => ofPotentialTerm_subset_ofPotentialTerm' T h - · exact fun h => ofPotentialTerm'_subset_ofPotentialTerm T h + n ∈ y.ofPotentialTerm T ↔ n ∈ y.ofPotentialTerm' T := + ⟨fun h => ofPotentialTerm_subset_ofPotentialTerm' T h, + fun h => ofPotentialTerm'_subset_ofPotentialTerm T h⟩ /-! diff --git a/Physlib/StringTheory/FTheory/SU5/Fluxes/NoExotics/Completeness.lean b/Physlib/StringTheory/FTheory/SU5/Fluxes/NoExotics/Completeness.lean index 986e2a3b2..d27a05f0f 100644 --- a/Physlib/StringTheory/FTheory/SU5/Fluxes/NoExotics/Completeness.lean +++ b/Physlib/StringTheory/FTheory/SU5/Fluxes/NoExotics/Completeness.lean @@ -272,10 +272,9 @@ lemma mem_elemsNoExotics_of_noExotics (F : FluxesFive) (hNE : F.NoExotics) (hnZ which obeys `NoExotics` is an element of `elemsNoExotics`, and every element of `elemsNoExotics` obeys `NoExotics`. -/ lemma noExotics_iff_mem_elemsNoExotics (F : FluxesFive) : - F.NoExotics ∧ F.HasNoZero ↔ F ∈ elemsNoExotics := by - constructor - · exact fun ⟨h1, h2⟩ => mem_elemsNoExotics_of_noExotics F h1 h2 - · exact fun h => ⟨noExotics_of_mem_elemsNoExotics F h, hasNoZero_of_mem_elemsNoExotics F h⟩ + F.NoExotics ∧ F.HasNoZero ↔ F ∈ elemsNoExotics := + ⟨fun ⟨h1, h2⟩ => mem_elemsNoExotics_of_noExotics F h1 h2, + fun h => ⟨noExotics_of_mem_elemsNoExotics F h, hasNoZero_of_mem_elemsNoExotics F h⟩⟩ end FluxesFive @@ -444,10 +443,9 @@ lemma mem_elemsNoExotics_of_noExotics (F : FluxesTen) (hNE : F.NoExotics) (hnZ : which obeys `NoExotics` is an element of `elemsNoExotics`, and every element of `elemsNoExotics` obeys `NoExotics`. -/ lemma noExotics_iff_mem_elemsNoExotics (F : FluxesTen) : - F.NoExotics ∧ F.HasNoZero ↔ F ∈ elemsNoExotics := by - constructor - · exact fun h => mem_elemsNoExotics_of_noExotics F h.1 h.2 - · exact fun h => ⟨noExotics_of_mem_elemsNoExotics F h, hasNoZero_of_mem_elemsNoExotics F h⟩ + F.NoExotics ∧ F.HasNoZero ↔ F ∈ elemsNoExotics := + ⟨fun h => mem_elemsNoExotics_of_noExotics F h.1 h.2, + fun h => ⟨noExotics_of_mem_elemsNoExotics F h, hasNoZero_of_mem_elemsNoExotics F h⟩⟩ end FluxesTen end SU5 diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean index 76ad31035..52366c0d7 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean @@ -969,10 +969,9 @@ lemma mem_liftCharge_iff_exists (c : Finset 𝓩) {x : TenQuanta 𝓩} : x ∈ liftCharge c ↔ ∃ a : TenQuanta 𝓩, a.reduce = x ∧ a.toCharges.toFinset = c ∧ (a.toFluxesTen = {⟨1, 0⟩, ⟨1, 0⟩, ⟨1, 0⟩} - ∨ a.toFluxesTen = {⟨1, 1⟩, ⟨1, -1⟩, ⟨1, 0⟩}) := by - constructor - · exact exists_toCharges_toFluxesTen_of_mem_liftCharge c - · exact mem_liftCharge_of_exists_toCharges_toFluxesTen c + ∨ a.toFluxesTen = {⟨1, 1⟩, ⟨1, -1⟩, ⟨1, 0⟩}) := + ⟨exists_toCharges_toFluxesTen_of_mem_liftCharge c, + mem_liftCharge_of_exists_toCharges_toFluxesTen c⟩ /-! diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 45efeb940..84c561c29 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -154,9 +154,8 @@ theorem rpow_pos {A : HermitianMat d 𝕜} (hA : 0 < A) {p : ℝ} : 0 < A ^ p := · exact fun i hi => Real.rpow_pos_of_pos hi _ · rcases eq_or_ne p 0 with h | h <;> simp [h] -theorem rpow_nonneg (hA : 0 ≤ A) {p : ℝ} : 0 ≤ A ^ p := by - apply cfc_nonneg_of_nonneg hA - exact fun i hi => Real.rpow_nonneg hi p +theorem rpow_nonneg (hA : 0 ≤ A) {p : ℝ} : 0 ≤ A ^ p := + cfc_nonneg_of_nonneg hA fun _ hi => Real.rpow_nonneg hi p open ComplexOrder in theorem inv_eq_rpow_neg_one (hA : A.mat.PosDef) : A⁻¹ = A ^ (-1 : ℝ) := by From 5f65c5323b91aedab1b653adc2ebabbdc29ca60d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:07:31 -0700 Subject: [PATCH 226/498] refactor: golf QuantumInfo proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/DPI.lean | 5 ++--- QuantumInfo/Entropy/Relative.lean | 5 ++--- QuantumInfo/Entropy/VonNeumann.lean | 5 ++--- QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 4 ++-- QuantumInfo/ResourceTheory/SteinsLemma.lean | 5 ++--- QuantumInfo/States/Mixed/MState.lean | 4 +--- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 2ddbf5800..3c2229fc8 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -536,9 +536,8 @@ theorem iSup_f_alpha_jointly_convex (hα : 1 < α) ∑ i, w i * (⨆ (H : {H : HermitianMat d ℂ // 0 ≤ H}), f_alpha α H.1 (ρs i) (σs i)) := by apply ciSup_le intro H - have h_sum : f_alpha α H.1 ρ_mix σ_mix ≤ ∑ i, w i * (f_alpha α H.1 (ρs i) (σs i)) := by - apply f_alpha_jointly_convex hα H.1 H.2 w hw_nonneg hw_sum ρs σs ρ_mix σ_mix hρ_mix hσ_mix - exact h_sum.trans (Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_left + exact (f_alpha_jointly_convex hα H.1 H.2 w hw_nonneg hw_sum ρs σs ρ_mix σ_mix + hρ_mix hσ_mix).trans (Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_left (le_ciSup (f_alpha_bddAbove hα (ρs i) (σs i) (hker i)) H) (hw_nonneg i)) /-- If for all i, ker(σs i) ≤ ker(ρs i), then ker(∑ w i • σs i) ≤ ker(∑ w i • ρs i), diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index e91ff2b82..f85d65fc5 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -268,9 +268,8 @@ lemma HermitianMat.rpow_neg_mul_rpow_eq_supportProj rw [ h_cfc, ← mat_cfc_mul ]; have h_cfc : ∀ x : ℝ, 0 ≤ x → x ^ (-p) * x ^ p = if x = 0 then 0 else 1 := by intro x hx; by_cases hx' : x = 0 <;> simp [ hx', Real.rpow_neg, hx, hp ] ; - have h_cfc_eq : (A.cfc (fun x => x ^ (-p) * x ^ p)) = (A.cfc (fun x => if x = 0 then 0 else 1)) := by - apply cfc_congr_of_nonneg hA; - exact fun x hx => h_cfc x hx; + have h_cfc_eq : (A.cfc (fun x => x ^ (-p) * x ^ p)) = (A.cfc (fun x => if x = 0 then 0 else 1)) := + cfc_congr_of_nonneg hA (fun x hx => h_cfc x hx) convert! congr_arg ( fun x : HermitianMat d ℂ => x.val ) h_cfc_eq using 1; exact congr_arg ( fun x : HermitianMat d ℂ => x.val ) ( supportProj_eq_cfc A ) diff --git a/QuantumInfo/Entropy/VonNeumann.lean b/QuantumInfo/Entropy/VonNeumann.lean index 192017247..e7853c852 100644 --- a/QuantumInfo/Entropy/VonNeumann.lean +++ b/QuantumInfo/Entropy/VonNeumann.lean @@ -146,9 +146,8 @@ theorem Sᵥₙ_relabel (ρ : MState d₁) (e : d₂ ≃ d₁) : /-- Von Neumann entropy is unchanged under SWAP. TODO: All unitaries-/ @[simp] -theorem Sᵥₙ_of_SWAP_eq (ρ : MState (d₁ × d₂)) : Sᵥₙ ρ.SWAP = Sᵥₙ ρ := by - apply Hₛ_eq_of_multiset_map_eq - exact ρ.multiset_spectrum_relabel_eq (Equiv.prodComm d₁ d₂).symm +theorem Sᵥₙ_of_SWAP_eq (ρ : MState (d₁ × d₂)) : Sᵥₙ ρ.SWAP = Sᵥₙ ρ := + Hₛ_eq_of_multiset_map_eq _ _ (ρ.multiset_spectrum_relabel_eq (Equiv.prodComm d₁ d₂).symm) /-- Von Neumann entropy is unchanged under assoc. -/ @[simp] diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 3483fc512..6a3a7b92f 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -371,8 +371,8 @@ theorem logApprox_eq_log_add_error convert! logApprox_eq_cfc_scalar x hx T hT using 1; apply cfc_congr_of_posDef hx; exact fun u hu => Eq.symm ( scalarLogApprox_eq u T hu.out hT ); - have h_cfc_add : x.cfc (fun u => Real.log u + Real.log ((1 + T) / (u + T))) = x.cfc Real.log + x.cfc (fun u => Real.log ((1 + T) / (u + T))) := by - apply cfc_add; + have h_cfc_add : x.cfc (fun u => Real.log u + Real.log ((1 + T) / (u + T))) = x.cfc Real.log + x.cfc (fun u => Real.log ((1 + T) / (u + T))) := + cfc_add x Real.log (fun u => Real.log ((1 + T) / (u + T))) exact h_logApprox.trans h_cfc_add open ComplexOrder Filter Topology in diff --git a/QuantumInfo/ResourceTheory/SteinsLemma.lean b/QuantumInfo/ResourceTheory/SteinsLemma.lean index 96d273d3b..2b2abf933 100644 --- a/QuantumInfo/ResourceTheory/SteinsLemma.lean +++ b/QuantumInfo/ResourceTheory/SteinsLemma.lean @@ -620,9 +620,8 @@ private lemma f_image_bound (mineig : ℝ) (n : ℕ) (h : 0 < mineig) (hn : 0 < exact Real.log_nonpos ( by linarith [ pow_pos h n ] ) right_1; · have := h_f_le n 1 simp_all only [Real.log_one, zero_div, Int.ceil_zero, Int.cast_zero, zero_mul, zero_add, lt_neg_add_iff_add_lt, add_zero] - have h_card_image : Set.ncard (Set.image (fun k : ℤ => Real.exp (k * (Real.log (1 / mineig) + Real.log 3 / (max n 1)))) (Set.Icc (⌈(n * Real.log mineig - Real.log 3) / (Real.log (1 / mineig) + Real.log 3 / (max n 1))⌉) 0)) ≤ Set.ncard (Set.Icc (⌈(n * Real.log mineig - Real.log 3) / (Real.log (1 / mineig) + Real.log 3 / (max n 1))⌉) 0) := by - apply Set.ncard_image_le; - exact Set.finite_Icc _ _; + have h_card_image : Set.ncard (Set.image (fun k : ℤ => Real.exp (k * (Real.log (1 / mineig) + Real.log 3 / (max n 1)))) (Set.Icc (⌈(n * Real.log mineig - Real.log 3) / (Real.log (1 / mineig) + Real.log 3 / (max n 1))⌉) 0)) ≤ Set.ncard (Set.Icc (⌈(n * Real.log mineig - Real.log 3) / (Real.log (1 / mineig) + Real.log 3 / (max n 1))⌉) 0) := + Set.ncard_image_le (Set.finite_Icc _ _) simp_all +decide [ Set.ncard_eq_toFinset_card' ]; refine le_trans h_card <| le_trans h_card_image ?_; rcases n with _ | n diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index e447c0b4e..f7fda7439 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -710,9 +710,7 @@ theorem eq_of_sum_eq_pure {d : Type*} [Fintype d] [DecidableEq d] exact ⟨ by assumption, h_eq _ ( ρs i |>.2 ) ( ρs i |>.3 ) ⟩; linarith [ h_trace i hi hpi, (ρ.M - (ρs i).M).inner_self_nonneg ]; -- Since the inner product of a matrix with itself is zero if and only if the matrix is zero, we have ρ.M - (ρs i).M = 0. - have h_zero : ρ.M - (ρs i).M = 0 := by - apply inner_self_eq_zero.mp h_eq; - exact eq_of_sub_eq_zero h_zero; + exact eq_of_sub_eq_zero (inner_self_eq_zero.mp h_eq); exact MState.ext h_eq.symm theorem purity_prod {d₁ d₂ : Type*} [Fintype d₁] [Fintype d₂] [DecidableEq d₁] [DecidableEq d₂] From 1079ec0e1e86aee41f9fe8d862d7509fa020ec65 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:14:34 -0700 Subject: [PATCH 227/498] refactor: golf trace and operator wrappers Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/Unbounded.lean | 5 ++-- .../CanonicalEnsemble/Basic.lean | 4 +-- .../JensenOperatorInequality.lean | 8 ++--- .../TraceInequality/LownerHeinzCore.lean | 30 ++++++------------- .../ForMathlib/MatrixNorm/TraceNorm.lean | 5 ++-- 5 files changed, 17 insertions(+), 35 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean index 0da5aa699..28413380c 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean @@ -690,9 +690,8 @@ lemma IsSelfAdjoint.isEssentiallySelfAdjoint [CompleteSpace H] (h : IsSelfAdjoin isEssentiallySelfAdjoint_def.mpr (h.isClosed.closure_eq.symm ▸ h) @[aesop safe apply] -lemma IsSelfAdjoint.adjoint [CompleteSpace H] (h : IsSelfAdjoint T) : IsSelfAdjoint T† := by - apply isSelfAdjoint_def.mp at h - exact h.symm ▸ h +lemma IsSelfAdjoint.adjoint [CompleteSpace H] (h : IsSelfAdjoint T) : IsSelfAdjoint T† := + isSelfAdjoint_def.mpr ((isSelfAdjoint_def.mp h).symm ▸ isSelfAdjoint_def.mp h) @[aesop safe apply] lemma IsSelfAdjoint.smul [CompleteSpace H] diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index b7ebb32ef..0b8959a42 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -721,9 +721,7 @@ lemma differentialEntropy_nonneg_of_prob_le_one intro i have hpos := probability_pos (𝓒:=𝓒) (T:=T) i have hle := hP_le_one i - have hle' : 𝓒.probability T i ≤ Real.exp 0 := by - simpa [Real.exp_zero] using hle - exact (log_le_iff_le_exp hpos).mpr hle' + exact (log_le_iff_le_exp hpos).mpr (by simpa [Real.exp_zero] using hle) have hInt0 : Integrable (fun _ : ι => (0 : ℝ)) (𝓒.μProd T) := integrable_const _ have hIntLe : (∫ i, Real.log (𝓒.probability T i) ∂𝓒.μProd T) ≤ (∫ _i, (0 : ℝ) ∂𝓒.μProd T) := diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean index 8d50f6eca..0a9846427 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean @@ -370,11 +370,9 @@ theorem theorem_2_5_2_i_ici_all_imp_v {f : ℝ → ℝ} theorem_2_5_2_i_ici_all_imp_iv (ℋ := HSum ℋ) (f := f) hfIci have hcore := hiv_hsum (A := Atilde) (X := Xtilde) hAtilde_sa hAtilde_spec hXtilde_norm have hsum_nonneg : (0 : L ℋ) ≤ star X * A * X + star Y * B * Y := by - have hXA : (0 : L ℋ) ≤ star X * A * X := by - simpa [mul_assoc] using star_left_conjugate_nonneg hA0 X - have hYB : (0 : L ℋ) ≤ star Y * B * Y := by - simpa [mul_assoc] using star_left_conjugate_nonneg hB0 Y - exact add_nonneg hXA hYB + exact add_nonneg + (by simpa [mul_assoc] using star_left_conjugate_nonneg hA0 X) + (by simpa [mul_assoc] using star_left_conjugate_nonneg hB0 Y) have hsum_sa : IsSelfAdjoint (star X * A * X + star Y * B * Y) := IsSelfAdjoint.of_nonneg hsum_nonneg have hmul_block : diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index cf5e1db80..a145e0caa 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -446,14 +446,10 @@ theorem one_div_add_t_operatorAntitoneOn_Ici : ∀ (t : ℝ), 0 < t → have hB_sa : IsSelfAdjoint B := IsSelfAdjoint.of_nonneg B_nonneg have hA_ne0 : ∀ x ∈ spectrum ℝ A, f x ≠ 0 := by intro x hx - have hx0 : (0 : ℝ) ≤ x := by - simpa [Set.Ici] using (As hx) - exact ne_of_gt (add_pos_of_nonneg_of_pos hx0 ht) + exact ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using As hx) ht) have hB_ne0 : ∀ x ∈ spectrum ℝ B, f x ≠ 0 := by intro x hx - have hx0 : (0 : ℝ) ≤ x := by - simpa [Set.Ici] using (Bs hx) - exact ne_of_gt (add_pos_of_nonneg_of_pos hx0 ht) + exact ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Bs hx) ht) let uA : (𝓐)ˣ := cfcUnits (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) f A hA_ne0 (ha := hA_sa) let uB : (𝓐)ˣ := @@ -475,9 +471,7 @@ theorem one_div_add_t_operatorAntitoneOn_Ici : ∀ (t : ℝ), 0 < t → simp only [uB, cfcUnits, f] refine cfc_nonneg (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (a := B) ?_ intro x hx - have hx0 : (0 : ℝ) ≤ x := by - simpa [Set.Ici] using (Bs hx) - exact le_of_lt (add_pos_of_nonneg_of_pos hx0 ht) + exact le_of_lt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Bs hx) ht) have hub_le_hua : (uB : 𝓐) ≤ (uA : 𝓐) := by simpa [huA_val, huB_val, add_assoc, add_left_comm, add_comm] using add_le_add_right BA (algebraMap ℝ (𝓐) t) have hinv : (↑uA⁻¹ : 𝓐) ≤ (↑uB⁻¹ : 𝓐) := by @@ -583,14 +577,12 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → simp [C, add_assoc, add_left_comm, add_comm, smul_add] have hshift_ne0_A : ∀ x ∈ spectrum ℝ A, shift x ≠ 0 := by intro x hx - have hx0 : 0 ≤ x := by - simpa [Set.Ici] using (As hx) - exact ne_of_gt (by simpa [shift] using (add_pos_of_nonneg_of_pos hx0 ht)) + exact ne_of_gt (by + simpa [shift] using add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using As hx) ht) have hshift_ne0_B : ∀ x ∈ spectrum ℝ B, shift x ≠ 0 := by intro x hx - have hx0 : 0 ≤ x := by - simpa [Set.Ici] using (Bs hx) - exact ne_of_gt (by simpa [shift] using (add_pos_of_nonneg_of_pos hx0 ht)) + exact ne_of_gt (by + simpa [shift] using add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Bs hx) ht) have hshift_ne0_C : ∀ x ∈ spectrum ℝ C, shift x ≠ 0 := fun x hx ↦ ne_of_gt (by simpa [shift] using (add_pos_of_nonneg_of_pos (spectrum_nonneg_of_nonneg C_nonneg hx) ht)) have hA_inv : cfcR (fun x : ℝ ↦ (x + t)⁻¹) A = Ring.inverse A1 := by @@ -696,9 +688,7 @@ theorem ratio_add_t_operatorMonotoneOn_Ici : ∀ (t : ℝ), 0 < t → ring have hT_ne0 : ∀ x ∈ spectrum ℝ T, x + t ≠ 0 := by intro x hx - have hx0 : (0 : ℝ) ≤ x := by - simpa [Set.Ici] using (hspT hx) - exact ne_of_gt (add_pos_of_nonneg_of_pos hx0 ht) + exact ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using hspT hx) ht) have hT_cont : ContinuousOn invfun (spectrum ℝ T) := by simpa [invfun, one_div] using (continuousOn_id.add continuousOn_const).inv₀ hT_ne0 dsimp [cfcR] @@ -761,9 +751,7 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → let invfun : ℝ → ℝ := fun x ↦ 1 / (x + t) have hne0 : ∀ x ∈ spectrum ℝ T, x + t ≠ 0 := by intro x hx - have hx0 : (0 : ℝ) ≤ x := by - simpa [Set.Ici] using (Ts hx) - exact ne_of_gt (add_pos_of_nonneg_of_pos hx0 ht) + exact ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Ts hx) ht) have hcont : ContinuousOn invfun (spectrum ℝ T) := by simpa [invfun, one_div] using (continuousOn_id.add continuousOn_const).inv₀ hne0 dsimp [cfcR] diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index af67fdd0a..de65b7d06 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -228,9 +228,8 @@ theorem exists_svd_sqrt_eigenvalues (A : Matrix n n ℂ) : have hleft : (A * W.val) i j = A.mulVec (hH.eigenvectorBasis j).ofLp i := by simp [Matrix.mul_apply, Matrix.mulVec, dotProduct, W, Matrix.IsHermitian.eigenvectorUnitary_apply] by_cases hj : hH.eigenvalues j = 0 - · have hzero : A.mulVec (hH.eigenvectorBasis j).ofLp = 0 := by - apply (WithLp.toLp_injective (p := 2)) - exact inner_self_eq_zero.mp (by + · have hzero : A.mulVec (hH.eigenvectorBasis j).ofLp = 0 := + WithLp.toLp_injective (p := 2) <| inner_self_eq_zero.mp (by rw [inner_A_mulVec_eq] rw [hH.mulVec_eigenvectorBasis j, hj] simp) From 34cacfefd71de92485a68b67ab6d703c61fe6f7f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:22:20 -0700 Subject: [PATCH 228/498] refactor: golf entropy and rpow witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 9 +++------ .../HayataGroup/TraceInequality/LiebAndoTrace.lean | 4 +--- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 5 ++--- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 4 +--- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index f85d65fc5..c499b965d 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -2224,8 +2224,6 @@ theorem qMutualInfo_as_qRelativeEnt (ρ : MState (dA × dB)) : have hP : ρ.M.support ≤ P.support := by intro x hx exact ⟨x, by simpa [P] using fixed_support_kron_prod hx⟩ - have hkerP : P.ker ≤ ρ.M.ker := by - simpa [HermitianMat.support_orthogonal_eq_range] using Submodule.orthogonal_le hP exact (show (ρ.traceRight ⊗ᴹ ρ.traceLeft).M.ker ≤ P.ker by change LinearMap.ker ((Matrix.kroneckerMap (· * ·) ρ.traceRight.M.mat ρ.traceLeft.M.mat).toEuclideanLin) @@ -2238,7 +2236,8 @@ theorem qMutualInfo_as_qRelativeEnt (ρ : MState (dA × dB)) : (show ρ.traceRight.M.ker ≤ ρ.traceRight.M.supportProj.ker by simp)) (by simpa [HermitianMat.ker, HermitianMat.lin] using - (show ρ.traceLeft.M.ker ≤ ρ.traceLeft.M.supportProj.ker by simp))).trans hkerP + (show ρ.traceLeft.M.ker ≤ ρ.traceLeft.M.supportProj.ker by simp))).trans + (by simpa [HermitianMat.support_orthogonal_eq_range] using Submodule.orthogonal_le hP) have right_mul_eq_of_fixed_support {Q ρM : HermitianMat (dA × dB) ℂ} (hfix : ∀ x : EuclideanSpace ℂ (dA × dB), x ∈ ρM.support → Q.lin x = x) : ρM.mat * Q.mat = ρM.mat := by @@ -2445,9 +2444,7 @@ theorem qRelEntropy_le_add_of_le_smul (ρ : MState d) {σ₁ σ₂ : MState d} ( <;> simp only [sup_of_le_left, *] <;> norm_cast at * <;> linarith [Real.log_nonneg one_le_two] - have h_final' : qRelativeEnt ρ σ₁ ≤ qRelativeEnt ρ σ₂ + ENNReal.ofReal (Real.log α) := by - exact_mod_cast h_final - exact h_final' + exact_mod_cast h_final · by_contra h_contra; have hker_le : σ₁.M.ker ≤ σ₂.M.ker := by apply_rules [ HermitianMat.ker_le_of_le_smul, hσ ]; diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean index 0ef287d9d..03a59c682 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean @@ -863,10 +863,8 @@ private lemma pdSet_rpow_of_mem_Icc_zero_one (algebraMap ℝ (L ℋ) r) ^ p = algebraMap ℝ (L ℋ) (r ^ p) := by rw [CFC.rpow_eq_cfc_real (A := L ℋ) (a := algebraMap ℝ (L ℋ) r) (y := p) (ha := hr0)] simp - have hbound : algebraMap ℝ (L ℋ) (r ^ p) ≤ A ^ p := by - simpa [hscalar, hApow] using hmono exact (CFC.exists_pos_algebraMap_le_iff (A := L ℋ) (a := A ^ p) (ha := hApow_sa)).1 - ⟨r ^ p, Real.rpow_pos_of_pos hr p, hbound⟩ + ⟨r ^ p, Real.rpow_pos_of_pos hr p, by simpa [hscalar, hApow] using hmono⟩ omit [Nontrivial ℋ] in set_option maxHeartbeats 400000 in diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index a145e0caa..82d259181 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1486,9 +1486,8 @@ private lemma convexOn_rpow_Ioo_one_two {p : ℝ} (hp : p ∈ Set.Ioo (1 : ℝ) -- reduce to the `ℝ≥0` exponent case with `p = 1 + q`, `q ∈ (0,1)` let q : NNReal := ⟨p - 1, sub_nonneg.mpr (le_of_lt hp.1)⟩ have hq0 : (0 : NNReal) < q := by - have : (0 : ℝ) < (q : ℝ) := by - exact_mod_cast sub_pos.mpr hp.1 - exact (NNReal.coe_pos).1 this + exact (NNReal.coe_pos).1 (show (0 : ℝ) < (q : ℝ) by + exact_mod_cast sub_pos.mpr hp.1) have hq1 : q < (1 : NNReal) := by have : (q : ℝ) < (1 : ℝ) := by have : p - 1 < (1 : ℝ) := by linarith [hp.2] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 84c561c29..89f22d04a 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -1271,9 +1271,7 @@ private lemma tendsto_intervalIntegral_weighted_trace_mul_inv_shift {A : Hermiti apply intervalIntegral.integral_congr_ae filter_upwards with t ht rw [trace_mul_inv_shift_eq_sum_div hA (by - have htIoc : t ∈ Set.Ioc (0 : ℝ) T := by - simpa [Set.uIoc_of_le hT.le] using ht - exact htIoc.1)] + exact (show t ∈ Set.Ioc (0 : ℝ) T by simpa [Set.uIoc_of_le hT.le] using ht).1)] simp [Finset.mul_sum] _ = ∑ i, ∫ t in (0)..T, t ^ (p - 1) * (A.H.eigenvalues i / (A.H.eigenvalues i + t)) := by rw [intervalIntegral.integral_finsetSum] From 8f6fa7e08b4135792ad263fffae615a284186716 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:32:40 -0700 Subject: [PATCH 229/498] refactor: golf Hermitian and regularity wrappers Co-authored-by: Claude Opus 4.8 --- .../SuperSymmetry/SU5/ChargeSpectrum/Basic.lean | 9 +++------ .../DDimensions/Operators/SpectralTheory/Basic.lean | 9 ++++----- .../TraceInequality/JensenOperatorInequality.lean | 4 ++-- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 4 ++-- QuantumInfo/ForMathlib/Matrix.lean | 4 ++-- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean index 69d205ad0..56408a140 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Basic.lean @@ -312,12 +312,9 @@ lemma powerset_of_empty : simp lemma powerset_mono {x y : ChargeSpectrum 𝓩} : - powerset x ⊆ powerset y ↔ x ⊆ y := by - constructor - · intro h - exact mem_powerset_iff_subset.mp (h (self_mem_powerset x)) - · intro h z hz - exact mem_powerset_iff_subset.mpr (subset_trans (mem_powerset_iff_subset.mp hz) h) + powerset x ⊆ powerset y ↔ x ⊆ y := + ⟨fun h => mem_powerset_iff_subset.mp (h (self_mem_powerset x)), + fun h _ hz => mem_powerset_iff_subset.mpr (subset_trans (mem_powerset_iff_subset.mp hz) h)⟩ lemma min_exists_inductive (S : Finset (ChargeSpectrum 𝓩)) (hS : S ≠ ∅) : (n : ℕ) → (hn : S.card = n) → diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean index 07678450e..442852037 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean @@ -150,11 +150,10 @@ lemma isLowerBound_closure def regularityDomain (T : H →ₗ.[ℂ] H) : Set ℂ := {z : ℂ | ∃ c > 0, IsLowerBound T z c} @[simp] -lemma regularityDomain_neg (T : H →ₗ.[ℂ] H) : (-T).regularityDomain = -T.regularityDomain := by - ext z - constructor - · exact fun ⟨c, hc, h_bound⟩ ↦ ⟨c, hc, neg_neg T ▸ isLowerBound_neg h_bound⟩ - · exact fun ⟨c, hc, h_bound⟩ ↦ ⟨c, hc, neg_neg z ▸ isLowerBound_neg h_bound⟩ +lemma regularityDomain_neg (T : H →ₗ.[ℂ] H) : (-T).regularityDomain = -T.regularityDomain := + Set.ext fun z => + ⟨fun ⟨c, hc, h_bound⟩ ↦ ⟨c, hc, neg_neg T ▸ isLowerBound_neg h_bound⟩, + fun ⟨c, hc, h_bound⟩ ↦ ⟨c, hc, neg_neg z ▸ isLowerBound_neg h_bound⟩⟩ @[simp] lemma regularityDomain_smul (T : H →ₗ.[ℂ] H) {w : ℂ} (hw : w ≠ 0) : diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean index 0a9846427..71c5191a9 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean @@ -369,8 +369,8 @@ theorem theorem_2_5_2_i_ici_all_imp_v {f : ℝ → ℝ} have hiv_hsum : CondIV (ℋ := HSum ℋ) f := theorem_2_5_2_i_ici_all_imp_iv (ℋ := HSum ℋ) (f := f) hfIci have hcore := hiv_hsum (A := Atilde) (X := Xtilde) hAtilde_sa hAtilde_spec hXtilde_norm - have hsum_nonneg : (0 : L ℋ) ≤ star X * A * X + star Y * B * Y := by - exact add_nonneg + have hsum_nonneg : (0 : L ℋ) ≤ star X * A * X + star Y * B * Y := + add_nonneg (by simpa [mul_assoc] using star_left_conjugate_nonneg hA0 X) (by simpa [mul_assoc] using star_left_conjugate_nonneg hB0 Y) have hsum_sa : IsSelfAdjoint (star X * A * X + star Y * B * Y) := diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 82d259181..4b64953cc 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1485,8 +1485,8 @@ private lemma convexOn_rpow_Ioo_one_two {p : ℝ} (hp : p ∈ Set.Ioo (1 : ℝ) ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun A : 𝓐 ↦ A ^ p) := by -- reduce to the `ℝ≥0` exponent case with `p = 1 + q`, `q ∈ (0,1)` let q : NNReal := ⟨p - 1, sub_nonneg.mpr (le_of_lt hp.1)⟩ - have hq0 : (0 : NNReal) < q := by - exact (NNReal.coe_pos).1 (show (0 : ℝ) < (q : ℝ) by + have hq0 : (0 : NNReal) < q := + (NNReal.coe_pos).1 (show (0 : ℝ) < (q : ℝ) by exact_mod_cast sub_pos.mpr hp.1) have hq1 : q < (1 : NNReal) := by have : (q : ℝ) < (1 : ℝ) := by diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index ed9f69648..eacea5b28 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -125,8 +125,8 @@ variable (hA : A.IsHermitian) (hB : B.IsHermitian) include hA hB in omit [DecidableEq n] in -theorem kroneckerMap_IsHermitian : (A ⊗ₖ B).IsHermitian := by - exact (hA ▸ hB ▸ kroneckerMap_conjTranspose A B : _ = _) +theorem kroneckerMap_IsHermitian : (A ⊗ₖ B).IsHermitian := + (kroneckerMap_conjTranspose A B).trans (congrArg₂ (· ⊗ₖ ·) hA hB) end Kronecker From 5b92e926b816c395d3aec679757fcf500d9fcede Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:37:00 -0700 Subject: [PATCH 230/498] refactor: golf range and spectrum witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Trigonometry/Tanh.lean | 7 ++----- .../TraceInequality/LownerHeinzCore.lean | 20 ++++++++----------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Physlib/Mathematics/Trigonometry/Tanh.lean b/Physlib/Mathematics/Trigonometry/Tanh.lean index 9f17baa83..9bf515d6a 100644 --- a/Physlib/Mathematics/Trigonometry/Tanh.lean +++ b/Physlib/Mathematics/Trigonometry/Tanh.lean @@ -110,11 +110,8 @@ lemma polynomial_tanh_bounded (P : Polynomial ℝ) : ∃ C : ℝ, ∀ x : ℝ, |P.eval (Real.tanh x)| ≤ C := by -- Since tanh maps to (-1, 1), it maps to [-1+ε, 1-ε] for any ε > 0 -- But more directly, tanh maps to (-1, 1) ⊆ [-1, 1] - have h_range : ∀ x : ℝ, Real.tanh x ∈ Set.Icc (-1) 1 := by - intro x - constructor - · exact le_of_lt (neg_one_lt_tanh x) - · exact le_of_lt (tanh_lt_one x) + have h_range : ∀ x : ℝ, Real.tanh x ∈ Set.Icc (-1) 1 := + fun x => ⟨le_of_lt (neg_one_lt_tanh x), le_of_lt (tanh_lt_one x)⟩ -- Apply polynomial boundedness on [-1, 1] obtain ⟨M, hM⟩ := polynomial_bounded_on_interval P (-1) 1 use M diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 4b64953cc..c2f750215 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -167,12 +167,10 @@ theorem one_div_operatorAntitoneOn_Ioi : let f : ℝ → ℝ := fun x ↦ x have hA_sa : IsSelfAdjoint A := IsSelfAdjoint.of_nonneg A_nonneg have hB_sa : IsSelfAdjoint B := IsSelfAdjoint.of_nonneg B_nonneg - have hA_ne0 : ∀ x ∈ spectrum ℝ A, f x ≠ 0 := by - intro x hx - exact ne_of_gt (As hx) - have hB_ne0 : ∀ x ∈ spectrum ℝ B, f x ≠ 0 := by - intro x hx - exact ne_of_gt (Bs hx) + have hA_ne0 : ∀ x ∈ spectrum ℝ A, f x ≠ 0 := + fun _ hx => ne_of_gt (As hx) + have hB_ne0 : ∀ x ∈ spectrum ℝ B, f x ≠ 0 := + fun _ hx => ne_of_gt (Bs hx) let uA : (𝓐)ˣ := cfcUnits (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) f A hA_ne0 (ha := hA_sa) let uB : (𝓐)ˣ := @@ -444,12 +442,10 @@ theorem one_div_add_t_operatorAntitoneOn_Ici : ∀ (t : ℝ), 0 < t → let f : ℝ → ℝ := fun x => x + t have hA_sa : IsSelfAdjoint A := IsSelfAdjoint.of_nonneg A_nonneg have hB_sa : IsSelfAdjoint B := IsSelfAdjoint.of_nonneg B_nonneg - have hA_ne0 : ∀ x ∈ spectrum ℝ A, f x ≠ 0 := by - intro x hx - exact ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using As hx) ht) - have hB_ne0 : ∀ x ∈ spectrum ℝ B, f x ≠ 0 := by - intro x hx - exact ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Bs hx) ht) + have hA_ne0 : ∀ x ∈ spectrum ℝ A, f x ≠ 0 := + fun _ hx => ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using As hx) ht) + have hB_ne0 : ∀ x ∈ spectrum ℝ B, f x ≠ 0 := + fun _ hx => ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Bs hx) ht) let uA : (𝓐)ˣ := cfcUnits (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) f A hA_ne0 (ha := hA_sa) let uB : (𝓐)ˣ := From efc14a7acff1f6f60750f4d89cd447a640ebcf18 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:40:09 -0700 Subject: [PATCH 231/498] refactor: golf spectrum and trace norm witnesses Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 20 ++++++++----------- .../ForMathlib/MatrixNorm/TraceNorm.lean | 5 ++--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index c2f750215..24135d243 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -571,13 +571,11 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → have hC1 : C1 = C + T := by subst A1 B1 C1 simp [C, add_assoc, add_left_comm, add_comm, smul_add] - have hshift_ne0_A : ∀ x ∈ spectrum ℝ A, shift x ≠ 0 := by - intro x hx - exact ne_of_gt (by + have hshift_ne0_A : ∀ x ∈ spectrum ℝ A, shift x ≠ 0 := + fun _ hx => ne_of_gt (by simpa [shift] using add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using As hx) ht) - have hshift_ne0_B : ∀ x ∈ spectrum ℝ B, shift x ≠ 0 := by - intro x hx - exact ne_of_gt (by + have hshift_ne0_B : ∀ x ∈ spectrum ℝ B, shift x ≠ 0 := + fun _ hx => ne_of_gt (by simpa [shift] using add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Bs hx) ht) have hshift_ne0_C : ∀ x ∈ spectrum ℝ C, shift x ≠ 0 := fun x hx ↦ ne_of_gt (by simpa [shift] using (add_pos_of_nonneg_of_pos (spectrum_nonneg_of_nonneg C_nonneg hx) ht)) @@ -682,9 +680,8 @@ theorem ratio_add_t_operatorMonotoneOn_Ici : ∀ (t : ℝ), 0 < t → simp [invfun] field_simp [ne_of_gt (add_pos_of_nonneg_of_pos hx0 ht)] ring - have hT_ne0 : ∀ x ∈ spectrum ℝ T, x + t ≠ 0 := by - intro x hx - exact ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using hspT hx) ht) + have hT_ne0 : ∀ x ∈ spectrum ℝ T, x + t ≠ 0 := + fun _ hx => ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using hspT hx) ht) have hT_cont : ContinuousOn invfun (spectrum ℝ T) := by simpa [invfun, one_div] using (continuousOn_id.add continuousOn_const).inv₀ hT_ne0 dsimp [cfcR] @@ -745,9 +742,8 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → = algebraMap ℝ (𝓐) (-1 : ℝ) + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) T := by let invfun : ℝ → ℝ := fun x ↦ 1 / (x + t) - have hne0 : ∀ x ∈ spectrum ℝ T, x + t ≠ 0 := by - intro x hx - exact ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Ts hx) ht) + have hne0 : ∀ x ∈ spectrum ℝ T, x + t ≠ 0 := + fun _ hx => ne_of_gt (add_pos_of_nonneg_of_pos (by simpa [Set.Ici] using Ts hx) ht) have hcont : ContinuousOn invfun (spectrum ℝ T) := by simpa [invfun, one_div] using (continuousOn_id.add continuousOn_const).inv₀ hne0 dsimp [cfcR] diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index de65b7d06..6aaa75f3f 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -314,9 +314,8 @@ theorem traceNorm_mul_le_opNorm_traceNorm [DecidableEq n] (A B : Matrix n n ℂ) rw [singularValuesSorted_zero_eq_sup A hcard] rw [Finset.sup'_le_iff] exact fun i _ => singularValues_le_opNorm A i - have hA_bound : ∀ i : Fin (Fintype.card n), singularValuesSorted A i ≤ ‖A‖ := by - intro i - exact ((singularValuesSorted_antitone A) (Fin.zero_le i)).trans htop + have hA_bound : ∀ i : Fin (Fintype.card n), singularValuesSorted A i ≤ ‖A‖ := + fun i => ((singularValuesSorted_antitone A) (Fin.zero_le i)).trans htop calc (A * B).traceNorm = ∑ i : Fin (Fintype.card n), singularValuesSorted (A * B) i := by rw [traceNorm_eq_sum_singularValuesSorted] From cf096dd15f1a13fbdf12612ac660cea29654bd64 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:44:06 -0700 Subject: [PATCH 232/498] refactor: golf continuity and kernel witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Pinching.lean | 5 ++--- QuantumInfo/Entropy/Relative.lean | 15 ++++++--------- .../TraceInequality/LiebAndoTrace.lean | 5 ++--- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 8d529f9ed..1a0d946bd 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -364,9 +364,8 @@ theorem ker_le_ker_pinching_map_ker (ρ σ : MState d) (h : σ.M.ker ≤ ρ.M.ke --TODO Cleanup intro v hv; -- Since $v \in \ker \sigma$, we have $P_k v = 0$ for all $k$ where the eigenvalue of $k$ is non-zero. - have h_proj_zero : ∀ k : spectrum ℝ σ.m, k.val ≠ 0 → (pinching_kraus σ k).mat *ᵥ v = 0 := by - intro k hk - exact pinching_kraus_ker_of_ne_zero σ v congr($hv) k hk + have h_proj_zero : ∀ k : spectrum ℝ σ.m, k.val ≠ 0 → (pinching_kraus σ k).mat *ᵥ v = 0 := + fun k hk => pinching_kraus_ker_of_ne_zero σ v congr($hv) k hk -- Since $v \in \ker \sigma$, we have $P_k v = v$ for all $k$ where the eigenvalue of $k$ is zero. have h_proj_one : ∀ k : spectrum ℝ σ.m, k.val = 0 → (pinching_kraus σ k).mat *ᵥ v = v := by intro k hk diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index c499b965d..682781ff2 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -987,12 +987,10 @@ private lemma trace_cfc_tendsto_of_tendsto (f : ℝ → ℝ) have h_cfc_cont : ContinuousWithinAt (fun A : HermitianMat d ℂ => A.cfc f) {A : HermitianMat d ℂ | 0 ≤ A} ρ := by have h_cont : ContinuousOn (fun A : HermitianMat d ℂ => A.cfc f) {A : HermitianMat d ℂ | 0 ≤ A} := by have h_cont_trace : ContinuousOn (fun A : HermitianMat d ℂ => (A.cfc f)) {A : HermitianMat d ℂ | 0 ≤ A} := by - have h_cont_cfc : ContinuousOn (fun A : HermitianMat d ℂ => A.cfc f) {A : HermitianMat d ℂ | spectrum ℝ A.mat ⊆ Set.Ici 0} := by - intro A hA - exact HermitianMat.continuousWithinAt_cfc_of_continuousOn hf hA - have h_spectrum_subset : ∀ A : HermitianMat d ℂ, 0 ≤ A → spectrum ℝ A.mat ⊆ Set.Ici 0 := by - intro A hA - exact (HermitianMat.posSemidef_iff_spectrum_Ici A).mp hA + have h_cont_cfc : ContinuousOn (fun A : HermitianMat d ℂ => A.cfc f) {A : HermitianMat d ℂ | spectrum ℝ A.mat ⊆ Set.Ici 0} := + fun A hA => HermitianMat.continuousWithinAt_cfc_of_continuousOn hf hA + have h_spectrum_subset : ∀ A : HermitianMat d ℂ, 0 ≤ A → spectrum ℝ A.mat ⊆ Set.Ici 0 := + fun A hA => (HermitianMat.posSemidef_iff_spectrum_Ici A).mp hA exact h_cont_cfc.mono fun A hA => h_spectrum_subset A hA exact h_cont_trace exact h_cont _ ( by simp [ ρ.2 ] ) |> ContinuousWithinAt.mono <| Set.Subset.refl _; @@ -2221,9 +2219,8 @@ theorem qMutualInfo_as_qRelativeEnt (ρ : MState (dA × dB)) : simpa [HermitianMat.lin, Matrix.toEuclideanLin, A, B, ← Matrix.mul_kronecker_mul] using hmul have prod_marginals_ker_le : (ρ.traceRight ⊗ᴹ ρ.traceLeft).M.ker ≤ ρ.M.ker := by let P : HermitianMat (dA × dB) ℂ := ρ.traceRight.M.supportProj ⊗ₖ ρ.traceLeft.M.supportProj - have hP : ρ.M.support ≤ P.support := by - intro x hx - exact ⟨x, by simpa [P] using fixed_support_kron_prod hx⟩ + have hP : ρ.M.support ≤ P.support := + fun x hx => ⟨x, by simpa [P] using fixed_support_kron_prod hx⟩ exact (show (ρ.traceRight ⊗ᴹ ρ.traceLeft).M.ker ≤ P.ker by change LinearMap.ker ((Matrix.kroneckerMap (· * ·) ρ.traceRight.M.mat ρ.traceLeft.M.mat).toEuclideanLin) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean index 03a59c682..46f6301fb 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean @@ -417,9 +417,8 @@ private lemma hmiddle_leftMul_rightMul exact (rightMulHS_cfcR (ℋ := ℋ) (fun x : ℝ ↦ x ^ s) (B ^ (-1 : ℝ)) hBinv_sa (by intro x hx - have hx0 : x ≠ 0 := by - intro hx0 - exact spectrum.zero_notMem (R := ℝ) hBinv_unit (by simpa [hx0] using hx) + have hx0 : x ≠ 0 := + fun hx0 => spectrum.zero_notMem (R := ℝ) hBinv_unit (by simpa [hx0] using hx) exact (Real.continuousAt_rpow_const x s (Or.inl hx0)).continuousWithinAt)).symm have hprod0 : 0 ≤ leftMulHS (ℋ := ℋ) A * rightMulHS (ℋ := ℋ) (B ^ (-1 : ℝ)) := (leftMulHS_rightMulHS_commute (ℋ := ℋ) A (B ^ (-1 : ℝ))).mul_nonneg From 117732cea40c625f1da6448d7b896ac7f7542eb0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:48:58 -0700 Subject: [PATCH 233/498] refactor: golf Lowner-Heinz forwarding wrappers Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzTheorem.lean | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean index 5f05b9fd7..b47d2296d 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean @@ -229,31 +229,26 @@ theorem one_div_operatorConvexOn_Ioi : omit [Nontrivial ℋ] in theorem one_div_add_t_operatorAntitoneOn_Ici : ∀ (t : ℝ), 0 < t → - OperatorAntitoneOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ 1 / (x + t)) := by - intro t ht - exact (LownerHeinzCore.one_div_add_t_operatorAntitoneOn_Ici (𝓐 := L ℋ) t ht) + OperatorAntitoneOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ 1 / (x + t)) := + fun t ht => LownerHeinzCore.one_div_add_t_operatorAntitoneOn_Ici (𝓐 := L ℋ) t ht theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → - OperatorConvexOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ 1 / (x + t)) := by - intro t ht - exact (LownerHeinzCore.one_div_add_t_operatorConvexOn_Ici (𝓐 := L ℋ) t ht) + OperatorConvexOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ 1 / (x + t)) := + fun t ht => LownerHeinzCore.one_div_add_t_operatorConvexOn_Ici (𝓐 := L ℋ) t ht omit [Nontrivial ℋ] in theorem ratio_add_t_operatorMonotoneOn_Ici : ∀ (t : ℝ), 0 < t → - OperatorMonotoneOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ x / (x + t)) := by - intro t ht - exact (LownerHeinzCore.ratio_add_t_operatorMonotoneOn_Ici (𝓐 := L ℋ) t ht) + OperatorMonotoneOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ x / (x + t)) := + fun t ht => LownerHeinzCore.ratio_add_t_operatorMonotoneOn_Ici (𝓐 := L ℋ) t ht theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → - OperatorConcaveOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ x / (x + t)) := by - intro t ht - exact (LownerHeinzCore.ratio_add_t_operatorConcaveOn_Ici (𝓐 := L ℋ) t ht) + OperatorConcaveOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ x / (x + t)) := + fun t ht => LownerHeinzCore.ratio_add_t_operatorConcaveOn_Ici (𝓐 := L ℋ) t ht omit [Nontrivial ℋ] in theorem power_Icc_zero_one_operatorMonotoneOn_Ici : ∀ p ∈ Set.Icc (0 : ℝ) 1, - OperatorMonotoneOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x ↦ x ^ p) := by - intro p hp - exact (LownerHeinzCore.power_Icc_zero_one_operatorMonotoneOn_Ici (𝓐 := L ℋ) p hp) + OperatorMonotoneOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x ↦ x ^ p) := + fun p hp => LownerHeinzCore.power_Icc_zero_one_operatorMonotoneOn_Ici (𝓐 := L ℋ) p hp theorem power_Icc_zero_one_operatorConcaveOn_Ici : ∀ p ∈ Set.Icc (0 : ℝ) 1, OperatorConcaveOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x ↦ x ^ p) := by From 8ed94bd7a10bba56da908f115ed9192ba6bb6343 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:52:08 -0700 Subject: [PATCH 234/498] refactor: golf power theorem wrappers Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzTheorem.lean | 20 ++++++++----------- .../OperatorGeometricMean.lean | 5 ++--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean index b47d2296d..ff6409706 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean @@ -251,24 +251,20 @@ theorem power_Icc_zero_one_operatorMonotoneOn_Ici : ∀ p ∈ Set.Icc (0 : ℝ) fun p hp => LownerHeinzCore.power_Icc_zero_one_operatorMonotoneOn_Ici (𝓐 := L ℋ) p hp theorem power_Icc_zero_one_operatorConcaveOn_Ici : ∀ p ∈ Set.Icc (0 : ℝ) 1, - OperatorConcaveOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x ↦ x ^ p) := by - intro p hp - exact (LownerHeinzCore.power_Icc_zero_one_operatorConcaveOn_Ici (𝓐 := L ℋ) p hp) + OperatorConcaveOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x ↦ x ^ p) := + fun p hp => LownerHeinzCore.power_Icc_zero_one_operatorConcaveOn_Ici (𝓐 := L ℋ) p hp theorem power_Icc_one_two_operatorConvexOn_Ici : ∀ p ∈ Set.Icc (1 : ℝ) 2, - OperatorConvexOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x ↦ x ^ p) := by - intro p hp - exact (LownerHeinzCore.power_Icc_one_two_operatorConvexOn_Ici (𝓐 := L ℋ) p hp) + OperatorConvexOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) (fun x ↦ x ^ p) := + fun p hp => LownerHeinzCore.power_Icc_one_two_operatorConvexOn_Ici (𝓐 := L ℋ) p hp omit [Nontrivial ℋ] in theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (-1 : ℝ) 0, - OperatorMonotoneOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x ↦ -(x ^ p)) := by - intro p hp - exact (LownerHeinzCore.power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi (𝓐 := L ℋ) p hp) + OperatorMonotoneOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x ↦ -(x ^ p)) := + fun p hp => LownerHeinzCore.power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi (𝓐 := L ℋ) p hp theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 : ℝ) 0, - OperatorConcaveOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x ↦ -(x ^ p)) := by - intro p hp - exact (LownerHeinzCore.power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi (𝓐 := L ℋ) p hp) + OperatorConcaveOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x ↦ -(x ^ p)) := + fun p hp => LownerHeinzCore.power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi (𝓐 := L ℋ) p hp end LownerHeinzTheorem diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean index 3c7883d7e..088d12670 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean @@ -25,9 +25,8 @@ noncomputable def operatorPowerMean (α β : ℝ) (A B : L ℋ) : L ℋ := GeneralizedPerspective (fun x : ℝ ↦ x ^ α) (fun x : ℝ ↦ x ^ β) A B private lemma rpow_continuousOn_Ici (p : ℝ) (hp : 0 ≤ p) : - ContinuousOn (fun x : ℝ ↦ x ^ p) (Set.Ici (0 : ℝ)) := by - intro x hx - exact (Real.continuousAt_rpow_const x p (Or.inr hp)).continuousWithinAt + ContinuousOn (fun x : ℝ ↦ x ^ p) (Set.Ici (0 : ℝ)) := + fun x _ => (Real.continuousAt_rpow_const x p (Or.inr hp)).continuousWithinAt omit [Nontrivial ℋ] in private lemma operatorConcaveOn_Ioi_of_Ici {f : ℝ → ℝ} From b21fc68a21477ae1bd2e751f0752e2ef8426c4b1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 20:55:46 -0700 Subject: [PATCH 235/498] refactor: golf continuity and time wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/Basic.lean | 5 ++--- Physlib/Thermodynamics/Temperature/Basic.lean | 5 ++--- QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean | 5 ++--- .../TraceInequality/OperatorGeometricMean.lean | 11 +++++------ 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 282cc14a6..35b20cc18 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -80,9 +80,8 @@ structure Time where namespace Time -lemma val_injective : Function.Injective val := by - intro _ _ h - exact Time.ext h +lemma val_injective : Function.Injective val := + fun _ _ h => Time.ext h /-! diff --git a/Physlib/Thermodynamics/Temperature/Basic.lean b/Physlib/Thermodynamics/Temperature/Basic.lean index 3f9f3ba22..7b51af74a 100644 --- a/Physlib/Thermodynamics/Temperature/Basic.lean +++ b/Physlib/Thermodynamics/Temperature/Basic.lean @@ -191,9 +191,8 @@ lemma beta_fun_T_formula (t : ℝ) (ht : 0 < t) : /-- On `Ioi 0`, `Beta_fun_T t` equals `1 / (kB * t)`. -/ lemma beta_fun_T_eq_on_Ioi : - EqOn betaFromReal (fun t : ℝ => 1 / (kB * t)) (Set.Ioi 0) := by - intro t ht - exact beta_fun_T_formula t ht + EqOn betaFromReal (fun t : ℝ => 1 / (kB * t)) (Set.Ioi 0) := + fun t ht => beta_fun_T_formula t ht lemma deriv_beta_wrt_T (T : Temperature) (hT_pos : 0 < T.val) : HasDerivWithinAt betaFromReal (-1 / (kB * (T.val : ℝ)^2)) (Set.Ioi 0) (T.val : ℝ) := by diff --git a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean index 5c8033b65..1b88c009b 100644 --- a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean +++ b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean @@ -187,9 +187,8 @@ theorem continuousAt_complexLaplaceTransform_of_mem_interior_convergenceDomain theorem continuousOn_complexLaplaceTransform_interior_convergenceDomain {α : Type*} [MeasureTheory.MeasureSpace α] {E : α → WithTop ℝ} : - ContinuousOn (ComplexLaplaceTransform E) (interior (ComplexLaplaceConvergenceDomain E)) := by - intro z hz - exact (continuousAt_complexLaplaceTransform_of_mem_interior_convergenceDomain hz).continuousWithinAt + ContinuousOn (ComplexLaplaceTransform E) (interior (ComplexLaplaceConvergenceDomain E)) := + fun _ hz => (continuousAt_complexLaplaceTransform_of_mem_interior_convergenceDomain hz).continuousWithinAt private theorem integrable_uncurry_complexLaplaceIntegrand_horizontal {α : Type*} [MeasureTheory.MeasureSpace α] diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean index 088d12670..8f7949601 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean @@ -31,9 +31,9 @@ private lemma rpow_continuousOn_Ici (p : ℝ) (hp : 0 ≤ p) : omit [Nontrivial ℋ] in private lemma operatorConcaveOn_Ioi_of_Ici {f : ℝ → ℝ} (h : OperatorConcaveOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) f) : - OperatorConcaveOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) f := by - intro A B t hA hB ht0 ht1 hAs hBs - exact h hA hB ht0 ht1 (Set.Subset.trans hAs Set.Ioi_subset_Ici_self) + OperatorConcaveOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) f := + fun _ _ _ hA hB ht0 ht1 hAs hBs => + h hA hB ht0 ht1 (Set.Subset.trans hAs Set.Ioi_subset_Ici_self) (Set.Subset.trans hBs Set.Ioi_subset_Ici_self) omit [Nontrivial ℋ] in @@ -43,9 +43,8 @@ private lemma pdSet_subset_psdSet : pdSet (ℋ := ℋ) ⊆ psdSet (ℋ := ℋ) : exact ⟨hA_sa, Set.Subset.trans hA_spec Set.Ioi_subset_Ici_self⟩ private lemma rpow_pos_on_Ioi (p : ℝ) : - ∀ x ∈ Set.Ioi (0 : ℝ), 0 < x ^ p := by - intro x hx - exact Real.rpow_pos_of_pos hx p + ∀ x ∈ Set.Ioi (0 : ℝ), 0 < x ^ p := + fun _ hx => Real.rpow_pos_of_pos hx p /-- Theorem 1.1, concave range: the operator `(α, β)`-power mean is jointly concave on From 7a38326a92eda3e2e19945508e3053155a92dd69 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:00:54 -0700 Subject: [PATCH 236/498] refactor: golf injectivity and variational wrappers Co-authored-by: Claude Opus 4.8 --- .../Mathematics/VariationalCalculus/HasVarAdjDeriv.lean | 5 ++--- .../VariationalCalculus/IsLocalizedfunctionTransform.lean | 7 ++++--- Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean | 5 ++--- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 5 ++--- QuantumInfo/States/Mixed/MState.lean | 5 ++--- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index 005814dde..858f8f266 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -190,9 +190,8 @@ lemma comp {F : (Y → V) → (Z → W)} {G : (X → U) → (Y → V)} {u : X {F' G'} (hF : HasVarAdjDerivAt F F' (G u)) (hG : HasVarAdjDerivAt G G' u) : HasVarAdjDerivAt (fun u => F (G u)) (fun ψ => G' (F' ψ)) u where smooth_at := hG.smooth_at - diff := by - intro φ hφ - exact hF.diff (φ := fun t x => G (φ t) x) (hG.diff φ hφ) + diff := fun φ hφ => + hF.diff (φ := fun t x => G (φ t) x) (hG.diff φ hφ) linearize := by intro φ hφ x rw[hF.linearize (fun t x => G (φ t) x) (hG.diff φ hφ)] diff --git a/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean b/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean index 54a7a8eb3..3b1ad4061 100644 --- a/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean +++ b/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean @@ -205,9 +205,10 @@ lemma gradient : IsLocalizedFunctionTransform fun (ψ : Space d → ℝ) x => gr exact Filter.EventuallyEq.fderiv_eq h lemma clm_apply [NormedAddCommGroup V] [NormedSpace ℝ V] [NormedAddCommGroup U] [NormedSpace ℝ U] - (f : X → (U →L[ℝ] V)) : IsLocalizedFunctionTransform fun φ x => (f x) (φ x) := by - intro K cK - exact ⟨K, cK, by intro _ _ hφ _ _; simp_all⟩ + (f : X → (U →L[ℝ] V)) : IsLocalizedFunctionTransform fun φ x => (f x) (φ x) := + fun K cK => ⟨K, cK, by + intro _ _ hφ _ _ + simp_all⟩ lemma deriv [NormedAddCommGroup U] [NormedSpace ℝ U] : IsLocalizedFunctionTransform (fun φ : ℝ → U => deriv φ) := by diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean index c1eb1d0f9..79a92eece 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean @@ -91,9 +91,8 @@ instance : Fintype FieldStatistic where · exact Finset.insert_eq_self.mp rfl @[simp] -lemma fermionic_not_eq_bonsic : ¬ fermionic = bosonic := by - intro h - exact FieldStatistic.noConfusion h +lemma fermionic_not_eq_bonsic : ¬ fermionic = bosonic := + fun h => FieldStatistic.noConfusion h lemma bonsic_eq_fermionic_false : bosonic = fermionic ↔ false := by simp only [reduceCtorEq, Bool.false_eq_true] diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index f6681bf35..7199f1dce 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -84,9 +84,8 @@ lemma val_range : Set.range val = Set.univ := by lemma val_inducing : Topology.IsInducing TimeTransMan.val where eq_induced := rfl -lemma val_injective : Function.Injective TimeTransMan.val := by - intro _ _ h - exact ext_of h +lemma val_injective : Function.Injective TimeTransMan.val := + fun _ _ h => ext_of h lemma val_isOpenEmbedding : Topology.IsOpenEmbedding TimeTransMan.val where eq_induced := rfl diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index f7fda7439..167075fbb 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -129,9 +129,8 @@ theorem ext_m {ρ₁ ρ₂ : MState d} (h : ρ₁.m = ρ₂.m) : ρ₁ = ρ₂ : theorem m_inj : (MState.m (d := d)).Injective := fun _ _ h ↦ by ext1; ext1; exact h -theorem M_Injective : Function.Injective (MState.M (d := d)) := by - intro _ _ - exact MState.ext +theorem M_Injective : Function.Injective (MState.M (d := d)) := + fun _ _ => MState.ext variable (d) in /-- The matrices corresponding to MStates are `Convex ℝ` -/ From dcefac2df4bacb4d344c366f680907a63c315b61 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:07:03 -0700 Subject: [PATCH 237/498] refactor: golf geometric mean and time-order proofs Co-authored-by: Claude Opus 4.8 --- .../AnomalyCancellation/NoGrav/Basic.lean | 4 +--- .../FieldOpFreeAlgebra/TimeOrder.lean | 10 ++++------ .../TraceInequality/OperatorGeometricMean.lean | 10 ++++------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/Basic.lean index d7da16d48..f26e674d9 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/Basic.lean @@ -31,9 +31,7 @@ def SMNoGrav (n : ℕ) : ACCSystem where | 0 => @accSU2 n | 1 => accSU3 numberQuadratic := 0 - quadraticACCs := by - intro i - exact Fin.elim0 i + quadraticACCs := fun i => Fin.elim0 i cubicACC := accCube namespace SMNoGrav diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean index 91ae0dd6f..0d9adc40a 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean @@ -268,18 +268,16 @@ lemma timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_all_not_crAnTimeOrderRel simp simp_all only [imp_false, Decidable.not_not] by_cases h12 : ¬ crAnTimeOrderRel φ1 φ2 - · have h13 : ¬ crAnTimeOrderRel φ1 φ3 := by - intro h13 - exact h12 (IsTrans.trans φ1 φ3 φ2 h13 h32) + · have h13 : ¬ crAnTimeOrderRel φ1 φ3 := + fun h13 => h12 (IsTrans.trans φ1 φ3 φ2 h13 h32) rw [timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_not_crAnTimeOrderRel h12 h13] simp_all only [Decidable.not_not, forall_const] have h13 : crAnTimeOrderRel φ1 φ3 := IsTrans.trans φ1 φ2 φ3 h12 h23 simp_all only [forall_const] by_cases h21 : ¬ crAnTimeOrderRel φ2 φ1 · simp_all only [IsEmpty.forall_iff] - have h31 : ¬ crAnTimeOrderRel φ3 φ1 := by - intro h31 - exact h21 (IsTrans.trans φ2 φ3 φ1 h23 h31) + have h31 : ¬ crAnTimeOrderRel φ3 φ1 := + fun h31 => h21 (IsTrans.trans φ2 φ3 φ1 h23 h31) rw [timeOrderF_superCommuteF_ofCrAnOpF_superCommuteF_not_crAnTimeOrderRel' h21 h31] simp_all only [Decidable.not_not, forall_const] exact False.elim (h (IsTrans.trans φ3 φ2 φ1 h32 h21)) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean index 8f7949601..8c598ee39 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean @@ -69,9 +69,8 @@ theorem operatorPowerMean_jointlyConcaveOn_pdSet (hf0 := Real.rpow_nonneg (show (0 : ℝ) ≤ 0 by simp) α) (hconc := operatorConcaveOn_Ioi_of_Ici (ℋ := ℋ) (power_Icc_zero_one_operatorConcaveOn_Ici (ℋ := ℋ) β hβ)) - (hcont := by - intro x hx - exact (Real.continuousAt_rpow_const x β (Or.inl (ne_of_gt hx))).continuousWithinAt) + (hcont := fun x hx => + (Real.continuousAt_rpow_const x β (Or.inl (ne_of_gt hx))).continuousWithinAt) (hpos := rpow_pos_on_Ioi β) simpa [operatorPowerMean] using hconc (A₁ := A₁) (A₂ := A₂) (B₁ := B₁) (B₂ := B₂) (θ := θ) @@ -104,9 +103,8 @@ theorem operatorPowerMean_jointlyConvexOn_pdSet ) (hconc := operatorConcaveOn_Ioi_of_Ici (ℋ := ℋ) (power_Icc_zero_one_operatorConcaveOn_Ici (ℋ := ℋ) β hβ)) - (hcont := by - intro x hx - exact (Real.continuousAt_rpow_const x β (Or.inl (ne_of_gt hx))).continuousWithinAt) + (hcont := fun x hx => + (Real.continuousAt_rpow_const x β (Or.inl (ne_of_gt hx))).continuousWithinAt) (hpos := rpow_pos_on_Ioi β) simpa [operatorPowerMean] using hconv (A₁ := A₁) (A₂ := A₂) (B₁ := B₁) (B₂ := B₂) (θ := θ) From 348c4d20c1412c5726d0ef80461248b9f42cf74c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:12:25 -0700 Subject: [PATCH 238/498] refactor: golf matrix and concavity wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/InnerProductSpace/Submodule.lean | 4 +--- QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean | 5 ++--- QuantumInfo/ForMathlib/Matrix.lean | 10 ++++------ QuantumInfo/States/Mixed/MState.lean | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Physlib/Mathematics/InnerProductSpace/Submodule.lean b/Physlib/Mathematics/InnerProductSpace/Submodule.lean index a72f1aa6e..475230135 100644 --- a/Physlib/Mathematics/InnerProductSpace/Submodule.lean +++ b/Physlib/Mathematics/InnerProductSpace/Submodule.lean @@ -32,9 +32,7 @@ variable /-- The submodule of `WithLp 2 (E × F)` defined by `M`. -/ def submoduleToLp : Submodule ℂ (WithLp 2 (E × F)) where carrier := {x | x.ofLp ∈ M} - add_mem' := by - intro a b ha hb - exact Submodule.add_mem M ha hb + add_mem' := fun {a b} ha hb => Submodule.add_mem M ha hb zero_mem' := Submodule.zero_mem M smul_mem' := by intro c x hx diff --git a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean index 25cd4b17e..3979ceac8 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean @@ -363,9 +363,8 @@ private lemma liebExtension_bridge_psd [Nonempty d] open scoped Topology in have h_cont : ∀ (ε : ℝ), 0 < ε → (1 - θ) * ⟪(σ₁ ^ q).conj K, (Z₁ + ε • 1) ^ r⟫_ℝ + θ * ⟪(σ₂ ^ q).conj K, (Z₂ + ε • 1) ^ r⟫_ℝ ≤ ⟪(((1 - θ) • σ₁ + θ • σ₂) ^ q).conj K, - ((1 - θ) • (Z₁ + ε • 1) + θ • (Z₂ + ε • 1)) ^ r⟫_ℝ := by - intro ε hε_pos - exact liebExtension_bridge hq hr hqr K σ₁ σ₂ (Z₁ + ε • 1) (Z₂ + ε • 1) hσ₁ hσ₂ + ((1 - θ) • (Z₁ + ε • 1) + θ • (Z₂ + ε • 1)) ^ r⟫_ℝ := fun ε hε_pos => + liebExtension_bridge hq hr hqr K σ₁ σ₂ (Z₁ + ε • 1) (Z₂ + ε • 1) hσ₁ hσ₂ (psd_add_eps_posdef Z₁ hZ₁ ε hε_pos) (psd_add_eps_posdef Z₂ hZ₂ ε hε_pos) θ hθ₀ hθ₁ -- Apply the continuity results to take the limit as ε approaches 0. have h_lim : diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index eacea5b28..eb7e4afa0 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -899,14 +899,12 @@ theorem PosSemidef.pos_of_mem_spectrum {A : Matrix d d 𝕜} (hA : A.PosSemidef) exact hA.eigenvalues_nonneg i theorem PosSemidef.pow_add {A : Matrix d d 𝕜} (hA : A.PosSemidef) {x y : ℝ} (hxy : x + y ≠ 0) : - cfc (· ^ (x + y) : ℝ → ℝ) A = cfc (fun r ↦ r ^ x * r ^ y : ℝ → ℝ) A := by - refine cfc_congr fun r hr ↦ ?_ - exact Real.rpow_add' (hA.pos_of_mem_spectrum r hr) hxy + cfc (· ^ (x + y) : ℝ → ℝ) A = cfc (fun r ↦ r ^ x * r ^ y : ℝ → ℝ) A := + cfc_congr fun r hr => Real.rpow_add' (hA.pos_of_mem_spectrum r hr) hxy theorem PosSemidef.pow_mul {A : Matrix d d 𝕜} {x y : ℝ} (hA : A.PosSemidef) : - cfc (· ^ (x * y) : ℝ → ℝ) A = cfc (fun r ↦ (r ^ x) ^ y : ℝ → ℝ) A := by - refine cfc_congr fun r hr ↦ ?_ - exact Real.rpow_mul (hA.pos_of_mem_spectrum r hr) x y + cfc (· ^ (x * y) : ℝ → ℝ) A = cfc (fun r ↦ (r ^ x) ^ y : ℝ → ℝ) A := + cfc_congr fun r hr => Real.rpow_mul (hA.pos_of_mem_spectrum r hr) x y end more_cfc diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 167075fbb..794b47084 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -127,7 +127,7 @@ theorem ext_m {ρ₁ ρ₂ : MState d} (h : ρ₁.m = ρ₂.m) : ρ₁ = ρ₂ : /-- The map from mixed states to their matrices is injective -/ theorem m_inj : (MState.m (d := d)).Injective := - fun _ _ h ↦ by ext1; ext1; exact h + fun _ _ h => ext_m h theorem M_Injective : Function.Injective (MState.M (d := d)) := fun _ _ => MState.ext From eae63584be15a5e315c77a263ec1cb986c94e866 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:17:26 -0700 Subject: [PATCH 239/498] refactor: golf continuity and closure witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/InnerProductSpace/Submodule.lean | 6 ++---- .../WickContraction/UncontractedList.lean | 8 +++----- .../DDimensions/Operators/Multiplication.lean | 6 +++--- QuantumInfo/Entropy/Relative.lean | 6 +++--- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 6 +++--- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/Physlib/Mathematics/InnerProductSpace/Submodule.lean b/Physlib/Mathematics/InnerProductSpace/Submodule.lean index 475230135..4a6957fac 100644 --- a/Physlib/Mathematics/InnerProductSpace/Submodule.lean +++ b/Physlib/Mathematics/InnerProductSpace/Submodule.lean @@ -32,11 +32,9 @@ variable /-- The submodule of `WithLp 2 (E × F)` defined by `M`. -/ def submoduleToLp : Submodule ℂ (WithLp 2 (E × F)) where carrier := {x | x.ofLp ∈ M} - add_mem' := fun {a b} ha hb => Submodule.add_mem M ha hb + add_mem' := fun {_ _} ha hb => Submodule.add_mem M ha hb zero_mem' := Submodule.zero_mem M - smul_mem' := by - intro c x hx - exact Submodule.smul_mem M c hx + smul_mem' := fun c {_} hx => Submodule.smul_mem M c hx lemma mem_submodule_iff_mem_submoduleToLp : f ∈ M ↔ (WithLp.toLp 2 f) ∈ submoduleToLp M := Eq.to_iff rfl diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index 953ab88dd..1c959aca6 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -52,11 +52,9 @@ lemma fin_finset_sort_map_monotone {n m : ℕ} (a : Finset (Fin n)) (f : Fin n ((a.map f).sort (· ≤ ·)) := by have h1 : ((a.sort (· ≤ ·)).map f).Pairwise (· ≤ ·) := fin_list_sorted_monotone_sorted _ (a.pairwise_sort (fun x1 x2 => x1 ≤ x2)) f hf - have h2 : ((a.sort (· ≤ ·)).map f).Nodup := by - refine (List.nodup_map_iff_inj_on ?_).mpr ?_ - exact a.sort_nodup (fun x1 x2 => x1 ≤ x2) - intro a ha b hb hf - exact f.2 hf + have h2 : ((a.sort (· ≤ ·)).map f).Nodup := + (List.nodup_map_iff_inj_on (a.sort_nodup (fun x1 x2 => x1 ≤ x2))).mpr + fun _ _ _ _ hf => f.2 hf have h3 : ((a.sort (· ≤ ·)).map f).toFinset = (a.map f) := by ext a simp diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean index 96e0856c5..d20b5d1a1 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean @@ -305,9 +305,9 @@ lemma mulOperator_isSelfAdjoint_ofReal -/ lemma mulOperator_isClosable {f : Space d → ℂ} (hf : AEStronglyMeasurable f) : - (𝓜 f).IsClosable := by - refine isClosable_of_exists_dense_formalAdjoint (mulOperator_hasDenseDomain hf) ?_ - exact ⟨𝓜 (conj ∘ f), mulOperator_hasDenseDomain (by measurability), + (𝓜 f).IsClosable := + isClosable_of_exists_dense_formalAdjoint (mulOperator_hasDenseDomain hf) + ⟨𝓜 (conj ∘ f), mulOperator_hasDenseDomain (by measurability), mulOperator_adjoint_eq_conj hf ▸ adjoint_isFormalAdjoint (mulOperator_hasDenseDomain hf)⟩ lemma mulOperator_isUnbounded {f : Space d → ℂ} (hf : AEStronglyMeasurable f) : diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 682781ff2..51f2f3520 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -2397,9 +2397,9 @@ private lemma HermitianMat.inner_log_mono_of_psd_of_le {A B C : HermitianMat d ⟪C, A.log⟫ ≤ ⟪C, B.log⟫ := by open scoped Topology in have h_eventually : ∀ᶠ ε in 𝓝[>] (0 : ℝ), - ⟪C, (A + ε • 1).log⟫ ≤ ⟪C, (B + ε • 1).log⟫ := by - refine eventually_nhdsWithin_of_forall fun ε hε ↦ ?_ - exact inner_log_mono_of_posDef_of_le hC (posDef_add_eps hA hε) (add_le_add_left hAB _) + ⟪C, (A + ε • 1).log⟫ ≤ ⟪C, (B + ε • 1).log⟫ := + eventually_nhdsWithin_of_forall fun ε hε => + inner_log_mono_of_posDef_of_le hC (posDef_add_eps hA hε) (add_le_add_left hAB _) refine le_of_tendsto_of_tendsto ?_ ?_ h_eventually · exact inner_log_shift_tendsto hker · apply inner_log_shift_tendsto diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 467c4b535..16a134711 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -575,9 +575,9 @@ theorem continuous_cfc_joint_compact {X d : Type*} [TopologicalSpace X] [Fintype (hA₂ : ContinuousOn (fun x ↦ A x) S) : ContinuousOn (fun x ↦ (A x).cfc (f x)) S := by intro x x_in_S - have h_eps_delta : ContinuousWithinAt (fun y => (A y).cfc (f x)) S x := by - refine ContinuousOn.continuousWithinAt ?_ x_in_S - exact (continuousOn_cfc_of_compact hT (hf.uncurry_left x x_in_S)).comp hA₂ hA₁ + have h_eps_delta : ContinuousWithinAt (fun y => (A y).cfc (f x)) S x := + ((continuousOn_cfc_of_compact hT (hf.uncurry_left x x_in_S)).comp hA₂ hA₁).continuousWithinAt + x_in_S rw [ ContinuousWithinAt ] at *; rw [ Metric.tendsto_nhds ] at *; intro ε ε_pos From a8002c1e62805cd1c78dfea6912092ab26f3165a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:24:54 -0700 Subject: [PATCH 240/498] refactor: golf equivalence and exponential witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/RatComplexNum.lean | 10 ++-------- .../Mathematics/VariationalCalculus/HasVarAdjoint.lean | 4 +--- Physlib/SpaceAndTime/Time/Basic.lean | 4 +--- QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 2 +- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Physlib/Mathematics/RatComplexNum.lean b/Physlib/Mathematics/RatComplexNum.lean index 49c19f846..042249e26 100644 --- a/Physlib/Mathematics/RatComplexNum.lean +++ b/Physlib/Mathematics/RatComplexNum.lean @@ -36,14 +36,8 @@ lemma ext {x y : RatComplexNum} (h1 : x.1 = y.1) (h2 : x.2 = y.2) : x = y := by def equivToProd : RatComplexNum ≃ ℚ × ℚ where toFun := fun x => (x.1, x.2) invFun := fun x => ⟨x.1, x.2⟩ - left_inv := by - intro x - cases x - rfl - right_inv := by - intro x - cases x - rfl + left_inv := fun ⟨_, _⟩ => rfl + right_inv := fun ⟨_, _⟩ => rfl instance : DecidableEq RatComplexNum := Equiv.decidableEq equivToProd diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean index 6d48dd71f..01f99c50d 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean @@ -405,9 +405,7 @@ lemma clm_apply apply HasAdjoint.congr_adj apply ContinuousLinearMap.hasAdjoint funext y; simp[adjoint_eq_clm_adjoint] - ext' := by - intro K cK - exact ⟨K, cK, by intro _ _ hφ _ _; simp_all⟩ + ext' := fun K cK => ⟨K, cK, by intro _ _ hφ _ _; simp_all⟩ -- ext := IsLocalizedFunctionTransform.clm_apply _ protected lemma deriv : diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 35b20cc18..e46740998 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -362,9 +362,7 @@ noncomputable def basis : OrthonormalBasis (Fin 1) ℝ Time where repr := { toFun := fun x => WithLp.toLp 2 (fun _ => x) invFun := fun f => ⟨f 0⟩ - left_inv := by - intro x - rfl + left_inv := fun _ => rfl right_inv := by intro f ext i diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 6a3a7b92f..5c45bd528 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -63,7 +63,7 @@ theorem reindex_exp (e : d ≃ d₂) : (A.reindex e).exp = A.exp.reindex e := variable (A) in instance nonSingular_exp : NonSingular A.exp := - cfc_nonSingular A Real.exp (fun i ↦ by positivity) + cfc_nonSingular A Real.exp (fun _ => Real.exp_ne_zero _) /-- The matrix exponential of a Hermitian matrix is nonnegative. -/ theorem exp_nonneg (A : HermitianMat d 𝕜) : 0 ≤ A.exp := by From 9b21c9aec07d10b51cd1fb9ad9ec03f7db688eff Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:32:13 -0700 Subject: [PATCH 241/498] refactor: golf time and randvar proof fields Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/TimeMan.lean | 4 +--- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 4 +--- QuantumInfo/ClassicalInfo/Distribution.lean | 6 +++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/TimeMan.lean b/Physlib/SpaceAndTime/Time/TimeMan.lean index 7cbd0277f..a9dffa839 100644 --- a/Physlib/SpaceAndTime/Time/TimeMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeMan.lean @@ -87,9 +87,7 @@ def valHomeomorphism : TimeMan ≃ₜ ℝ where intro t cases t rfl - right_inv := by - intro t - rfl + right_inv := fun _ => rfl continuous_toFun := by fun_prop continuous_invFun := by refine { isOpen_preimage := ?_ } diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index 7199f1dce..32aa0ad12 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -105,9 +105,7 @@ def valHomeomorphism : TimeTransMan ≃ₜ ℝ where intro t cases t rfl - right_inv := by - intro t - rfl + right_inv := fun _ => rfl continuous_toFun := by fun_prop continuous_invFun := by refine { isOpen_preimage := ?_ } diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index f3e7dd4be..9b339aade 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -225,9 +225,9 @@ structure RandVar (α : Type*) [Fintype α] (T : Type*) where instance instFunctor : Functor (RandVar α) where map f e := ⟨f ∘ e.1, e.2⟩ instance instLawfulFunctor : LawfulFunctor (RandVar α) where - map_const {α} {β} := by rfl - id_map _ := by rfl - comp_map _ _ _ := by rfl + map_const {_} {_} := rfl + id_map _ := rfl + comp_map _ _ _ := rfl -- `U` is required to be a group just because mix below uses Convex.sum_mem, -- but it should be provable with just `AddCommMonoid U` From 49b70b119c510dfe52a0b2c697e8af32f9bf8e75 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:36:37 -0700 Subject: [PATCH 242/498] refactor: golf inverse and probability witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean | 5 +---- Physlib/SpaceAndTime/Time/TimeMan.lean | 5 +---- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 5 +---- QuantumInfo/ClassicalInfo/Prob.lean | 4 ++-- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean index eb5b2d6b5..388a31624 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean @@ -520,9 +520,6 @@ def sigmaContractedEquiv : (a : c.1) × a ≃ {x : Fin n // (c.getDual? x).isSom not_false_eq_true] exact Subtype.ext (id (Eq.symm hc)) · simp - right_inv := by - intro x - cases x - rfl + right_inv := fun ⟨_, _⟩ => rfl end WickContraction diff --git a/Physlib/SpaceAndTime/Time/TimeMan.lean b/Physlib/SpaceAndTime/Time/TimeMan.lean index a9dffa839..0de96bad5 100644 --- a/Physlib/SpaceAndTime/Time/TimeMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeMan.lean @@ -83,10 +83,7 @@ lemma isOpen_iff {s : Set TimeMan} : def valHomeomorphism : TimeMan ≃ₜ ℝ where toFun := TimeMan.val invFun := fun t => { val := t } - left_inv := by - intro t - cases t - rfl + left_inv := fun ⟨_⟩ => rfl right_inv := fun _ => rfl continuous_toFun := by fun_prop continuous_invFun := by diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index 32aa0ad12..fd14f6989 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -101,10 +101,7 @@ lemma isOpen_iff {s : Set TimeTransMan} : def valHomeomorphism : TimeTransMan ≃ₜ ℝ where toFun := TimeTransMan.val invFun := fun t => { val := t } - left_inv := by - intro t - cases t - rfl + left_inv := fun ⟨_⟩ => rfl right_inv := fun _ => rfl continuous_toFun := by fun_prop continuous_invFun := by diff --git a/QuantumInfo/ClassicalInfo/Prob.lean b/QuantumInfo/ClassicalInfo/Prob.lean index 6cc1eaa9e..897b5690f 100644 --- a/QuantumInfo/ClassicalInfo/Prob.lean +++ b/QuantumInfo/ClassicalInfo/Prob.lean @@ -43,10 +43,10 @@ instance canLift : CanLift ℝ Prob Subtype.val fun r => 0 ≤ r ∧ r ≤ 1 := Subtype.canLift _ instance instZero : Zero Prob := - ⟨0, by simp⟩ + ⟨0, ⟨le_rfl, zero_le_one⟩⟩ instance instOne : One Prob := - ⟨1, by simp⟩ + ⟨1, ⟨zero_le_one, le_rfl⟩⟩ instance instMul : Mul Prob := ⟨fun x y ↦ ⟨x.1 * y.1, From b24024f9e5c295d486c156c3d44b913774697979 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:40:44 -0700 Subject: [PATCH 243/498] refactor: golf classical probability witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ClassicalInfo/Distribution.lean | 4 ++-- QuantumInfo/ClassicalInfo/Entropy.lean | 4 ++-- QuantumInfo/ClassicalInfo/Prob.lean | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 9b339aade..656d696ac 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -192,10 +192,10 @@ def coin (p : Prob) : ProbDistribution (Fin 2) := ⟨(if · = 0 then p else 1 - p), by simp⟩ @[simp] -theorem coin_val_zero (p : Prob) : coin p 0 = p := by simp [coin] +theorem coin_val_zero (p : Prob) : coin p 0 = p := rfl @[simp] -theorem coin_val_one (p : Prob) : coin p 1 = 1 - p := by simp [coin] +theorem coin_val_one (p : Prob) : coin p 1 = 1 - p := rfl /-- Every distribution on two variable is some coin. -/ theorem fin_two_eq_coin (d : ProbDistribution (Fin 2)) : d = coin (d 0) := by diff --git a/QuantumInfo/ClassicalInfo/Entropy.lean b/QuantumInfo/ClassicalInfo/Entropy.lean index dc861525d..3c9e381a1 100644 --- a/QuantumInfo/ClassicalInfo/Entropy.lean +++ b/QuantumInfo/ClassicalInfo/Entropy.lean @@ -31,11 +31,11 @@ def H₁ : Prob → ℝ := /-- H₁ of 0 is zero.-/ @[simp] -def H₁_zero_eq_zero : H₁ 0 = 0 := by simp [H₁] +def H₁_zero_eq_zero : H₁ 0 = 0 := Real.negMulLog_zero /-- H₁ of 1 is zero.-/ @[simp] -def H₁_one_eq_zero : H₁ 1 = 0 := by simp [H₁] +def H₁_one_eq_zero : H₁ 1 = 0 := Real.negMulLog_one /-- Entropy is nonnegative. -/ theorem H₁_nonneg (p : Prob) : 0 ≤ H₁ p := by diff --git a/QuantumInfo/ClassicalInfo/Prob.lean b/QuantumInfo/ClassicalInfo/Prob.lean index 897b5690f..f8682d1f0 100644 --- a/QuantumInfo/ClassicalInfo/Prob.lean +++ b/QuantumInfo/ClassicalInfo/Prob.lean @@ -120,7 +120,7 @@ theorem ne_iff {x y : Prob} : (x : ℝ) ≠ (y : ℝ) ↔ x ≠ y := not_congr <| Prob.ext_iff.symm @[simp, norm_cast] -theorem toReal_mul (x y : Prob) : (x * y : Prob) = (x : ℝ) * (y : ℝ) := by simp only [coe_mul] +theorem toReal_mul (x y : Prob) : (x * y : Prob) = (x : ℝ) * (y : ℝ) := rfl /-- Coercion `Prob → ℝ≥0`. -/ @[coe] def toNNReal : Prob → ℝ≥0 := From 20d784c6221f486193828e44acd3ed264ed79a8c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:46:48 -0700 Subject: [PATCH 244/498] refactor: golf unit and scalar witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 4 ++-- QuantumInfo/ClassicalInfo/Distribution.lean | 2 +- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index b8b35c3bb..859f805dc 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -112,8 +112,8 @@ def UnitDependent.scaleUnitEquiv {M : Type} [UnitDependent M] (u1 u2 : UnitChoices) : M ≃ M where toFun m := scaleUnit u1 u2 m invFun m := scaleUnit u2 u1 m - right_inv m := by simp - left_inv m := by simp + right_inv m := UnitDependent.scaleUnit_symm_apply u2 u1 m + left_inv m := UnitDependent.scaleUnit_symm_apply u1 u2 m /-- For an `M` with an instance of `LinearUnitDependent M`, `scaleUnit u1 u2` as a linear map. -/ diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 656d696ac..9bb050895 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -300,7 +300,7 @@ def congrRandVar (σ : α ≃ β) : RandVar α T ≃ RandVar β T := by /-- Given a `T`-valued random variable `X` over `α`, mapping over `T` commutes with the equivalence over `α` -/ def map_congr_eq_congr_map {S : Type _} [Mixable U S] (f : T → S) (σ : α ≃ β) (X : RandVar α T) : - f <$> congrRandVar σ X = congrRandVar σ (f <$> X) := by rfl + f <$> congrRandVar σ X = congrRandVar σ (f <$> X) := rfl /-- The expectation value is invariant under equivalence of random variables -/ @[simp] diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 24135d243..907ac3a48 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1586,8 +1586,9 @@ private lemma square_convexity_diff_hL (A B : 𝓐) (u : ℝ) : have : u • (B * B) - (u * u) • (B * B) = (u - u * u) • (B * B) := by simpa using (sub_smul u (u * u) (B * B)).symm simp [this, hα2] - have hAB : ((1 - u) * u) • (A * B) = α • (A * B) := by simp [hα3] - have hBA : (u * (1 - u)) • (B * A) = α • (B * A) := by rfl + have hAB : ((1 - u) * u) • (A * B) = α • (A * B) := + congrArg (fun x => x • (A * B)) hα3 + have hBA : (u * (1 - u)) • (B * A) = α • (B * A) := rfl have hL : (1 - u) • (A * A) + u • (B * B) - (((1 - u) * (1 - u)) • (A * A) + ((1 - u) * u) • (A * B) From 2d67a9f883c3bd29ef672020434069bd6da0123d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:53:34 -0700 Subject: [PATCH 245/498] refactor: golf unit linearity witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 859f805dc..1870338c7 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -122,8 +122,8 @@ def LinearUnitDependent.scaleUnitLinear (u1 u2 : UnitChoices) : M →ₗ[ℝ] M where toFun m := scaleUnit u1 u2 m - map_add' m1 m2 := by simp [LinearUnitDependent.scaleUnit_add] - map_smul' r m2 := by simp [LinearUnitDependent.scaleUnit_smul] + map_add' m1 m2 := LinearUnitDependent.scaleUnit_add u1 u2 m1 m2 + map_smul' r m2 := LinearUnitDependent.scaleUnit_smul u1 u2 r m2 /-- For an `M` with an instance of `LinearUnitDependent M`, `scaleUnit u1 u2` as a linear equivalence. -/ @@ -307,15 +307,19 @@ noncomputable instance {M1 M2 : Type} [AddCommMonoid M1] [Module ℝ M1] LinearUnitDependent (M1 →ₗ[ℝ] M2) where scaleUnit u1 u2 f := { toFun m1 := scaleUnit u1 u2 (f m1) - map_add' m1 m2 := by simp [scaleUnit_add] - map_smul' := by simp [scaleUnit_smul]} + map_add' m1 m2 := + Eq.trans (congrArg (scaleUnit u1 u2) (map_add f m1 m2)) + (scaleUnit_add u1 u2 (f m1) (f m2)) + map_smul' r m2 := + Eq.trans (congrArg (scaleUnit u1 u2) (map_smul f r m2)) + (scaleUnit_smul u1 u2 r (f m2))} scaleUnit_trans u1 u2 u3 f := LinearMap.ext fun m1 => scaleUnit_trans u1 u2 u3 (f m1) scaleUnit_trans' u1 u2 u3 f := LinearMap.ext fun m1 => scaleUnit_trans' u1 u2 u3 (f m1) scaleUnit_id u f := LinearMap.ext fun m1 => scaleUnit_id u (f m1) - scaleUnit_add u1 u2 f1 f2 := LinearMap.ext fun m => by - simp [scaleUnit_add] + scaleUnit_add u1 u2 f1 f2 := LinearMap.ext fun m => + scaleUnit_add u1 u2 (f1 m) (f2 m) scaleUnit_smul u1 u2 r f := LinearMap.ext fun m => by simp [scaleUnit_smul] From 0efdbb1d9fc052f06f5a79abe5f547fb0d0af097 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 21:58:06 -0700 Subject: [PATCH 246/498] refactor: golf unit map linearity witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 1870338c7..3ea1241b6 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -320,8 +320,8 @@ noncomputable instance {M1 M2 : Type} [AddCommMonoid M1] [Module ℝ M1] scaleUnit_id u f := LinearMap.ext fun m1 => scaleUnit_id u (f m1) scaleUnit_add u1 u2 f1 f2 := LinearMap.ext fun m => scaleUnit_add u1 u2 (f1 m) (f2 m) - scaleUnit_smul u1 u2 r f := LinearMap.ext fun m => by - simp [scaleUnit_smul] + scaleUnit_smul u1 u2 r f := LinearMap.ext fun m => + scaleUnit_smul u1 u2 r (f m) open LinearUnitDependent ContinuousLinearUnitDependent in noncomputable instance {M1 M2 : Type} [AddCommGroup M1] [Module ℝ M1] @@ -338,8 +338,10 @@ noncomputable instance {M1 M2 : Type} [AddCommGroup M1] [Module ℝ M1] scaleUnit_trans' u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => scaleUnit_trans' u1 u2 u3 (f m1) scaleUnit_id u f := ContinuousLinearMap.ext fun m1 => scaleUnit_id u (f m1) - scaleUnit_add u1 u2 f1 f2 := by simp - scaleUnit_smul u1 u2 r f := by simp + scaleUnit_add u1 u2 f1 f2 := ContinuousLinearMap.ext fun m => + scaleUnit_add u1 u2 (f1 m) (f2 m) + scaleUnit_smul u1 u2 r f := ContinuousLinearMap.ext fun m => + scaleUnit_smul u1 u2 r (f m) scaleUnit_cont u1 u2 := ContinuousLinearEquiv.continuous ((ContinuousLinearEquiv.refl ℝ M1).arrowCongr (scaleUnitContLinearEquiv u1 u2)) @@ -404,8 +406,10 @@ noncomputable instance instContinuousLinearUnitDependentMap simp [scaleUnit_trans'] scaleUnit_id u f := ContinuousLinearMap.ext fun m1 => by simp [scaleUnit_id] - scaleUnit_add u1 u2 f1 f2 := by simp - scaleUnit_smul u1 u2 r f := by simp + scaleUnit_add u1 u2 f1 f2 := ContinuousLinearMap.ext fun m => + scaleUnit_add u1 u2 (f1 (scaleUnit u2 u1 m)) (f2 (scaleUnit u2 u1 m)) + scaleUnit_smul u1 u2 r f := ContinuousLinearMap.ext fun m => + scaleUnit_smul u1 u2 r (f (scaleUnit u2 u1 m)) scaleUnit_cont u1 u2 := ContinuousLinearEquiv.continuous ((scaleUnitContLinearEquiv u1 u2).arrowCongr (scaleUnitContLinearEquiv u1 u2)) From fe4a2abef3f948558aaaf3ce8a9308af5210612c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 22:02:03 -0700 Subject: [PATCH 247/498] refactor: golf function unit-dependence witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 3ea1241b6..804b6fd2d 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -348,12 +348,11 @@ noncomputable instance {M1 M2 : Type} [AddCommGroup M1] [Module ℝ M1] noncomputable instance {M1 M2 : Type} [UnitDependent M1] : UnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => f (scaleUnit u2 u1 m1) - scaleUnit_trans u1 u2 u3 f := funext fun m1 => by - simp [scaleUnit_trans] - scaleUnit_trans' u1 u2 u3 f := funext fun m1 => by - simp [scaleUnit_trans'] - scaleUnit_id u f := funext fun m1 => by - simp [scaleUnit_id] + scaleUnit_trans u1 u2 u3 f := funext fun m1 => + congrArg f (scaleUnit_trans u3 u2 u1 m1) + scaleUnit_trans' u1 u2 u3 f := funext fun m1 => + congrArg f (scaleUnit_trans' u3 u2 u1 m1) + scaleUnit_id u f := funext fun m1 => congrArg f (scaleUnit_id u m1) @[simp] lemma UnitDependent.scaleUnit_apply_fun_left {M1 M2 : Type} [UnitDependent M1] @@ -364,10 +363,16 @@ noncomputable instance instUnitDependentTwoSided {M1 M2 : Type} [UnitDependent M1] [UnitDependent M2] : UnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => scaleUnit u1 u2 (f (scaleUnit u2 u1 m1)) - scaleUnit_trans u1 u2 u3 f := funext fun m1 => by - simp [scaleUnit_trans] - scaleUnit_trans' u1 u2 u3 f := funext fun m1 => by - simp [scaleUnit_trans'] + scaleUnit_trans u1 u2 u3 f := funext fun m1 => + Eq.trans + (congrArg (fun x => scaleUnit u2 u3 (scaleUnit u1 u2 (f x))) + (scaleUnit_trans u3 u2 u1 m1)) + (scaleUnit_trans u1 u2 u3 (f (scaleUnit u3 u1 m1))) + scaleUnit_trans' u1 u2 u3 f := funext fun m1 => + Eq.trans + (congrArg (fun x => scaleUnit u1 u2 (scaleUnit u2 u3 (f x))) + (scaleUnit_trans' u3 u2 u1 m1)) + (scaleUnit_trans' u1 u2 u3 (f (scaleUnit u3 u1 m1))) scaleUnit_id u f := funext fun m1 => by simp [scaleUnit_id] From 0c48b55237ceb2bb376bfba355cc00c7317392a0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 22:05:49 -0700 Subject: [PATCH 248/498] refactor: golf multiplicative function unit witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 804b6fd2d..a8abdb707 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -373,8 +373,9 @@ noncomputable instance instUnitDependentTwoSided (congrArg (fun x => scaleUnit u1 u2 (scaleUnit u2 u3 (f x))) (scaleUnit_trans' u3 u2 u1 m1)) (scaleUnit_trans' u1 u2 u3 (f (scaleUnit u3 u1 m1))) - scaleUnit_id u f := funext fun m1 => by - simp [scaleUnit_id] + scaleUnit_id u f := funext fun m1 => + Eq.trans (congrArg (scaleUnit u u) (congrArg f (scaleUnit_id u m1))) + (scaleUnit_id u (f m1)) @[simp] lemma UnitDependent.scaleUnit_apply_fun {M1 M2 : Type} [UnitDependent M1] @@ -385,14 +386,21 @@ noncomputable instance instUnitDependentTwoSidedMul {M1 M2 : Type} [UnitDependent M1] [MulAction ℝ≥0 M2] [MulUnitDependent M2] : MulUnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => scaleUnit u1 u2 (f (scaleUnit u2 u1 m1)) - scaleUnit_trans u1 u2 u3 f := funext fun m1 => by - simp [scaleUnit_trans] - scaleUnit_trans' u1 u2 u3 f := funext fun m1 => by - simp [scaleUnit_trans'] - scaleUnit_id u f := funext fun m1 => by - simp [scaleUnit_id] - scaleUnit_mul u1 u2 r f := funext fun m1 => by - simp [MulUnitDependent.scaleUnit_mul] + scaleUnit_trans u1 u2 u3 f := funext fun m1 => + Eq.trans + (congrArg (fun x => scaleUnit u2 u3 (scaleUnit u1 u2 (f x))) + (scaleUnit_trans u3 u2 u1 m1)) + (scaleUnit_trans u1 u2 u3 (f (scaleUnit u3 u1 m1))) + scaleUnit_trans' u1 u2 u3 f := funext fun m1 => + Eq.trans + (congrArg (fun x => scaleUnit u1 u2 (scaleUnit u2 u3 (f x))) + (scaleUnit_trans' u3 u2 u1 m1)) + (scaleUnit_trans' u1 u2 u3 (f (scaleUnit u3 u1 m1))) + scaleUnit_id u f := funext fun m1 => + Eq.trans (congrArg (scaleUnit u u) (congrArg f (scaleUnit_id u m1))) + (scaleUnit_id u (f m1)) + scaleUnit_mul u1 u2 r f := funext fun m1 => + MulUnitDependent.scaleUnit_mul u1 u2 r (f (scaleUnit u2 u1 m1)) open LinearUnitDependent ContinuousLinearUnitDependent in noncomputable instance instContinuousLinearUnitDependentMap From 6e5f305c9298e707862cca0638e167015f17eaff Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 22:09:46 -0700 Subject: [PATCH 249/498] refactor: golf continuous map and dimset witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index a8abdb707..c436dd44a 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -413,12 +413,19 @@ noncomputable instance instContinuousLinearUnitDependentMap scaleUnit u1 u2 f := ContinuousLinearEquiv.arrowCongr (scaleUnitContLinearEquiv u1 u2) (scaleUnitContLinearEquiv u1 u2) f - scaleUnit_trans u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => by - simp [scaleUnit_trans] - scaleUnit_trans' u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => by - simp [scaleUnit_trans'] - scaleUnit_id u f := ContinuousLinearMap.ext fun m1 => by - simp [scaleUnit_id] + scaleUnit_trans u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => + Eq.trans + (congrArg (fun x => scaleUnit u2 u3 (scaleUnit u1 u2 (f x))) + (scaleUnit_trans u3 u2 u1 m1)) + (scaleUnit_trans u1 u2 u3 (f (scaleUnit u3 u1 m1))) + scaleUnit_trans' u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => + Eq.trans + (congrArg (fun x => scaleUnit u1 u2 (scaleUnit u2 u3 (f x))) + (scaleUnit_trans' u3 u2 u1 m1)) + (scaleUnit_trans' u1 u2 u3 (f (scaleUnit u3 u1 m1))) + scaleUnit_id u f := ContinuousLinearMap.ext fun m1 => + Eq.trans (congrArg (scaleUnit u u) (congrArg f (scaleUnit_id u m1))) + (scaleUnit_id u (f m1)) scaleUnit_add u1 u2 f1 f2 := ContinuousLinearMap.ext fun m => scaleUnit_add u1 u2 (f1 (scaleUnit u2 u1 m)) (f2 (scaleUnit u2 u1 m)) scaleUnit_smul u1 u2 r f := ContinuousLinearMap.ext fun m => @@ -525,14 +532,8 @@ instance (M : Type) [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) : smul a f := ⟨a • f.1, fun u1 u2 => by rw [smul_comm, ← f.2] rw [MulUnitDependent.scaleUnit_mul]⟩ - one_smul f := by - ext - change (1 : ℝ≥0) • f.1 = f.1 - simp - mul_smul a b f := by - ext - change (a * b) • f.1 = a • (b • f.1) - rw [smul_smul] + one_smul f := Subtype.ext (one_smul ℝ≥0 f.1) + mul_smul a b f := Subtype.ext (mul_smul a b f.1) instance (M : Type) [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) : CarriesDimension (DimSet M d) where From dfe24bf025f47b2c6f115f32ad1b91cb9ae6d8bc Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 22:14:08 -0700 Subject: [PATCH 250/498] refactor: golf unitary and ulift witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/ULift.lean | 2 +- QuantumInfo/ForMathlib/Unitary.lean | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/QuantumInfo/ForMathlib/ULift.lean b/QuantumInfo/ForMathlib/ULift.lean index 355989d42..1987b34f2 100644 --- a/QuantumInfo/ForMathlib/ULift.lean +++ b/QuantumInfo/ForMathlib/ULift.lean @@ -32,7 +32,7 @@ theorem ULift.star_eq {𝕜 : Type u} [Star 𝕜] (x : ULift.{v,u} 𝕜) : star instance ULift.instInvolutiveStar {𝕜 : Type u} [InvolutiveStar 𝕜] : InvolutiveStar (ULift.{v,u} 𝕜) where - star_involutive x := by simp + star_involutive x := congrArg ULift.up (star_star x.down) instance ULift.instStarMul {𝕜 : Type u} [Mul 𝕜] [StarMul 𝕜] : StarMul (ULift.{v,u} 𝕜) where star_mul x y := by simp; rfl diff --git a/QuantumInfo/ForMathlib/Unitary.lean b/QuantumInfo/ForMathlib/Unitary.lean index 5b09a3d5b..d8bc70797 100644 --- a/QuantumInfo/ForMathlib/Unitary.lean +++ b/QuantumInfo/ForMathlib/Unitary.lean @@ -45,10 +45,10 @@ noncomputable def conj_unitary_eigenspace_equiv (T : E →ₗ[𝕜] E) (U : unit have hv := v.2 rw [mem_eigenspace_iff] at hv ⊢ simpa using congrArg ((star U.val) ·) hv⟩ - map_add' := by simp - map_smul' := by simp - left_inv _ := by simp - right_inv _ := by simp + map_add' v w := Subtype.ext (map_add U.val v.val w.val) + map_smul' c v := Subtype.ext (map_smul U.val c v.val) + left_inv v := Subtype.ext (unitary_star_apply_eq U v.val) + right_inv v := Subtype.ext (unitary_apply_star_eq U v.val) end unitary namespace IsSymmetric From 4a8e6ec948fda3868dd884cf8dbce6b170fe873d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 22:21:32 -0700 Subject: [PATCH 251/498] refactor: golf ulift and unit equivalence witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Units/UnitDependent.lean | 4 ++-- QuantumInfo/ForMathlib/ULift.lean | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index c436dd44a..522e6daca 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -131,8 +131,8 @@ def LinearUnitDependent.scaleUnitLinearEquiv {M : Type} [AddCommMonoid M] [Module ℝ M] [LinearUnitDependent M] (u1 u2 : UnitChoices) : M ≃ₗ[ℝ] M := LinearEquiv.ofLinear (scaleUnitLinear u1 u2) (scaleUnitLinear u2 u1) - (by ext u; simp [scaleUnitLinear]) - (by ext u; simp [scaleUnitLinear]) + (LinearMap.ext fun m => UnitDependent.scaleUnit_symm_apply u2 u1 m) + (LinearMap.ext fun m => UnitDependent.scaleUnit_symm_apply u1 u2 m) /-- For an `M` with an instance of `ContinuousLinearUnitDependent M`, `scaleUnit u1 u2` as a continuous linear map. -/ diff --git a/QuantumInfo/ForMathlib/ULift.lean b/QuantumInfo/ForMathlib/ULift.lean index 1987b34f2..75672d4dc 100644 --- a/QuantumInfo/ForMathlib/ULift.lean +++ b/QuantumInfo/ForMathlib/ULift.lean @@ -35,10 +35,10 @@ instance ULift.instInvolutiveStar {𝕜 : Type u} [InvolutiveStar 𝕜] : star_involutive x := congrArg ULift.up (star_star x.down) instance ULift.instStarMul {𝕜 : Type u} [Mul 𝕜] [StarMul 𝕜] : StarMul (ULift.{v,u} 𝕜) where - star_mul x y := by simp; rfl + star_mul x y := congrArg ULift.up (star_mul x.down y.down) instance {𝕜 : Type u} [NonUnitalNonAssocSemiring 𝕜] [StarRing 𝕜] : StarRing (ULift.{v,u} 𝕜) where - star_add x y := by simp; rfl + star_add x y := congrArg ULift.up (star_add x.down y.down) @[simp] theorem ULift.starRingEnd_down {𝕜 : Type u} (x : ULift.{v,u} 𝕜) [CommSemiring 𝕜] [StarRing 𝕜] : @@ -69,7 +69,7 @@ noncomputable instance {𝕜 : Type u} [RCLike 𝕜] : RCLike (ULift.{v,u} 𝕜) ext1 exact h re_add_im_ax z := by exact congrArg ULift.up (RCLike.re_add_im_ax z.down) - ofReal_re_ax r := by simp + ofReal_re_ax r := RCLike.ofReal_re_ax r ofReal_im_ax := by simp mul_re_ax z w := by simp mul_im_ax := by simp From a13962e4e08de54be363eb73ae1f1d8c246a4548 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 22:26:44 -0700 Subject: [PATCH 252/498] refactor: golf Hilbert-Schmidt op-star hom witnesses Co-authored-by: Claude Opus 4.8 --- .../HilbertSchmidtOperatorSpace.lean | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean index a772a8cc2..e23a2fe49 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean @@ -521,21 +521,15 @@ noncomputable def rightMulHSStarAlgHom : (L ℋ)ᵐᵒᵖ →⋆ₐ[ℝ] L (HSOp /-- The `⋆`-algebra hom sending `A` to `op (star A)`. On selfadjoint operators this is just `op`. -/ noncomputable def opStarHSStarAlgHom : L ℋ →⋆ₐ[ℝ] (L ℋ)ᵐᵒᵖ where toFun := fun A => MulOpposite.op (star A) - map_one' := by simp - map_mul' := by - intro A B - simp [star_mul] - map_zero' := by simp - map_add' := by - intro A B - simp + map_one' := congrArg MulOpposite.op (star_one (R := L ℋ)) + map_mul' A B := congrArg MulOpposite.op (star_mul A B) + map_zero' := congrArg MulOpposite.op (star_zero (R := L ℋ)) + map_add' A B := congrArg MulOpposite.op (star_add A B) commutes' := by intro r apply congrArg MulOpposite.op simp [Algebra.algebraMap_eq_smul_one] - map_star' := by - intro A - simp + map_star' A := rfl private noncomputable def opStarHSAlgEquiv : L ℋ ≃ₐ[ℝ] (L ℋ)ᵐᵒᵖ where toFun A := MulOpposite.op (star A) From 4f3b9ee438d477cc2bbdf2979b0454571a20d7d8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 22:49:15 -0700 Subject: [PATCH 253/498] refactor: remove non-golf proof expansions Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/EulerLagrange.lean | 3 +- .../HarmonicOscillator/Basic.lean | 12 +-- .../AnomalyCancellation/Basic.lean | 3 +- .../StandardModel/HiggsBoson/Potential.lean | 6 +- .../SU5/ChargeSpectrum/Yukawa.lean | 3 +- .../WickAlgebra/SuperCommute.lean | 6 +- .../WickAlgebra/TimeContraction.lean | 3 +- .../WickAlgebra/TimeOrder.lean | 3 +- .../WickAlgebra/Universality.lean | 6 +- .../LorentzGroup/Orthochronous/Basic.lean | 3 +- Physlib/Relativity/PauliMatrices/Basic.lean | 3 +- .../Relativity/PauliMatrices/Relations.lean | 5 +- Physlib/Relativity/SL2C/Basic.lean | 3 +- Physlib/Relativity/Tensors/Basic.lean | 3 +- .../Tensors/RealTensor/CoVector/Basic.lean | 3 +- .../RealTensor/CoVector/Representation.lean | 3 +- .../Tensors/RealTensor/Vector/Basic.lean | 3 +- .../Tensors/RealTensor/Vector/Pre/Basic.lean | 6 +- .../RealTensor/Vector/Pre/Contraction.lean | 9 +- .../RealTensor/Vector/Pre/Modules.lean | 3 +- .../RealTensor/Vector/Representation.lean | 3 +- .../Tensors/RealTensor/Velocity/Basic.lean | 3 +- Physlib/Units/UnitDependent.lean | 93 +++++++------------ .../TraceInequality/LownerHeinzCore.lean | 5 +- 24 files changed, 69 insertions(+), 124 deletions(-) diff --git a/Physlib/ClassicalMechanics/EulerLagrange.lean b/Physlib/ClassicalMechanics/EulerLagrange.lean index d57013dd1..bc5a9a3e4 100644 --- a/Physlib/ClassicalMechanics/EulerLagrange.lean +++ b/Physlib/ClassicalMechanics/EulerLagrange.lean @@ -33,8 +33,7 @@ noncomputable def eulerLagrangeOp (L : Time → X → X → ℝ) (q : Time → X lemma eulerLagrangeOp_eq (L : Time → X → X → ℝ) (q : Time → X) : eulerLagrangeOp L q = fun t => gradient (L t · (∂ₜ q t)) (q t) - - ∂ₜ (fun t' => gradient (L t' (q t') ·) (∂ₜ q t')) t := - rfl + - ∂ₜ (fun t' => gradient (L t' (q t') ·) (∂ₜ q t')) t := rfl lemma eulerLagrangeOp_zero (q : Time → X) : eulerLagrangeOp (fun _ _ _ => 0) q = fun _ => 0 := by simp [eulerLagrangeOp_eq, Time.deriv_eq] diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index 147fb079b..643dcde33 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -209,16 +209,13 @@ noncomputable def energy (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : Time → -/ lemma kineticEnergy_eq (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - kineticEnergy S xₜ = fun t => (1 / (2 : ℝ)) * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ := - rfl + kineticEnergy S xₜ = fun t => (1 / (2 : ℝ)) * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ := rfl lemma potentialEnergy_eq (x : EuclideanSpace ℝ (Fin 1)) : - potentialEnergy S x = (1 / (2 : ℝ)) • S.k • ⟪x, x⟫_ℝ := - rfl + potentialEnergy S x = (1 / (2 : ℝ)) • S.k • ⟪x, x⟫_ℝ := rfl lemma energy_eq (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - energy S xₜ = fun t => kineticEnergy S xₜ t + potentialEnergy S (xₜ t) := - rfl + energy S xₜ = fun t => kineticEnergy S xₜ t + potentialEnergy S (xₜ t) := rfl /-! ### C.3. Differentiability of the energies @@ -516,8 +513,7 @@ We write a simple iff statement for the definition of the equation of motions. -/ lemma equationOfMotion_iff_gradLagrangian_zero (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - S.EquationOfMotion xₜ ↔ S.gradLagrangian xₜ = 0 := - Iff.rfl + S.EquationOfMotion xₜ ↔ S.gradLagrangian xₜ = 0 := Iff.rfl /-! diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index 6a0d9f4c2..a0f7efd39 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -53,8 +53,7 @@ def toSpecies (i : Fin 5) : (SMCharges n).Charges →ₗ[ℚ] (SMSpecies n).Char map_smul' _ _ := rfl lemma toSpecies_apply_eq (i : Fin 5) (S : (SMCharges n).Charges) : - toSpecies i S = fun j => toSpeciesEquiv S i j := - rfl + toSpecies i S = fun j => toSpeciesEquiv S i j := rfl lemma charges_eq_toSpecies_eq (S T : (SMCharges n).Charges) : S = T ↔ ∀ i, toSpecies i S = toSpecies i T := diff --git a/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean b/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean index 437aebe98..5ab279b1f 100644 --- a/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean +++ b/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean @@ -77,12 +77,10 @@ lemma toFun_neg (φ : HiggsField) (x : SpaceTime) : P.neg.toFun φ x = - P.toFun ring @[simp] -lemma μ2_neg : P.neg.μ2 = - P.μ2 := - rfl +lemma μ2_neg : P.neg.μ2 = - P.μ2 := rfl @[simp] -lemma 𝓵_neg : P.neg.𝓵 = - P.𝓵 := - rfl +lemma 𝓵_neg : P.neg.𝓵 = - P.𝓵 := rfl /-! diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean index 705a9039a..ecf0eeb8d 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean @@ -166,8 +166,7 @@ instance (x : ChargeSpectrum 𝓩) (n : ℕ) : Decidable (YukawaGeneratesDangero lemma YukawaGeneratesDangerousAtLevel_iff_inter {x : ChargeSpectrum 𝓩} {n : ℕ} : YukawaGeneratesDangerousAtLevel x n ↔ - (x.ofYukawaTermsNSum n) ∩ x.phenoConstrainingChargesSP ≠ ∅ := - Iff.rfl + (x.ofYukawaTermsNSum n) ∩ x.phenoConstrainingChargesSP ≠ ∅ := by rfl lemma yukawaGeneratesDangerousAtLevel_iff_toFinset (x : ChargeSpectrum 𝓩) (n : ℕ) : x.YukawaGeneratesDangerousAtLevel n ↔ diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 6d443ed25..ebff68e69 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -69,12 +69,10 @@ noncomputable def superCommuteRight (a : 𝓕.FieldOpFreeAlgebra) : simp lemma superCommuteRight_apply_ι (a b : 𝓕.FieldOpFreeAlgebra) : - superCommuteRight a (ι b) = ι [a, b]ₛF := - rfl + superCommuteRight a (ι b) = ι [a, b]ₛF := rfl lemma superCommuteRight_apply_quot (a b : 𝓕.FieldOpFreeAlgebra) : - superCommuteRight a ⟦b⟧= ι [a, b]ₛF := - rfl + superCommuteRight a ⟦b⟧= ι [a, b]ₛF := rfl lemma superCommuteRight_eq_of_equiv (a1 a2 : 𝓕.FieldOpFreeAlgebra) (h : a1 ≈ a2) : superCommuteRight a1 = superCommuteRight a2 := by diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean index f789e8f50..58dfc0e7c 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean @@ -33,8 +33,7 @@ def timeContract (φ ψ : 𝓕.FieldOp) : 𝓕.WickAlgebra := 𝓣(ofFieldOp φ * ofFieldOp ψ) - 𝓝(ofFieldOp φ * ofFieldOp ψ) lemma timeContract_eq_smul (φ ψ : 𝓕.FieldOp) : timeContract φ ψ = - 𝓣(ofFieldOp φ * ofFieldOp ψ) + (-1 : ℂ) • 𝓝(ofFieldOp φ * ofFieldOp ψ) := - rfl + 𝓣(ofFieldOp φ * ofFieldOp ψ) + (-1 : ℂ) • 𝓝(ofFieldOp φ * ofFieldOp ψ) := rfl /-- For a field specification `𝓕`, and `φ` and `ψ` elements of `𝓕.FieldOp`, if `φ` and `ψ` are time-ordered then diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 4cca33b7a..c7f6f07f2 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -180,8 +180,7 @@ lemma ι_timeOrderF_superCommuteF_superCommuteF {φ1 φ2 φ3 : 𝓕.CrAnFieldOp} simp_all [pb] example (c1 c2 : ℂ) (a : 𝓕.WickAlgebra) : c1 • c2 • a = - c2 • c1 • a := - smul_comm c1 c2 a + c2 • c1 • a := smul_comm c1 c2 a lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp} (hφψ : crAnTimeOrderRel φ ψ) (hψφ : crAnTimeOrderRel ψ φ) (a b : 𝓕.FieldOpFreeAlgebra) : ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * b) = diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean index ae5847347..0c435b782 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean @@ -40,8 +40,7 @@ def universalLiftMap {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnField @[simp] lemma universalLiftMap_ι {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp → A) (h1 : ∀ a ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet, FreeAlgebra.lift ℂ f a = 0) : - universalLiftMap f h1 (ι a) = FreeAlgebra.lift ℂ f a := - rfl + universalLiftMap f h1 (ι a) = FreeAlgebra.lift ℂ f a := rfl /-- For a field specification, `𝓕`, given an algebra `A` and a function `f : 𝓕.CrAnFieldOp → A` such that the lift of `f` to `FreeAlgebra.lift ℂ f : FreeAlgebra ℂ 𝓕.CrAnFieldOp → A` is @@ -75,8 +74,7 @@ def universalLift {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp @[simp] lemma universalLift_ι {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp → A) (h1 : ∀ a ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet, FreeAlgebra.lift ℂ f a = 0) : - universalLift f h1 (ι a) = FreeAlgebra.lift ℂ f a := - rfl + universalLift f h1 (ι a) = FreeAlgebra.lift ℂ f a := rfl /-- For a field specification, `𝓕`, the algebra `𝓕.WickAlgebra` satisfies the following universal diff --git a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean index 316a6c58e..2f7b739e3 100644 --- a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean @@ -42,8 +42,7 @@ lemma isOrthochronous_iff_toVector_timeComponet_nonneg : /-- A Lorentz transformation is orthochronous if and only if its transpose is orthochronous. -/ lemma isOrthochronous_iff_transpose : - IsOrthochronous Λ ↔ IsOrthochronous (transpose Λ) := - Iff.rfl + IsOrthochronous Λ ↔ IsOrthochronous (transpose Λ) := Iff.rfl @[simp] lemma isOrthochronous_inv_iff {Λ : LorentzGroup d} : diff --git a/Physlib/Relativity/PauliMatrices/Basic.lean b/Physlib/Relativity/PauliMatrices/Basic.lean index 13ba8fa2b..471937671 100644 --- a/Physlib/Relativity/PauliMatrices/Basic.lean +++ b/Physlib/Relativity/PauliMatrices/Basic.lean @@ -101,8 +101,7 @@ instance pauliMatrixInvertiable (μ : Fin 1 ⊕ Fin 3) : Invertible (σ μ) := b · simp lemma pauliMatrix_inv (μ : Fin 1 ⊕ Fin 3) : - ⅟ (σ μ) = σ μ := - rfl + ⅟ (σ μ) = σ μ := by rfl /-! ### Products diff --git a/Physlib/Relativity/PauliMatrices/Relations.lean b/Physlib/Relativity/PauliMatrices/Relations.lean index 18c334032..fd5aecf1a 100644 --- a/Physlib/Relativity/PauliMatrices/Relations.lean +++ b/Physlib/Relativity/PauliMatrices/Relations.lean @@ -124,10 +124,7 @@ lemma pauliContr_mul_pauliContrDown_add : lemma auliContrDown_pauliContr_mul_add : {((σ^__ | μ β α ⊗ σ^^^ | ν α β') + (σ^__ | ν β α ⊗ σ^^^ | μ α β')) = 2 •ₜ η | μ ν ⊗ δR' | β β'}ᵀ := by - rw [show Tensorial.toTensor σ^__ = σ^__ from rfl, - show Tensorial.toTensor (Tensorial.toTensor σ) = Tensorial.toTensor σ from rfl, - show Tensorial.toTensor η = η from rfl, - show Tensorial.toTensor δR' = δR' from rfl] + simp only [Tensorial.self_toTensor_apply] conv_lhs => rw [pauliContrDown_ofRat, toTensor_eq_ofRat, prodT_ofRat_ofRat, contrT_ofRat, permT_ofRat, ← map_add] diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index c1ad0370a..89738d925 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -176,8 +176,7 @@ def toLorentzGroup : SL(2, ℂ) →* LorentzGroup 3 where lemma toLorentzGroup_eq_pauliBasis' (M : SL(2, ℂ)) : toLorentzGroup M = LinearMap.toMatrix - PauliMatrix.pauliBasis' PauliMatrix.pauliBasis' (toSelfAdjointMap M) := - rfl + PauliMatrix.pauliBasis' PauliMatrix.pauliBasis' (toSelfAdjointMap M) := rfl lemma toSelfAdjointMap_basis (i : Fin 1 ⊕ Fin 3) : toSelfAdjointMap M (PauliMatrix.pauliBasis' i) = diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index 5d47abd1b..9ab0ed6ed 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -209,8 +209,7 @@ noncomputable def component {n : ℕ} {c : Fin n → C} (p : Pure S c) ∏ i, (b (c i)).repr (p i) (φ i) lemma component_eq {n : ℕ} {c : Fin n → C} (p : Pure S c) (φ : ComponentIdx c) : - p.component φ = ∏ i, (b (c i)).repr (p i) (φ i) := - rfl + p.component φ = ∏ i, (b (c i)).repr (p i) (φ i) := rfl lemma component_eq_drop {n : ℕ} {c : Fin (n + 1) → C} (p : Pure S c) (i : Fin (n + 1)) (φ : ComponentIdx c) : diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean index 94fb4021d..b7cd4902f 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean @@ -120,8 +120,7 @@ lemma apply_add {d : ℕ} (v w : CoVector d) (i : Fin 1 ⊕ Fin d) : @[simp] lemma apply_sub {d : ℕ} (v w : CoVector d) (i : Fin 1 ⊕ Fin d) : - (v - w) i = v i - w i := - rfl + (v - w) i = v i - w i := rfl @[simp] lemma apply_sum {d : ℕ} {ι : Type} [Fintype ι] (f : ι → CoVector d) (i : Fin 1 ⊕ Fin d) : diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean index f1400cf1a..0babc590a 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean @@ -46,8 +46,7 @@ def rep {d : ℕ} : Representation ℝ (LorentzGroup d) (CoVector d) where -/ lemma rep_apply_eq_mulVec (d : ℕ) (Λ : LorentzGroup d) (v : CoVector d) : - rep Λ v = (LorentzGroup.transpose Λ⁻¹) *ᵥ v := - rfl + rep Λ v = (LorentzGroup.transpose Λ⁻¹) *ᵥ v := rfl lemma rep_apply_eq_sum (d : ℕ) (Λ : LorentzGroup d) (v : CoVector d) (k : Fin 1 ⊕ Fin d) : rep Λ v k = ∑ j, (Λ⁻¹).1 j k • v j := rfl diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean index f698ec9ed..c0dcc239b 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean @@ -137,8 +137,7 @@ lemma apply_add {d : ℕ} (v w : Vector d) (i : Fin 1 ⊕ Fin d) : @[simp] lemma apply_sub {d : ℕ} (v w : Vector d) (i : Fin 1 ⊕ Fin d) : - (v - w) i = v i - w i := - rfl + (v - w) i = v i - w i := rfl lemma apply_sum {d : ℕ} {ι : Type} [Fintype ι] (f : ι → Vector d) (i : Fin 1 ⊕ Fin d) : (∑ j, f j) i = ∑ j, f j i := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index f4bc80206..5879219bf 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -63,8 +63,7 @@ lemma contrBasisFin_toFin1dℝ {d : ℕ} (i : Fin (1 + d)) : simp only [contrBasisFin, Basis.reindex_apply, contrBasis_toFin1dℝ] lemma contrBasisFin_repr_apply {d : ℕ} (p : ContrMod d) (i : Fin (1 + d)) : - (contrBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := - rfl + (contrBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := rfl /-- The representation of contravariant Lorentz vectors forms a topological space, induced by its equivalence to `Fin 1 ⊕ Fin d → ℝ`. -/ @@ -120,8 +119,7 @@ lemma coBasisFin_toFin1dℝ {d : ℕ} (i : Fin (1 + d)) : simp only [coBasisFin, Basis.reindex_apply, coBasis_toFin1dℝ] lemma coBasisFin_repr_apply {d : ℕ} (p : Co d) (i : Fin (1 + d)) : - (coBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := - rfl + (coBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := rfl open CategoryTheory.MonoidalCategory diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 57441ddfd..635aa9b2f 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -97,8 +97,7 @@ def contrCoContract : ((ContrMod.rep).tprod (CoMod.rep)).IntertwiningMap /-- Notation for `contrCoContract` acting on a tmul. -/ local notation "⟪" ψ "," φ "⟫ₘ" => contrCoContract (ψ ⊗ₜ φ) -lemma contrCoContract_hom_tmul (ψ : Contr d) (φ : Co d) : ⟪ψ, φ⟫ₘ = ψ.toFin1dℝ ⬝ᵥ φ.toFin1dℝ := - rfl +lemma contrCoContract_hom_tmul (ψ : Contr d) (φ : Co d) : ⟪ψ, φ⟫ₘ = ψ.toFin1dℝ ⬝ᵥ φ.toFin1dℝ := rfl /-- The linear map from Co d ⊗ Contr d to ℝ given by summing over components of contravariant Lorentz vector and @@ -119,8 +118,7 @@ def coContrContract : ((CoMod.rep (d := d)).tprod (ContrMod.rep (d := d))).Inter /-- Notation for `coContrContract` acting on a tmul. -/ local notation "⟪" φ "," ψ "⟫ₘ" => coContrContract (φ ⊗ₜ ψ) -lemma coContrContract_hom_tmul (φ : Co d) (ψ : Contr d) : ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ ψ.toFin1dℝ := - rfl +lemma coContrContract_hom_tmul (φ : Co d) (ψ : Contr d) : ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ ψ.toFin1dℝ := rfl /-! @@ -172,8 +170,7 @@ def coCoContract : ((CoMod.rep (d := d)).tprod (CoMod.rep (d := d))).Intertwinin local notation "⟪" ψ "," φ "⟫ₘ" => coCoContract (ψ ⊗ₜ φ) lemma coCoContract_hom_tmul (φ : Co d) (ψ : Co d) : - ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ := - rfl + ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ := rfl /-! diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index ae6b139d0..ccd607f57 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -72,8 +72,7 @@ def toFin1dℝEquiv : ContrMod d ≃ₗ[ℝ] (Fin 1 ⊕ Fin d → ℝ) := through the linear equivalence `toFin1dℝEquiv`. -/ abbrev toFin1dℝ (ψ : ContrMod d) := toFin1dℝEquiv ψ -lemma toFin1dℝ_eq_val (ψ : ContrMod d) : ψ.toFin1dℝ = ψ.val := - rfl +lemma toFin1dℝ_eq_val (ψ : ContrMod d) : ψ.toFin1dℝ = ψ.val := rfl /-! ## The standard basis. diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean index 4e00521f8..3b650d4f3 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean @@ -43,8 +43,7 @@ def rep {d : ℕ} : Representation ℝ (LorentzGroup d) (Vector d) where -/ lemma rep_apply_eq_mulVec (d : ℕ) (Λ : LorentzGroup d) (v : Vector d) : - rep Λ v = Λ *ᵥ v := - rfl + rep Λ v = Λ *ᵥ v := rfl lemma rep_apply_eq_sum (d : ℕ) (Λ : LorentzGroup d) (v : Vector d) (k : Fin 1 ⊕ Fin d) : rep Λ v k = ∑ j, Λ.1 k j • v j := rfl diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index 1fa115ef6..cd7ea0a61 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -38,8 +38,7 @@ noncomputable instance : TopologicalSpace (Velocity d) := instTopologicalSpaceSu lemma ext {v w : Velocity d} (h : v.1 = w.1) : v = w := SetCoe.ext h -lemma mem_iff {v : Vector d} : v ∈ Velocity d ↔ ⟪v, v⟫ₘ = (1 : ℝ) ∧ 0 < v.timeComponent := - Iff.rfl +lemma mem_iff {v : Vector d} : v ∈ Velocity d ↔ ⟪v, v⟫ₘ = (1 : ℝ) ∧ 0 < v.timeComponent := Iff.rfl @[simp] lemma minkowskiProduct_self_eq_one (v : Velocity d) : ⟪v.1, v.1⟫ₘ = (1 : ℝ) := v.2.1 diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 522e6daca..c6381bd1e 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -131,8 +131,8 @@ def LinearUnitDependent.scaleUnitLinearEquiv {M : Type} [AddCommMonoid M] [Module ℝ M] [LinearUnitDependent M] (u1 u2 : UnitChoices) : M ≃ₗ[ℝ] M := LinearEquiv.ofLinear (scaleUnitLinear u1 u2) (scaleUnitLinear u2 u1) - (LinearMap.ext fun m => UnitDependent.scaleUnit_symm_apply u2 u1 m) - (LinearMap.ext fun m => UnitDependent.scaleUnit_symm_apply u1 u2 m) + (by ext u; simp [scaleUnitLinear]) + (by ext u; simp [scaleUnitLinear]) /-- For an `M` with an instance of `ContinuousLinearUnitDependent M`, `scaleUnit u1 u2` as a continuous linear map. -/ @@ -307,12 +307,8 @@ noncomputable instance {M1 M2 : Type} [AddCommMonoid M1] [Module ℝ M1] LinearUnitDependent (M1 →ₗ[ℝ] M2) where scaleUnit u1 u2 f := { toFun m1 := scaleUnit u1 u2 (f m1) - map_add' m1 m2 := - Eq.trans (congrArg (scaleUnit u1 u2) (map_add f m1 m2)) - (scaleUnit_add u1 u2 (f m1) (f m2)) - map_smul' r m2 := - Eq.trans (congrArg (scaleUnit u1 u2) (map_smul f r m2)) - (scaleUnit_smul u1 u2 r (f m2))} + map_add' m1 m2 := by simp [scaleUnit_add] + map_smul' := by simp [scaleUnit_smul]} scaleUnit_trans u1 u2 u3 f := LinearMap.ext fun m1 => scaleUnit_trans u1 u2 u3 (f m1) scaleUnit_trans' u1 u2 u3 f := LinearMap.ext fun m1 => @@ -338,10 +334,8 @@ noncomputable instance {M1 M2 : Type} [AddCommGroup M1] [Module ℝ M1] scaleUnit_trans' u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => scaleUnit_trans' u1 u2 u3 (f m1) scaleUnit_id u f := ContinuousLinearMap.ext fun m1 => scaleUnit_id u (f m1) - scaleUnit_add u1 u2 f1 f2 := ContinuousLinearMap.ext fun m => - scaleUnit_add u1 u2 (f1 m) (f2 m) - scaleUnit_smul u1 u2 r f := ContinuousLinearMap.ext fun m => - scaleUnit_smul u1 u2 r (f m) + scaleUnit_add u1 u2 f1 f2 := by simp + scaleUnit_smul u1 u2 r f := by simp scaleUnit_cont u1 u2 := ContinuousLinearEquiv.continuous ((ContinuousLinearEquiv.refl ℝ M1).arrowCongr (scaleUnitContLinearEquiv u1 u2)) @@ -363,19 +357,15 @@ noncomputable instance instUnitDependentTwoSided {M1 M2 : Type} [UnitDependent M1] [UnitDependent M2] : UnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => scaleUnit u1 u2 (f (scaleUnit u2 u1 m1)) - scaleUnit_trans u1 u2 u3 f := funext fun m1 => - Eq.trans - (congrArg (fun x => scaleUnit u2 u3 (scaleUnit u1 u2 (f x))) - (scaleUnit_trans u3 u2 u1 m1)) - (scaleUnit_trans u1 u2 u3 (f (scaleUnit u3 u1 m1))) - scaleUnit_trans' u1 u2 u3 f := funext fun m1 => - Eq.trans - (congrArg (fun x => scaleUnit u1 u2 (scaleUnit u2 u3 (f x))) - (scaleUnit_trans' u3 u2 u1 m1)) - (scaleUnit_trans' u1 u2 u3 (f (scaleUnit u3 u1 m1))) - scaleUnit_id u f := funext fun m1 => - Eq.trans (congrArg (scaleUnit u u) (congrArg f (scaleUnit_id u m1))) - (scaleUnit_id u (f m1)) + scaleUnit_trans u1 u2 u3 f := by + funext m1 + simp [scaleUnit_trans] + scaleUnit_trans' u1 u2 u3 f := by + funext m1 + simp [scaleUnit_trans'] + scaleUnit_id u f := by + funext m1 + simp [scaleUnit_id] @[simp] lemma UnitDependent.scaleUnit_apply_fun {M1 M2 : Type} [UnitDependent M1] @@ -386,19 +376,15 @@ noncomputable instance instUnitDependentTwoSidedMul {M1 M2 : Type} [UnitDependent M1] [MulAction ℝ≥0 M2] [MulUnitDependent M2] : MulUnitDependent (M1 → M2) where scaleUnit u1 u2 f := fun m1 => scaleUnit u1 u2 (f (scaleUnit u2 u1 m1)) - scaleUnit_trans u1 u2 u3 f := funext fun m1 => - Eq.trans - (congrArg (fun x => scaleUnit u2 u3 (scaleUnit u1 u2 (f x))) - (scaleUnit_trans u3 u2 u1 m1)) - (scaleUnit_trans u1 u2 u3 (f (scaleUnit u3 u1 m1))) - scaleUnit_trans' u1 u2 u3 f := funext fun m1 => - Eq.trans - (congrArg (fun x => scaleUnit u1 u2 (scaleUnit u2 u3 (f x))) - (scaleUnit_trans' u3 u2 u1 m1)) - (scaleUnit_trans' u1 u2 u3 (f (scaleUnit u3 u1 m1))) - scaleUnit_id u f := funext fun m1 => - Eq.trans (congrArg (scaleUnit u u) (congrArg f (scaleUnit_id u m1))) - (scaleUnit_id u (f m1)) + scaleUnit_trans u1 u2 u3 f := by + funext m1 + simp [scaleUnit_trans] + scaleUnit_trans' u1 u2 u3 f := by + funext m1 + simp [scaleUnit_trans'] + scaleUnit_id u f := by + funext m1 + simp [scaleUnit_id] scaleUnit_mul u1 u2 r f := funext fun m1 => MulUnitDependent.scaleUnit_mul u1 u2 r (f (scaleUnit u2 u1 m1)) @@ -413,23 +399,17 @@ noncomputable instance instContinuousLinearUnitDependentMap scaleUnit u1 u2 f := ContinuousLinearEquiv.arrowCongr (scaleUnitContLinearEquiv u1 u2) (scaleUnitContLinearEquiv u1 u2) f - scaleUnit_trans u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => - Eq.trans - (congrArg (fun x => scaleUnit u2 u3 (scaleUnit u1 u2 (f x))) - (scaleUnit_trans u3 u2 u1 m1)) - (scaleUnit_trans u1 u2 u3 (f (scaleUnit u3 u1 m1))) - scaleUnit_trans' u1 u2 u3 f := ContinuousLinearMap.ext fun m1 => - Eq.trans - (congrArg (fun x => scaleUnit u1 u2 (scaleUnit u2 u3 (f x))) - (scaleUnit_trans' u3 u2 u1 m1)) - (scaleUnit_trans' u1 u2 u3 (f (scaleUnit u3 u1 m1))) - scaleUnit_id u f := ContinuousLinearMap.ext fun m1 => - Eq.trans (congrArg (scaleUnit u u) (congrArg f (scaleUnit_id u m1))) - (scaleUnit_id u (f m1)) - scaleUnit_add u1 u2 f1 f2 := ContinuousLinearMap.ext fun m => - scaleUnit_add u1 u2 (f1 (scaleUnit u2 u1 m)) (f2 (scaleUnit u2 u1 m)) - scaleUnit_smul u1 u2 r f := ContinuousLinearMap.ext fun m => - scaleUnit_smul u1 u2 r (f (scaleUnit u2 u1 m)) + scaleUnit_trans u1 u2 u3 f := by + ext m1 + simp [scaleUnit_trans] + scaleUnit_trans' u1 u2 u3 f := by + ext m1 + simp [scaleUnit_trans'] + scaleUnit_id u f := by + ext m1 + simp [scaleUnit_id] + scaleUnit_add u1 u2 f1 f2 := by simp + scaleUnit_smul u1 u2 r f := by simp scaleUnit_cont u1 u2 := ContinuousLinearEquiv.continuous ((scaleUnitContLinearEquiv u1 u2).arrowCongr (scaleUnitContLinearEquiv u1 u2)) @@ -547,5 +527,4 @@ lemma scaleUnit_dimSet_val {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] rfl lemma DimSet.mem_iff {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) (m : M) : - m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := - Iff.rfl + m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := Iff.rfl diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 907ac3a48..24135d243 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1586,9 +1586,8 @@ private lemma square_convexity_diff_hL (A B : 𝓐) (u : ℝ) : have : u • (B * B) - (u * u) • (B * B) = (u - u * u) • (B * B) := by simpa using (sub_smul u (u * u) (B * B)).symm simp [this, hα2] - have hAB : ((1 - u) * u) • (A * B) = α • (A * B) := - congrArg (fun x => x • (A * B)) hα3 - have hBA : (u * (1 - u)) • (B * A) = α • (B * A) := rfl + have hAB : ((1 - u) * u) • (A * B) = α • (A * B) := by simp [hα3] + have hBA : (u * (1 - u)) • (B * A) = α • (B * A) := by rfl have hL : (1 - u) • (A * A) + u • (B * B) - (((1 - u) * (1 - u)) • (A * A) + ((1 - u) * u) • (A * B) From bb9cbd291d78298e916c3ad09dba166b462e7309 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 22:59:59 -0700 Subject: [PATCH 254/498] refactor: golf bundled channel map wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Bundled.lean | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/QuantumInfo/Channels/Bundled.lean b/QuantumInfo/Channels/Bundled.lean index a30c1f75a..4ab4982bf 100644 --- a/QuantumInfo/Channels/Bundled.lean +++ b/QuantumInfo/Channels/Bundled.lean @@ -177,8 +177,7 @@ namespace PMap @[ext] theorem ext {Λ₁ Λ₂ : PMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - rw [PMap.mk.injEq] - exact HPMap.ext h + exact (mk.injEq _ _ _ _).mpr (HPMap.ext h) theorem injective_toHPMap : (PMap.toHPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := fun _ _ ↦ (mk.injEq _ _ _ _).mpr @@ -231,8 +230,7 @@ namespace PTPMap @[ext] theorem ext {Λ₁ Λ₂ : PTPMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - rw [PTPMap.mk.injEq] - exact PMap.ext h + exact (mk.injEq _ _ _ _).mpr (PMap.ext h) theorem injective_toPMap : (PTPMap.toPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := fun _ _ ↦ (mk.injEq _ _ _ _).mpr @@ -317,8 +315,7 @@ variable [DecidableEq dIn] /-- Two `CPTPMap`s are equal if their `MatrixMap`s are equal. -/ @[ext] theorem ext {Λ₁ Λ₂ : CPTPMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - rw [CPTPMap.mk.injEq] - exact PTPMap.ext h + exact (mk.injEq _ _ _ _).mpr (PTPMap.ext h) theorem injective_toPTPMap : (CPTPMap.toPTPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := fun _ _ ↦ (mk.injEq _ _ _ _).mpr @@ -375,12 +372,10 @@ variable [DecidableEq dIn] [DecidableEq dOut] @[ext] theorem ext {Λ₁ Λ₂ : PUMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - rw [PUMap.mk.injEq] - exact PMap.ext h + exact (mk.injEq _ _ _ _).mpr (PMap.ext h) -theorem injective_toPMap : (PUMap.toPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := by - intro _ _ _ - rwa [PUMap.mk.injEq] +theorem injective_toPMap : (PUMap.toPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := + fun _ _ ↦ (mk.injEq _ _ _ _).mpr /-- `PUMap`s are functions from `HermitianMat`s to `HermitianMat`s. -/ noncomputable instance instFunLike : FunLike (PUMap dIn dOut ℂ) (HermitianMat dIn ℂ) (HermitianMat dOut ℂ) where From fbbed1f1177298b4066202092e1b88e87a5a7884 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:02:44 -0700 Subject: [PATCH 255/498] refactor: golf channel choi wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Bundled.lean | 8 +++----- QuantumInfo/Channels/CPTP.lean | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Channels/Bundled.lean b/QuantumInfo/Channels/Bundled.lean index 4ab4982bf..1d40380c5 100644 --- a/QuantumInfo/Channels/Bundled.lean +++ b/QuantumInfo/Channels/Bundled.lean @@ -413,12 +413,10 @@ variable [DecidableEq dIn] [DecidableEq dOut] @[ext] theorem ext {Λ₁ Λ₂ : CPUMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - rw [CPUMap.mk.injEq, CPMap.mk.injEq] - exact PMap.ext h + exact (mk.injEq _ _ _ _).mpr ((CPMap.mk.injEq _ _ _ _).mpr (PMap.ext h)) -theorem injective_toPMap : (CPMap.toPMap ∘ CPUMap.toCPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := by - intro _ _ _ - rwa [CPUMap.mk.injEq, CPMap.mk.injEq] +theorem injective_toPMap : (CPMap.toPMap ∘ CPUMap.toCPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := + fun _ _ h => (mk.injEq _ _ _ _).mpr ((CPMap.mk.injEq _ _ _ _).mpr h) /-- `CPUMap`s are functions from `HermitianMat`s to `HermitianMat`s. -/ noncomputable instance instFunLike : FunLike (CPUMap dIn dOut ℂ) (HermitianMat dIn ℂ) (HermitianMat dOut ℂ) where diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index 6a83217c2..418c2be24 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -57,8 +57,7 @@ def choi := Λ.map.choi_matrix /-- Two CPTPMaps are equal if their Choi matrices are equal. -/ theorem choi_ext {Λ₁ Λ₂ : CPTPMap dIn dOut} (h : Λ₁.choi = Λ₂.choi) : Λ₁ = Λ₂ := by - ext1 - exact MatrixMap.choi_equiv.injective h + exact CPTPMap.ext (MatrixMap.choi_equiv.injective h) /-- The Choi matrix of a channel is PSD. -/ theorem choi_PSD_of_CPTP : Λ.map.choi_matrix.PosSemidef := @@ -82,8 +81,7 @@ def CPTP_of_choi_PSD_Tr {M : Matrix (dOut × dIn) (dOut × dIn) ℂ} (h₁ : M.P @[simp] theorem choi_of_CPTP_of_choi (M : Matrix (dOut × dIn) (dOut × dIn) ℂ) {h₁} {h₂} : (CPTP_of_choi_PSD_Tr (M := M) h₁ h₂).choi = M := by - simp only [choi, CPTP_of_choi_PSD_Tr] - rw [MatrixMap.map_choi_inv] + exact MatrixMap.map_choi_inv M theorem mat_coe_eq_apply_mat [DecidableEq dOut] (ρ : MState dIn) : (Λ ρ).m = Λ.map ρ.m := rfl @@ -166,7 +164,7 @@ theorem id_MState (ρ : MState dIn) : CPTPMap.id (dIn := dIn) ρ = ρ := by /-- The map `CPTPMap.id` composed with any map is the same map. -/ @[simp] theorem id_compose [DecidableEq dOut] (Λ : CPTPMap dIn dOut) : id ∘ₘ Λ = Λ := by - apply funext + ext ρ simp /-- Any map composed with `CPTPMap.id` is the same map. -/ From 5749036a2034f0334346430433268bc800f1dd5b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:05:25 -0700 Subject: [PATCH 256/498] refactor: golf matrix map wrapper fields Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/MatrixMap.lean | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index 43b25bf23..8a3987da6 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -109,8 +109,8 @@ variable {R : Type*} [CommSemiring R] def choi_equiv : MatrixMap A B R ≃ₗ[R] Matrix (B × A) (B × A) R where toFun := choi_matrix invFun := of_choi_matrix - left_inv _ := by simp - right_inv _ := by simp + left_inv := choi_map_inv + right_inv := map_choi_inv map_add' _ _ := by ext; simp [choi_matrix] map_smul' _ _ := by ext; simp [choi_matrix] @@ -188,12 +188,11 @@ variable {A B : Type*} (R : Type*) [Semiring R] @[simps] def submatrix (f : B → A) : MatrixMap A B R where toFun x := x.submatrix f f - map_add' := by simp [Matrix.submatrix_add] - map_smul' := by simp [Matrix.submatrix_smul] + map_add' x y := congrFun (congrFun (Matrix.submatrix_add x y) f) f + map_smul' r x := congrFun (congrFun (Matrix.submatrix_smul r x) f) f @[simp] -theorem submatrix_id : submatrix R _root_.id = id A R := by - ext1; simp +theorem submatrix_id : submatrix R _root_.id = id A R := rfl @[simp] theorem submatrix_comp (f : C → B) (g : B → A) : From bf124cdd0757988c2ee42d5455a4accba594d5d7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:08:02 -0700 Subject: [PATCH 257/498] refactor: golf channel matrix identities Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/CPTP.lean | 4 ++-- QuantumInfo/Channels/MatrixMap.lean | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index 418c2be24..c87c23e6f 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -285,8 +285,8 @@ end trace def replacement [Nonempty dIn] [DecidableEq dOut] (ρ : MState dOut) : CPTPMap dIn dOut := traceLeft ∘ₘ { toFun := fun M => Matrix.kroneckerMap (fun x1 x2 => x1 * x2) M ρ.m - map_add' := by simp [Matrix.add_kronecker] - map_smul' := by simp [Matrix.smul_kronecker] + map_add' M N := Matrix.add_kronecker M N ρ.m + map_smul' r M := Matrix.smul_kronecker r M ρ.m cp := MatrixMap.kron_kronecker_const ρ.psd TP := by intro; simp [Matrix.trace_kronecker] } diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index 8a3987da6..5f9c66a62 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -196,8 +196,7 @@ theorem submatrix_id : submatrix R _root_.id = id A R := rfl @[simp] theorem submatrix_comp (f : C → B) (g : B → A) : - submatrix R f ∘ₗ submatrix R g = submatrix R (g ∘ f) := by - ext1; simp + submatrix R f ∘ₗ submatrix R g = submatrix R (g ∘ f) := rfl end submatrix @@ -385,10 +384,10 @@ theorem submatrix_kron_submatrix [CommSemiring R] (f : B → A) (g : D → C) : simp [Prod.map, Matrix.single, ite_and] theorem submatrix_kron_id [CommSemiring R] (f : B → A) : - submatrix R f ⊗ₖₘ id C R = submatrix R (Prod.map f _root_.id) := by simp [← submatrix_kron_submatrix] + submatrix R f ⊗ₖₘ id C R = submatrix R (Prod.map f _root_.id) := submatrix_kron_submatrix f _root_.id theorem id_kron_submatrix [CommSemiring R] (f : B → A) : - id C R ⊗ₖₘ submatrix R f = submatrix R (Prod.map _root_.id f) := by simp [← submatrix_kron_submatrix] + id C R ⊗ₖₘ submatrix R f = submatrix R (Prod.map _root_.id f) := submatrix_kron_submatrix _root_.id f end kron From 18f9fa5adc9736868cccc5635918424582a2ea14 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:10:45 -0700 Subject: [PATCH 258/498] refactor: golf cptp trace wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/CPTP.lean | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index c87c23e6f..053ca1960 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -157,9 +157,8 @@ theorem id_map : (id (dIn := dIn)).map = LinearMap.id := rfl /-- The map `CPTPMap.id` leaves the input state unchanged. -/ @[simp] theorem id_MState (ρ : MState dIn) : CPTPMap.id (dIn := dIn) ρ = ρ := by - apply MState.ext_m - rw [mat_coe_eq_apply_mat] - simp + ext + rfl /-- The map `CPTPMap.id` composed with any map is the same map. -/ @[simp] @@ -183,7 +182,7 @@ variable [DecidableEq dOut] def ofEquiv (σ : dIn ≃ dOut) : CPTPMap dIn dOut where toLinearMap := MatrixMap.submatrix ℂ σ.symm cp := .submatrix σ.symm - TP x := by rw [MatrixMap.IsTracePreserving.submatrix] + TP := MatrixMap.IsTracePreserving.submatrix σ.symm @[simp] theorem ofEquiv_apply (σ : dIn ≃ dOut) (ρ : MState dIn) : @@ -239,16 +238,12 @@ def traceLeft : CPTPMap (d₁ × d₂) d₂ := --TODO: make Matrix.traceLeft a linear map, a `MatrixMap`. letI f (d) [Fintype d] [DecidableEq d]: Matrix (d₁ × d) (d₁ × d) ℂ →ₗ[ℂ] Matrix d d ℂ := { toFun x := Matrix.traceLeft x - map_add' := by - intros; ext - simp [Matrix.traceLeft, Finset.sum_add_distrib] - map_smul' := by - intros; ext - simp [Matrix.traceLeft, Finset.mul_sum] + map_add' x y := Matrix.traceLeft_add + map_smul' r x := Matrix.traceLeft_smul r } { toLinearMap := f d₂ - TP := by intro; simp [f] + TP := Matrix.traceLeft_trace cp := by --(traceLeft ⊗ₖₘ I) = traceLeft ∘ₘ (ofEquiv prod_assoc) --Both go (A × B) × C → B × C From 2540ffe372d8efca1ae0c8903f14106a8eec1662 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:13:00 -0700 Subject: [PATCH 259/498] refactor: golf unbundled channel identities Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Unbundled.lean | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/QuantumInfo/Channels/Unbundled.lean b/QuantumInfo/Channels/Unbundled.lean index 1630ef6c9..46ac9f1ed 100644 --- a/QuantumInfo/Channels/Unbundled.lean +++ b/QuantumInfo/Channels/Unbundled.lean @@ -86,7 +86,7 @@ theorem comp (h₁ : M.IsTracePreserving) (h₂ : M₂.IsTracePreserving) : /-- The identity MatrixMap IsTracePreserving. -/ @[simp] -theorem id : (id A R).IsTracePreserving := by simp [IsTracePreserving, MatrixMap.id] +theorem id : (id A R).IsTracePreserving := fun _ => rfl variable {R : Type*} [CommSemiring R] in /-- Unit linear combinations of IsTracePreserving maps are IsTracePreserving. -/ @@ -201,7 +201,7 @@ theorem map_1 (h : M.Unital) : M 1 = 1 := /-- The identity `MatrixMap` is `Unital`. -/ @[simp] -theorem id : (id A R).Unital := by simp [Unital, MatrixMap.id] +theorem id : (id A R).Unital := rfl --TODO: Closed under composition, kronecker products, it's iff M.choi_matrix.traceLeft = 1... @@ -356,15 +356,14 @@ theorem comp [DecidableEq B] {M₁ : MatrixMap A B R} {M₂ : MatrixMap B C R} ( /-- The identity MatrixMap IsCompletelyPositive. -/ @[simp] theorem id : (id A R).IsCompletelyPositive := by - intro n ρ h - rwa [show LinearMap.id = MatrixMap.id (Fin n) R from rfl, kron_id_id] + intro n _ h + simpa [show LinearMap.id = MatrixMap.id (Fin n) R from rfl, kron_id_id] using h /-- Sums of IsCompletelyPositive maps are IsCompletelyPositive. -/ theorem add {M₁ M₂ : MatrixMap A B R} (h₁ : M₁.IsCompletelyPositive) (h₂ : M₂.IsCompletelyPositive) : (M₁ + M₂).IsCompletelyPositive := fun n _ h ↦ by - simp only [add_kron, LinearMap.add_apply] - exact Matrix.PosSemidef.add (h₁ n h) (h₂ n h) + simpa only [add_kron, LinearMap.add_apply] using Matrix.PosSemidef.add (h₁ n h) (h₂ n h) /-- Nonnegative scalings of `IsCompletelyPositive` maps are `IsCompletelyPositive`. -/ theorem smul {M : MatrixMap A B R} (hM : M.IsCompletelyPositive) {x : R} (hx : 0 ≤ x) : @@ -539,8 +538,8 @@ theorem congruence_CP {A B : Type*} [Fintype A] [Fintype B] [DecidableEq A] [Dec convert conj_isPositive ( M ⊗ₖ ( 1 : Matrix ( Fin n ) ( Fin n ) 𝕜 ) ) using 1 theorem IsCompletelyPositive_sum {ι : Type*} [Fintype ι] (f : ι → MatrixMap A B ℂ) (h : ∀ i, (f i).IsCompletelyPositive) : - (∑ i, f i).IsCompletelyPositive := by - convert IsCompletelyPositive.finset_sum h using 1 + (∑ i, f i).IsCompletelyPositive := + IsCompletelyPositive.finset_sum h omit [Fintype B] [DecidableEq A] in theorem of_kraus_eq_sum_conj (K : κ → Matrix B A 𝕜) : From a6ae609a3c5936c823b141905d5cea8d43391a3e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:21:02 -0700 Subject: [PATCH 260/498] refactor: drop non-golf proof rewrites Co-authored-by: Claude Opus 4.8 --- .../HarmonicOscillator/Basic.lean | 18 ++-- .../Distributional/Dynamics/IsExtrema.lean | 2 +- .../Distributional/FieldStrength.lean | 7 +- .../Electromagnetism/Dynamics/IsExtrema.lean | 2 +- .../Kinematics/EMPotential.lean | 60 ++++++------ .../Kinematics/FieldStrength.lean | 12 +-- .../Kinematics/ScalarPotential.lean | 12 +-- .../Kinematics/VectorPotential.lean | 8 +- Physlib/Electromagnetism/Vacuum/Constant.lean | 4 +- Physlib/Mathematics/Distribution/Basic.lean | 8 +- .../Mathematics/InnerProductSpace/Basic.lean | 5 +- Physlib/Mathematics/List/InsertIdx.lean | 11 +-- .../SpecialFunctions/PhysHermite.lean | 16 ++-- .../VariationalCalculus/HasVarAdjDeriv.lean | 6 +- .../VariationalCalculus/HasVarGradient.lean | 6 +- .../IsLocalizedfunctionTransform.lean | 7 +- .../FieldOpFreeAlgebra/Basic.lean | 4 +- .../FieldOpFreeAlgebra/SuperCommute.lean | 12 +-- .../FieldSpecification/CrAnSection.lean | 8 +- .../FieldSpecification/NormalOrder.lean | 13 ++- .../PerturbationTheory/Koszul/KoszulSign.lean | 12 +-- .../WickAlgebra/NormalOrder/Basic.lean | 4 +- .../WickAlgebra/NormalOrder/Lemmas.lean | 4 +- .../WickAlgebra/SuperCommute.lean | 4 +- .../WickAlgebra/TimeOrder.lean | 6 +- .../WickAlgebra/WicksTheoremNormal.lean | 4 +- .../WickContraction/Uncontracted.lean | 8 +- .../WickContraction/UncontractedList.lean | 8 +- .../DDimensions/Operators/Momentum.lean | 7 +- .../Operators/SpectralTheory/Basic.lean | 10 +- Physlib/Relativity/LorentzGroup/Basic.lean | 4 +- .../LorentzGroup/Orthochronous/Basic.lean | 2 +- .../Relativity/PauliMatrices/Relations.lean | 5 +- .../Relativity/PauliMatrices/ToTensor.lean | 4 +- Physlib/Relativity/Tensors/Basic.lean | 4 +- .../RealTensor/Vector/MinkowskiProduct.lean | 4 +- .../SpaceAndTime/Space/ConstantSliceDist.lean | 13 ++- .../Space/Derivatives/Iterated.lean | 4 +- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 4 +- .../SpaceAndTime/SpaceTime/Derivatives.lean | 4 +- Physlib/SpaceAndTime/Time/Basic.lean | 14 +-- .../TimeAndSpace/ConstantTimeDist.lean | 7 +- .../CanonicalEnsemble/Finite.lean | 13 ++- Physlib/Units/Examples.lean | 13 ++- Physlib/Units/FDeriv.lean | 8 +- Physlib/Units/UnitDependent.lean | 12 +-- Physlib/Units/WithDim/Area.lean | 11 +-- Physlib/Units/WithDim/Speed.lean | 9 +- QuantumInfo/Channels/CPTP.lean | 6 +- QuantumInfo/Channels/Dual.lean | 10 +- QuantumInfo/Channels/MatrixMap.lean | 8 +- QuantumInfo/Channels/Pinching.lean | 16 +--- QuantumInfo/ClassicalInfo/Prob.lean | 4 +- QuantumInfo/Entropy/DPI.lean | 5 +- QuantumInfo/Entropy/Relative.lean | 57 +++++------- QuantumInfo/Entropy/SSA.lean | 6 +- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 92 +++++++------------ .../ForMathlib/HermitianMat/LogExp.lean | 43 +++------ QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 18 ++-- .../ForMathlib/HermitianMat/Schatten.lean | 15 ++- QuantumInfo/ForMathlib/Majorization.lean | 63 +++++-------- QuantumInfo/ForMathlib/Matrix.lean | 4 +- QuantumInfo/ForMathlib/Misc.lean | 11 +-- QuantumInfo/ForMathlib/ULift.lean | 8 +- QuantumInfo/ForMathlib/Unitary.lean | 8 +- QuantumInfo/ResourceTheory/SteinsLemma.lean | 8 +- QuantumInfo/States/Mixed/MState.lean | 10 +- QuantumInfo/States/Pure/BlochSphere.lean | 1 - 68 files changed, 345 insertions(+), 471 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index 643dcde33..347e2bc7e 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -209,13 +209,13 @@ noncomputable def energy (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : Time → -/ lemma kineticEnergy_eq (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - kineticEnergy S xₜ = fun t => (1 / (2 : ℝ)) * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ := rfl + kineticEnergy S xₜ = fun t => (1 / (2 : ℝ)) * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ:= by rfl lemma potentialEnergy_eq (x : EuclideanSpace ℝ (Fin 1)) : - potentialEnergy S x = (1 / (2 : ℝ)) • S.k • ⟪x, x⟫_ℝ := rfl + potentialEnergy S x = (1 / (2 : ℝ)) • S.k • ⟪x, x⟫_ℝ:= by rfl lemma energy_eq (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - energy S xₜ = fun t => kineticEnergy S xₜ t + potentialEnergy S (xₜ t) := rfl + energy S xₜ = fun t => kineticEnergy S xₜ t + potentialEnergy S (xₜ t) := by rfl /-! ### C.3. Differentiability of the energies @@ -513,7 +513,7 @@ We write a simple iff statement for the definition of the equation of motions. -/ lemma equationOfMotion_iff_gradLagrangian_zero (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : - S.EquationOfMotion xₜ ↔ S.gradLagrangian xₜ = 0 := Iff.rfl + S.EquationOfMotion xₜ ↔ S.gradLagrangian xₜ = 0 := by rfl /-! @@ -588,8 +588,8 @@ lemma gradLagrangian_eq_force (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : calc ∂ₜ (fun t' => S.m • ∂ₜ xₜ t') t = fderiv ℝ (fun t' => S.m • ∂ₜ xₜ t') t 1 := rfl - _ = S.m • (fderiv ℝ (∂ₜ xₜ) t 1) := - congrArg (fun L => L 1) (fderiv_const_smul (c := S.m) (f := ∂ₜ xₜ) hd) + _ = S.m • (fderiv ℝ (∂ₜ xₜ) t 1) := by + exact congrArg (fun L => L 1) (fderiv_const_smul (c := S.m) (f := ∂ₜ xₜ) hd) _ = S.m • ∂ₜ (∂ₜ xₜ) t := rfl /-! @@ -743,7 +743,7 @@ lemma hamiltonian_eq : funext t x p simp only [hamiltonian, toCanonicalMomentum, lagrangian_eq, one_div, LinearEquiv.coe_symm_mk', inner_smul_right, inner_smul_left, map_inv₀, ringHom_apply] - have hm : S.m ≠ 0 := m_ne_zero S + have hm : S.m ≠ 0 := by exact m_ne_zero S field_simp ring @@ -875,8 +875,8 @@ lemma equationOfMotion_iff_hamiltonEqOp_eq_zero (xₜ : Time → EuclideanSpace calc ∂ₜ (fun t' => S.m • ∂ₜ xₜ t') t = fderiv ℝ (fun t' => S.m • ∂ₜ xₜ t') t 1 := rfl - _ = S.m • (fderiv ℝ (∂ₜ xₜ) t 1) := - congrArg (fun L => L 1) (fderiv_const_smul (c := S.m) (f := ∂ₜ xₜ) hd) + _ = S.m • (fderiv ℝ (∂ₜ xₜ) t 1) := by + exact congrArg (fun L => L 1) (fderiv_const_smul (c := S.m) (f := ∂ₜ xₜ) hd) _ = S.m • ∂ₜ (∂ₜ xₜ) t := rfl simp [hderiv_smul, force_eq_linear] diff --git a/Physlib/Electromagnetism/Distributional/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Distributional/Dynamics/IsExtrema.lean index 9ad1c4165..1bb99344f 100644 --- a/Physlib/Electromagnetism/Distributional/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Distributional/Dynamics/IsExtrema.lean @@ -60,7 +60,7 @@ def IsExtrema {d} (𝓕 : FreeSpace) lemma isExtrema_iff_gradLagrangian {𝓕 : FreeSpace} (A : DistElectromagneticPotential d) (J : DistLorentzCurrentDensity d) : - IsExtrema 𝓕 A J ↔ A.gradLagrangian 𝓕 J = 0 := Iff.rfl + IsExtrema 𝓕 A J ↔ A.gradLagrangian 𝓕 J = 0 := by rfl lemma isExtrema_iff_components {𝓕 : FreeSpace} (A : DistElectromagneticPotential d) diff --git a/Physlib/Electromagnetism/Distributional/FieldStrength.lean b/Physlib/Electromagnetism/Distributional/FieldStrength.lean index 952474218..4c0526df0 100644 --- a/Physlib/Electromagnetism/Distributional/FieldStrength.lean +++ b/Physlib/Electromagnetism/Distributional/FieldStrength.lean @@ -249,10 +249,9 @@ lemma fieldStrength_eq_basis {d} (A : DistElectromagneticPotential d) lemma fieldStrength_basis_repr_eq_single {d} {μν : (Fin 1 ⊕ Fin d) × (Fin 1 ⊕ Fin d)} (A : DistElectromagneticPotential d) (ε : 𝓢(SpaceTime d, ℝ)) : (Lorentz.Vector.basis.tensorProduct Lorentz.Vector.basis).repr (A.fieldStrength ε) μν = - ((η μν.1 μν.1 * distDeriv μν.1 A ε μν.2) - η μν.2 μν.2 * distDeriv μν.2 A ε μν.1) := - (congrArg (fun F => (Lorentz.Vector.basis.tensorProduct Lorentz.Vector.basis).repr F μν) - (fieldStrength_eq_fieldStrengthAux A ε)).trans - (fieldStrengthAux_basis_repr_apply_eq_single A ε) + ((η μν.1 μν.1 * distDeriv μν.1 A ε μν.2) - η μν.2 μν.2 * distDeriv μν.2 A ε μν.1) := by + rw [fieldStrength] + exact fieldStrengthAux_basis_repr_apply_eq_single A ε @[simp] lemma fieldStrength_diag_zero {d} (A : DistElectromagneticPotential d) diff --git a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean index 8c329e9d3..cd95454b3 100644 --- a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean @@ -77,7 +77,7 @@ def IsExtrema {d} (𝓕 : FreeSpace) (A : ElectromagneticPotential d) lemma isExtrema_iff_gradLagrangian {𝓕 : FreeSpace} (A : ElectromagneticPotential d) (J : LorentzCurrentDensity d) : - IsExtrema 𝓕 A J ↔ A.gradLagrangian 𝓕 J = 0 := Iff.rfl + IsExtrema 𝓕 A J ↔ A.gradLagrangian 𝓕 J = 0 := by rfl /-! diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index 4916f5ab4..9dabc877d 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -341,60 +341,60 @@ TODO "Add results related to the differentiability of the lemma differentiable_ofScalarPotential {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (hϕ : Differentiable ℝ ↿φ) : Differentiable ℝ (ofScalarPotential c φ) := by simp [ofScalarPotential] - exact (SpaceTime.differentiable_vector _).mp fun μ => by - rcases μ with μ | i - · fin_cases μ - fun_prop - · fun_prop + rw [← SpaceTime.differentiable_vector] + intro μ + match μ with + | Sum.inl 0 => fun_prop + | Sum.inr i => fun_prop lemma contDiff_ofScalarPotential {n} {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (hϕ : ContDiff ℝ n ↿φ) : ContDiff ℝ n (ofScalarPotential c φ) := by simp [ofScalarPotential] - exact (SpaceTime.contDiff_vector _).mp fun μ => by - rcases μ with μ | i - · fin_cases μ - fun_prop - · fun_prop + rw [← SpaceTime.contDiff_vector] + intro μ + match μ with + | Sum.inl 0 => fun_prop + | Sum.inr i => fun_prop lemma differentiable_ofVectorPotential {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hA : Differentiable ℝ ↿A) : Differentiable ℝ (ofVectorPotential c A) := by simp [ofVectorPotential] - exact (SpaceTime.differentiable_vector _).mp fun μ => by - rcases μ with μ | i - · fin_cases μ - fun_prop - · fun_prop + rw [← SpaceTime.differentiable_vector] + intro μ + match μ with + | Sum.inl 0 => fun_prop + | Sum.inr _ => fun_prop lemma contDiff_ofVectorPotential {n} {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hA : ContDiff ℝ n ↿A) : ContDiff ℝ n (ofVectorPotential c A) := by simp [ofVectorPotential] - exact (SpaceTime.contDiff_vector _).mp fun μ => by - rcases μ with μ | i - · fin_cases μ - fun_prop - · fun_prop + rw [← SpaceTime.contDiff_vector] + intro μ + match μ with + | Sum.inl 0 => fun_prop + | Sum.inr _ => fun_prop lemma differentiable_ofPotentials {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hϕ : Differentiable ℝ ↿φ) (hA : Differentiable ℝ ↿A) : Differentiable ℝ (ofPotentials c φ A) := by simp [ofPotentials] - exact (SpaceTime.differentiable_vector _).mp fun μ => by - rcases μ with μ | i - · fin_cases μ - fun_prop - · fun_prop + rw [← SpaceTime.differentiable_vector] + intro μ + match μ with + | Sum.inl 0 => fun_prop + | Sum.inr i => fun_prop lemma contDiff_ofPotentials {n} {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hϕ : ContDiff ℝ n ↿φ) (hA : ContDiff ℝ n ↿A) : ContDiff ℝ n (ofPotentials c φ A) := by simp [ofPotentials] - exact (SpaceTime.contDiff_vector _).mp fun μ => by - rcases μ with μ | i - · fin_cases μ - fun_prop - · fun_prop + rw [← SpaceTime.contDiff_vector] + intro μ + match μ with + | Sum.inl 0 => fun_prop + | Sum.inr i => fun_prop open MeasureTheory Matrix Space InnerProductSpace Time in lemma contDiff_ofElectromagneticField {n : ℕ} (c : SpeedOfLight) diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index 5d1b48f19..eae09cd4a 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -391,18 +391,18 @@ electromagnetic potential. -/ lemma toFieldStrength_eval_apply {d} (A : ElectromagneticPotential d) (x : SpaceTime d) (μ ν : Fin 1 ⊕ Fin d) : toField {A.toFieldStrength x | [μ] [ν]}ᵀ = - ∑ κ, (η μ κ * ∂_ κ A x ν - η ν κ * ∂_ κ A x μ) := - (toFieldStrength_eval_eq_basis_repr A x μ ν).trans - (toFieldStrength_basis_repr_apply (μν := (μ, ν)) A x) + ∑ κ, (η μ κ * ∂_ κ A x ν - η ν κ * ∂_ κ A x μ) := by + rw [toFieldStrength_eval_eq_basis_repr] + exact toFieldStrength_basis_repr_apply (μν := (μ, ν)) A x /-- The evaluated components of the field strength tensor after using diagonal form of the Minkowski metric. -/ lemma toFieldStrength_eval_apply_eq_single {d} (A : ElectromagneticPotential d) (x : SpaceTime d) (μ ν : Fin 1 ⊕ Fin d) : toField {A.toFieldStrength x | [μ] [ν]}ᵀ = - η μ μ * ∂_ μ A x ν - η ν ν * ∂_ ν A x μ := - (toFieldStrength_eval_eq_basis_repr A x μ ν).trans - (toFieldStrength_basis_repr_apply_eq_single (μν := (μ, ν)) A x) + η μ μ * ∂_ μ A x ν - η ν ν * ∂_ ν A x μ := by + rw [toFieldStrength_eval_eq_basis_repr] + exact toFieldStrength_basis_repr_apply_eq_single (μν := (μ, ν)) A x /-! diff --git a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean index 1d99ed571..9e9e0093a 100644 --- a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean @@ -79,8 +79,8 @@ lemma ofScalarPotential_scalarPotential {d} (c : SpeedOfLight) @[simp] lemma ofStaticScalarPotential_scalarPotential {d} (c : SpeedOfLight) - (φ : Space d → ℝ) : (ofStaticScalarPotential c φ).scalarPotential c = - fun _ => φ := by simp [ofStaticScalarPotential] + (φ : Space d → ℝ) : (ofStaticScalarPotential c φ).scalarPotential c = fun _ => φ := by + simp [ofStaticScalarPotential] @[simp] lemma ofVectorPotential_scalarPotential {d} (c : SpeedOfLight) @@ -105,8 +105,8 @@ lemma ofPotentials_scalarPotential {d} (c : SpeedOfLight) (φ : Time → Space d @[simp] lemma ofStaticPotentials_scalarPotential {d} (c : SpeedOfLight) (φ : Space d → ℝ) (A : Space d → EuclideanSpace ℝ (Fin d)) : - (ofStaticPotentials c φ A).scalarPotential c = - fun _ => φ := by simp [ofStaticPotentials_eq_ofPotentials] + (ofStaticPotentials c φ A).scalarPotential c = fun _ => φ := by + simp [ofStaticPotentials_eq_ofPotentials] open MeasureTheory Matrix Space InnerProductSpace Time in lemma ofElectromagneticField_scalarPotential (c : SpeedOfLight) @@ -144,7 +144,7 @@ lemma scalarPotential_contDiff {n} {d} (c : SpeedOfLight) (A : ElectromagneticPo apply timeSlice_contDiff apply ContDiff.mul · fun_prop - exact (SpaceTime.contDiff_vector A).mpr hA (Sum.inl 0) + exact h1 (Sum.inl 0) @[fun_prop] lemma scalarPotential_contDiff_space {n} {d} (c : SpeedOfLight) @@ -178,7 +178,7 @@ lemma scalarPotential_differentiable {d} (c : SpeedOfLight) (A : Electromagnetic apply timeSlice_differentiable apply Differentiable.mul · fun_prop - exact (SpaceTime.differentiable_vector A).mpr hA (Sum.inl 0) + exact h1 (Sum.inl 0) lemma scalarPotential_differentiable_space {d} (c : SpeedOfLight) (A : ElectromagneticPotential d) (hA : Differentiable ℝ A) (t : Time) : Differentiable ℝ (A.scalarPotential c t) := diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index a68244ddf..c20d2563f 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -92,8 +92,8 @@ lemma ofVectorPotential_vectorPotential {d} (c : SpeedOfLight) @[simp] lemma ofStaticVectorPotential_vectorPotential {d} (c : SpeedOfLight) (A : Space d → EuclideanSpace ℝ (Fin d)) : - (ofStaticVectorPotential c A).vectorPotential c = - fun _ => A := by simp [ofStaticVectorPotential] + (ofStaticVectorPotential c A).vectorPotential c = fun _ => A := by + simp [ofStaticVectorPotential] @[simp] lemma ofPotentials_vectorPotential {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) @@ -105,8 +105,8 @@ lemma ofPotentials_vectorPotential {d} (c : SpeedOfLight) (φ : Time → Space d @[simp] lemma ofStaticPotentials_vectorPotential {d} (c : SpeedOfLight) (φ : Space d → ℝ) (A : Space d → EuclideanSpace ℝ (Fin d)) : - (ofStaticPotentials c φ A).vectorPotential c = - fun _ => A := by simp [ofStaticPotentials_eq_ofPotentials] + (ofStaticPotentials c φ A).vectorPotential c = fun _ => A := by + simp [ofStaticPotentials_eq_ofPotentials] /-! diff --git a/Physlib/Electromagnetism/Vacuum/Constant.lean b/Physlib/Electromagnetism/Vacuum/Constant.lean index 4a83b75c6..be1431c8e 100644 --- a/Physlib/Electromagnetism/Vacuum/Constant.lean +++ b/Physlib/Electromagnetism/Vacuum/Constant.lean @@ -96,7 +96,7 @@ lemma constantEB_smooth {c : SpeedOfLight} apply ContDiff.inner · fun_prop · fun_prop - | Sum.inr i => + | Sum.inr i => simp [constantEB] apply ContDiff.mul · fun_prop @@ -104,7 +104,7 @@ lemma constantEB_smooth {c : SpeedOfLight} intro j _ apply ContDiff.mul · fun_prop - fun_prop) + fun_prop /-! diff --git a/Physlib/Mathematics/Distribution/Basic.lean b/Physlib/Mathematics/Distribution/Basic.lean index adeb0d2ef..5993ad028 100644 --- a/Physlib/Mathematics/Distribution/Basic.lean +++ b/Physlib/Mathematics/Distribution/Basic.lean @@ -368,11 +368,9 @@ lemma fderivD_const [hμ : Measure.IsAddHaarMeasure (volume (α := E))] · simp rw [integral_smul_fderiv_eq_neg_fderiv_smul_of_integrable] simp only [evalCLM_apply_apply, fderivCLM_apply, neg_neg] - · exact (show - Integrable - (SchwartzMap.evalCLM (𝕜 := ℝ) E ℝ v - (SchwartzMap.fderivCLM ℝ E ℝ η)) volume from - integrable ((SchwartzMap.evalCLM ℝ E ℝ v) ((fderivCLM ℝ) E ℝ η))).smul_const _ + · apply MeasureTheory.Integrable.smul_const + change Integrable (SchwartzMap.evalCLM (𝕜 := ℝ) E ℝ v (SchwartzMap.fderivCLM ℝ E ℝ η)) volume + exact integrable ((SchwartzMap.evalCLM ℝ E ℝ v) ((fderivCLM ℝ) E ℝ η)) · simp · exact (integrable η).smul_const _ · fun_prop diff --git a/Physlib/Mathematics/InnerProductSpace/Basic.lean b/Physlib/Mathematics/InnerProductSpace/Basic.lean index a5a39c9ca..cb7c5d000 100644 --- a/Physlib/Mathematics/InnerProductSpace/Basic.lean +++ b/Physlib/Mathematics/InnerProductSpace/Basic.lean @@ -546,9 +546,8 @@ instance {ι : Type*} [Fintype ι] : InnerProductSpace' 𝕜 (ι → E) where ring apply Finset.sum_le_card_nsmul intro j _ - exact mul_le_mul_of_nonneg (by simp) - ((sq_le_sq₀ (norm_nonneg (x j)) (norm_nonneg (x i))).mpr (hj j)) - (by positivity) (by positivity) + refine mul_le_mul_of_nonneg (by simp) ?_ (by positivity) (by positivity) + exact (sq_le_sq₀ (norm_nonneg (x j)) (norm_nonneg (x i))).mpr (hj j) · rw [not_nonempty_iff] at hnEmpty refine ⟨1, 1, zero_lt_one, zero_lt_one, fun x => ?_⟩ rw [Subsingleton.elim x 0] diff --git a/Physlib/Mathematics/List/InsertIdx.lean b/Physlib/Mathematics/List/InsertIdx.lean index 063a06317..6df5c8e6a 100644 --- a/Physlib/Mathematics/List/InsertIdx.lean +++ b/Physlib/Mathematics/List/InsertIdx.lean @@ -186,11 +186,10 @@ lemma take_insert_let {I : Type} (i : I) : simp at hm | n + 1, m + 1, h, a::as, hm => by simp only [List.insertIdx_succ_cons, List.take_succ_cons] - have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := - List.Perm.swap a i (List.take n as) - exact List.Perm.trans - (List.Perm.cons a - (take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm))) - hp.symm + have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := by + exact List.Perm.swap a i (List.take n as) + refine List.Perm.trans ?_ hp.symm + refine List.Perm.cons a ?_ + exact take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm) end Physlib.List diff --git a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean index dc6a9ff7b..61d76d42f 100644 --- a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean +++ b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean @@ -35,8 +35,8 @@ noncomputable def physHermite : ℕ → Polynomial ℤ | n + 1 => 2 • X * physHermite n - derivative (physHermite n) lemma physHermite_succ (n : ℕ) : - physHermite (n + 1) = - 2 • X * physHermite n - derivative (physHermite n) := by simp [physHermite] + physHermite (n + 1) = 2 • X * physHermite n - derivative (physHermite n) := by + simp [physHermite] lemma physHermite_eq_iterate (n : ℕ) : physHermite n = (fun p => 2 * X * p - derivative p)^[n] 1 := by @@ -73,8 +73,8 @@ lemma physHermite_succ' (n : ℕ) : rw [physHermite_succ, derivative_physHermite] lemma coeff_physHhermite_succ_zero (n : ℕ) : - coeff (physHermite (n + 1)) 0 = - - coeff (physHermite n) 1 := by simp [physHermite_succ, coeff_derivative] + coeff (physHermite (n + 1)) 0 = - coeff (physHermite n) 1 := by + simp [physHermite_succ, coeff_derivative] lemma coeff_physHermite_succ_succ (n k : ℕ) : coeff (physHermite (n + 1)) (k + 1) = 2 * coeff (physHermite n) k - (k + 2) * coeff (physHermite n) (k + 2) := by @@ -135,8 +135,8 @@ lemma iterate_derivative_physHermite_self {n : ℕ} : rfl @[simp] -lemma physHermite_leadingCoeff {n : ℕ} : - (physHermite n).leadingCoeff = 2 ^ n := by simp [leadingCoeff] +lemma physHermite_leadingCoeff {n : ℕ} : (physHermite n).leadingCoeff = 2 ^ n := by + simp [leadingCoeff] @[simp] lemma physHermite_ne_zero {n : ℕ} : physHermite n ≠ 0 := by @@ -151,8 +151,8 @@ lemma physHermite_eq_aeval (n : ℕ) (x : ℝ) : lemma physHermite_zero_apply (x : ℝ) : physHermite 0 x = 1 := by simp -lemma physHermite_pow (n m : ℕ) (x : ℝ) : - physHermite n x ^ m = aeval x (physHermite n ^ m) := by simp +lemma physHermite_pow (n m : ℕ) (x : ℝ) : physHermite n x ^ m = aeval x (physHermite n ^ m) := by + simp lemma physHermite_succ_fun (n : ℕ) : (physHermite (n + 1) : ℝ → ℝ) = 2 • (fun x => x) * diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index 858f8f266..917312547 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -584,9 +584,9 @@ lemma sum {ι : Type} [Fintype ι] fun_prop · intro i ι' hp F F' u hu ih simp only [Fintype.sum_option] - exact HasVarAdjDerivAt.add _ _ _ _ _ (ih none) - (hp (fun i_1 => F (some i_1)) (fun i_1 => F' (some i_1)) u hu fun i_1 => - ih (some i_1)) + apply HasVarAdjDerivAt.add + exact ih none + exact hp (fun i_1 => F (some i_1)) (fun i_1 => F' (some i_1)) u hu fun i_1 => ih (some i_1) exact hp F F' u hu hF lemma mul diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean b/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean index 2c34070a7..170644aae 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarGradient.lean @@ -102,9 +102,9 @@ lemma HasVarGradientAt.sum {ι : Type} [Fintype ι] (F : ι → (X → U) → (X rfl · intro i ι' hp F F' u hu ih simp only [Fintype.sum_option] - exact HasVarGradientAt.add _ _ (ih none) - (hp (fun i_1 => F (some i_1)) (fun i_1 => F' (some i_1)) u hu fun i_1 => - ih (some i_1)) + apply HasVarGradientAt.add + exact ih none + exact hp (fun i_1 => F (some i_1)) (fun i_1 => F' (some i_1)) u hu fun i_1 => ih (some i_1) exact hp F grad u hu h lemma HasVarGradientAt.neg {F : (X → U) → (X → ℝ)} diff --git a/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean b/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean index 3b1ad4061..54a7a8eb3 100644 --- a/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean +++ b/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean @@ -205,10 +205,9 @@ lemma gradient : IsLocalizedFunctionTransform fun (ψ : Space d → ℝ) x => gr exact Filter.EventuallyEq.fderiv_eq h lemma clm_apply [NormedAddCommGroup V] [NormedSpace ℝ V] [NormedAddCommGroup U] [NormedSpace ℝ U] - (f : X → (U →L[ℝ] V)) : IsLocalizedFunctionTransform fun φ x => (f x) (φ x) := - fun K cK => ⟨K, cK, by - intro _ _ hφ _ _ - simp_all⟩ + (f : X → (U →L[ℝ] V)) : IsLocalizedFunctionTransform fun φ x => (f x) (φ x) := by + intro K cK + exact ⟨K, cK, by intro _ _ hφ _ _; simp_all⟩ lemma deriv [NormedAddCommGroup U] [NormedSpace ℝ U] : IsLocalizedFunctionTransform (fun φ : ℝ → U => deriv φ) := by diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Basic.lean index 99576211c..237a98cc2 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Basic.lean @@ -85,8 +85,8 @@ lemma ofCrAnListF_cons (φ : 𝓕.CrAnFieldOp) (φs : List 𝓕.CrAnFieldOp) : ofCrAnListF (φ :: φs) = ofCrAnOpF φ * ofCrAnListF φs := rfl lemma ofCrAnListF_append (φs φs' : List 𝓕.CrAnFieldOp) : - ofCrAnListF (φs ++ φs') = - ofCrAnListF φs * ofCrAnListF φs' := by simp [ofCrAnListF, List.map_append] + ofCrAnListF (φs ++ φs') = ofCrAnListF φs * ofCrAnListF φs' := by + simp [ofCrAnListF, List.map_append] lemma ofCrAnListF_singleton (φ : 𝓕.CrAnFieldOp) : ofCrAnListF [φ] = ofCrAnOpF φ := by simp [ofCrAnListF] diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 9dfdf870b..65f67b7ee 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -266,8 +266,8 @@ lemma ofCrAnListF_mul_ofCrAnListF_eq_superCommuteF (φs φs' : List 𝓕.CrAnFie lemma ofCrAnOpF_mul_ofCrAnListF_eq_superCommuteF (φ : 𝓕.CrAnFieldOp) (φs' : List 𝓕.CrAnFieldOp) : ofCrAnOpF φ * ofCrAnListF φs' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs') • ofCrAnListF φs' * ofCrAnOpF φ + [ofCrAnOpF φ, ofCrAnListF φs']ₛF := by - simpa [ofCrAnListF_singleton] using - ofCrAnListF_mul_ofCrAnListF_eq_superCommuteF [φ] φs' + rw [← ofCrAnListF_singleton, ofCrAnListF_mul_ofCrAnListF_eq_superCommuteF] + simp lemma ofFieldOpListF_mul_ofFieldOpListF_eq_superCommuteF (φs φs' : List 𝓕.FieldOp) : ofFieldOpListF φs * ofFieldOpListF φs' = @@ -278,14 +278,14 @@ lemma ofFieldOpListF_mul_ofFieldOpListF_eq_superCommuteF (φs φs' : List 𝓕.F lemma ofFieldOpF_mul_ofFieldOpListF_eq_superCommuteF (φ : 𝓕.FieldOp) (φs' : List 𝓕.FieldOp) : ofFieldOpF φ * ofFieldOpListF φs' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs') • ofFieldOpListF φs' * ofFieldOpF φ + [ofFieldOpF φ, ofFieldOpListF φs']ₛF := by - simpa [ofFieldOpListF_singleton] using - ofFieldOpListF_mul_ofFieldOpListF_eq_superCommuteF [φ] φs' + rw [superCommuteF_ofFieldOpF_ofFieldOpFsList] + simp lemma ofFieldOpListF_mul_ofFieldOpF_eq_superCommuteF (φs : List 𝓕.FieldOp) (φ : 𝓕.FieldOp) : ofFieldOpListF φs * ofFieldOpF φ = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φ) • ofFieldOpF φ * ofFieldOpListF φs + [ofFieldOpListF φs, ofFieldOpF φ]ₛF := by - simpa [ofFieldOpListF_singleton] using - ofFieldOpListF_mul_ofFieldOpListF_eq_superCommuteF φs [φ] + rw [superCommuteF_ofFieldOpListF_ofFieldOpF] + simp lemma crPartF_mul_anPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : crPartF φ * anPartF φ' = diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index fa6fb2a83..8bc7c9536 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -199,8 +199,8 @@ lemma sum_nil (f : CrAnSection (𝓕 := 𝓕) [] → M) [AddCommMonoid M] : lemma sum_cons (f : CrAnSection (φ :: φs) → M) [AddCommMonoid M] : ∑ (s : CrAnSection (φ :: φs)), f s = ∑ (a : 𝓕.fieldOpToCrAnType φ), ∑ (s : CrAnSection φs), f (cons a s) := by - simpa [Fintype.sum_prod_type, consEquiv] using - Eq.symm (Equiv.sum_comp consEquiv.symm f) + rw [← consEquiv.symm.sum_comp, Fintype.sum_prod_type] + rfl lemma sum_over_length {s : CrAnSection φs} (f : Fin s.1.length → M) [AddCommMonoid M] : ∑ (n : Fin s.1.length), f n = @@ -418,8 +418,8 @@ lemma sum_eraseIdxEquiv (n : ℕ) (φs : List 𝓕.FieldOp) (hn : n < φs.length (f : CrAnSection φs → M) [AddCommMonoid M] : ∑ (s : CrAnSection φs), f s = ∑ (a : 𝓕.fieldOpToCrAnType φs[n]), ∑ (s : CrAnSection (φs.eraseIdx n)), f ((eraseIdxEquiv n φs hn).symm ⟨a, s⟩) := by - simpa [Fintype.sum_prod_type] using - Eq.symm (Equiv.sum_comp (eraseIdxEquiv n φs hn).symm f) + rw [← (eraseIdxEquiv n φs hn).symm.sum_comp] + rw [Fintype.sum_prod_type] end CrAnSection diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index 616ddd608..b388fde09 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -56,8 +56,8 @@ def normalOrderSign (φs : List 𝓕.CrAnFieldOp) : ℂ := @[simp] lemma normalOrderSign_mul_self (φs : List 𝓕.CrAnFieldOp) : - normalOrderSign φs * normalOrderSign φs = - 1 := by simp [normalOrderSign, Wick.koszulSign_mul_self] + normalOrderSign φs * normalOrderSign φs = 1 := by + simp [normalOrderSign, Wick.koszulSign_mul_self] lemma koszulSignInsert_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) : (φs : List 𝓕.CrAnFieldOp) → @@ -73,13 +73,12 @@ lemma koszulSignInsert_create (φ : 𝓕.CrAnFieldOp) lemma normalOrderSign_cons_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) (φs : List 𝓕.CrAnFieldOp) : - normalOrderSign (φ :: φs) = - normalOrderSign φs := by simp [normalOrderSign, Wick.koszulSign, - koszulSignInsert_create φ hφ φs] + normalOrderSign (φ :: φs) = normalOrderSign φs := by + simp [normalOrderSign, Wick.koszulSign, koszulSignInsert_create φ hφ φs] @[simp] -lemma normalOrderSign_singleton (φ : 𝓕.CrAnFieldOp) : - normalOrderSign [φ] = 1 := by simp [normalOrderSign] +lemma normalOrderSign_singleton (φ : 𝓕.CrAnFieldOp) : normalOrderSign [φ] = 1 := by + simp [normalOrderSign] @[simp] lemma normalOrderSign_nil : normalOrderSign (𝓕 := 𝓕) [] = 1 := rfl diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index ded05a082..47ddb9aed 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -277,8 +277,8 @@ lemma koszulSign_swap_eq_rel {ψ φ : 𝓕} (h1 : le φ ψ) (h2 : le ψ φ) : ( simp only [List.cons_append, koszulSign] rw [koszulSign_swap_eq_rel h1 h2] congr 1 - exact Wick.koszulSignInsert_eq_perm q le _ _ _ - (List.Perm.append_left φs (List.Perm.swap ψ φ φs')) + apply Wick.koszulSignInsert_eq_perm + exact List.Perm.append_left φs (List.Perm.swap ψ φ φs') lemma koszulSign_eq_rel_eq_stat_append {ψ φ : 𝓕} [IsTrans 𝓕 le] (h1 : le φ ψ) (h2 : le ψ φ) (hq : q ψ = q φ) : (φs : List 𝓕) → @@ -306,8 +306,8 @@ lemma koszulSign_eq_rel_eq_stat {ψ φ : 𝓕} [IsTrans 𝓕 le] simp only [mul_eq_mul_right_iff] left trans koszulSignInsert q le φ'' (φ :: ψ :: (φs' ++ φs)) - · exact koszulSignInsert_eq_perm q le _ _ _ - (List.perm_cons_append_cons φ List.perm_middle.symm).symm + · apply koszulSignInsert_eq_perm + exact (List.perm_cons_append_cons φ List.perm_middle.symm).symm · rw [koszulSignInsert_eq_remove_same_stat_append q le h1 h2 hq] lemma koszulSign_of_sorted : (φs : List 𝓕) @@ -401,8 +401,8 @@ lemma koszulSign_perm_eq_append [IsTrans 𝓕 le] (φ : 𝓕) (φs φs' φs2 : L forall_eq_or_imp, List.cons_append, motive] simp only [koszulSign, ih, mul_eq_mul_right_iff] left - exact koszulSignInsert_eq_perm q le _ _ _ - ((List.perm_append_right_iff φs2).mpr h) + apply koszulSignInsert_eq_perm + exact (List.perm_append_right_iff φs2).mpr h · intro x y l h simp_all only [List.mem_cons, forall_eq_or_imp, List.cons_append] apply Wick.koszulSign_swap_eq_rel_cons diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean index 9634831a6..a5c91ec80 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean @@ -170,8 +170,8 @@ lemma ι_normalOrderF_superCommuteF_eq_zero_mul_mul_right (a b1 b2 c d: 𝓕.Fie @[simp] lemma ι_normalOrderF_superCommuteF_eq_zero (c d : 𝓕.FieldOpFreeAlgebra) : ι 𝓝ᶠ([d, c]ₛF) = 0 := by - simpa using ι_normalOrderF_superCommuteF_eq_zero_mul - (1 : 𝓕.FieldOpFreeAlgebra) (1 : 𝓕.FieldOpFreeAlgebra) c d + rw [← ι_normalOrderF_superCommuteF_eq_zero_mul 1 1 c d] + simp /-! diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index 882971453..7d23ed569 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -34,8 +34,8 @@ lemma normalOrder_eq_ι_normalOrderF (a : 𝓕.FieldOpFreeAlgebra) : lemma normalOrder_ofCrAnList (φs : List 𝓕.CrAnFieldOp) : 𝓝(ofCrAnList φs) = normalOrderSign φs • ofCrAnList (normalOrderList φs) := by - simpa [ofCrAnList, normalOrder_eq_ι_normalOrderF] using - congrArg ι (normalOrderF_ofCrAnListF φs) + rw [ofCrAnList, normalOrder_eq_ι_normalOrderF, normalOrderF_ofCrAnListF] + rfl @[simp] lemma normalOrder_one_eq_one : normalOrder (𝓕 := 𝓕) 1 = 1 := by diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index ebff68e69..7df5a1a1a 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -81,8 +81,8 @@ lemma superCommuteRight_eq_of_equiv (a1 a2 : 𝓕.FieldOpFreeAlgebra) (h : a1 obtain ⟨b, rfl⟩ := ι_surjective b have ha1b1 : (superCommuteRight (a1 - a2)) (ι b) = 0 := by rw [superCommuteRight_apply_ι] - exact ι_superCommuteF_eq_zero_of_ι_left_zero (a1 - a2) b - ((ι_eq_zero_iff_mem_ideal (a1 - a2)).mpr h) + apply ι_superCommuteF_eq_zero_of_ι_left_zero + exact (ι_eq_zero_iff_mem_ideal (a1 - a2)).mpr h simp_all only [superCommuteRight_apply_ι, map_sub, LinearMap.sub_apply] trans ι ((superCommuteF a2) b) + 0 rw [← ha1b1] diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index c7f6f07f2..029ef3c51 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -474,7 +474,7 @@ lemma timeOrder_ofFieldOpList_nil : 𝓣(ofFieldOpList (𝓕 := 𝓕) []) = 1 := @[simp] lemma timeOrder_ofFieldOpList_singleton (φ : 𝓕.FieldOp) : 𝓣(ofFieldOpList [φ]) = ofFieldOpList [φ] := by - simp [ofFieldOpList, timeOrder_eq_ι_timeOrderF, timeOrderF_ofFieldOpListF_singleton] + rw [ofFieldOpList, timeOrder_eq_ι_timeOrderF, timeOrderF_ofFieldOpListF_singleton] /-- For a field specification `𝓕`, the time order operator acting on a list of `𝓕.FieldOp`, `𝓣(φ₀…φₙ)`, is equal to @@ -487,8 +487,8 @@ lemma timeOrder_eq_maxTimeField_mul_finset (φ : 𝓕.FieldOp) (φs : List 𝓕. (Finset.univ.filter (fun x => (maxTimeFieldPosFin φ φs).succAbove x < maxTimeFieldPosFin φ φs))⟩) • ofFieldOp (maxTimeField φ φs) * 𝓣(ofFieldOpList (eraseMaxTimeField φ φs)) := by - simpa [ofFieldOpList, ofFieldOp, timeOrder_eq_ι_timeOrderF] using - congrArg ι (timeOrderF_eq_maxTimeField_mul_finset φ φs) + rw [ofFieldOpList, timeOrder_eq_ι_timeOrderF, timeOrderF_eq_maxTimeField_mul_finset] + rfl lemma timeOrder_superCommute_eq_time_mid {φ ψ : 𝓕.CrAnFieldOp} (hφψ : crAnTimeOrderRel φ ψ) (hψφ : crAnTimeOrderRel ψ φ) (a b : 𝓕.WickAlgebra) : diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean index 59b29cf81..5d2dec371 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean @@ -109,8 +109,8 @@ lemma normalOrder_timeOrder_ofFieldOpList_eq_eqTimeOnly_empty (φs : List 𝓕.F 𝓣(𝓝(ofFieldOpList φs)) = 𝓣(ofFieldOpList φs) - ∑ (φsΛ : {φsΛ // φsΛ.EqTimeOnly (φs := φs) ∧ φsΛ ≠ empty}), φsΛ.1.sign • φsΛ.1.timeContract.1 * 𝓣(𝓝(ofFieldOpList [φsΛ.1]ᵘᶜ)) := by - simpa [eq_sub_iff_add_eq] using - (timeOrder_ofFieldOpList_eq_eqTimeOnly_empty (𝓕 := 𝓕) φs).symm + rw [timeOrder_ofFieldOpList_eq_eqTimeOnly_empty] + simp /-- For a list `φs` of `𝓕.FieldOp`, then `𝓣(φs)` is equal to the sum of diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean index f9d90820c..f12264ff1 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean @@ -43,8 +43,8 @@ lemma uncontractedCongr_none {c c': WickContraction n} (h : c = c') : @[simp] lemma uncontractedCongr_some {c c': WickContraction n} (h : c = c') (i : c.uncontracted) : - (uncontractedCongr h) (some i) = - some (Equiv.subtypeEquivRight (by rw [h]; simp) i) := by simp [uncontractedCongr] + (uncontractedCongr h) (some i) = some (Equiv.subtypeEquivRight (by rw [h]; simp) i) := by + simp [uncontractedCongr] lemma mem_uncontracted_iff_not_contracted (i : Fin n) : i ∈ c.uncontracted ↔ ∀ p ∈ c.1, i ∉ p := by @@ -79,8 +79,8 @@ lemma mem_uncontracted_empty (i : Fin n) : i ∈ empty.uncontracted := by simp [empty] at hp @[simp] -lemma getDual?_empty_eq_none (i : Fin n) : - empty.getDual? i = none := by simpa [uncontracted] using mem_uncontracted_empty i +lemma getDual?_empty_eq_none (i : Fin n) : empty.getDual? i = none := by + simpa [uncontracted] using mem_uncontracted_empty i @[simp] lemma uncontracted_empty {n : ℕ} : (@empty n).uncontracted = Finset.univ := by simp [uncontracted] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index 1c959aca6..f54256b5a 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -192,11 +192,11 @@ lemma uncontractedList_mem_iff (i : Fin n) : i ∈ c.uncontractedList ↔ i ∈ c.uncontracted := by simp [uncontractedList] @[simp] -lemma uncontractedList_empty : - (empty (n := n)).uncontractedList = List.finRange n := by simp [uncontractedList] +lemma uncontractedList_empty : (empty (n := n)).uncontractedList = List.finRange n := by + simp [uncontractedList] -lemma nil_zero_uncontractedList : - (empty (n := 0)).uncontractedList = [] := by simp [empty, uncontractedList] +lemma nil_zero_uncontractedList : (empty (n := 0)).uncontractedList = [] := by + simp [empty, uncontractedList] lemma congr_uncontractedList {n m : ℕ} (h : n = m) (c : WickContraction n) : ((congr h) c).uncontractedList = List.map (finCongr h) c.uncontractedList := by diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean index 045f98bae..e1b95f4c4 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean @@ -117,10 +117,9 @@ lemma momentumOperator_isSymmetric : (𝓟 i).IsSymmetric := by exact ((g.fderivCLM ℂ _ _).evalCLM ℂ _ _ _).memLp_top have hI₃ : Integrable fun x ↦ g x * fderiv ℝ (star ∘ f) x (basis i) := by simp_rw [heq] - exact Integrable.mul_of_top_right - ((starL' ℝ).integrable_comp_iff.mpr - ((f.fderivCLM ℂ _ _).evalCLM ℂ _ _ (basis i)).integrable) - g.memLp_top + refine Integrable.mul_of_top_right ?_ g.memLp_top + apply (starL' ℝ).integrable_comp_iff.mpr + exact ((f.fderivCLM ℂ _ _).evalCLM ℂ _ _ _).integrable have hI₄ : Integrable fun x ↦ g x * star (f x) := hI₁.mul_of_top_right g.memLp_top trans I * ℏ * ∫ x, g x * fderiv ℝ (star ∘ f) x (basis i) · simp_rw [← integral_const_mul_of_integrable hI₃, heq] diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean index 442852037..da9259ec6 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean @@ -400,9 +400,8 @@ lemma IsClosable.defectNumber_eq_of_mem_ball [CompleteSpace H] {T : H →ₗ.[ · exact hT.closure_isClosed.exists_inner_eq_zero_of_defectNumber_lt hz₂ hle refine not_le (a := ‖z₁ - z₂‖ * ‖x‖).mpr ?_ le_rfl refine lt_of_lt_of_le (b := ‖Tcl x - z₁ • x‖) ?_ ?_ - · exact lt_of_lt_of_le - ((mul_lt_mul_iff_left₀ <| norm_pos_iff.mpr hx).mpr (mem_ball_iff_norm'.mp h_ball)) - (isLowerBound_closure h x) + · refine lt_of_lt_of_le ?_ (isLowerBound_closure h x) + exact (mul_lt_mul_iff_left₀ <| norm_pos_iff.mpr hx).mpr (mem_ball_iff_norm'.mp h_ball) · rcases eq_or_ne (Tcl x - z₁ • x) 0 with heq | hne · exact heq ▸ norm_zero (E := H) ▸ mul_nonneg (norm_nonneg _) (norm_nonneg x) · apply (mul_le_mul_iff_left₀ (norm_pos_iff.mpr hne)).mp @@ -837,9 +836,8 @@ lemma IsClosed.spectrum_eq [CompleteSpace H] {T : H →ₗ.[ℂ] H} (hT : T.IsCl exact (inverse_closed_iff h_ker).mpr (hT.sub_continuous (Continuous.const_smul (by fun_prop) _) le_top) · left; left; exact h_ker - · exact union_subset - (union_subset T.pointSpectrum_subset_spectrum T.residualSpectrum_subset_spectrum) - T.continuousSpectrum_subset_spectrum + · refine union_subset ?_ T.continuousSpectrum_subset_spectrum + exact union_subset T.pointSpectrum_subset_spectrum T.residualSpectrum_subset_spectrum lemma pointSpectrum_inter_residualSpectrum (T : H →ₗ.[ℂ] H) : σᵖ T ∩ σʳ T = ∅ := by ext diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 78c0e0005..f030a0e54 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -59,8 +59,8 @@ variable {Λ Λ' : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ} -/ -lemma mem_iff_self_mul_dual : Λ ∈ LorentzGroup d ↔ Λ * dual Λ = 1 := - Iff.rfl +lemma mem_iff_self_mul_dual : Λ ∈ LorentzGroup d ↔ Λ * dual Λ = 1 := by + rfl lemma mem_iff_dual_mul_self : Λ ∈ LorentzGroup d ↔ dual Λ * Λ = 1 := by rw [mem_iff_self_mul_dual] diff --git a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean index 2f7b739e3..efc9f1b9d 100644 --- a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean @@ -42,7 +42,7 @@ lemma isOrthochronous_iff_toVector_timeComponet_nonneg : /-- A Lorentz transformation is orthochronous if and only if its transpose is orthochronous. -/ lemma isOrthochronous_iff_transpose : - IsOrthochronous Λ ↔ IsOrthochronous (transpose Λ) := Iff.rfl + IsOrthochronous Λ ↔ IsOrthochronous (transpose Λ) := by rfl @[simp] lemma isOrthochronous_inv_iff {Λ : LorentzGroup d} : diff --git a/Physlib/Relativity/PauliMatrices/Relations.lean b/Physlib/Relativity/PauliMatrices/Relations.lean index fd5aecf1a..98dcfc360 100644 --- a/Physlib/Relativity/PauliMatrices/Relations.lean +++ b/Physlib/Relativity/PauliMatrices/Relations.lean @@ -105,10 +105,7 @@ lemma pauliCo_trace_pauliCoDown: {σ_^^ | μ α β ⊗ σ___ | ν β α = 2 • lemma pauliContr_mul_pauliContrDown_add : {((σ^^^ | μ α β ⊗ σ^__ | ν β α') + (σ^^^ | ν α β ⊗ σ^__ | μ β α')) = 2 •ₜ η | μ ν ⊗ δL | α α'}ᵀ := by - rw [show Tensorial.toTensor (Tensorial.toTensor σ) = Tensorial.toTensor σ from rfl, - show Tensorial.toTensor σ^__ = σ^__ from rfl, - show Tensorial.toTensor η = η from rfl, - show Tensorial.toTensor δL = δL from rfl] + simp only [Tensorial.self_toTensor_apply] conv_lhs => rw [pauliContrDown_ofRat, toTensor_eq_ofRat, prodT_ofRat_ofRat, contrT_ofRat, permT_ofRat, ← map_add] diff --git a/Physlib/Relativity/PauliMatrices/ToTensor.lean b/Physlib/Relativity/PauliMatrices/ToTensor.lean index 6f6cb5438..f7d34fc34 100644 --- a/Physlib/Relativity/PauliMatrices/ToTensor.lean +++ b/Physlib/Relativity/PauliMatrices/ToTensor.lean @@ -372,9 +372,7 @@ set_option backward.isDefEq.respectTransparency false in lemma smul_pauliContrDown (g : SL(2,ℂ)) : g • pauliContrDown = pauliContrDown := by rw [← permT_equivariant, ← contrT_equivariant, ← prodT_equivariant, ← contrT_equivariant, ← prodT_equivariant] - rw [show toTensor (toTensor σ) = toTensor σ from rfl, - show toTensor εR' = εR' from rfl, - show toTensor εL' = εL' from rfl] + simp only [Tensorial.self_toTensor_apply] rw [toTensor_smul_eq_self, actionT_dualLeftMetric, actionT_dualRightMetric] rfl diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index 9ab0ed6ed..351ee0edf 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -153,8 +153,8 @@ lemma update_succAbove_apply {n : ℕ} {c : Fin (n + 1) → C} [inst : Decidable @[simp] lemma toTensor_update_add {n : ℕ} {c : Fin n → C} [inst : DecidableEq (Fin n)] (p : Pure S c) (i : Fin n) (x y : V (c i)) : - (update p i (x + y)).toTensor = - (update p i x).toTensor + (update p i y).toTensor := by simp [toTensor, update] + (update p i (x + y)).toTensor = (update p i x).toTensor + (update p i y).toTensor := by + simp [toTensor, update] @[simp] lemma toTensor_update_smul {n : ℕ} {c : Fin n → C} [inst : DecidableEq (Fin n)] (p : Pure S c) diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean index 1c96f0e77..4dc3e8655 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean @@ -253,8 +253,8 @@ def IsLorentz {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : Prop := ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ lemma isLorentz_iff {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : - IsLorentz f ↔ ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ := - Iff.rfl + IsLorentz f ↔ ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ := by + rfl lemma isLorentz_iff_basis {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : IsLorentz f ↔ ∀ μ ν : Fin 1 ⊕ Fin d, ⟪f (basis μ), f (basis ν)⟫ₘ = ⟪basis μ, basis ν⟫ₘ := by diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index 3368f8772..59f70c1e3 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -464,9 +464,9 @@ lemma schwartzMap_slice_integral_iteratedFDeriv_norm_le {d : ℕ} (n : ℕ) (η (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n := by rw [schwartzMap_slice_integral_iteratedFDeriv] apply le_trans (ContinuousMultilinearMap.norm_compContinuousLinearMap_le _ _) - simp only [Nat.succ_eq_add_one, Finset.prod_const, Finset.card_univ, Fintype.card_fin] - exact mul_le_mul (norm_integral_le_integral_norm fun a => iteratedFDeriv ℝ n ⇑η _) - (by rfl) (by positivity) (by positivity) + simp + refine mul_le_mul ?_ (by rfl) (by positivity) (by positivity) + exact norm_integral_le_integral_norm fun a => iteratedFDeriv ℝ n ⇑η _ lemma schwartzMap_mul_pow_slice_integral_iteratedFDeriv_norm_le {d : ℕ} (n m : ℕ) (i : Fin d.succ) : ∃ rt, ∀ (η : 𝓢(Space d.succ, ℝ)),∀ (x : Space d), @@ -490,10 +490,9 @@ lemma schwartzMap_mul_pow_slice_integral_iteratedFDeriv_norm_le {d : ℕ} (n m : calc _ _ ≤ ‖x‖ ^ m * ((∫ (r : ℝ), ‖iteratedFDeriv ℝ n η ((slice i).symm (r, x))‖) * ‖(slice i).symm.toContinuousLinearMap.comp - ((0 : Space d →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n) := - mul_le_mul_of_nonneg (by rfl) - (schwartzMap_slice_integral_iteratedFDeriv_norm_le n η i x) (by positivity) - (by positivity) + ((0 : Space d →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n) := by + refine mul_le_mul_of_nonneg (by rfl) ?_ (by positivity) (by positivity) + exact schwartzMap_slice_integral_iteratedFDeriv_norm_le n η i x _ ≤ (∫ (r : ℝ), ‖x‖ ^ m * ‖iteratedFDeriv ℝ n η ((slice i).symm (r, x))‖) * ‖(slice i).symm.toContinuousLinearMap.comp ((0 : Space d →L[ℝ] ℝ).prod (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n := by diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean b/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean index f2ec5d3fe..a7bcc3db5 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean @@ -103,8 +103,8 @@ lemma iteratedDeriv_increment_zero [NeZero d] [AddCommGroup M] [Module ℝ M] [T @[simp] lemma iteratedDeriv_single [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (i : Fin d) (f : Space d → M) : - ∂^[MultiIndex.increment 0 i] f = - ∂[i] f := by simp [iteratedDeriv, Physlib.MultiIndex.toList_single] + ∂^[MultiIndex.increment 0 i] f = ∂[i] f := by + simp [iteratedDeriv, Physlib.MultiIndex.toList_single] lemma iteratedDeriv_add (I : MultiIndex d) {f g : Space d → ℝ} (hf : ContDiff ℝ ∞ f) (hg : ContDiff ℝ ∞ g) : diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index 35da2f800..614ff5490 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -1116,8 +1116,8 @@ lemma norm_smul_zpow {d} (p : ℤ) (c : Space d) (hn : - (d - 1 : ℕ) ≤ p) : ring suffices h0 : IsDistBounded (fun x => ‖x‖ * (‖x‖ ^ (p + 1))⁻¹) by apply h0.add - · exact IsDistBounded.const_mul_fun - (IsDistBounded.pow (d := d) (n := -(p + 1)) (by grind)) ‖c‖ + · apply IsDistBounded.const_mul_fun + exact IsDistBounded.pow (d := d) (n := -(p + 1)) (by grind) by_cases hp : p = 0 · subst hp simp only [zero_add, pow_one] diff --git a/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean b/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean index 8e3926344..28eb65a7c 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean @@ -376,9 +376,7 @@ noncomputable def distDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] map_smul' _ _ := rfl } ev.comp (Distribution.fderivD ℝ f) - map_add' _ _ := by - simp - map_smul' _ _ := by + map_add' f1 f2 := by simp lemma distDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index e46740998..5f2bc9227 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -255,15 +255,15 @@ instance : AddGroup Time where zsmul := zsmulRec instance : AddCommGroup Time where - add_comm t1 t2 := Time.ext (by simp [add_comm]) + add_comm := by intros; ext; simp [add_comm] instance : Module ℝ Time where - one_smul t := Time.ext (by simp) - smul_add k t1 t2 := Time.ext (by simp [mul_add]) - smul_zero k := Time.ext (by simp) - add_smul k1 k2 t := Time.ext (by simp [add_mul]) - mul_smul k1 k2 t := Time.ext (by simp [mul_assoc]) - zero_smul t := Time.ext (by simp) + one_smul t := by ext; simp + smul_add k t1 t2 := by ext; simp [mul_add] + smul_zero k := by ext; simp [mul_zero] + add_smul k1 k2 t := by ext; simp [add_mul] + mul_smul k1 k2 t := by ext; simp [mul_assoc] + zero_smul t := by ext; simp /-! diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 412620afd..69fab2fdf 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -769,10 +769,9 @@ lemma time_integral_iteratedFDeriv_norm_le {d : ℕ} (n : ℕ) (η : 𝓢(Time (ContinuousLinearMap.id ℝ (Space d)))‖ ^ n := by rw [time_integral_iteratedFDeriv_eq] apply le_trans (ContinuousMultilinearMap.norm_compContinuousLinearMap_le _ _) - simp only [ContinuousLinearMap.opNorm_prod, Prod.norm_mk, norm_zero, norm_nonneg, - sup_of_le_right, Finset.prod_const, Finset.card_univ, Fintype.card_fin] - exact mul_le_mul (norm_integral_le_integral_norm fun a => iteratedFDeriv ℝ n ⇑η (a, x)) - (by rfl) (by positivity) (by positivity) + simp + refine mul_le_mul ?_ (by rfl) (by positivity) (by positivity) + exact norm_integral_le_integral_norm fun a => iteratedFDeriv ℝ n ⇑η (a, x) /-! diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index ba2c3355c..3a0e4ec64 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -215,8 +215,8 @@ variable {ι1 : Type} [Fintype ι1] [MeasurableSpace ι1] open Constants lemma entropy_of_fintype (T : Temperature) : - 𝓒.shannonEntropy T = - - kB * ∑ i, 𝓒.probability T i * log (𝓒.probability T i) := by simp [shannonEntropy] + 𝓒.shannonEntropy T = - kB * ∑ i, 𝓒.probability T i * log (𝓒.probability T i) := by + simp [shannonEntropy] lemma probability_le_one [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] (T : Temperature) (i : ι) : @@ -232,8 +232,8 @@ lemma probability_le_one /-- Finite specialization: strict positivity of the mathematical partition function. -/ lemma mathematicalPartitionFunction_pos_finite [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] (T : Temperature) : - 0 < 𝓒.mathematicalPartitionFunction T := by simpa using - (CanonicalEnsemble.mathematicalPartitionFunction_pos (𝓒:=𝓒) T) + 0 < 𝓒.mathematicalPartitionFunction T := by + simpa using (CanonicalEnsemble.mathematicalPartitionFunction_pos (𝓒:=𝓒) T) /-- Finite specialization: strict positivity of the (physical) partition function. -/ lemma partitionFunction_pos_finite @@ -272,9 +272,8 @@ lemma entropy_nonneg [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] lemma shannonEntropy_eq_differentialEntropy [MeasurableSingletonClass ι] [IsFinite 𝓒] (T : Temperature) : - 𝓒.shannonEntropy T = - 𝓒.differentialEntropy T := by simp [shannonEntropy, differentialEntropy, - integral_fintype, μProd_of_fintype] + 𝓒.shannonEntropy T = 𝓒.differentialEntropy T := by + simp [shannonEntropy, differentialEntropy, integral_fintype, μProd_of_fintype] /-- In the finite, nonempty case the thermodynamic and Shannon entropies coincide. All semi-classical correction factors vanish (`dof = 0`, `phaseSpaceUnit = 1`), diff --git a/Physlib/Units/Examples.lean b/Physlib/Units/Examples.lean index e8546fbd3..8a2877403 100644 --- a/Physlib/Units/Examples.lean +++ b/Physlib/Units/Examples.lean @@ -34,8 +34,7 @@ noncomputable def meters400 : Dimensionful (WithDim L𝓭 ℝ) := toDimensionful 400 meters is very almost a quarter of a mile. -/ example : meters400 {SI with length := LengthUnit.miles} = ⟨1/4 - 73/50292⟩ := by ext - norm_num [meters400, toDimensionful_apply_apply, dimScale, LengthUnit.miles, NNReal.smul_def] - rw [NNReal.toReal] + show (1609.344 : ℝ)⁻¹ * 400 = _ norm_num /-! @@ -90,8 +89,8 @@ def EnergyMassWithDim (m : WithDim M𝓭 ℝ) (E : WithDim (M𝓭 * L𝓭 * L lemma energyMassWithDim_isDimensionallyCorrect : IsDimensionallyCorrect EnergyMassWithDim := by simp [funext_iff, EnergyMassWithDim] - intro _ _ _ _ _ - exact WithDim.scaleUnit_val_eq_scaleUnit_val_of_dim_eq + intros + rw [WithDim.scaleUnit_val_eq_scaleUnit_val_of_dim_eq] /-- An example of dimensions corresponding to `F = m a` using `WithDim` with `.val`. -/ def NewtonsSecondWithDim (m : WithDim M𝓭 ℝ) (F : WithDim (M𝓭 * L𝓭 * T𝓭⁻¹ * T𝓭⁻¹) ℝ) @@ -101,8 +100,8 @@ def NewtonsSecondWithDim (m : WithDim M𝓭 ℝ) (F : WithDim (M𝓭 * L𝓭 * T lemma newtonsSecondWithDim_isDimensionallyCorrect : IsDimensionallyCorrect NewtonsSecondWithDim := by simp [funext_iff, NewtonsSecondWithDim] - intro _ _ _ _ _ - exact WithDim.scaleUnit_val_eq_scaleUnit_val_of_dim_eq + intros + rw [WithDim.scaleUnit_val_eq_scaleUnit_val_of_dim_eq] /-- An example of dimensions corresponding to `E = m c` using `WithDim` with `.val`, which is not dimensionally correct. -/ @@ -164,7 +163,7 @@ We now explore the consequences of `energyMass_isDimensionallyCorrect` and how w -/ lemma example1_energyMass : EnergyMass ⟨2⟩ ⟨2 * 299792458 ^ 2⟩ SI := by - norm_num [EnergyMass, speedOfLight, toDimensionful_apply_apply, dimScale, SI] + simp [EnergyMass, speedOfLight, toDimensionful_apply_apply, dimScale, SI] /- The lemma `energyMass_isDimensionallyCorrect` allows us to scale the units of `example1_energyMass`, that is - we proved it in one set of units, but we get the result diff --git a/Physlib/Units/FDeriv.lean b/Physlib/Units/FDeriv.lean index 2d6a2be3e..f015b8ebe 100644 --- a/Physlib/Units/FDeriv.lean +++ b/Physlib/Units/FDeriv.lean @@ -52,10 +52,10 @@ lemma fderiv_isDimensionallyCorrect (f : M1 → M2) (hf : IsDimensionallyCorrect IsDimensionallyCorrect (fderiv ℝ f) := by simp only [isDimensionallyCorrect_fun_iff] intro u1 u2 m - exact ContinuousLinearMap.ext fun m' => by - simp only [ContinuousLinearUnitDependent.scaleUnit_apply_fun] - rw [fderiv_apply_scaleUnit u1 u2 m (scaleUnit u2 u1 m') f hf f_diff] - simp [HasDim.scaleUnit_apply, smul_smul] + ext m' + simp only [ContinuousLinearUnitDependent.scaleUnit_apply_fun] + rw [fderiv_apply_scaleUnit u1 u2 m (scaleUnit u2 u1 m') f hf f_diff] + simp [HasDim.scaleUnit_apply, smul_smul] /-- The expression `fderiv ℝ f x dm = v.1` for a fixed `dm` and for `v` with dimension `d M2 * (d M1)⁻¹` is dimensionally correct. This is the diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index c6381bd1e..cd1ef30fd 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -112,8 +112,8 @@ def UnitDependent.scaleUnitEquiv {M : Type} [UnitDependent M] (u1 u2 : UnitChoices) : M ≃ M where toFun m := scaleUnit u1 u2 m invFun m := scaleUnit u2 u1 m - right_inv m := UnitDependent.scaleUnit_symm_apply u2 u1 m - left_inv m := UnitDependent.scaleUnit_symm_apply u1 u2 m + right_inv m := by simp + left_inv m := by simp /-- For an `M` with an instance of `LinearUnitDependent M`, `scaleUnit u1 u2` as a linear map. -/ @@ -122,8 +122,8 @@ def LinearUnitDependent.scaleUnitLinear (u1 u2 : UnitChoices) : M →ₗ[ℝ] M where toFun m := scaleUnit u1 u2 m - map_add' m1 m2 := LinearUnitDependent.scaleUnit_add u1 u2 m1 m2 - map_smul' r m2 := LinearUnitDependent.scaleUnit_smul u1 u2 r m2 + map_add' m1 m2 := by simp [LinearUnitDependent.scaleUnit_add] + map_smul' r m2 := by simp [LinearUnitDependent.scaleUnit_smul] /-- For an `M` with an instance of `LinearUnitDependent M`, `scaleUnit u1 u2` as a linear equivalence. -/ @@ -445,7 +445,7 @@ def IsDimensionallyCorrect {M : Type} [UnitDependent M] (m : M) : Prop := lemma isDimensionallyCorrect_iff {M : Type} [UnitDependent M] (m : M) : IsDimensionallyCorrect m ↔ ∀ u1 u2 : UnitChoices, - scaleUnit u1 u2 m = m := Iff.rfl + scaleUnit u1 u2 m = m := by rfl @[simp] lemma isDimensionallyCorrect_fun_iff {M1 M2 : Type} [UnitDependent M1] [UnitDependent M2] @@ -527,4 +527,4 @@ lemma scaleUnit_dimSet_val {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] rfl lemma DimSet.mem_iff {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) (m : M) : - m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := Iff.rfl + m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := by rfl diff --git a/Physlib/Units/WithDim/Area.lean b/Physlib/Units/WithDim/Area.lean index 0327509bb..1bb15f0d6 100644 --- a/Physlib/Units/WithDim/Area.lean +++ b/Physlib/Units/WithDim/Area.lean @@ -69,16 +69,14 @@ lemma squareMeter_in_SI : squareMeter.1 SI = ⟨1⟩ := by @[simp] lemma squareFoot_in_SI : squareFoot.1 SI = ⟨0.09290304⟩ := by ext - norm_num [squareFoot, dimScale, LengthUnit.feet, toDimensionful_apply_apply, - NNReal.coe_ofScientific] + simp [NNReal.coe_ofScientific] rw [toReal] norm_num @[simp] lemma squareMile_in_SI : squareMile.1 SI = ⟨2589988.110336⟩ := by ext - norm_num [squareMile, dimScale, LengthUnit.miles, toDimensionful_apply_apply, - NNReal.coe_ofScientific] + simp [NNReal.coe_ofScientific] rw [toReal] norm_num @@ -93,8 +91,7 @@ lemma hectare_in_SI : hectare.1 SI = ⟨10000⟩ := by @[simp] lemma acre_in_SI : acre.1 SI = ⟨4046.8564224⟩ := by ext - norm_num [acre, dimScale, LengthUnit.miles, toDimensionful_apply_apply, - NNReal.coe_ofScientific] + simp [NNReal.coe_ofScientific] rw [toReal] norm_num @@ -108,6 +105,6 @@ lemma acre_in_SI : acre.1 SI = ⟨4046.8564224⟩ := by lemma acre_eq_mul_squareFeet : acre = (43560 : ℝ≥0) • squareFoot := by apply (toDimensionful SI).symm.injective ext - norm_num [toDimensionful] + norm_num end DimArea diff --git a/Physlib/Units/WithDim/Speed.lean b/Physlib/Units/WithDim/Speed.lean index 7364b9fd5..c12552e6b 100644 --- a/Physlib/Units/WithDim/Speed.lean +++ b/Physlib/Units/WithDim/Speed.lean @@ -66,8 +66,7 @@ lemma oneMeterPerSecond_in_SI : oneMeterPerSecond SI = ⟨1⟩ := by @[simp] lemma oneMilePerHour_in_SI : oneMilePerHour SI = ⟨0.44704⟩ := by ext - norm_num [oneMilePerHour, dimScale, LengthUnit.miles, TimeUnit.hours, - toDimensionful_apply_apply, NNReal.coe_ofScientific] + simp [NNReal.coe_ofScientific] rw [toReal] norm_num @@ -101,18 +100,18 @@ lemma oneKnot_eq_mul_oneKilometerPerHour : oneKnot = (1.852 : ℝ≥0) • oneKilometerPerHour := by apply (toDimensionful SI).symm.injective ext - norm_num [toDimensionful] + norm_num lemma oneKilometerPerHour_eq_mul_oneKnot: oneKilometerPerHour = (250/463 : ℝ≥0) • oneKnot := by apply (toDimensionful SI).symm.injective ext - norm_num [toDimensionful] + norm_num lemma oneMeterPerSecond_eq_mul_oneMilePerHour : oneMeterPerSecond = (3125/1397 : ℝ≥0) • oneMilePerHour := by apply (toDimensionful SI).symm.injective ext - norm_num [toDimensionful] + norm_num end DimSpeed diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index 053ca1960..e4b8f04ad 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -243,7 +243,7 @@ def traceLeft : CPTPMap (d₁ × d₂) d₂ := } { toLinearMap := f d₂ - TP := Matrix.traceLeft_trace + TP := by intro; simp [f] cp := by --(traceLeft ⊗ₖₘ I) = traceLeft ∘ₘ (ofEquiv prod_assoc) --Both go (A × B) × C → B × C @@ -280,8 +280,8 @@ end trace def replacement [Nonempty dIn] [DecidableEq dOut] (ρ : MState dOut) : CPTPMap dIn dOut := traceLeft ∘ₘ { toFun := fun M => Matrix.kroneckerMap (fun x1 x2 => x1 * x2) M ρ.m - map_add' M N := Matrix.add_kronecker M N ρ.m - map_smul' r M := Matrix.smul_kronecker r M ρ.m + map_add' := by simp [Matrix.add_kronecker] + map_smul' := by simp [Matrix.smul_kronecker] cp := MatrixMap.kron_kronecker_const ρ.psd TP := by intro; simp [Matrix.trace_kronecker] } diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index 78f19b63c..0b3ed100c 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -170,13 +170,11 @@ lemma dual_unique (h : ∀ A B, (M A * B).trace = (A * M' B).trace) : M.dual = M' := by -- By definition of dual, we know that for any A and B, the trace of (M A) * B equals the trace of -- A * (M.dual B). - have h_dual : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, - (M A * B).trace = (A * M.dual B).trace := - fun A B => Dual.trace_eq M A B + have h_dual : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, (M A * B).trace = (A * M.dual B).trace := by + exact fun A B => Dual.trace_eq M A B; -- Since these two linear maps agree on all bases, they must be equal. - have h_eq : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, - (A * M.dual B).trace = (A * M' B).trace := - fun A B => h_dual A B ▸ h A B + have h_eq : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, (A * M.dual B).trace = (A * M' B).trace := by + exact fun A B => h_dual A B ▸ h A B; refine' LinearMap.ext fun B => _; exact Matrix.ext_iff_trace_mul_left.mpr fun x => h_eq x B diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index 5f9c66a62..303959fab 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -109,8 +109,8 @@ variable {R : Type*} [CommSemiring R] def choi_equiv : MatrixMap A B R ≃ₗ[R] Matrix (B × A) (B × A) R where toFun := choi_matrix invFun := of_choi_matrix - left_inv := choi_map_inv - right_inv := map_choi_inv + left_inv _ := by simp + right_inv _ := by simp map_add' _ _ := by ext; simp [choi_matrix] map_smul' _ _ := by ext; simp [choi_matrix] @@ -188,8 +188,8 @@ variable {A B : Type*} (R : Type*) [Semiring R] @[simps] def submatrix (f : B → A) : MatrixMap A B R where toFun x := x.submatrix f f - map_add' x y := congrFun (congrFun (Matrix.submatrix_add x y) f) f - map_smul' r x := congrFun (congrFun (Matrix.submatrix_smul r x) f) f + map_add' := by simp [Matrix.submatrix_add] + map_smul' := by simp [Matrix.submatrix_smul] @[simp] theorem submatrix_id : submatrix R _root_.id = id A R := rfl diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 1a0d946bd..1db1a6452 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -123,8 +123,7 @@ theorem pinching_commutes_kraus (σ ρ : MState d) (i : spectrum ℝ σ.m) : theorem pinching_commutes (ρ σ : MState d) : Commute (pinching_map σ ρ).m σ.m := by - rw [commute_iff_eq] - change (pinching_map σ ρ).M.mat * σ.M.mat = σ.M.mat * (pinching_map σ ρ).M.mat + dsimp [MState.m, Commute, SemiconjBy] rw [pinchingMap_apply_M] simp only [MatrixMap.of_kraus, Function.comp_apply] simp only [HermitianMat.conjTranspose_mat, MState.mat_M, LinearMap.coe_sum, @@ -282,10 +281,8 @@ theorem inner_cfc_pinching_right (ρ σ : MState d) (f : ℝ → ℝ) : ⟪(pinching_map σ ρ).M, σ.M.cfc f⟫ = ⟪ρ.M, σ.M.cfc f⟫ := by --TODO Cleanup -- By definition of pinching_map, we have pinching_map σ ρ = ∑ k, (pinching_kraus σ k).toMat * ρ.toMat * (pinching_kraus σ k).toMat. - have h_pinching_def : - (pinching_map σ ρ).M = ∑ k, (pinching_kraus σ k).mat * ρ.M.mat * - (pinching_kraus σ k).mat := - pinching_eq_sum_conj σ ρ + have h_pinching_def : (pinching_map σ ρ).M = ∑ k, (pinching_kraus σ k).mat * ρ.M.mat * (pinching_kraus σ k).mat := by + exact pinching_eq_sum_conj σ ρ -- By definition of pinching_map, we know that (pinching_kraus σ k).toMat * (σ.M.cfc f).toMat = (σ.M.cfc f).toMat * (pinching_kraus σ k).toMat. have h_comm_cfc : ∀ k, (pinching_kraus σ k).mat * (σ.M.cfc f).mat = (σ.M.cfc f).mat * (pinching_kraus σ k).mat := by intro k @@ -299,11 +296,8 @@ theorem inner_cfc_pinching_right (ρ σ : MState d) (f : ℝ → ℝ) : convert pinching_sum σ using 1; simp [HermitianMat.ext_iff ]; -- Since each pinching_kraus is a projection, multiplying it by itself gives the same projection. Therefore, the sum of the squares is the same as the sum of the pinching_kraus themselves. - have h_proj : ∀ k : spectrum ℝ σ.m, (pinching_kraus σ k).mat * - (pinching_kraus σ k).mat = (pinching_kraus σ k).mat := - fun k => by - simpa [sq, -pinching_sq_eq_self] using - congr_arg (fun x : HermitianMat d ℂ => x.mat) (pinching_sq_eq_self σ k) + have h_proj : ∀ k : spectrum ℝ σ.m, (pinching_kraus σ k).mat * (pinching_kraus σ k).mat = (pinching_kraus σ k).mat := by + exact fun k => by simpa [ sq, -pinching_sq_eq_self ] using congr_arg ( fun x : HermitianMat d ℂ => x.mat ) ( pinching_sq_eq_self σ k ) ; rw [ Finset.sum_congr rfl fun _ _ => h_proj _ ]; convert congr_arg ( fun x : Matrix d d ℂ => x.trace.re ) ( congr_arg ( fun x : Matrix d d ℂ => x * ( ρ.m * cfc f σ.m ) ) h_sum_kraus ) using 1; · simp [Matrix.sum_mul] diff --git a/QuantumInfo/ClassicalInfo/Prob.lean b/QuantumInfo/ClassicalInfo/Prob.lean index f8682d1f0..cf8adac49 100644 --- a/QuantumInfo/ClassicalInfo/Prob.lean +++ b/QuantumInfo/ClassicalInfo/Prob.lean @@ -43,10 +43,10 @@ instance canLift : CanLift ℝ Prob Subtype.val fun r => 0 ≤ r ∧ r ≤ 1 := Subtype.canLift _ instance instZero : Zero Prob := - ⟨0, ⟨le_rfl, zero_le_one⟩⟩ + ⟨0, by simp⟩ instance instOne : One Prob := - ⟨1, ⟨zero_le_one, le_rfl⟩⟩ + ⟨1, by simp⟩ instance instMul : Mul Prob := ⟨fun x y ↦ ⟨x.1 * y.1, diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 3c2229fc8..907f105c3 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -267,9 +267,8 @@ Proof: f_α(H_hat, ρ, σ) = α · Tr[(σ^γ ρ σ^γ)^α] - (α-1) · Tr[(σ^γ -/ theorem f_alpha_at_optimizer (hα : 1 < α) (ρ σ : MState d) : f_alpha α (H_hat α ρ σ) ρ σ = Q̃_ α(ρ‖σ) := by - have h_inner : ⟪ρ.M, H_hat α ρ σ⟫_ℝ = - ((ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ α).trace := - inner_rho_H_hat hα ρ σ + have h_inner : ⟪ρ.M, H_hat α ρ σ⟫_ℝ = ((ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ α).trace := by + exact inner_rho_H_hat hα ρ σ have h_conj : (H_hat α ρ σ).conj (σ.M ^ ((α - 1) / (2 * α))).mat = (ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ (α - 1) := by convert H_hat_conj_sigma (hα := hα) (ρ := ρ) (σ := σ) using 1 diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 51f2f3520..11e8f5c1c 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -176,11 +176,8 @@ lemma HermitianMat.trace_rpow_le_trace_of_le_one (p : ℝ) (hp : 1 ≤ p) : (A ^ p).trace ≤ A.trace := by -- Rewrite both sides using trace_rpow_eq_sum: Tr[A^p] = ∑ λ_i^p and Tr[A] = ∑ λ_i (using trace_rpow_eq_sum and rpow_one for the latter). - have h_trace_eq_sum : (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p ∧ - A.trace = ∑ i, A.H.eigenvalues i := - ⟨by rw [HermitianMat.trace_rpow_eq_sum], - by rw [show A.trace = ∑ i, A.H.eigenvalues i by - simpa using HermitianMat.trace_rpow_eq_sum A 1]⟩ + have h_trace_eq_sum : (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p ∧ A.trace = ∑ i, (A.H.eigenvalues i) := by + exact ⟨ by rw [ HermitianMat.trace_rpow_eq_sum ], by rw [ show A.trace = ∑ i, ( A.H.eigenvalues i ) by simpa using HermitianMat.trace_rpow_eq_sum A 1 ] ⟩; rw [ h_trace_eq_sum.1, h_trace_eq_sum.2 ]; apply_rules [ Finset.sum_le_sum ]; intro i hi; by_cases hi0 : A.H.eigenvalues i = 0 <;> simp_all @@ -514,9 +511,8 @@ private lemma trace_conj_eq_inner_rpow {ρ σ : MState d} {t : ℝ} (ht : t ≠ fun h => ht (by linarith) exact HermitianMat.mat_rpow_add h_nonneg h_ne_zero rw [ mul_two, h_exp ] - have h_inner : ⟪ρ.M, σ.M ^ (2 * t)⟫ = - ((ρ.M.mat * (σ.M ^ (2 * t)).mat).trace).re := - rfl + have h_inner : ⟪ρ.M, σ.M ^ (2 * t)⟫ = ((ρ.M.mat * (σ.M ^ (2 * t)).mat).trace).re := by + exact rfl simp_all convert congr_arg Complex.re h_cyclic using 1 ; simp [ HermitianMat.conj ] ; ring!; rw [ Matrix.trace_mul_comm ] @@ -528,9 +524,8 @@ private def eigenWeight (ρ σ : MState d) (i : d) : ℝ := private lemma inner_cfc_eq_sum_eigenWeight (ρ σ : MState d) (f : ℝ → ℝ) : ⟪ρ.M, σ.M.cfc f⟫ = ∑ i, f (σ.M.H.eigenvalues i) * eigenWeight ρ σ i := by -- By definition of the inner product in the context of Hermitian matrices, we can expand it using the trace. - have h_inner : ⟪ρ.M, σ.M.cfc f⟫ = - RCLike.re (Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat)) := - rfl + have h_inner : ⟪ρ.M, σ.M.cfc f⟫ = RCLike.re (Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat)) := by + exact rfl; have h_trace : Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat) = ∑ i, f (σ.M.H.eigenvalues i) * (star (σ.M.H.eigenvectorBasis i) ⬝ᵥ ρ.M.mat.mulVec (σ.M.H.eigenvectorBasis i)) := by rw [ Matrix.trace ]; have h_cfc_def : (σ.M.cfc f).mat = ∑ i, (f (Matrix.IsHermitian.eigenvalues σ.M.H i)) • Matrix.of (fun x y => (σ.M.H.eigenvectorBasis i x) * (star (σ.M.H.eigenvectorBasis i y))) := by @@ -770,9 +765,8 @@ private lemma scalar_rpow_cross_term_of_continuous_zero {b : ℝ → ℝ} intro ε hε_pos obtain ⟨δ₁, hδ₁_pos, hδ₁⟩ : ∃ δ₁ > 0, ∀ α, abs (α - 1) < δ₁ → Real.sqrt (|b α|) * |Real.log (|b α|)| < ε := by simpa using Metric.tendsto_nhds_nhds.mp h_sqrt_log ε hε_pos |> fun ⟨ δ₁, hδ₁₁, hδ₁₂ ⟩ => ⟨ δ₁, hδ₁₁, fun α hα => lt_of_abs_lt <| by simpa using hδ₁₂ hα ⟩; - obtain ⟨δ₂, hδ₂_pos, hδ₂⟩ : ∃ δ₂ > 0, ∀ α, abs (α - 1) < δ₂ → |b α ^ α - b α| ≤ |α - 1| * Real.sqrt (|b α|) * |Real.log (|b α|)| := - Metric.mem_nhds_iff.mp h_bound |> fun ⟨δ₂, hδ₂_pos, hδ₂⟩ => - ⟨δ₂, hδ₂_pos, fun α hα => hδ₂ hα⟩ + obtain ⟨δ₂, hδ₂_pos, hδ₂⟩ : ∃ δ₂ > 0, ∀ α, abs (α - 1) < δ₂ → |b α ^ α - b α| ≤ |α - 1| * Real.sqrt (|b α|) * |Real.log (|b α|)| := by + exact Metric.mem_nhds_iff.mp h_bound |> fun ⟨ δ₂, hδ₂_pos, hδ₂ ⟩ => ⟨ δ₂, hδ₂_pos, fun α hα => hδ₂ hα ⟩; exact ⟨ Min.min δ₁ δ₂, lt_min hδ₁_pos hδ₂_pos, fun α hα => le_trans ( hδ₂ α ( lt_of_lt_of_le hα ( min_le_right _ _ ) ) ) ( by nlinarith [ hδ₁ α ( lt_of_lt_of_le hα ( min_le_left _ _ ) ), abs_nonneg ( α - 1 ) ] ) ⟩; rw [ hasDerivAt_iff_isLittleO_nhds_zero ]; rw [ Asymptotics.isLittleO_iff ]; @@ -1076,9 +1070,8 @@ private lemma cross_term_slope_tendsto_zero rw [ Filter.EventuallyEq, eventually_nhdsWithin_iff ]; rw [ Metric.eventually_nhds_iff ] at *; obtain ⟨ ε, ε_pos, hε ⟩ := hK; use ε, ε_pos; intro y hy hy'; simp_all [ div_eq_inv_mul] ; - have h_trace_rpow : ∀ (A : HermitianMat d ℂ) (p : ℝ), - (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p := - fun A p => HermitianMat.trace_rpow_eq_sum A p + have h_trace_rpow : ∀ (A : HermitianMat d ℂ) (p : ℝ), (A ^ p).trace = ∑ i, (A.H.eigenvalues i) ^ p := by + exact fun A p => HermitianMat.trace_rpow_eq_sum A p; have := h_trace_rpow ( M ( 1 + y ) ) 1; have := h_trace_rpow ( ρ : HermitianMat d ℂ ) 1; simp_all simp +zetaDelta at *; simp [ ← this, div_eq_inv_mul, mul_sub, hy' ]; @@ -1286,19 +1279,16 @@ lemma ker_le_of_ker_kron_le_left (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSta · exact ⟨ 0, by simp, v, h_contra v hvU, by simp ⟩; have h_union : ∃ v : EuclideanSpace ℂ d₂, v ∉ U ∧ v ∈ V := by have h_union : ∃ v : EuclideanSpace ℂ d₂, v ∈ V ∧ v ∉ U := by - have h_not_subset : ¬V ≤ U := - fun h => hU <| by - rw [eq_top_iff] - exact h_union ▸ sup_le (by tauto) h + have h_not_subset : ¬V ≤ U := by + exact fun h => hU <| by rw [ eq_top_iff ] ; exact h_union ▸ sup_le ( by tauto ) h; exact Set.not_subset.mp h_not_subset; exact ⟨ h_union.choose, h_union.choose_spec.2, h_union.choose_spec.1 ⟩; obtain ⟨ v, hv₁, hv₂ ⟩ := h_union; obtain ⟨ w, hw₁, hw₂ ⟩ : ∃ w : EuclideanSpace ℂ d₂, w ∉ V ∧ w ∈ U := by obtain ⟨ w, hw ⟩ := ( show ∃ w : EuclideanSpace ℂ d₂, w ∉ V from by simpa [ Submodule.eq_top_iff' ] using hV ) ; use w; simp_all [ Submodule.eq_top_iff' ] ; exact Classical.not_not.1 fun hw' => hw <| h_contra _ hw'; - have h_union : v + w ∉ U ∧ v + w ∉ V := - ⟨fun h => hv₁ <| by simpa using U.sub_mem h hw₂, - fun h => hw₁ <| by simpa using V.sub_mem h hv₂⟩ + have h_union : v + w ∉ U ∧ v + w ∉ V := by + exact ⟨ fun h => hv₁ <| by simpa using U.sub_mem h hw₂, fun h => hw₁ <| by simpa using V.sub_mem h hv₂ ⟩; exact h_contra ⟨ v + w, h_union.1, h_union.2 ⟩; exact h_union _ _ ( by tauto ) ( by tauto ); -- Consider $z = u \otimes v$. @@ -1356,9 +1346,8 @@ lemma ker_le_of_ker_kron_le_right (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSt intro U V hU hV by_contra h_contra push Not at h_contra; - have h_union : ∃ u : EuclideanSpace ℂ d₁, u ∉ U ∧ u ∈ V := - Exists.elim (show ∃ u : EuclideanSpace ℂ d₁, u ∉ U from by - simpa [Submodule.eq_top_iff'] using hU) fun u hu => ⟨u, hu, h_contra u hu⟩ + have h_union : ∃ u : EuclideanSpace ℂ d₁, u ∉ U ∧ u ∈ V := by + exact Exists.elim ( show ∃ u : EuclideanSpace ℂ d₁, u ∉ U from by simpa [ Submodule.eq_top_iff' ] using hU ) fun u hu => ⟨ u, hu, h_contra u hu ⟩; obtain ⟨ u, hu₁, hu₂ ⟩ := h_union; have h_union : ∀ v : EuclideanSpace ℂ d₁, v ∈ U → v + u ∈ V := by intro v hv; specialize h_contra ( v + u ) ; simp_all [ Submodule.add_mem_iff_right ] ; @@ -1470,9 +1459,8 @@ theorem sandwichedRelRentropy_additive_alpha_one_aux (ρ₁ σ₁ : MState d₁) ⟪ρ₁.M, ρ₁.M.log - σ₁.M.log⟫_ℝ + ⟪ρ₂.M, ρ₂.M.log - σ₂.M.log⟫ := by have h_log_kron : (ρ₁ ⊗ᴹ ρ₂).M.log = ρ₁.M.log ⊗ₖ ρ₂.M.supportProj + ρ₁.M.supportProj ⊗ₖ ρ₂.M.log ∧ (σ₁ ⊗ᴹ σ₂).M.log = σ₁.M.log ⊗ₖ σ₂.M.supportProj + σ₁.M.supportProj ⊗ₖ σ₂.M.log := by constructor <;> apply HermitianMat.log_kron_with_proj; - have h_inner_supportProj : ∀ (A : HermitianMat d₁ ℂ) (B : HermitianMat d₂ ℂ), - ⟪A ⊗ₖ B, ρ₁ ⊗ᴹ ρ₂⟫ = ⟪A, ρ₁⟫ * ⟪B, ρ₂⟫ := - fun A B => HermitianMat.inner_kron A B ρ₁ ρ₂ + have h_inner_supportProj : ∀ (A : HermitianMat d₁ ℂ) (B : HermitianMat d₂ ℂ), ⟪A ⊗ₖ B, ρ₁ ⊗ᴹ ρ₂⟫ = ⟪A, ρ₁⟫ * ⟪B, ρ₂⟫ := by + exact fun A B => HermitianMat.inner_kron A B ρ₁ ρ₂; simp only [HermitianMat.ker] at h1 h2 simp_all only [inner_sub_right, inner_add_right, real_inner_comm, HermitianMat.inner_supportProj_self, MState.tr, mul_one, one_mul, @@ -1986,10 +1974,8 @@ private lemma ker_le_iff_eigenWeight_zero (ρ x : MState d) : have h_w_zero : ∀ i, x.M.H.eigenvalues i ≠ 0 → w i = 0 := by intro i hi have h_eigenvalue : x.M.val.mulVec v = ∑ i, (x.M.H.eigenvalues i) • w i • x.M.H.eigenvectorBasis i := by - have h_eigenvalue : ∀ i, - x.M.val.mulVec (x.M.H.eigenvectorBasis i) = - x.M.H.eigenvalues i • x.M.H.eigenvectorBasis i := - fun i => x.M.H.mulVec_eigenvectorBasis i |> fun h => by simpa [mul_comm] using h + have h_eigenvalue : ∀ i, x.M.val.mulVec (x.M.H.eigenvectorBasis i) = x.M.H.eigenvalues i • x.M.H.eigenvectorBasis i := by + exact fun i => x.M.H.mulVec_eigenvectorBasis i |> fun h => by simpa [ mul_comm ] using h; rw [ hw] simp only [WithLp.ofLp_sum, WithLp.ofLp_smul] rw [Matrix.mulVec_sum ]; @@ -2233,8 +2219,7 @@ theorem qMutualInfo_as_qRelativeEnt (ρ : MState (dA × dB)) : (show ρ.traceRight.M.ker ≤ ρ.traceRight.M.supportProj.ker by simp)) (by simpa [HermitianMat.ker, HermitianMat.lin] using - (show ρ.traceLeft.M.ker ≤ ρ.traceLeft.M.supportProj.ker by simp))).trans - (by simpa [HermitianMat.support_orthogonal_eq_range] using Submodule.orthogonal_le hP) + (show ρ.traceLeft.M.ker ≤ ρ.traceLeft.M.supportProj.ker by simp))).trans hkerP have right_mul_eq_of_fixed_support {Q ρM : HermitianMat (dA × dB) ℂ} (hfix : ∀ x : EuclideanSpace ℂ (dA × dB), x ∈ ρM.support → Q.lin x = x) : ρM.mat * Q.mat = ρM.mat := by diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 662b13edf..0f154e701 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -401,10 +401,8 @@ private lemma W_mat_sq_eq_conj [Nonempty dA] [Nonempty dB] [Nonempty dC] convert! h_inv_pos.posSemidef using 1; exact zero_le_iff; have h_simp : (ρAB.sqrt : Matrix (dA × dB) (dA × dB) ℂ) ⊗ₖ (σBC.traceLeft⁻¹.sqrt : Matrix dC dC ℂ) * (ρAB.sqrt : Matrix (dA × dB) (dA × dB) ℂ) ⊗ₖ (σBC.traceLeft⁻¹.sqrt : Matrix dC dC ℂ) = (ρAB : Matrix (dA × dB) (dA × dB) ℂ) ⊗ₖ (σBC.traceLeft⁻¹ : Matrix dC dC ℂ) := by - have h_simp : - ∀ (A B C D : Matrix (dA × dB) (dA × dB) ℂ) (E F : Matrix dC dC ℂ), - (A ⊗ₖ E) * (B ⊗ₖ F) = (A * B) ⊗ₖ (E * F) := - fun A B _ _ E F => Eq.symm (Matrix.mul_kronecker_mul A B E F) + have h_simp : ∀ (A B C D : Matrix (dA × dB) (dA × dB) ℂ) (E F : Matrix dC dC ℂ), (A ⊗ₖ E) * (B ⊗ₖ F) = (A * B) ⊗ₖ (E * F) := by + exact fun A B C D E F => Eq.symm (Matrix.mul_kronecker_mul A B E F); aesop; simp_all [ ← Matrix.mul_assoc ] diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 16a134711..0ae7e8d84 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -428,9 +428,8 @@ lemma norm_cfc_le_sqrt_card_mul_bound {A : HermitianMat d ℂ} {f : ℝ → ℝ} ‖A.cfc f‖ ≤ Real.sqrt (Fintype.card d) * C := by rw [ ← Real.sqrt_sq ( norm_nonneg _ ) ]; -- Recall that the Frobenius norm of a Hermitian matrix is the square root of the sum of the squares of its eigenvalues. - have h_frobenius_eigenvalues : - ∀ (M : HermitianMat d ℂ), ‖M‖ ^ 2 = ∑ i ∈ Finset.univ, (M.H.eigenvalues i) ^ 2 := - fun M => norm_eq_sum_eigenvalues_sq M + have h_frobenius_eigenvalues : ∀ (M : HermitianMat d ℂ), ‖M‖ ^ 2 = ∑ i ∈ Finset.univ, (M.H.eigenvalues i) ^ 2 := by + exact fun M => norm_eq_sum_eigenvalues_sq M; -- Applying the bound on the eigenvalues to the Frobenius norm. have h_bound : ∑ i ∈ Finset.univ, ((A.cfc f).H.eigenvalues i) ^ 2 ≤ (Fintype.card d) * C ^ 2 := by have h_bound : ∀ i, ((A.cfc f).H.eigenvalues i) ^ 2 ≤ C ^ 2 := by @@ -521,9 +520,8 @@ lemma continuousOn_cfc_of_compact {K : Set ℝ} {g : ℝ → ℝ} (hK : IsCompac obtain ⟨p_n, hp_n⟩ : ∃ p_n : ℕ → Polynomial ℝ, (∀ n, ∀ x ∈ K, |(p_n n).eval x - g x| ≤ 1 / (n + 1)) := by have h_stone_weierstrass : ∀ ε > 0, ∃ p : Polynomial ℝ, ∀ x ∈ K, |p.eval x - g x| < ε := by have := @exists_polynomial_near_of_continuousOn; - obtain ⟨a, b, hab⟩ : ∃ a b : ℝ, K ⊆ Set.Icc a b := - ⟨hK.bddBelow.some, hK.bddAbove.some, - fun x hx => ⟨hK.bddBelow.choose_spec hx, hK.bddAbove.choose_spec hx⟩⟩ + obtain ⟨a, b, hab⟩ : ∃ a b : ℝ, K ⊆ Set.Icc a b := by + exact ⟨ hK.bddBelow.some, hK.bddAbove.some, fun x hx => ⟨ hK.bddBelow.choose_spec hx, hK.bddAbove.choose_spec hx ⟩ ⟩; -- Extend $g$ to a continuous function on $[a, b]$. obtain ⟨f, hf⟩ : ∃ f : ℝ → ℝ, ContinuousOn f (Set.Icc a b) ∧ ∀ x ∈ K, f x = g x := by have := @ContinuousMap.exists_restrict_eq; @@ -536,10 +534,8 @@ lemma continuousOn_cfc_of_compact {K : Set ℝ} {g : ℝ → ℝ} (hK : IsCompac -- By the properties of the functional calculus, we have `‖A.cfc p_n - A.cfc g‖ ≤ sqrt(d) * ‖p_n - g‖_{∞, K}`. have h_uniform_bound : ∀ n, ∀ A : HermitianMat d ℂ, spectrum ℝ A.mat ⊆ K → ‖A.cfc (fun x => (p_n n).eval x) - A.cfc g‖ ≤ Real.sqrt (Fintype.card d) * (1 / (n + 1)) := by intro n A hA - have h_uniform_bound : - ‖A.cfc (fun x => (p_n n).eval x) - A.cfc g‖ ≤ - Real.sqrt (Fintype.card d) * ⨆ x ∈ spectrum ℝ A.mat, |(p_n n).eval x - g x| := - norm_cfc_sub_cfc_le_sqrt_card + have h_uniform_bound : ‖A.cfc (fun x => (p_n n).eval x) - A.cfc g‖ ≤ Real.sqrt (Fintype.card d) * ⨆ x ∈ spectrum ℝ A.mat, |(p_n n).eval x - g x| := by + exact norm_cfc_sub_cfc_le_sqrt_card; refine' le_trans h_uniform_bound ( mul_le_mul_of_nonneg_left _ ( Real.sqrt_nonneg _ ) ); refine' ciSup_le fun x => _; field_simp; @@ -751,18 +747,16 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} have := @ContinuousMap.exists_restrict_eq ℝ; specialize this ( show IsClosed ( spectrum ℝ A₀.val ) from h_finite.isClosed ) ( ContinuousMap.mk ( fun x => g x ) <| by exact continuousOn_iff_continuous_restrict.mp h_cont ) ; rcases this with ⟨ h, hh ⟩ ; exact ⟨ h, h.continuous, fun x hx => by simpa using congr_arg ( fun f => f ⟨ x, hx ⟩ ) hh ⟩ ;)); obtain ⟨h, hh_cont, hh_eq⟩ := h_ext; - have h_cfc_cont : - ContinuousWithinAt (fun B => B.cfc h) {B : HermitianMat d ℂ | spectrum ℝ B.mat ⊆ T} A₀ := - Continuous.continuousWithinAt (HermitianMat.cfc_continuous hh_cont) + have h_cfc_cont : ContinuousWithinAt (fun B => B.cfc h) {B : HermitianMat d ℂ | spectrum ℝ B.mat ⊆ T} A₀ := by + exact Continuous.continuousWithinAt (HermitianMat.cfc_continuous hh_cont) have h_diff_small : ∀ ε > 0, ∃ U ∈ nhds A₀, ∀ B ∈ U ∩ {B : HermitianMat d ℂ | spectrum ℝ B.mat ⊆ T}, ‖B.cfc g - B.cfc h‖ < ε := by intro ε ε_pos obtain ⟨δ, δ_pos, hδ⟩ : ∃ δ > 0, ∀ x ∈ T, ∀ y ∈ spectrum ℝ A₀.mat, |x - y| < δ → |g x - h x| < ε / (Real.sqrt (Fintype.card d) + 1) := by have h_diff_small : ∀ y ∈ spectrum ℝ A₀.mat, ∃ δ > 0, ∀ x ∈ T, |x - y| < δ → |g x - h x| < ε / (Real.sqrt (Fintype.card d) + 1) := by intro y hy have h_diff_small : Filter.Tendsto (fun x => |g x - h x|) (nhdsWithin y T) (nhds 0) := by - have h_diff_small : - Filter.Tendsto (fun x => g x - h x) (nhdsWithin y T) (nhds (g y - h y)) := - Filter.Tendsto.sub (hg.continuousWithinAt (hA₀ hy)) hh_cont.continuousWithinAt + have h_diff_small : Filter.Tendsto (fun x => g x - h x) (nhdsWithin y T) (nhds (g y - h y)) := by + exact Filter.Tendsto.sub ( hg.continuousWithinAt ( hA₀ hy ) ) ( hh_cont.continuousWithinAt ); simpa [ hh_eq y hy ] using h_diff_small.abs; have := Metric.tendsto_nhdsWithin_nhds.mp h_diff_small ( ε / ( Real.sqrt ( Fintype.card d ) + 1 ) ) ( div_pos ε_pos ( add_pos_of_nonneg_of_pos ( Real.sqrt_nonneg _ ) zero_lt_one ) ) ; aesop; choose! δ hδ_pos hδ using h_diff_small; @@ -890,19 +884,14 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] generalize_proofs at *; ( exact h_eigenvalues.subset ht |> Exists.imp fun i hi => hi.symm) aesop - have hW_subset : ∀ᶠ B in nhds (A x₀), spectrum ℝ B.mat ⊆ W := - spectrum_subset_of_isOpen (A x₀) W hW_open hW_spectrum - have hW_subset_S : ∀ᶠ y in nhdsWithin x₀ S, spectrum ℝ (A y).mat ⊆ W := - Filter.mem_of_superset (hA₂.continuousWithinAt hx₀ |> fun h => h.eventually hW_subset) - fun _ hy => hy + have hW_subset : ∀ᶠ B in nhds (A x₀), spectrum ℝ B.mat ⊆ W := by + exact spectrum_subset_of_isOpen (A x₀) W hW_open hW_spectrum + have hW_subset_S : ∀ᶠ y in nhdsWithin x₀ S, spectrum ℝ (A y).mat ⊆ W := by + exact Filter.mem_of_superset ( hA₂.continuousWithinAt hx₀ |> fun h => h.eventually ( hW_subset ) ) fun y hy => hy obtain ⟨U', hU'⟩ : ∃ U' ∈ nhds x₀, ∀ y ∈ U' ∩ S, spectrum ℝ (A y).mat ⊆ W := by obtain ⟨ U', hU' ⟩ := mem_nhdsWithin_iff_exists_mem_nhds_inter.mp hW_subset_S; use U'; aesop; - obtain ⟨U'', hU''⟩ : ∃ U'' ∈ nhds x₀, ∀ i, U'' ⊆ U_i i := - ⟨⋂ i, U_i i, - Filter.mem_of_superset - (Filter.iInter_mem.mpr fun i => IsOpen.mem_nhds (hU_i i) (h_cont.1 i)) - fun x hx => by aesop, - fun i => Set.iInter_subset _ i⟩ + obtain ⟨U'', hU''⟩ : ∃ U'' ∈ nhds x₀, ∀ i, U'' ⊆ U_i i := by + exact ⟨ ⋂ i, U_i i, Filter.mem_of_superset ( Filter.iInter_mem.mpr fun i => IsOpen.mem_nhds ( hU_i i ) ( h_cont.1 i ) ) fun x hx => by aesop, fun i => Set.iInter_subset _ i ⟩ set U := U' ∩ U'' with hU_def have hU_mem : U ∈ nhds x₀ := Filter.inter_mem hU'.1 hU''.1 @@ -910,11 +899,10 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] fun y hy => hU'.2 y ⟨hy.1.1, hy.2⟩ |> Set.Subset.trans <| by simp [hW_def] have hU_cont : ∀ y ∈ U ∩ S, ∀ t ∈ spectrum ℝ (A y).mat, ‖f y t - f x₀ t‖ < ε := by intro y hy t ht - obtain ⟨i, hi⟩ : ∃ i, t ∈ V_i i := - Set.mem_iUnion.mp (hU_subset y hy ht) |> Exists.imp fun i => by tauto - have h_cont_i : ‖f y t - f x₀ t‖ < ε := - h_cont.2.2 i y ⟨hU''.2 i (by aesop), hy.2⟩ t ⟨hi, hA₁ y hy.2 ht⟩ |> - fun h => by simpa using h + obtain ⟨i, hi⟩ : ∃ i, t ∈ V_i i := by + exact Set.mem_iUnion.mp ( hU_subset y hy ht ) |> Exists.imp fun i => by tauto; + have h_cont_i : ‖f y t - f x₀ t‖ < ε := by + exact h_cont.2.2 i y ⟨ hU''.2 i ( by aesop ), hy.2 ⟩ t ⟨ hi, hA₁ y hy.2 ht ⟩ |> fun h => by simpa using h; exact h_cont_i exact h_contra ⟨U, hU_mem, hU_cont⟩ @@ -988,12 +976,8 @@ theorem continuous_cfc_joint {X d : Type*} [TopologicalSpace X] [Fintype d] [Dec · exact abs_le.mpr ⟨ by linarith [ hU₂ x hx t ht ], by linarith [ hU₂ x hx t ht ] ⟩; · linarith [ ε_pos ])) generalize_proofs at *; ( - have h_final : - Filter.Tendsto (fun x => ‖(A x).cfc (f x) - (A x).cfc (f x₀)‖) - (nhdsWithin x₀ S) (nhds 0) := - squeeze_zero_norm' (by filter_upwards [h_triangle] with x hx; simpa using hx) - (by simpa using h_sup.const_mul _) |> - fun h => h.trans (by simp) + have h_final : Filter.Tendsto (fun x => ‖(A x).cfc (f x) - (A x).cfc (f x₀)‖) (nhdsWithin x₀ S) (nhds 0) := by + exact squeeze_zero_norm' ( by filter_upwards [ h_triangle ] with x hx; simpa using hx ) ( by simpa using h_sup.const_mul _ ) |> fun h => h.trans ( by simp ) ; generalize_proofs at *; ( convert h_cont.add ( show ContinuousWithinAt ( fun x => ( A x |> HermitianMat.cfc ) ( f x ) - ( A x |> HermitianMat.cfc ) ( f x₀ ) ) S x₀ from ?_ ) using 1 ; aesop generalize_proofs at *; ( @@ -1040,16 +1024,10 @@ lemma inv_cfc_eq_cfc_inv (hf : ∀ i, f (A.H.eigenvalues i) ≠ 0) : suffices (A.cfc f).mat⁻¹ = (A.cfc (fun u ↦ 1 / f u)).mat by ext1 simpa using this - have h_def : (A.cfc f).mat = - ∑ i, f (A.H.eigenvalues i) • - (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * - A.H.eigenvectorUnitary.val.conjTranspose) := - cfc_toMat_eq_sum_smul_proj A f - have h_subst : (A.cfc (fun u ↦ 1 / f u)).mat = - ∑ i, (1 / f (A.H.eigenvalues i)) • - (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * - A.H.eigenvectorUnitary.val.conjTranspose) := - cfc_toMat_eq_sum_smul_proj A fun u ↦ 1 / f u + have h_def : (A.cfc f).mat = ∑ i, f (A.H.eigenvalues i) • (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * A.H.eigenvectorUnitary.val.conjTranspose) := by + exact cfc_toMat_eq_sum_smul_proj A f; + have h_subst : (A.cfc (fun u ↦ 1 / f u)).mat = ∑ i, (1 / f (A.H.eigenvalues i)) • (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * A.H.eigenvectorUnitary.val.conjTranspose) := by + exact cfc_toMat_eq_sum_smul_proj A fun u ↦ 1 / f u; have h_inv : (A.cfc f).mat * (A.cfc (fun u ↦ 1 / f u)).mat = 1 := by -- Since the eigenvectorUnitary is unitary, we have that the product of the projections is the identity matrix. have h_unitary : A.H.eigenvectorUnitary.val * A.H.eigenvectorUnitary.val.conjTranspose = 1 := by @@ -1118,10 +1096,8 @@ lemma intervalIntegrable_toMat_iff (A : ℝ → HermitianMat d 𝕜) (T₁ T₂ have h_toMat_linear : Function.Injective L := by intro x y hxy; simp_all only [HermitianMat.ext_iff] - have h_toMat_linear : - ∃ (L_inv : Matrix d d 𝕜 →ₗ[ℝ] HermitianMat d 𝕜), - L_inv.comp L = LinearMap.id := - IsSemisimpleModule.extension_property L h_toMat_linear LinearMap.id + have h_toMat_linear : ∃ (L_inv : Matrix d d 𝕜 →ₗ[ℝ] HermitianMat d 𝕜), L_inv.comp L = LinearMap.id := by + exact IsSemisimpleModule.extension_property L h_toMat_linear LinearMap.id; exact ⟨ h_toMat_linear.choose, fun x ↦ by simpa using LinearMap.congr_fun h_toMat_linear.choose_spec x ⟩; obtain ⟨ L_inv, hL_inv ⟩ := h_toMat_linear; have h_toMat_linear : IntegrableOn (fun t ↦ L_inv (L (A t))) (Set.uIoc T₁ T₂) μ := @@ -1141,11 +1117,8 @@ The CFC of an integrable function family is integrable. lemma integrable_cfc (T₁ T₂ : ℝ) (f : ℝ → ℝ → ℝ) {μ : Measure ℝ} (hf : ∀ i, IntervalIntegrable (fun t ↦ f t (A.H.eigenvalues i)) μ T₁ T₂) : IntervalIntegrable (fun t ↦ A.cfc (f t)) μ T₁ T₂ := by - have h_expand : ∀ t, (A.cfc (f t)).mat = - ∑ i, f t (A.H.eigenvalues i) • - (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * - A.H.eigenvectorUnitary.val.conjTranspose) := - fun t ↦ cfc_toMat_eq_sum_smul_proj A (f t) + have h_expand : ∀ t, (A.cfc (f t)).mat = ∑ i, f t (A.H.eigenvalues i) • (A.H.eigenvectorUnitary.val * (Matrix.single i i 1) * A.H.eigenvectorUnitary.val.conjTranspose) := by + exact fun t ↦ cfc_toMat_eq_sum_smul_proj A (f t); rw [ ← intervalIntegrable_toMat_iff ]; rw [ funext h_expand ]; apply intervalIntegrable_sum_smul_const @@ -1292,9 +1265,8 @@ theorem inv_ge_one_of_le_one (hA : A.mat.PosDef) (h : A ≤ 1) : 1 ≤ A⁻¹ := exact (cfc_nonneg_iff A fun x => x⁻¹ - 1).mpr h_cfc_nonneg; -- Since $A.cfc (fun x => x⁻¹ - 1) \geq 0$, we have $A.cfc (fun x => x⁻¹) \geq 1$. have h_cfc_ge_one : A.cfc (fun x => x⁻¹) ≥ 1 := by - have h_cfc_sub : A.cfc (fun x => x⁻¹ - 1) = - A.cfc (fun x => x⁻¹) - A.cfc (fun _ => 1) := - cfc_sub_apply A Inv.inv fun x => 1 + have h_cfc_sub : A.cfc (fun x => x⁻¹ - 1) = A.cfc (fun x => x⁻¹) - A.cfc (fun _ => 1) := by + exact cfc_sub_apply A Inv.inv fun x => 1; aesop; convert h_cfc_ge_one.le using 1; convert cfc_inv.symm; diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 5c45bd528..97fd60f2b 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -151,12 +151,8 @@ theorem inv_antitone (hA : A.mat.PosDef) (h : A ≤ B) : B⁻¹ ≤ A⁻¹ := by have hB_inv : B.mat⁻¹ = A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹ := by have hB_inv : (A.mat + C.conjTranspose * C)⁻¹ = A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹ := by have hB_inv : (A.mat + C.conjTranspose * C) * (A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹) = 1 := by - have h_inv : - (1 + C * A.mat⁻¹ * C.conjTranspose) * - (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ = 1 := - Matrix.mul_nonsing_inv _ - (show IsUnit _ from by - simpa [Matrix.isUnit_iff_isUnit_det] using h_inv_posDef.det_pos.ne') + have h_inv : (1 + C * A.mat⁻¹ * C.conjTranspose) * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ = 1 := by + exact Matrix.mul_nonsing_inv _ ( show IsUnit _ from by simpa [ Matrix.isUnit_iff_isUnit_det ] using h_inv_posDef.det_pos.ne' ); simp only [mul_assoc, Matrix.mul_sub] at * simp only [← Matrix.mul_assoc, add_mul, one_mul] at * simp only [isUnit_iff_ne_zero, ne_eq, hA.det_pos.ne', not_false_eq_true, @@ -297,10 +293,8 @@ theorem logApprox_mono {x y : HermitianMat d 𝕜} (hx : x.mat.PosDef) (hy : y.m simp [ Matrix.one_apply, Finset.mul_sum, mul_left_comm ]; simp [ mul_left_comm, Algebra.smul_def ]; · exact add_le_add_left hxy _; - have h_integral_limit : - ∀ t ∈ Set.Ioc 0 T, - (1 + t)⁻¹ • 1 - (x + t • 1)⁻¹ ≤ (1 + t)⁻¹ • 1 - (y + t • 1)⁻¹ := - fun t ht => sub_le_sub_left (h_integral_limit t <| Set.Ioc_subset_Icc_self ht) _ + have h_integral_limit : ∀ t ∈ Set.Ioc 0 T, (1 + t)⁻¹ • 1 - (x + t • 1)⁻¹ ≤ (1 + t)⁻¹ • 1 - (y + t • 1)⁻¹ := by + exact fun t ht => sub_le_sub_left ( h_integral_limit t <| Set.Ioc_subset_Icc_self ht ) _; filter_upwards [MeasureTheory.ae_restrict_mem measurableSet_Ioc] with t ht exact h_integral_limit t ht @@ -371,8 +365,8 @@ theorem logApprox_eq_log_add_error convert! logApprox_eq_cfc_scalar x hx T hT using 1; apply cfc_congr_of_posDef hx; exact fun u hu => Eq.symm ( scalarLogApprox_eq u T hu.out hT ); - have h_cfc_add : x.cfc (fun u => Real.log u + Real.log ((1 + T) / (u + T))) = x.cfc Real.log + x.cfc (fun u => Real.log ((1 + T) / (u + T))) := - cfc_add x Real.log (fun u => Real.log ((1 + T) / (u + T))) + have h_cfc_add : x.cfc (fun u => Real.log u + Real.log ((1 + T) / (u + T))) = x.cfc Real.log + x.cfc (fun u => Real.log ((1 + T) / (u + T))) := by + apply cfc_add; exact h_logApprox.trans h_cfc_add open ComplexOrder Filter Topology in @@ -384,12 +378,8 @@ The error term in the log approximation tends to 0 as T goes to infinity. lemma tendsto_cfc_log_div_add_atTop (x : HermitianMat d 𝕜) : Tendsto (fun T => x.cfc (fun u => Real.log ((1 + T) / (u + T)))) atTop (nhds 0) := by -- Expand `(cfc x ...).mat` using `cfc_toMat_eq_sum_smul_proj`. - have h_expand : - ∀ T : ℝ, (x.cfc (fun u => Real.log ((1 + T) / (u + T)))).mat = - ∑ i, Real.log ((1 + T) / (x.H.eigenvalues i + T)) • - (x.H.eigenvectorUnitary.val * (Matrix.single i i 1) * - x.H.eigenvectorUnitary.val.conjTranspose) := - fun T => cfc_toMat_eq_sum_smul_proj x fun u => Real.log ((1 + T) / (u + T)) + have h_expand : ∀ T : ℝ, (x.cfc (fun u => Real.log ((1 + T) / (u + T)))).mat = ∑ i, Real.log ((1 + T) / (x.H.eigenvalues i + T)) • (x.H.eigenvectorUnitary.val * (Matrix.single i i 1) * x.H.eigenvectorUnitary.val.conjTranspose) := by + exact fun T => cfc_toMat_eq_sum_smul_proj x fun u => Real.log ((1 + T) / (u + T)); -- The limit of a sum is the sum of the limits. have h_sum : Filter.Tendsto (fun T : ℝ => ∑ i, Real.log ((1 + T) / (x.H.eigenvalues i + T)) • (x.H.eigenvectorUnitary.val * (Matrix.single i i 1) * x.H.eigenvectorUnitary.val.conjTranspose)) Filter.atTop (nhds (∑ i, 0 • (x.H.eigenvectorUnitary.val * (Matrix.single i i 1) * x.H.eigenvectorUnitary.val.conjTranspose))) := by refine' tendsto_finsetSum _ fun i _ => _; @@ -599,10 +589,8 @@ theorem logApprox_concave {n 𝕜 : Type*} [Fintype n] [DecidableEq n] [RCLike rw [ intervalIntegrable_iff_integrableOn_Ioc_of_le hT ] at * refine MeasureTheory.Integrable.sub ?_ h_integrable exact ContinuousOn.integrableOn_Icc ( by exact continuousOn_of_forall_continuousAt fun t ht => ContinuousAt.smul ( ContinuousAt.inv₀ ( continuousAt_const.add continuousAt_id ) ( by linarith [ ht.1 ] ) ) continuousAt_const ) |> fun h => h.mono_set ( Set.Ioc_subset_Icc_self ); - have h_int2 : IntervalIntegrable - (fun t => (1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - - ((a • x + b • y) + t • 1)⁻¹) MeasureTheory.volume 0 T := - h_integrable (Matrix.PosDef.Convex hx hy ha hb hab) + have h_int2 : IntervalIntegrable (fun t => (1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - ((a • x + b • y) + t • 1)⁻¹) MeasureTheory.volume 0 T := by + exact h_integrable (Matrix.PosDef.Convex hx hy ha hb hab) have h_integral_mono : ∫ t in (0)..T, a • ((1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - (x + t • 1)⁻¹) + b • ((1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - (y + t • 1)⁻¹) ≤ ∫ t in (0)..T, (1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - ((a • x + b • y) + t • 1)⁻¹ := by have h_integral_mono : ∀ t ∈ Set.Icc 0 T, a • ((1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - (x + t • 1)⁻¹) + b • ((1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - (y + t • 1)⁻¹) ≤ (1 + t)⁻¹ • (1 : HermitianMat n 𝕜) - ((a • x + b • y) + t • 1)⁻¹ := by intros t ht @@ -641,10 +629,8 @@ lemma log_kron_diagonal {m n 𝕜 : Type*} [Fintype m] [DecidableEq m] [Fintype {d₁ : m → ℝ} {d₂ : n → ℝ} (h₁ : ∀ i, 0 < d₁ i) (h₂ : ∀ j, 0 < d₂ j) : (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂).log = (diagonal 𝕜 d₁).log ⊗ₖ 1 + 1 ⊗ₖ (diagonal 𝕜 d₂).log := by - have h_eq : - (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂) = - (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)) := - kronecker_diagonal d₁ d₂ + have h_eq : (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂) = (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)) := by + exact kronecker_diagonal d₁ d₂ convert congr_arg _ h_eq using 1; -- By definition of logarithm, we can rewrite the right-hand side. have h_rhs : (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)).log = @@ -662,9 +648,8 @@ lemma log_kron_diagonal {m n 𝕜 : Type*} [Fintype m] [DecidableEq m] [Fintype · rw [← diagonal_one, kronecker_diagonal] simp · exact cfc_diagonal Real.log d₁ - · have h_rhs : (diagonal 𝕜 d₂).log = - (diagonal 𝕜 (fun (i : n) => Real.log (d₂ i))) := - cfc_diagonal Real.log d₂ + · have h_rhs : (diagonal 𝕜 d₂).log = (diagonal 𝕜 (fun (i : n) => Real.log (d₂ i))) := by + exact cfc_diagonal Real.log d₂ rw [ h_rhs ]; convert kronecker_diagonal 1 ( fun i => Real.log ( d₂ i ) ) using 1; all_goals try infer_instance; diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 89f22d04a..a46bcb143 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -64,9 +64,8 @@ theorem diagonal_pow (f : d → ℝ) : rfl @[fun_prop] -theorem rpow_const_continuous {r : ℝ} (hr : 0 ≤ r) : - Continuous (fun A : HermitianMat d ℂ ↦ A ^ r) := - HermitianMat.cfc_continuous (Real.continuous_rpow_const hr) +theorem rpow_const_continuous {r : ℝ} (hr : 0 ≤ r) : Continuous (fun A : HermitianMat d ℂ ↦ A ^ r) := by + exact HermitianMat.cfc_continuous (Real.continuous_rpow_const hr) @[fun_prop] theorem const_rpow_continuous [NonSingular A] : Continuous (fun r : ℝ ↦ A ^ r) := by @@ -216,13 +215,12 @@ lemma rpow_neg_mul_rpow_self (hA : A.mat.PosDef) (p : ℝ) : have h_pos_def : (A ^ p).mat.PosDef := by have h_pos_def : ∀ p : ℝ, A.mat.PosDef → (A ^ p).mat.PosDef := by intro p hA_pos_def - have h_eigenvalues_pos : ∀ i, 0 < (A.H.eigenvalues i) ^ p := - fun i => Real.rpow_pos_of_pos (Matrix.PosDef.eigenvalues_pos hA i) _ - have h_eigenvalues_pos : (A ^ p).mat.PosDef ↔ ∀ i, 0 < (A ^ p).H.eigenvalues i := - Matrix.IsHermitian.posDef_iff_eigenvalues_pos (H (A ^ p)) - have h_eigenvalues_pos : - ∃ e : d ≃ d, (A ^ p).H.eigenvalues = fun i => (A.H.eigenvalues (e i)) ^ p := - Matrix.IsHermitian.cfc_eigenvalues (H A) fun x => x.rpow p + have h_eigenvalues_pos : ∀ i, 0 < (A.H.eigenvalues i) ^ p := by + exact fun i => Real.rpow_pos_of_pos ( by exact Matrix.PosDef.eigenvalues_pos hA i ) _; + have h_eigenvalues_pos : (A ^ p).mat.PosDef ↔ ∀ i, 0 < (A ^ p).H.eigenvalues i := by + exact Matrix.IsHermitian.posDef_iff_eigenvalues_pos (H (A ^ p)); + have h_eigenvalues_pos : ∃ e : d ≃ d, (A ^ p).H.eigenvalues = fun i => (A.H.eigenvalues (e i)) ^ p := by + exact Matrix.IsHermitian.cfc_eigenvalues (H A) fun x => x.rpow p; aesop; exact h_pos_def p hA; convert! Matrix.nonsing_inv_mul _ _; diff --git a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean index 325a48226..d06ad1b27 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean @@ -97,9 +97,8 @@ lemma schattenNorm_rpow_eq_sum_singularValues (A : Matrix d d ℂ) {p : ℝ} (hp ring_nf simp +zetaDelta at *; exact Matrix.eigenvalues_conjTranspose_mul_self_nonneg A i; - · have h_nonneg : ∀ i : d, - 0 ≤ ((Matrix.isHermitian_mul_conjTranspose_self A.conjTranspose).eigenvalues i) ^ (p / 2) := - fun i => Real.rpow_nonneg (by have := Matrix.eigenvalues_conjTranspose_mul_self_nonneg A; aesop) _ + · have h_nonneg : ∀ i : d, 0 ≤ ((Matrix.isHermitian_mul_conjTranspose_self A.conjTranspose).eigenvalues i) ^ (p / 2) := by + exact fun i => Real.rpow_nonneg ( by have := Matrix.eigenvalues_conjTranspose_mul_self_nonneg A; aesop ) _; convert! Finset.sum_nonneg fun i _ => h_nonneg i using 1; convert schattenNorm_trace_as_eigenvalue_sum A p using 1 @@ -180,9 +179,8 @@ lemma schattenNorm_half_mul_rpow_eq_trace_conj {α : ℝ} (hα : 0 < α) : (schattenNorm ((A ^ (1/2 : ℝ)).mat * B.mat) (2 * α)) ^ (2 * α) = ((A.conj B.mat) ^ α).trace := by - have h_conj : ((A ^ (1 / 2 : ℝ)).mat * B.mat).conjTranspose * - ((A ^ (1 / 2 : ℝ)).mat * B.mat) = (A.conj B.mat).mat := - conjTranspose_half_mul_eq_conj hA + have h_conj : ((A ^ (1 / 2 : ℝ)).mat * B.mat).conjTranspose * ((A ^ (1 / 2 : ℝ)).mat * B.mat) = (A.conj B.mat).mat := by + exact conjTranspose_half_mul_eq_conj hA; unfold schattenNorm; rw [ ← Real.rpow_mul ] <;> norm_num [ hα.ne' ]; · ring_nf; norm_num [ hα.ne' ]; @@ -296,9 +294,8 @@ lemma HermitianMat.trace_rpow_conj_le (((A ^ (p / 2)).trace) ^ (1 / p) * ((B ^ q).trace) ^ (1 / q)) ^ (2 * α) := by -- Raise both sides of the inequality to the power of $2\alpha$. have h_exp : ((A.conj B.mat) ^ α).trace ≤ (schattenNorm (A ^ (1 / 2 : ℝ)).mat p * schattenNorm B.mat q) ^ (2 * α) := by - have h_exp : (schattenNorm ((A ^ (1 / 2 : ℝ)).mat * B.mat) (2 * α)) ^ (2 * α) = - ((A.conj B.mat) ^ α).trace := - schattenNorm_half_mul_rpow_eq_trace_conj hA hα + have h_exp : (schattenNorm ((A ^ (1 / 2 : ℝ)).mat * B.mat) (2 * α)) ^ (2 * α) = ((A.conj B.mat) ^ α).trace := by + exact schattenNorm_half_mul_rpow_eq_trace_conj hA hα rw [← h_exp] -- Apply the Schatten-Hölder inequality to the matrices $A^{1/2} * B$. refine Real.rpow_le_rpow ?_ (schattenNorm_mul_le _ _ (by positivity) hp hq hpq) (by positivity) diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index 9824b9bc0..c33499d07 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -317,13 +317,10 @@ lemma singularValues_compoundMatrix_eq (M : Matrix d d ℂ) (k : ℕ) : rotate_right exact compoundMatrix (Matrix.IsHermitian.eigenvectorUnitary (isHermitian_mul_conjTranspose_self M.conjTranspose)) k · exact compoundMatrix_unitary _ (by simp [Matrix.unitaryGroup]) _ - · have h_compoundMatrix_mul : - compoundMatrix (M.conjTranspose * M) k = - compoundMatrix M.conjTranspose k * compoundMatrix M k := - compoundMatrix_mul _ _ _ - have h_compoundMatrix_conjTranspose : - compoundMatrix M.conjTranspose k = (compoundMatrix M k).conjTranspose := - compoundMatrix_conjTranspose M k + · have h_compoundMatrix_mul : compoundMatrix (M.conjTranspose * M) k = compoundMatrix M.conjTranspose k * compoundMatrix M k := by + exact compoundMatrix_mul _ _ _ + have h_compoundMatrix_conjTranspose : compoundMatrix M.conjTranspose k = (compoundMatrix M k).conjTranspose := by + exact compoundMatrix_conjTranspose M k have := Matrix.IsHermitian.spectral_theorem (isHermitian_mul_conjTranspose_self M.conjTranspose) convert congr_arg (fun x => compoundMatrix x k) this using 1 <;> simp [h_compoundMatrix_mul, h_compoundMatrix_conjTranspose] rw [compoundMatrix_mul, compoundMatrix_mul] @@ -434,13 +431,10 @@ lemma singularValues_compoundMatrix_perm (M : Matrix d d ℂ) (k : ℕ) : rotate_right exact compoundMatrix (Matrix.IsHermitian.eigenvectorUnitary (isHermitian_mul_conjTranspose_self M.conjTranspose)) k · exact compoundMatrix_unitary _ (by simp [Matrix.unitaryGroup]) _ - · have h_compoundMatrix_mul : - compoundMatrix (M.conjTranspose * M) k = - compoundMatrix M.conjTranspose k * compoundMatrix M k := - compoundMatrix_mul _ _ _ - have h_compoundMatrix_conjTranspose : - compoundMatrix M.conjTranspose k = (compoundMatrix M k).conjTranspose := - compoundMatrix_conjTranspose M k + · have h_compoundMatrix_mul : compoundMatrix (M.conjTranspose * M) k = compoundMatrix M.conjTranspose k * compoundMatrix M k := by + exact compoundMatrix_mul _ _ _ + have h_compoundMatrix_conjTranspose : compoundMatrix M.conjTranspose k = (compoundMatrix M k).conjTranspose := by + exact compoundMatrix_conjTranspose M k have := Matrix.IsHermitian.spectral_theorem (isHermitian_mul_conjTranspose_self M.conjTranspose) convert congr_arg (fun x => compoundMatrix x k) this using 1 <;> simp [h_compoundMatrix_mul, h_compoundMatrix_conjTranspose] rw [compoundMatrix_mul, compoundMatrix_mul] @@ -476,9 +470,8 @@ lemma exists_sorting_equiv (M : Matrix d d ℂ) : have h_bij : ∃ σ : Fin (Fintype.card d) ≃ d, ∀ i, singularValues M (σ i) = singularValuesSorted M i := by have h_perm : Multiset.ofList (List.ofFn (singularValuesSorted M)) = Multiset.ofList (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := by have h_multiset : Multiset.ofList (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) = Finset.univ.val.map (singularValues M) := by - have h_multiset : - Finset.univ.val = Multiset.map (fun i => (Fintype.equivFin d).symm i) Finset.univ.val := - Eq.symm (Multiset.map_univ_val_equiv (Fintype.equivFin d |> Equiv.symm)) + have h_multiset : Finset.univ.val = Multiset.map (fun i => (Fintype.equivFin d).symm i) (Finset.univ.val) := by + exact Eq.symm (Multiset.map_univ_val_equiv (Fintype.equivFin d |> Equiv.symm)) rw [h_multiset, Multiset.map_map] aesop have h_multiset_sorted : Multiset.ofList (List.ofFn (singularValuesSorted M)) = Multiset.map (singularValues M) Finset.univ.val := by @@ -486,9 +479,8 @@ lemma exists_sorting_equiv (M : Matrix d d ℂ) : refine' List.ext_get _ _ <;> simp [List.ofFn_eq_map] at *; aesop (simp_config := { singlePass := true }) exact h_multiset_sorted_eq ▸ by simp rw [h_multiset, h_multiset_sorted] - have h_perm : List.Perm (List.ofFn (singularValuesSorted M)) - (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := - Multiset.coe_eq_coe.mp h_perm + have h_perm : List.Perm (List.ofFn (singularValuesSorted M)) (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := by + exact Multiset.coe_eq_coe.mp h_perm have h_perm : ∃ σ : Fin (Fintype.card d) ≃ Fin (Fintype.card d), ∀ i, singularValuesSorted M i = singularValues M (Fintype.equivFin d |>.symm (σ i)) := by have h_perm : ∀ {l1 l2 : List ℝ}, l1.Perm l2 → ∃ σ : Fin l1.length ≃ Fin l2.length, ∀ i, l1.get i = l2.get (σ i) := by intros l1 l2 h_perm; induction' h_perm with l1 l2 h_perm ih <;> simp_all @@ -572,9 +564,8 @@ lemma exists_subset_prod_eq_sorted_prod (M : Matrix d d ℂ) (k : ℕ) · exact List.Nodup.filter _ (List.nodup_finRange _) · exact Multiset.Nodup.filter _ (Finset.nodup _) exact h_perm.trans (by simp) - have h_perm : List.Perm (List.ofFn (singularValuesSorted M)) - (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := - Multiset.coe_eq_coe.mp h_perm + have h_perm : List.Perm (List.ofFn (singularValuesSorted M)) (List.ofFn (singularValues M ∘ (Fintype.equivFin d).symm)) := by + exact Multiset.coe_eq_coe.mp h_perm have h_perm : ∃ σ : Fin (Fintype.card d) ≃ Fin (Fintype.card d), List.ofFn (singularValuesSorted M) = List.map (fun i => singularValues M ((Fintype.equivFin d).symm (σ i))) (List.finRange (Fintype.card d)) := by have := h_perm have h_perm : ∀ {l₁ l₂ : List ℝ}, List.Perm l₁ l₂ → ∃ σ : Fin l₁.length ≃ Fin l₂.length, l₁ = List.map (fun i => l₂.get (σ i)) (List.finRange l₁.length) := by @@ -606,10 +597,8 @@ lemma exists_subset_prod_eq_sorted_prod (M : Matrix d d ℂ) (k : ℕ) obtain ⟨a, ha⟩ := σ.surjective ⟨i, by simp⟩ exact ⟨⟨a, by simpa using a.2⟩, Fin.ext <| by simpa [Fin.ext_iff] using congr_arg Fin.val ha⟩⟩, fun i => by simpa [Fin.ext_iff] using congr_arg (fun l => l[i]!) hσ⟩) obtain ⟨σ, hσ⟩ := h_perm - use Equiv.ofBijective (fun i => (Fintype.equivFin d).symm (σ i)) - ⟨fun i j hij => by - simpa [Fin.ext_iff] using σ.injective (by simpa [Fin.ext_iff] using hij), - fun i => ⟨σ.symm (Fintype.equivFin d i), by simp⟩⟩ + use Equiv.ofBijective (fun i => (Fintype.equivFin d).symm (σ i)) ⟨fun i j hij => by simpa [Fin.ext_iff] using σ.injective (by simpa [Fin.ext_iff] using hij), fun i => by + exact ⟨σ.symm (Fintype.equivFin d i), by simp⟩;⟩ intro i replace hσ := congr_arg (fun l => l[i]!) hσ simp_all @@ -767,12 +756,8 @@ lemma singularValuesSorted_mul_le {e : Type*} [Fintype e] [DecidableEq e] have h_sqrt_eigenvalue_le : ∀ i, singularValues (M * N) i ≤ singularValuesSorted M ⟨0, h⟩ * singularValuesSorted N ⟨0, h⟩ := by intro i have h_sqrt_eigenvalue_le_i : (isHermitian_mul_conjTranspose_self (M * N).conjTranspose).eigenvalues i ≤ (singularValuesSorted M ⟨0, h⟩ * singularValuesSorted N ⟨0, h⟩) ^ 2 := h_eigenvalue_le i - have h_sqrt_eigenvalue_le_i' : - Real.sqrt ((isHermitian_mul_conjTranspose_self (M * N).conjTranspose).eigenvalues i) ≤ - singularValuesSorted M ⟨0, h⟩ * singularValuesSorted N ⟨0, h⟩ := - Real.sqrt_le_iff.mpr - ⟨mul_nonneg (singularValuesSorted_nonneg M ⟨0, h⟩) - (singularValuesSorted_nonneg N ⟨0, h⟩), h_sqrt_eigenvalue_le_i⟩ + have h_sqrt_eigenvalue_le_i' : Real.sqrt ((isHermitian_mul_conjTranspose_self (M * N).conjTranspose).eigenvalues i) ≤ singularValuesSorted M ⟨0, h⟩ * singularValuesSorted N ⟨0, h⟩ := by + exact Real.sqrt_le_iff.mpr ⟨mul_nonneg (singularValuesSorted_nonneg M ⟨0, h⟩) (singularValuesSorted_nonneg N ⟨0, h⟩), h_sqrt_eigenvalue_le_i⟩ exact h_sqrt_eigenvalue_le_i' |> le_trans (by exact le_rfl) simp_all [Finset.sup'_le_iff] @@ -939,19 +924,15 @@ lemma weak_log_maj_sum_le {n : ℕ} simp exact h_log_maj k (by linarith) · -- Since $x_{\text{last}} > 0$, we have $x_i > 0$ for all $i$. - have hx_pos : ∀ i, 0 < x i := - fun i => lt_of_lt_of_le (lt_of_le_of_ne (hx_nn _) (Ne.symm h_last)) - (hx_anti (Fin.le_last _)) + have hx_pos : ∀ i, 0 < x i := by + exact fun i => lt_of_lt_of_le (lt_of_le_of_ne (hx_nn _) (Ne.symm h_last)) (hx_anti (Fin.le_last _)) have hy_pos : ∀ i, 0 < y i := by intro i; specialize h_log_maj (n + 1) le_rfl; contrapose! h_log_maj; simp_all [Fin.prod_univ_castSucc] exact lt_of_le_of_lt (mul_nonpos_of_nonneg_of_nonpos (Finset.prod_nonneg fun _ _ => hy_nn _) (by linarith [hy_anti (show i ≤ Fin.last n from Fin.le_last i)])) (mul_pos (Finset.prod_pos fun _ _ => hx_pos _) (hx_pos _)) have h_sum_mul_log_nonneg : 0 ≤ ∑ i, x i * Real.log (y i / x i) := by apply sum_mul_log_nonneg_of_weak_log_maj (fun i => hx_pos i) (fun i => hy_pos i) hx_anti (fun k hk => h_log_maj k hk) - have h_sum_mul_log_nonneg : ∑ i, (y i - x i) ≥ ∑ i, x i * Real.log (y i / x i) := - Finset.sum_le_sum fun i _ => by - have := sub_ge_mul_log_div (hx_pos i) (hy_pos i) - ring_nf at * - linarith + have h_sum_mul_log_nonneg : ∑ i, (y i - x i) ≥ ∑ i, x i * Real.log (y i / x i) := by + exact Finset.sum_le_sum fun i _ => by have := sub_ge_mul_log_div (hx_pos i) (hy_pos i); ring_nf at *; linarith norm_num at *; linarith /-- Weak log-majorization of nonneg antitone sequences implies the sum of diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index eb7e4afa0..20a0f6958 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -125,8 +125,8 @@ variable (hA : A.IsHermitian) (hB : B.IsHermitian) include hA hB in omit [DecidableEq n] in -theorem kroneckerMap_IsHermitian : (A ⊗ₖ B).IsHermitian := - (kroneckerMap_conjTranspose A B).trans (congrArg₂ (· ⊗ₖ ·) hA hB) +theorem kroneckerMap_IsHermitian : (A ⊗ₖ B).IsHermitian := by + exact (hA ▸ hB ▸ kroneckerMap_conjTranspose A B : _ = _) end Kronecker diff --git a/QuantumInfo/ForMathlib/Misc.lean b/QuantumInfo/ForMathlib/Misc.lean index 1ca8e10bf..6efee8a7a 100644 --- a/QuantumInfo/ForMathlib/Misc.lean +++ b/QuantumInfo/ForMathlib/Misc.lean @@ -102,10 +102,8 @@ theorem csInf_mul_nonneg {s t : Set ℝ} intro ε hε obtain ⟨x, hx₁, hx₂, y, hy₁, hy₂⟩ := h_eps ε hε exact ⟨x, hx₁, y, hy₁, by nlinarith [hs₁ x hx₁, ht₁ y hy₁]⟩ - have h_lim : Filter.Tendsto (fun ε => (a + ε) * (b + ε)) - (nhdsWithin 0 (Set.Ioi 0)) (nhds (a * b)) := - tendsto_nhdsWithin_of_tendsto_nhds - (Continuous.tendsto' (by continuity) _ _ (by norm_num)) + have h_lim : Filter.Tendsto (fun ε => (a + ε) * (b + ε)) (nhdsWithin 0 (Set.Ioi 0)) (nhds (a * b)) := by + exact tendsto_nhdsWithin_of_tendsto_nhds (Continuous.tendsto' (by continuity) _ _ (by norm_num)) apply le_of_tendsto_of_tendsto tendsto_const_nhds h_lim filter_upwards [self_mem_nhdsWithin] with ε hε specialize h_prod_eps ε hε @@ -158,9 +156,8 @@ lemma Multiset.map_univ_eq_iff {α β : Type*} [Fintype α] (f g : α → β) : subst h simp_all only [Function.comp_apply, Finset.univ] -- Since $w$ is a bijection, the multiset of $w(x)$ for $x$ in the original multiset is just a permutation of the original multiset. - have h_perm : - Multiset.map (fun x => w x) (Finset.val Fintype.elems) = Finset.val Fintype.elems := - Multiset.map_univ_val_equiv w + have h_perm : Multiset.map (fun x => w x) (Finset.val Fintype.elems) = Finset.val Fintype.elems := by + exact Multiset.map_univ_val_equiv w; conv_rhs => rw [ ← h_perm ]; simp +zetaDelta at * diff --git a/QuantumInfo/ForMathlib/ULift.lean b/QuantumInfo/ForMathlib/ULift.lean index 75672d4dc..355989d42 100644 --- a/QuantumInfo/ForMathlib/ULift.lean +++ b/QuantumInfo/ForMathlib/ULift.lean @@ -32,13 +32,13 @@ theorem ULift.star_eq {𝕜 : Type u} [Star 𝕜] (x : ULift.{v,u} 𝕜) : star instance ULift.instInvolutiveStar {𝕜 : Type u} [InvolutiveStar 𝕜] : InvolutiveStar (ULift.{v,u} 𝕜) where - star_involutive x := congrArg ULift.up (star_star x.down) + star_involutive x := by simp instance ULift.instStarMul {𝕜 : Type u} [Mul 𝕜] [StarMul 𝕜] : StarMul (ULift.{v,u} 𝕜) where - star_mul x y := congrArg ULift.up (star_mul x.down y.down) + star_mul x y := by simp; rfl instance {𝕜 : Type u} [NonUnitalNonAssocSemiring 𝕜] [StarRing 𝕜] : StarRing (ULift.{v,u} 𝕜) where - star_add x y := congrArg ULift.up (star_add x.down y.down) + star_add x y := by simp; rfl @[simp] theorem ULift.starRingEnd_down {𝕜 : Type u} (x : ULift.{v,u} 𝕜) [CommSemiring 𝕜] [StarRing 𝕜] : @@ -69,7 +69,7 @@ noncomputable instance {𝕜 : Type u} [RCLike 𝕜] : RCLike (ULift.{v,u} 𝕜) ext1 exact h re_add_im_ax z := by exact congrArg ULift.up (RCLike.re_add_im_ax z.down) - ofReal_re_ax r := RCLike.ofReal_re_ax r + ofReal_re_ax r := by simp ofReal_im_ax := by simp mul_re_ax z w := by simp mul_im_ax := by simp diff --git a/QuantumInfo/ForMathlib/Unitary.lean b/QuantumInfo/ForMathlib/Unitary.lean index d8bc70797..5b09a3d5b 100644 --- a/QuantumInfo/ForMathlib/Unitary.lean +++ b/QuantumInfo/ForMathlib/Unitary.lean @@ -45,10 +45,10 @@ noncomputable def conj_unitary_eigenspace_equiv (T : E →ₗ[𝕜] E) (U : unit have hv := v.2 rw [mem_eigenspace_iff] at hv ⊢ simpa using congrArg ((star U.val) ·) hv⟩ - map_add' v w := Subtype.ext (map_add U.val v.val w.val) - map_smul' c v := Subtype.ext (map_smul U.val c v.val) - left_inv v := Subtype.ext (unitary_star_apply_eq U v.val) - right_inv v := Subtype.ext (unitary_apply_star_eq U v.val) + map_add' := by simp + map_smul' := by simp + left_inv _ := by simp + right_inv _ := by simp end unitary namespace IsSymmetric diff --git a/QuantumInfo/ResourceTheory/SteinsLemma.lean b/QuantumInfo/ResourceTheory/SteinsLemma.lean index 2b2abf933..b39c2aa54 100644 --- a/QuantumInfo/ResourceTheory/SteinsLemma.lean +++ b/QuantumInfo/ResourceTheory/SteinsLemma.lean @@ -854,7 +854,7 @@ private theorem hσ₁_le_σ' : (1 / 3 : ℝ) • ((σ₁ i) ⊗ᵣ^[n]).M ≤ ( positivity private theorem σ''_unnormalized_PosDef : Matrix.PosDef (σ''_unnormalized ρ ε m σ n).mat := by - change Matrix.PosDef (((σ' ρ ε m σ n).M.cfc fun e ↦ Real.exp (f_map i n e)).mat) + dsimp [σ''_unnormalized] rw [HermitianMat.cfc_posDef] intro positivity @@ -1855,10 +1855,8 @@ theorem Lemma7 (ρ : MState (H i)) {ε : Prob} (hε : 0 < ε ∧ ε < 1) (σ : ( dsimp [σ₁_mineig, iInf] rw [← Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues] rw [← Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues] - change sInf (spectrum ℝ (σ₁ i).m) ^ n / 3 ≤ - sInf (spectrum ℝ ((1 / 3 : ℝ) • ((σ₁ i) ⊗ᵣ^[n]).m)) - rw [spectrum.smul_eq_smul _ _ - (ContinuousFunctionalCalculus.spectrum_nonempty _ ((σ₁ i) ⊗ᵣ^[n]).Hermitian)] + rw [HermitianMat.val_eq_coe, HermitianMat.mat_smul] + rw [spectrum.smul_eq_smul _ _ (ContinuousFunctionalCalculus.spectrum_nonempty _ ((σ₁ i) ⊗ᵣ^[n]).M.H)] rw [Real.sInf_smul_of_nonneg (by norm_num)] simp [div_eq_inv_mul, sInf_spectrum_spacePow] diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 794b47084..e5ec38046 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -773,12 +773,10 @@ theorem pure_separable_imp_IsProd {d₁ d₂ : Type*} [Fintype d₁] [Fintype d obtain ⟨ ρLRs, ps, hps ⟩ := h; -- Since `pure ψ` is pure (`purity = 1`), by `MState.eq_of_sum_eq_pure`, for any `k` with `p_k > 0`, we have `pure ψ = ρL_k ⊗ᴹ ρR_k`. obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) ∧ (MState.pure ψ).M = (k.val.1).M ⊗ₖ (k.val.2).M := by - have h_pure : (MState.pure ψ).purity = 1 := - ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; - obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) := - not_forall_not.mp fun h => by - have := ps.2 - simp_all + have h_pure : (MState.pure ψ).purity = 1 := by + exact ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; + obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) := by + exact ⟨ Classical.choose ( show ∃ k : ρLRs, 0 < ( ps k : ℝ ) from by exact not_forall_not.mp fun h => by have := ps.2; simp_all ), Classical.choose_spec ( show ∃ k : ρLRs, 0 < ( ps k : ℝ ) from by exact not_forall_not.mp fun h => by have := ps.2; simp_all) ⟩; refine' ⟨ k, hk, _ ⟩; convert MState.eq_of_sum_eq_pure h_pure _ _ _ k _ _; rotate_left; diff --git a/QuantumInfo/States/Pure/BlochSphere.lean b/QuantumInfo/States/Pure/BlochSphere.lean index 7b8d68c3f..f07ef1331 100644 --- a/QuantumInfo/States/Pure/BlochSphere.lean +++ b/QuantumInfo/States/Pure/BlochSphere.lean @@ -5,7 +5,6 @@ Authors: Anand Nambakam -/ module -public import QuantumInfo.States.Pure.BargmannInvariant public import Mathlib.LinearAlgebra.CrossProduct public import Mathlib.Analysis.InnerProductSpace.PiL2 From 7c29851374ca5d9f44cf920d79f4f445fdbaa8c0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:25:41 -0700 Subject: [PATCH 261/498] refactor: golf unbundled positivity proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Unbundled.lean | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/QuantumInfo/Channels/Unbundled.lean b/QuantumInfo/Channels/Unbundled.lean index 46ac9f1ed..7eb8b0df3 100644 --- a/QuantumInfo/Channels/Unbundled.lean +++ b/QuantumInfo/Channels/Unbundled.lean @@ -356,8 +356,8 @@ theorem comp [DecidableEq B] {M₁ : MatrixMap A B R} {M₂ : MatrixMap B C R} ( /-- The identity MatrixMap IsCompletelyPositive. -/ @[simp] theorem id : (id A R).IsCompletelyPositive := by - intro n _ h - simpa [show LinearMap.id = MatrixMap.id (Fin n) R from rfl, kron_id_id] using h + intro n ρ h + rwa [show LinearMap.id = MatrixMap.id (Fin n) R from rfl, kron_id_id] /-- Sums of IsCompletelyPositive maps are IsCompletelyPositive. -/ theorem add {M₁ M₂ : MatrixMap A B R} (h₁ : M₁.IsCompletelyPositive) (h₂ : M₂.IsCompletelyPositive) : @@ -368,9 +368,8 @@ theorem add {M₁ M₂ : MatrixMap A B R} (h₁ : M₁.IsCompletelyPositive) (h /-- Nonnegative scalings of `IsCompletelyPositive` maps are `IsCompletelyPositive`. -/ theorem smul {M : MatrixMap A B R} (hM : M.IsCompletelyPositive) {x : R} (hx : 0 ≤ x) : (x • M).IsCompletelyPositive := - fun n ρ h ↦ by - rw [MatrixMap.smul_kron] - exact (hM n h).smul hx + fun n _ h ↦ by + simpa only [smul_kron, LinearMap.smul_apply] using (hM n h).smul hx variable (A B) in /-- The zero map `IsCompletelyPositive`. -/ @@ -479,9 +478,7 @@ omit [DecidableEq A] in theorem of_kraus_isPositive (K : κ → Matrix B A ℂ) : (of_kraus K K).IsPositive := by rw [of_kraus] - apply IsPositive_sum - intro k - exact conj_isPositive (K k) + exact IsPositive_sum _ fun k => conj_isPositive (K k) theorem conj_kron (M : Matrix B A 𝕜) (N : Matrix D C 𝕜) [DecidableEq C] : conj M ⊗ₖₘ conj N = conj (M ⊗ₖ N) := by @@ -549,14 +546,11 @@ theorem of_kraus_eq_sum_conj (K : κ → Matrix B A 𝕜) : theorem of_kraus_CP (K : κ → Matrix B A 𝕜) : (of_kraus K K).IsCompletelyPositive := by -- By definition of `MatrixMap.of_kraus`, we know that it is a sum of congruence maps. - have h_sum_congruence : MatrixMap.of_kraus K K = ∑ k, conj (K k) := by - -- By definition of `MatrixMap.of_kraus`, we know that it is equal to the sum of the congruence maps of each Kraus operator. - apply of_kraus_eq_sum_conj - have h_congruence_CP : ∀ k, (conj (K k)).IsCompletelyPositive := by - intro k; exact (by - convert congruence_CP ( K k ) using 1; - -- Since B is a finite type, we can use the fact that finite types have decidable equality. - apply Classical.decEq); + have h_sum_congruence : MatrixMap.of_kraus K K = ∑ k, conj (K k) := + of_kraus_eq_sum_conj K + have h_congruence_CP : ∀ k, (conj (K k)).IsCompletelyPositive := fun k => by + convert congruence_CP (K k) using 1 + exact Classical.decEq _ exact h_sum_congruence.symm ▸ IsCompletelyPositive.finset_sum h_congruence_CP theorem exists_kraus_of_choi_PSD @@ -595,8 +589,7 @@ theorem choi_PSD_iff_CP_map (M : MatrixMap A B R) : exact this ( Matrix.PosSemidef.outer_self_conj _ ) · intro h_psd obtain ⟨K, hK⟩ := exists_kraus_of_choi_PSD M.choi_matrix h_psd - rw [choi_matrix_inj hK] - exact of_kraus_CP K + exact (choi_matrix_inj hK) ▸ of_kraus_CP K omit [Fintype B] [DecidableEq A] in theorem conj_eq_mulRightLinearMap_comp_mulRightLinearMap (y : Matrix B A R) : From 4f1e21df54e8454ab8d957199cfecc404c32fccb Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:30:24 -0700 Subject: [PATCH 262/498] refactor: golf dual channel proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Dual.lean | 37 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index 0b3ed100c..72fef778f 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -137,11 +137,9 @@ theorem IsPositive.dual {M : MatrixMap dIn dOut ℂ} (h : M.IsPositive) : M.dual intro v have h_dual_pos : 0 ≤ (M (Matrix.vecMulVec v (star v)) * x).trace := by --TODO Cleanup. Should be all in terms of HermitianMat - apply Matrix.PosSemidef.trace_mul_nonneg; - · apply h; - exact Matrix.posSemidef_vecMulVec_self_star v; - · rw [← Matrix.posSemidef_iff_dotProduct_mulVec] at hx - exact hx; + exact Matrix.PosSemidef.trace_mul_nonneg + (h (Matrix.posSemidef_vecMulVec_self_star v)) + (by rwa [← Matrix.posSemidef_iff_dotProduct_mulVec] at hx) convert h_dual_pos using 1; rw [ MatrixMap.Dual.trace_eq ]; simp [ Matrix.vecMulVec, Matrix.mul_apply, Matrix.trace ]; @@ -170,13 +168,9 @@ lemma dual_unique (h : ∀ A B, (M A * B).trace = (A * M' B).trace) : M.dual = M' := by -- By definition of dual, we know that for any A and B, the trace of (M A) * B equals the trace of -- A * (M.dual B). - have h_dual : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, (M A * B).trace = (A * M.dual B).trace := by - exact fun A B => Dual.trace_eq M A B; - -- Since these two linear maps agree on all bases, they must be equal. - have h_eq : ∀ A : Matrix dIn dIn 𝕜, ∀ B : Matrix dOut dOut 𝕜, (A * M.dual B).trace = (A * M' B).trace := by - exact fun A B => h_dual A B ▸ h A B; - refine' LinearMap.ext fun B => _; - exact Matrix.ext_iff_trace_mul_left.mpr fun x => h_eq x B + refine LinearMap.ext fun B => ?_ + exact Matrix.ext_iff_trace_mul_left.mpr fun A => + (Dual.trace_eq M A B).symm.trans (h A B) /-- The Choi matrix of the dual map is the transpose of the reindexed Choi matrix of the original map. @@ -206,10 +200,8 @@ positive semidefinite. -/ lemma dual_choi_matrix_posSemidef_of_posSemidef (M : MatrixMap dIn dOut 𝕜) (h : M.choi_matrix.PosSemidef) : M.dual.choi_matrix.PosSemidef := by - rw [ dual_choi_matrix ]; - simp +zetaDelta at *; - apply_rules [ Matrix.PosSemidef.submatrix ]; - convert h.transpose using 1 + rw [dual_choi_matrix] + simpa +zetaDelta using Matrix.PosSemidef.submatrix h.transpose (Equiv.prodComm dIn dOut) /-- The dual of the identity map is the identity map. @@ -267,13 +259,11 @@ lemma dual_kron {A B C D : Type*} [Fintype A] [Fintype B] [Fintype C] [Fintype D -- see Lemma 3.1 of https://www.math.uwaterloo.ca/~krdavids/Preprints/CDPRpositivereal.pdf theorem IsCompletelyPositive.dual {M : MatrixMap dIn dOut ℂ} (h : M.IsCompletelyPositive) : M.dual.IsCompletelyPositive := by intro n - have h_dual_pos : (MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ)).IsPositive := - IsPositive.dual (h n) -- By definition of complete positivity, we know that $(M ⊗ₖₘ id) dually map = M.dual ⊗ₖₘ id.dual$. - have h_dual_kron : (MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ)) = (MatrixMap.dual M) ⊗ₖₘ (MatrixMap.dual (MatrixMap.id (Fin n) ℂ)) := by - convert dual_kron M ( MatrixMap.id ( Fin n ) ℂ ) using 1; - convert h_dual_pos using 1; - rw [ h_dual_kron, dual_id ] + convert IsPositive.dual (h n) using 1 + rw [show MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ) = + MatrixMap.dual M ⊗ₖₘ MatrixMap.dual (MatrixMap.id (Fin n) ℂ) by + convert dual_kron M (MatrixMap.id (Fin n) ℂ) using 1, dual_id] /-- The composition of the dual of the inverse of the dual basis isomorphism with the dual basis @@ -464,8 +454,7 @@ theorem MatrixMap.IsPositive.hermDual (h : MatrixMap.IsPositive f.map) : f.hermD theorem HPMap.hermDual_Unital [DecidableEq dIn] [DecidableEq dOut] (h : MatrixMap.IsTracePreserving f.map) : f.hermDual.map.Unital := by suffices f.hermDual 1 = 1 by --todo: make this is an accessible 'constructor' for Unital - rw [HermitianMat.ext_iff] at this - exact this + rwa [HermitianMat.ext_iff] at this open RealInnerProductSpace in apply ext_inner_left ℝ intro v From cf35fe9d2d59b6acbaf257ef727a56235ee70899 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:42:57 -0700 Subject: [PATCH 263/498] refactor: golf channel algebra proofs Restore the local Relative entropy kernel witness that a previous golf left referenced, and avoid the recursive Pinching unfold while keeping the channel proof reductions. Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/CPTP.lean | 5 ++--- QuantumInfo/Channels/MatrixMap.lean | 5 ++--- QuantumInfo/Channels/Pinching.lean | 13 ++++++------- QuantumInfo/Entropy/Relative.lean | 2 ++ 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index e4b8f04ad..7062ab5f2 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -559,9 +559,8 @@ private lemma exists_unitary_extending_isometry refine ⟨⟨Matrix.of (fun i j ↦ b j i), ?_⟩, ?_⟩ · simp only [Matrix.mem_unitaryGroup_iff] ext1 i j - have := b.sum_inner_mul_inner (EuclideanSpace.single i 1) (EuclideanSpace.single j 1) - simp_all [inner] - exact this + simpa [Matrix.mul_apply, Matrix.one_apply, Matrix.star_apply, inner] using + b.sum_inner_mul_inner (EuclideanSpace.single i 1) (EuclideanSpace.single j 1) · simp [hb, u] omit [DecidableEq dOut] [Inhabited dOut] in diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index 303959fab..9a81efaf9 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -330,9 +330,8 @@ theorem kron_map_of_kron_state [CommRing R] (M₁ : MatrixMap A B R) (M₂ : Mat congr --TODO: Cleanup, these two branches are nearly identical (separate lemma?) · have h_linear : M₁ MA = ∑ i : A, ∑ i_1 : A, MA i i_1 • M₁ (Matrix.single i i_1 1) := by - have h_linear : M₁ MA = M₁ (∑ i : A, ∑ i_1 : A, Matrix.single i i_1 (MA i i_1)) := by - congr; - exact Matrix.matrix_eq_sum_single MA + have h_linear : M₁ MA = M₁ (∑ i : A, ∑ i_1 : A, Matrix.single i i_1 (MA i i_1)) := + congrArg M₁ (Matrix.matrix_eq_sum_single MA) simp [ h_linear, Matrix.single] congr! 2 with i _ j _ convert M₁.map_smul (MA i j) (Matrix.of fun i' j' ↦ if i = i' ∧ j = j' then 1 else 0) using 2 diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 1db1a6452..a0fddf7a3 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -123,7 +123,7 @@ theorem pinching_commutes_kraus (σ ρ : MState d) (i : spectrum ℝ σ.m) : theorem pinching_commutes (ρ σ : MState d) : Commute (pinching_map σ ρ).m σ.m := by - dsimp [MState.m, Commute, SemiconjBy] + change (pinching_map σ ρ).M.mat * σ.M.mat = σ.M.mat * (pinching_map σ ρ).M.mat rw [pinchingMap_apply_M] simp only [MatrixMap.of_kraus, Function.comp_apply] simp only [HermitianMat.conjTranspose_mat, MState.mat_M, LinearMap.coe_sum, @@ -296,8 +296,8 @@ theorem inner_cfc_pinching_right (ρ σ : MState d) (f : ℝ → ℝ) : convert pinching_sum σ using 1; simp [HermitianMat.ext_iff ]; -- Since each pinching_kraus is a projection, multiplying it by itself gives the same projection. Therefore, the sum of the squares is the same as the sum of the pinching_kraus themselves. - have h_proj : ∀ k : spectrum ℝ σ.m, (pinching_kraus σ k).mat * (pinching_kraus σ k).mat = (pinching_kraus σ k).mat := by - exact fun k => by simpa [ sq, -pinching_sq_eq_self ] using congr_arg ( fun x : HermitianMat d ℂ => x.mat ) ( pinching_sq_eq_self σ k ) ; + have h_proj : ∀ k : spectrum ℝ σ.m, (pinching_kraus σ k).mat * (pinching_kraus σ k).mat = (pinching_kraus σ k).mat := + fun k => by simpa [ sq, -pinching_sq_eq_self ] using congr_arg ( fun x : HermitianMat d ℂ => x.mat ) ( pinching_sq_eq_self σ k ) ; rw [ Finset.sum_congr rfl fun _ _ => h_proj _ ]; convert congr_arg ( fun x : Matrix d d ℂ => x.trace.re ) ( congr_arg ( fun x : Matrix d d ℂ => x * ( ρ.m * cfc f σ.m ) ) h_sum_kraus ) using 1; · simp [Matrix.sum_mul] @@ -324,10 +324,9 @@ theorem pinching_map_ker_le (ρ σ : MState d) : (pinching_map σ ρ).M.ker ≤ simp only [WithLp.toLp_sum, WithLp.toLp_ofLp] at hv_sum rw [← hv_sum] exact Submodule.sum_mem _ fun k _ ↦ by - have h1 := hv k; - simp only [HermitianMat.ker_conj ρ.nonneg, HermitianMat.conjTranspose_mat, - Submodule.mem_comap] at h1 ⊢ - exact h1 + change Matrix.toEuclideanLin (pinching_kraus σ k).mat v ∈ ρ.M.ker + simpa only [HermitianMat.ker_conj ρ.nonneg, HermitianMat.conjTranspose_mat, + Submodule.mem_comap] using hv k noncomputable section AristotleLemmas diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 11e8f5c1c..40cb13793 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -2207,6 +2207,8 @@ theorem qMutualInfo_as_qRelativeEnt (ρ : MState (dA × dB)) : let P : HermitianMat (dA × dB) ℂ := ρ.traceRight.M.supportProj ⊗ₖ ρ.traceLeft.M.supportProj have hP : ρ.M.support ≤ P.support := fun x hx => ⟨x, by simpa [P] using fixed_support_kron_prod hx⟩ + have hkerP : P.ker ≤ ρ.M.ker := by + simpa [HermitianMat.support_orthogonal_eq_range] using Submodule.orthogonal_le hP exact (show (ρ.traceRight ⊗ᴹ ρ.traceLeft).M.ker ≤ P.ker by change LinearMap.ker ((Matrix.kroneckerMap (· * ·) ρ.traceRight.M.mat ρ.traceLeft.M.mat).toEuclideanLin) From 96dc8195e88150f035e2e1f77ed8895a69d5a90f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:50:04 -0700 Subject: [PATCH 264/498] refactor: golf matrix and state witnesses Compress a mirrored matrix-basis reconstruction and direct small Lorentz, entropy, and purity witnesses. Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Basic.lean | 3 +-- QuantumInfo/Channels/MatrixMap.lean | 6 ++---- QuantumInfo/Entropy/Relative.lean | 6 ++---- QuantumInfo/States/Mixed/MState.lean | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index f030a0e54..6402fc26e 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -59,8 +59,7 @@ variable {Λ Λ' : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ} -/ -lemma mem_iff_self_mul_dual : Λ ∈ LorentzGroup d ↔ Λ * dual Λ = 1 := by - rfl +lemma mem_iff_self_mul_dual : Λ ∈ LorentzGroup d ↔ Λ * dual Λ = 1 := Iff.rfl lemma mem_iff_dual_mul_self : Λ ∈ LorentzGroup d ↔ dual Λ * Λ = 1 := by rw [mem_iff_self_mul_dual] diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index 9a81efaf9..566e3ed15 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -339,10 +339,8 @@ theorem kron_map_of_kron_state [CommRing R] (M₁ : MatrixMap A B R) (M₂ : Mat simp simp [h_linear, mul_comm, Matrix.sum_apply] · have h_expand : M₂ MC = ∑ i : C, ∑ j : C, MC i j • M₂ (Matrix.single i j 1) := by - have h_expand : MC = ∑ i : C, ∑ j : C, MC i j • Matrix.single i j 1 := by - ext i j - simp [Matrix.sum_apply, Matrix.single] - rw [ Finset.sum_eq_single i ] <;> aesop + have h_expand : MC = ∑ i : C, ∑ j : C, Matrix.single i j (MC i j) := + Matrix.matrix_eq_sum_single MC conv_lhs => rw [ h_expand ]; simp [map_sum] congr! 2 with i _ j _ diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 40cb13793..9b40edacc 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -511,8 +511,7 @@ private lemma trace_conj_eq_inner_rpow {ρ σ : MState d} {t : ℝ} (ht : t ≠ fun h => ht (by linarith) exact HermitianMat.mat_rpow_add h_nonneg h_ne_zero rw [ mul_two, h_exp ] - have h_inner : ⟪ρ.M, σ.M ^ (2 * t)⟫ = ((ρ.M.mat * (σ.M ^ (2 * t)).mat).trace).re := by - exact rfl + have h_inner : ⟪ρ.M, σ.M ^ (2 * t)⟫ = ((ρ.M.mat * (σ.M ^ (2 * t)).mat).trace).re := rfl simp_all convert congr_arg Complex.re h_cyclic using 1 ; simp [ HermitianMat.conj ] ; ring!; rw [ Matrix.trace_mul_comm ] @@ -524,8 +523,7 @@ private def eigenWeight (ρ σ : MState d) (i : d) : ℝ := private lemma inner_cfc_eq_sum_eigenWeight (ρ σ : MState d) (f : ℝ → ℝ) : ⟪ρ.M, σ.M.cfc f⟫ = ∑ i, f (σ.M.H.eigenvalues i) * eigenWeight ρ σ i := by -- By definition of the inner product in the context of Hermitian matrices, we can expand it using the trace. - have h_inner : ⟪ρ.M, σ.M.cfc f⟫ = RCLike.re (Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat)) := by - exact rfl; + have h_inner : ⟪ρ.M, σ.M.cfc f⟫ = RCLike.re (Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat)) := rfl; have h_trace : Matrix.trace (ρ.M.mat * (σ.M.cfc f).mat) = ∑ i, f (σ.M.H.eigenvalues i) * (star (σ.M.H.eigenvectorBasis i) ⬝ᵥ ρ.M.mat.mulVec (σ.M.H.eigenvectorBasis i)) := by rw [ Matrix.trace ]; have h_cfc_def : (σ.M.cfc f).mat = ∑ i, (f (Matrix.IsHermitian.eigenvalues σ.M.H i)) • Matrix.of (fun x y => (σ.M.H.eigenvectorBasis i x) * (star (σ.M.H.eigenvectorBasis i y))) := by diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index e5ec38046..834267097 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -773,8 +773,7 @@ theorem pure_separable_imp_IsProd {d₁ d₂ : Type*} [Fintype d₁] [Fintype d obtain ⟨ ρLRs, ps, hps ⟩ := h; -- Since `pure ψ` is pure (`purity = 1`), by `MState.eq_of_sum_eq_pure`, for any `k` with `p_k > 0`, we have `pure ψ = ρL_k ⊗ᴹ ρR_k`. obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) ∧ (MState.pure ψ).M = (k.val.1).M ⊗ₖ (k.val.2).M := by - have h_pure : (MState.pure ψ).purity = 1 := by - exact ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; + have h_pure : (MState.pure ψ).purity = 1 := ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; obtain ⟨k, hk⟩ : ∃ k : { x : MState d₁ × MState d₂ // x ∈ ρLRs }, 0 < (ps k : ℝ) := by exact ⟨ Classical.choose ( show ∃ k : ρLRs, 0 < ( ps k : ℝ ) from by exact not_forall_not.mp fun h => by have := ps.2; simp_all ), Classical.choose_spec ( show ∃ k : ρLRs, 0 < ( ps k : ℝ ) from by exact not_forall_not.mp fun h => by have := ps.2; simp_all) ⟩; refine' ⟨ k, hk, _ ⟩; From 2b4774e03bc0ae9585bf5a021146549a859849ac Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:52:37 -0700 Subject: [PATCH 265/498] refactor: golf direct witness terms Replace small local exact wrappers with direct proof terms in list, entropy, and Hermitian matrix witnesses. Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List/InsertIdx.lean | 4 ++-- QuantumInfo/Entropy/DPI.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 6 ++---- QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 3 +-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/List/InsertIdx.lean b/Physlib/Mathematics/List/InsertIdx.lean index 6df5c8e6a..5ec53f7a2 100644 --- a/Physlib/Mathematics/List/InsertIdx.lean +++ b/Physlib/Mathematics/List/InsertIdx.lean @@ -186,8 +186,8 @@ lemma take_insert_let {I : Type} (i : I) : simp at hm | n + 1, m + 1, h, a::as, hm => by simp only [List.insertIdx_succ_cons, List.take_succ_cons] - have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := by - exact List.Perm.swap a i (List.take n as) + have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := + List.Perm.swap a i (List.take n as) refine List.Perm.trans ?_ hp.symm refine List.Perm.cons a ?_ exact take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm) diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 907f105c3..ce90ff486 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -267,8 +267,7 @@ Proof: f_α(H_hat, ρ, σ) = α · Tr[(σ^γ ρ σ^γ)^α] - (α-1) · Tr[(σ^γ -/ theorem f_alpha_at_optimizer (hα : 1 < α) (ρ σ : MState d) : f_alpha α (H_hat α ρ σ) ρ σ = Q̃_ α(ρ‖σ) := by - have h_inner : ⟪ρ.M, H_hat α ρ σ⟫_ℝ = ((ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ α).trace := by - exact inner_rho_H_hat hα ρ σ + have h_inner : ⟪ρ.M, H_hat α ρ σ⟫_ℝ = ((ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ α).trace := inner_rho_H_hat hα ρ σ have h_conj : (H_hat α ρ σ).conj (σ.M ^ ((α - 1) / (2 * α))).mat = (ρ.M.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ^ (α - 1) := by convert H_hat_conj_sigma (hα := hα) (ρ := ρ) (σ := σ) using 1 diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 0ae7e8d84..543584872 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -884,8 +884,7 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] generalize_proofs at *; ( exact h_eigenvalues.subset ht |> Exists.imp fun i hi => hi.symm) aesop - have hW_subset : ∀ᶠ B in nhds (A x₀), spectrum ℝ B.mat ⊆ W := by - exact spectrum_subset_of_isOpen (A x₀) W hW_open hW_spectrum + have hW_subset : ∀ᶠ B in nhds (A x₀), spectrum ℝ B.mat ⊆ W := spectrum_subset_of_isOpen (A x₀) W hW_open hW_spectrum have hW_subset_S : ∀ᶠ y in nhdsWithin x₀ S, spectrum ℝ (A y).mat ⊆ W := by exact Filter.mem_of_superset ( hA₂.continuousWithinAt hx₀ |> fun h => h.eventually ( hW_subset ) ) fun y hy => hy obtain ⟨U', hU'⟩ : ∃ U' ∈ nhds x₀, ∀ y ∈ U' ∩ S, spectrum ℝ (A y).mat ⊆ W := by @@ -1265,8 +1264,7 @@ theorem inv_ge_one_of_le_one (hA : A.mat.PosDef) (h : A ≤ 1) : 1 ≤ A⁻¹ := exact (cfc_nonneg_iff A fun x => x⁻¹ - 1).mpr h_cfc_nonneg; -- Since $A.cfc (fun x => x⁻¹ - 1) \geq 0$, we have $A.cfc (fun x => x⁻¹) \geq 1$. have h_cfc_ge_one : A.cfc (fun x => x⁻¹) ≥ 1 := by - have h_cfc_sub : A.cfc (fun x => x⁻¹ - 1) = A.cfc (fun x => x⁻¹) - A.cfc (fun _ => 1) := by - exact cfc_sub_apply A Inv.inv fun x => 1; + have h_cfc_sub : A.cfc (fun x => x⁻¹ - 1) = A.cfc (fun x => x⁻¹) - A.cfc (fun _ => 1) := cfc_sub_apply A Inv.inv fun x => 1; aesop; convert h_cfc_ge_one.le using 1; convert cfc_inv.symm; diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 97fd60f2b..954564360 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -629,8 +629,7 @@ lemma log_kron_diagonal {m n 𝕜 : Type*} [Fintype m] [DecidableEq m] [Fintype {d₁ : m → ℝ} {d₂ : n → ℝ} (h₁ : ∀ i, 0 < d₁ i) (h₂ : ∀ j, 0 < d₂ j) : (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂).log = (diagonal 𝕜 d₁).log ⊗ₖ 1 + 1 ⊗ₖ (diagonal 𝕜 d₂).log := by - have h_eq : (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂) = (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)) := by - exact kronecker_diagonal d₁ d₂ + have h_eq : (diagonal 𝕜 d₁ ⊗ₖ diagonal 𝕜 d₂) = (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)) := kronecker_diagonal d₁ d₂ convert congr_arg _ h_eq using 1; -- By definition of logarithm, we can rewrite the right-hand side. have h_rhs : (diagonal 𝕜 (fun (i : m × n) => d₁ i.1 * d₂ i.2)).log = From 548a125c88802941628031fce9497791da216f7f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:54:28 -0700 Subject: [PATCH 266/498] refactor: golf bundled extensionality proofs Replace five bundled channel extensionality by-exact wrappers with direct proof terms. Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Bundled.lean | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Channels/Bundled.lean b/QuantumInfo/Channels/Bundled.lean index 1d40380c5..f9349a249 100644 --- a/QuantumInfo/Channels/Bundled.lean +++ b/QuantumInfo/Channels/Bundled.lean @@ -176,8 +176,8 @@ variable [Fintype dIn] [Fintype dOut] namespace PMap @[ext] -theorem ext {Λ₁ Λ₂ : PMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - exact (mk.injEq _ _ _ _).mpr (HPMap.ext h) +theorem ext {Λ₁ Λ₂ : PMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := + (mk.injEq _ _ _ _).mpr (HPMap.ext h) theorem injective_toHPMap : (PMap.toHPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := fun _ _ ↦ (mk.injEq _ _ _ _).mpr @@ -229,8 +229,8 @@ end CPMap namespace PTPMap @[ext] -theorem ext {Λ₁ Λ₂ : PTPMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - exact (mk.injEq _ _ _ _).mpr (PMap.ext h) +theorem ext {Λ₁ Λ₂ : PTPMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := + (mk.injEq _ _ _ _).mpr (PMap.ext h) theorem injective_toPMap : (PTPMap.toPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := fun _ _ ↦ (mk.injEq _ _ _ _).mpr @@ -314,8 +314,8 @@ variable [DecidableEq dIn] /-- Two `CPTPMap`s are equal if their `MatrixMap`s are equal. -/ @[ext] -theorem ext {Λ₁ Λ₂ : CPTPMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - exact (mk.injEq _ _ _ _).mpr (PTPMap.ext h) +theorem ext {Λ₁ Λ₂ : CPTPMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := + (mk.injEq _ _ _ _).mpr (PTPMap.ext h) theorem injective_toPTPMap : (CPTPMap.toPTPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := fun _ _ ↦ (mk.injEq _ _ _ _).mpr @@ -371,8 +371,8 @@ namespace PUMap variable [DecidableEq dIn] [DecidableEq dOut] @[ext] -theorem ext {Λ₁ Λ₂ : PUMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - exact (mk.injEq _ _ _ _).mpr (PMap.ext h) +theorem ext {Λ₁ Λ₂ : PUMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := + (mk.injEq _ _ _ _).mpr (PMap.ext h) theorem injective_toPMap : (PUMap.toPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := fun _ _ ↦ (mk.injEq _ _ _ _).mpr @@ -412,8 +412,8 @@ namespace CPUMap variable [DecidableEq dIn] [DecidableEq dOut] @[ext] -theorem ext {Λ₁ Λ₂ : CPUMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := by - exact (mk.injEq _ _ _ _).mpr ((CPMap.mk.injEq _ _ _ _).mpr (PMap.ext h)) +theorem ext {Λ₁ Λ₂ : CPUMap dIn dOut 𝕜} (h : Λ₁.map = Λ₂.map) : Λ₁ = Λ₂ := + (mk.injEq _ _ _ _).mpr ((CPMap.mk.injEq _ _ _ _).mpr (PMap.ext h)) theorem injective_toPMap : (CPMap.toPMap ∘ CPUMap.toCPMap (dIn := dIn) (dOut := dOut) (𝕜 := 𝕜)).Injective := fun _ _ h => (mk.injEq _ _ _ _).mpr ((CPMap.mk.injEq _ _ _ _).mpr h) From 99c5ca83c6e248db1410f00ce60947c8dbaf7787 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:57:07 -0700 Subject: [PATCH 267/498] refactor: golf tensor invariance proofs Replace complex tensor metric and unit invariance tactic wrappers with direct invariant proof terms. Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Metrics/Basic.lean | 24 +++++-------------- .../Tensors/ComplexTensor/Units/Basic.lean | 24 +++++-------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean index 3ff818d0e..06f6f9776 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean @@ -397,34 +397,22 @@ lemma dualRightMetric_eq_ofRat : εR' = ofRat fun f => open TensorSpecies -set_option backward.isDefEq.respectTransparency false in /-- The tensor `coMetric` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_coMetric (g : SL(2,ℂ)) : g • η' = η' := by - rw [metricTensor_invariant] +lemma actionT_coMetric (g : SL(2,ℂ)) : g • η' = η' := metricTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `contrMetric` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_contrMetric (g : SL(2,ℂ)) : g • η = η := by - rw [metricTensor_invariant] +lemma actionT_contrMetric (g : SL(2,ℂ)) : g • η = η := metricTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `leftMetric` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_leftMetric (g : SL(2,ℂ)) : g • εL = εL := by - rw [metricTensor_invariant] +lemma actionT_leftMetric (g : SL(2,ℂ)) : g • εL = εL := metricTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `rightMetric` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_rightMetric (g : SL(2,ℂ)) : g • εR = εR := by - rw [metricTensor_invariant] +lemma actionT_rightMetric (g : SL(2,ℂ)) : g • εR = εR := metricTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `dualLeftMetric` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_dualLeftMetric (g : SL(2,ℂ)) : g • εL' = εL' := by - rw [metricTensor_invariant] +lemma actionT_dualLeftMetric (g : SL(2,ℂ)) : g • εL' = εL' := metricTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `dualRightMetric` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_dualRightMetric (g : SL(2,ℂ)) : g • εR' = εR' := by - rw [metricTensor_invariant] +lemma actionT_dualRightMetric (g : SL(2,ℂ)) : g • εR' = εR' := metricTensor_invariant g end complexLorentzTensor diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index 42b82c094..d9243eb74 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -332,34 +332,22 @@ lemma rightDualRightUnit_eq_ofRat : δR = ofRat fun f => -/ -set_option backward.isDefEq.respectTransparency false in /-- The tensor `coContrUnit` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_coContrUnit (g : SL(2,ℂ)) : g • δ' = δ' := by - rw [unitTensor_invariant] +lemma actionT_coContrUnit (g : SL(2,ℂ)) : g • δ' = δ' := unitTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `contrCoUnit` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_contrCoUnit (g : SL(2,ℂ)) : g • δ = δ := by - rw [unitTensor_invariant] +lemma actionT_contrCoUnit (g : SL(2,ℂ)) : g • δ = δ := unitTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `dualLeftLeftUnit` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_dualLeftLeftUnit (g : SL(2,ℂ)) : g • δL' = δL' := by - rw [unitTensor_invariant] +lemma actionT_dualLeftLeftUnit (g : SL(2,ℂ)) : g • δL' = δL' := unitTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `leftDualLeftUnit` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_leftDualLeftUnit (g : SL(2,ℂ)) : g • δL = δL := by - rw [unitTensor_invariant] +lemma actionT_leftDualLeftUnit (g : SL(2,ℂ)) : g • δL = δL := unitTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `dualRightRightUnit` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_dualRightRightUnit (g : SL(2,ℂ)) : g • δR' = δR' := by - rw [unitTensor_invariant] +lemma actionT_dualRightRightUnit (g : SL(2,ℂ)) : g • δR' = δR' := unitTensor_invariant g -set_option backward.isDefEq.respectTransparency false in /-- The tensor `rightDualRightUnit` is invariant under the action of `SL(2,ℂ)`. -/ -lemma actionT_rightDualRightUnit (g : SL(2,ℂ)) : g • δR = δR := by - rw [unitTensor_invariant] +lemma actionT_rightDualRightUnit (g : SL(2,ℂ)) : g • δR = δR := unitTensor_invariant g end complexLorentzTensor From 298e109a22433fc130228f6b3e364e1ab91817cf Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Tue, 30 Jun 2026 23:58:28 -0700 Subject: [PATCH 268/498] refactor: golf complex unit tensor identities Replace six complex tensor unit fromConstPair wrappers with direct rfl proofs. Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Units/Basic.lean | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index d9243eb74..9167e2313 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -84,29 +84,17 @@ scoped[complexLorentzTensor] notation "δR" => rightDualRightUnit -/ -lemma coContrUnit_eq_fromConstPair : δ' = fromConstPair Lorentz.coContrUnit := by - rw [Lorentz.coContrUnit] - rfl +lemma coContrUnit_eq_fromConstPair : δ' = fromConstPair Lorentz.coContrUnit := rfl -lemma contrCoUnit_eq_fromConstPair : δ = fromConstPair Lorentz.contrCoUnit := by - rw [Lorentz.contrCoUnit] - rfl +lemma contrCoUnit_eq_fromConstPair : δ = fromConstPair Lorentz.contrCoUnit := rfl -lemma dualLeftLeftUnit_eq_fromConstPair : δL' = fromConstPair Fermion.dualLeftLeftUnit := by - rw [Fermion.dualLeftLeftUnit] - rfl +lemma dualLeftLeftUnit_eq_fromConstPair : δL' = fromConstPair Fermion.dualLeftLeftUnit := rfl -lemma leftDualLeftUnit_eq_fromConstPair : δL = fromConstPair Fermion.leftDualLeftUnit := by - rw [Fermion.leftDualLeftUnit] - rfl +lemma leftDualLeftUnit_eq_fromConstPair : δL = fromConstPair Fermion.leftDualLeftUnit := rfl -lemma dualRightRightUnit_eq_fromConstPair : δR' = fromConstPair Fermion.dualRightRightUnit := by - rw [Fermion.dualRightRightUnit] - rfl +lemma dualRightRightUnit_eq_fromConstPair : δR' = fromConstPair Fermion.dualRightRightUnit := rfl -lemma rightDualRightUnit_eq_fromConstPair : δR = fromConstPair Fermion.rightDualRightUnit := by - rw [Fermion.rightDualRightUnit] - rfl +lemma rightDualRightUnit_eq_fromConstPair : δR = fromConstPair Fermion.rightDualRightUnit := rfl /-! From 6eb53f349447fa9432824c7bcd56aa62f994c299 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:02:18 -0700 Subject: [PATCH 269/498] refactor: golf tensor metric wrappers Compress metric fromConstPair identities, real tensor metric invariance, and Wick contraction permutation reflexivity. Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean | 3 +-- .../Relativity/Tensors/ComplexTensor/Metrics/Basic.lean | 8 ++------ Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean | 7 +++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean index f7a9b9323..57865cb27 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean @@ -49,8 +49,7 @@ variable {φs : List 𝓕.FieldOp} {φsΛ φsΛ₁ φsΛ₂ φsΛ₃ : WickContr /-- The reflexivity of the `Perm` relation. -/ @[refl] -lemma refl : Perm φsΛ φsΛ := by - rw [Perm] +lemma refl : Perm φsΛ φsΛ := rfl /-- The symmetry of the `Perm` relation. -/ @[symm] diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean index 06f6f9776..bdee85a44 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean @@ -85,14 +85,10 @@ open Tensor -/ lemma coMetric_eq_fromConstPair : η' = fromConstPair (S := complexLorentzTensor) - (c1 := .down) (c2 := .down) Lorentz.coMetric := by - rw [Lorentz.coMetric] - rfl + (c1 := .down) (c2 := .down) Lorentz.coMetric := rfl lemma contrMetric_eq_fromConstPair : η = fromConstPair (S := complexLorentzTensor) - (c1 := .up) (c2 := .up) Lorentz.contrMetric := by - rw [Lorentz.contrMetric] - rfl + (c1 := .up) (c2 := .up) Lorentz.contrMetric := rfl lemma leftMetric_eq_fromConstPair : εL = fromConstPair Fermion.leftMetric := rfl diff --git a/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean index c3f4e031a..f3453e400 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean @@ -85,13 +85,12 @@ lemma contrMetric_eq_fromPairT {d : ℕ} : /-- The tensor `coMetric` is invariant under the action of `LorentzGroup d`. -/ @[simp] lemma actionT_coMetric {d : ℕ} (g : LorentzGroup d) : - g • η' d = η' d:= by - erw [TensorSpecies.metricTensor_invariant] + g • η' d = η' d := TensorSpecies.metricTensor_invariant g /-- The tensor `contrMetric` is invariant under the action of `LorentzGroup d`. -/ @[simp] -lemma actionT_contrMetric {d} (g : LorentzGroup d) : g • η d = η d := by - erw [TensorSpecies.metricTensor_invariant] +lemma actionT_contrMetric {d} (g : LorentzGroup d) : g • η d = η d := + TensorSpecies.metricTensor_invariant g /- From 27d71d3643dc87e8d0248a837478b4922a7466e4 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:05:54 -0700 Subject: [PATCH 270/498] refactor: golf relation and tensor invariant proofs Use direct equality and invariant proof terms for Wick contraction permutations, exchange signs, and tensor invariance wrappers. Co-authored-by: Claude Opus 4.8 --- .../FieldStatistics/ExchangeSign.lean | 4 ++-- .../QFT/PerturbationTheory/WickContraction/Perm.lean | 10 ++++------ Physlib/Relativity/Tensors/MetricTensor.lean | 4 ++-- Physlib/Relativity/Tensors/UnitTensor.lean | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean index 64be719ac..ed1efb6ad 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean @@ -77,8 +77,8 @@ lemma exchangeSign_bosonic (a : FieldStatistic) : 𝓢(a, bosonic) = 1 := by fin_cases a <;> rfl @[simp] -lemma bosonic_exchangeSign (a : FieldStatistic) : 𝓢(bosonic, a) = 1 := by - rw [exchangeSign_symm, exchangeSign_bosonic] +lemma bosonic_exchangeSign (a : FieldStatistic) : 𝓢(bosonic, a) = 1 := + (exchangeSign_symm bosonic a).trans (exchangeSign_bosonic a) @[simp] lemma fermionic_exchangeSign_fermionic : 𝓢(fermionic, fermionic) = - 1 := rfl diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean index 57865cb27..5da4ea233 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Perm.lean @@ -53,16 +53,14 @@ lemma refl : Perm φsΛ φsΛ := rfl /-- The symmetry of the `Perm` relation. -/ @[symm] -lemma symm (h : Perm φsΛ₁ φsΛ₂) : Perm φsΛ₂ φsΛ₁ := by - rw [Perm] at h ⊢ - exact h.symm +lemma symm (h : Perm φsΛ₁ φsΛ₂) : Perm φsΛ₂ φsΛ₁ := + show φsΛ₂.wickTerm = φsΛ₁.wickTerm from Eq.symm h /-- The transitivity of the `Perm` relation. -/ @[trans] lemma trans (h12 : Perm φsΛ₁ φsΛ₂) (h23 : Perm φsΛ₂ φsΛ₃) : - Perm φsΛ₁ φsΛ₃ := by - rw [Perm] at h12 h23 ⊢ - exact h12.trans h23 + Perm φsΛ₁ φsΛ₃ := + show φsΛ₁.wickTerm = φsΛ₃.wickTerm from Eq.trans h12 h23 /-- If `Perm φsΛ₁ φsΛ₂` and both contractions are grading-compliant, then if `φsΛ₁` is a full Wick contraction, so is `φsΛ₂`. -/ diff --git a/Physlib/Relativity/Tensors/MetricTensor.lean b/Physlib/Relativity/Tensors/MetricTensor.lean index d4c685995..3c485bc62 100644 --- a/Physlib/Relativity/Tensors/MetricTensor.lean +++ b/Physlib/Relativity/Tensors/MetricTensor.lean @@ -36,8 +36,8 @@ lemma metricTensor_congr {c c1 : C} (h : c = c1) : @[simp] lemma metricTensor_invariant {c : C} (g : G) : - g • S.metricTensor c = metricTensor c := by - rw [metricTensor, actionT_fromConstPair] + g • S.metricTensor c = metricTensor c := + actionT_fromConstPair (S.metric c) g lemma permT_fromPairTContr_metric_metric {c : C} : permT ![1, 0] (And.intro (by decide) (fun i => by fin_cases i <;> rfl)) diff --git a/Physlib/Relativity/Tensors/UnitTensor.lean b/Physlib/Relativity/Tensors/UnitTensor.lean index fa197d681..931df8928 100644 --- a/Physlib/Relativity/Tensors/UnitTensor.lean +++ b/Physlib/Relativity/Tensors/UnitTensor.lean @@ -105,7 +105,7 @@ lemma contrT_unitTensor_dual_single {c : C} (x : Tensor S ![S.τ c]) : @[simp] lemma unitTensor_invariant {c : C} (g : G) : - g • S.unitTensor c = S.unitTensor c := by - rw [unitTensor, actionT_fromConstPair] + g • S.unitTensor c = S.unitTensor c := + actionT_fromConstPair (S.unit c) g end TensorSpecies From 477cff5da2596ff37854b1cde0df8ae86b21e018 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:16:41 -0700 Subject: [PATCH 271/498] refactor: golf quantum information proof wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/CPTP.lean | 14 ++++++-------- QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 5 ++--- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index 7062ab5f2..8a5b1e5c6 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -56,8 +56,8 @@ variable (Λ : CPTPMap dIn dOut) def choi := Λ.map.choi_matrix /-- Two CPTPMaps are equal if their Choi matrices are equal. -/ -theorem choi_ext {Λ₁ Λ₂ : CPTPMap dIn dOut} (h : Λ₁.choi = Λ₂.choi) : Λ₁ = Λ₂ := by - exact CPTPMap.ext (MatrixMap.choi_equiv.injective h) +theorem choi_ext {Λ₁ Λ₂ : CPTPMap dIn dOut} (h : Λ₁.choi = Λ₂.choi) : Λ₁ = Λ₂ := + CPTPMap.ext (MatrixMap.choi_equiv.injective h) /-- The Choi matrix of a channel is PSD. -/ theorem choi_PSD_of_CPTP : Λ.map.choi_matrix.PosSemidef := @@ -80,8 +80,8 @@ def CPTP_of_choi_PSD_Tr {M : Matrix (dOut × dIn) (dOut × dIn) ℂ} (h₁ : M.P @[simp] theorem choi_of_CPTP_of_choi (M : Matrix (dOut × dIn) (dOut × dIn) ℂ) {h₁} {h₂} : - (CPTP_of_choi_PSD_Tr (M := M) h₁ h₂).choi = M := by - exact MatrixMap.map_choi_inv M + (CPTP_of_choi_PSD_Tr (M := M) h₁ h₂).choi = M := + MatrixMap.map_choi_inv M theorem mat_coe_eq_apply_mat [DecidableEq dOut] (ρ : MState dIn) : (Λ ρ).m = Λ.map ρ.m := rfl @@ -350,10 +350,8 @@ infixl:70 "⊗ᶜᵖ" => CPTPMap.prod @[simp] theorem prod_apply_prod (Λ₁ : CPTPMap dI₁ dO₁) (Λ₂ : CPTPMap dI₂ dO₂) (ρ₁ : MState dI₁) (ρ₂ : MState dI₂) : - (Λ₁ ⊗ᶜᵖ Λ₂) (ρ₁ ⊗ᴹ ρ₂) = (Λ₁ ρ₁) ⊗ᴹ (Λ₂ ρ₂) := by - apply MState.ext_m - exact - MatrixMap.kron_map_of_kron_state Λ₁.map Λ₂.map ρ₁.m ρ₂.m + (Λ₁ ⊗ᶜᵖ Λ₂) (ρ₁ ⊗ᴹ ρ₂) = (Λ₁ ρ₁) ⊗ᴹ (Λ₂ ρ₂) := + MState.ext_m (MatrixMap.kron_map_of_kron_state Λ₁.map Λ₂.map ρ₁.m ρ₂.m) end prod diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 954564360..a6cc21db9 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -365,9 +365,8 @@ theorem logApprox_eq_log_add_error convert! logApprox_eq_cfc_scalar x hx T hT using 1; apply cfc_congr_of_posDef hx; exact fun u hu => Eq.symm ( scalarLogApprox_eq u T hu.out hT ); - have h_cfc_add : x.cfc (fun u => Real.log u + Real.log ((1 + T) / (u + T))) = x.cfc Real.log + x.cfc (fun u => Real.log ((1 + T) / (u + T))) := by - apply cfc_add; - exact h_logApprox.trans h_cfc_add + exact h_logApprox.trans (cfc_add (A := x) (f := Real.log) + (g := fun u => Real.log ((1 + T) / (u + T)))) open ComplexOrder Filter Topology in open scoped Matrix.Norms.Frobenius in diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index a46bcb143..3f77ab651 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -64,8 +64,8 @@ theorem diagonal_pow (f : d → ℝ) : rfl @[fun_prop] -theorem rpow_const_continuous {r : ℝ} (hr : 0 ≤ r) : Continuous (fun A : HermitianMat d ℂ ↦ A ^ r) := by - exact HermitianMat.cfc_continuous (Real.continuous_rpow_const hr) +theorem rpow_const_continuous {r : ℝ} (hr : 0 ≤ r) : Continuous (fun A : HermitianMat d ℂ ↦ A ^ r) := + HermitianMat.cfc_continuous (Real.continuous_rpow_const hr) @[fun_prop] theorem const_rpow_continuous [NonSingular A] : Continuous (fun r : ℝ ↦ A ^ r) := by From 39c17ebbe286ae0302c50ecfe7978f1fb9fe9d35 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:21:07 -0700 Subject: [PATCH 272/498] refactor: golf rewrite-exact proof steps Co-authored-by: Claude Opus 4.8 --- Physlib/Thermodynamics/Temperature/Basic.lean | 3 +-- QuantumInfo/Entropy/DPI.lean | 7 +++---- QuantumInfo/ForMathlib/Matrix.lean | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Physlib/Thermodynamics/Temperature/Basic.lean b/Physlib/Thermodynamics/Temperature/Basic.lean index 7b51af74a..7e3b30466 100644 --- a/Physlib/Thermodynamics/Temperature/Basic.lean +++ b/Physlib/Thermodynamics/Temperature/Basic.lean @@ -226,8 +226,7 @@ lemma chain_rule_T_beta {F : ℝ → ℝ} {F' : ℝ} rw [beta_fun_T_eq_on_Ioi (show (T.val : ℝ) ∈ Set.Ioi 0 from hT_pos), β_toReal] rfl have hF_deriv' : HasDerivWithinAt F F' (Set.Ioi 0) (betaFromReal (T.val : ℝ)) := by - rw [h_beta_at_T] - exact hF_deriv + simpa [h_beta_at_T] using hF_deriv exact hF_deriv'.comp (T.val : ℝ) (deriv_beta_wrt_T (T := T) hT_pos) h_map end Temperature diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index ce90ff486..b331865a4 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -571,8 +571,8 @@ theorem sandwichedTraceFunctional_jointly_convex (hα : 1 < α) {ι : Type*} [Fi (hker : ∀ i, (σs i).M.ker ≤ (ρs i).M.ker) : Q̃_ α(ρ_mix‖σ_mix) ≤ ∑ i, w i * Q̃_ α(ρs i‖σs i) := by have hker' : σ_mix.M.ker ≤ ρ_mix.M.ker := by - rw [hρ_mix, hσ_mix] - exact ker_weighted_sum_le w hw_nonneg _ _ (fun i => (ρs i).nonneg) (fun i => (σs i).nonneg) hker + simpa [hρ_mix, hσ_mix] using + ker_weighted_sum_le w hw_nonneg _ _ (fun i => (ρs i).nonneg) (fun i => (σs i).nonneg) hker rw [traceFunctional_eq_iSup_f_alpha hα ρ_mix σ_mix hker'] calc ⨆ H : {H : HermitianMat d ℂ // 0 ≤ H}, f_alpha α H.1 ρ_mix σ_mix ≤ ∑ i, w i * (⨆ H : {H : HermitianMat d ℂ // 0 ≤ H}, f_alpha α H.1 (ρs i) (σs i)) := @@ -1096,8 +1096,7 @@ theorem sandwichedTraceFunctional_mono_traceRight [Nonempty dB] field_simp -- Step 3: By joint convexity (α > 1) have hw_sum : ∑ i : κ, (Fintype.card κ : ℝ)⁻¹ = 1 := by - rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] - exact mul_inv_cancel₀ hcard_ne + simp [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, hcard_ne] set ρ_mix := ρ.traceRight ⊗ᴹ MState.uniform (d := dB) set σ_mix := σ.traceRight ⊗ᴹ MState.uniform (d := dB) have hρ_mix : ρ_mix.M = ∑ i : κ, (Fintype.card κ : ℝ)⁻¹ • (ρ.conjTensorUnitary (V i)).M := diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index 20a0f6958..b0d20ea9b 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -430,8 +430,7 @@ theorem le_smul_one_of_eigenvalues_iff (hA : A.IsHermitian) (c : ℝ) : simp only [smul_apply, one_apply, smul_ite, RCLike.real_smul_eq_coe_mul, mul_one, smul_zero, diagonal, Function.comp_apply, of_apply] have hAST : A = U * diagonal (RCLike.ofReal ∘ hA.eigenvalues) * U.conjTranspose := by - rw [hU] - exact IsHermitian.spectral_theorem hA + simpa [hU] using IsHermitian.spectral_theorem hA constructor · intro h rw [hc, hc', hAST] @@ -468,8 +467,7 @@ theorem smul_one_le_of_eigenvalues_iff (hA : A.IsHermitian) (c : ℝ) : simp only [smul_apply, one_apply, smul_ite, RCLike.real_smul_eq_coe_mul, mul_one, smul_zero, diagonal, Function.comp_apply, of_apply] have hAST : A = U * diagonal (RCLike.ofReal ∘ hA.eigenvalues) * U.conjTranspose := by - rw [hU] - exact IsHermitian.spectral_theorem hA + simpa [hU] using IsHermitian.spectral_theorem hA constructor · intro h rw [hc, hc', hAST] From 82ff60f602a901dc84667dcd8b8207ecd91d889e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:24:08 -0700 Subject: [PATCH 273/498] refactor: golf physics rewrite proofs Co-authored-by: Claude Opus 4.8 --- .../HarmonicOscillator/Solution.lean | 3 +-- Physlib/Relativity/LorentzGroup/Rotations.lean | 14 ++++++-------- .../CanonicalEnsemble/Finite.lean | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index a28b8ed43..01a95151e 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -548,8 +548,7 @@ lemma trajectories_unique (IC : InitialConditions) (x : Time → EuclideanSpace have hy_deriv : ∂ₜ y = fun t => ∂ₜ x t - ∂ₜ (IC.trajectory S) t := dsub x _ (hx.differentiable (by simp)) (hTraj.differentiable (by simp)) have hy_deriv2 : ∂ₜ (∂ₜ y) = fun t => ∂ₜ (∂ₜ x) t - ∂ₜ (∂ₜ (IC.trajectory S)) t := by - rw [hy_deriv] - exact dsub _ _ (deriv_differentiable_of_contDiff _ hx) + simpa [hy_deriv] using dsub _ _ (deriv_differentiable_of_contDiff _ hx) (deriv_differentiable_of_contDiff _ hTraj) have hNewt_x := (S.equationOfMotion_iff_newtons_2nd_law x hx).1 hEOM have hNewt_traj := (S.equationOfMotion_iff_newtons_2nd_law (IC.trajectory S) hTraj).1 diff --git a/Physlib/Relativity/LorentzGroup/Rotations.lean b/Physlib/Relativity/LorentzGroup/Rotations.lean index 45842ce4a..f97280370 100644 --- a/Physlib/Relativity/LorentzGroup/Rotations.lean +++ b/Physlib/Relativity/LorentzGroup/Rotations.lean @@ -77,12 +77,11 @@ def ofSpecialOrthogonal {d} : let M : Matrix (Fin d) (Fin d) ℝ := fun i j => Λ.1 (Sum.inr i) (Sum.inr j) have h1 : Matrix.fromBlocks 1 0 0 M = Λ.1 := by have h1 : LorentzGroup.toVector Λ = Lorentz.Vector.basis (Sum.inl 0) := by - rw [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] - exact h.1 + simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] using h.1 have h2 : LorentzGroup.toVector (LorentzGroup.transpose Λ) = Lorentz.Vector.basis (Sum.inl 0) := by - rw [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] - exact h.1 + simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one, + LorentzGroup.transpose_val] using h.1 funext i j match i, j with | .inl 0, .inl 0 => simp [h.1] @@ -130,12 +129,11 @@ def ofSpecialOrthogonal {d} : let M : Matrix (Fin d) (Fin d) ℝ := fun i j => Λ.1 (Sum.inr i) (Sum.inr j) have h1 : Matrix.fromBlocks 1 0 0 M = Λ.1 := by have h1 : LorentzGroup.toVector Λ = Lorentz.Vector.basis (Sum.inl 0) := by - rw [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] - exact h.1 + simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] using h.1 have h2 : LorentzGroup.toVector (LorentzGroup.transpose Λ) = Lorentz.Vector.basis (Sum.inl 0) := by - rw [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] - exact h.1 + simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one, + LorentzGroup.transpose_val] using h.1 funext i j match i, j with | .inl 0, .inl 0 => simp [h.1] diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index 3a0e4ec64..8e24d7ea1 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -222,8 +222,8 @@ lemma probability_le_one [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] (T : Temperature) (i : ι) : 𝓒.probability T i ≤ 1 := by have hZpos : 0 < 𝓒.mathematicalPartitionFunction T := by - rw [mathematicalPartitionFunction_of_fintype] - exact Finset.sum_pos (fun j _ => Real.exp_pos _) Finset.univ_nonempty + simpa [mathematicalPartitionFunction_of_fintype] using + Finset.sum_pos (fun j _ => Real.exp_pos _) Finset.univ_nonempty rw [probability, div_le_one hZpos, mathematicalPartitionFunction_of_fintype] simpa [neg_mul] using Finset.single_le_sum (f := fun j : ι => Real.exp (- β T * 𝓒.energy j)) (fun j _ => Real.exp_nonneg _) From 24d0733d2223751a7f56f11ee505f6b4841b0406 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:29:37 -0700 Subject: [PATCH 274/498] refactor: golf rewrite witness proofs Co-authored-by: Claude Opus 4.8 --- .../ClassicalMechanics/DampedHarmonicOscillator/Basic.lean | 4 ++-- .../QFT/PerturbationTheory/WickContraction/Uncontracted.lean | 3 +-- QuantumInfo/Channels/MatrixMap.lean | 3 +-- QuantumInfo/ForMathlib/LimSupInf.lean | 3 +-- QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean | 3 +-- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 9945afe1e..433dee9a6 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -166,8 +166,8 @@ decreasing at that time. -/ lemma energy_not_conserved (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (t : Time) (h1 : S.EquationOfMotion xₜ) (hx : ContDiff ℝ ∞ xₜ) (hdx : ∂ₜ xₜ t ≠ 0) (hγ : 0 < S.γ) : ∂ₜ (S.energy xₜ) t < 0 := by - rw [energy_dissipation_rate S xₜ t h1 hx, neg_mul] - exact neg_neg_of_pos (mul_pos hγ (real_inner_self_pos.mpr hdx)) + simpa [energy_dissipation_rate S xₜ t h1 hx, neg_mul] using + neg_neg_of_pos (mul_pos hγ (real_inner_self_pos.mpr hdx)) /-! ## C. Newton's second law diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean index f12264ff1..b2500f021 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean @@ -101,8 +101,7 @@ lemma uncontracted_card_eq_iff (c : WickContraction n) : have hc' := exists_pair_of_not_eq_empty c hn obtain ⟨i, j, hij⟩ := hc' have hci : c.getDual? i = some j := by - rw [@getDual?_eq_some_iff_mem] - exact hij + simpa [getDual?_eq_some_iff_mem] using hij simp_all · intro h subst h diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index 566e3ed15..ba94eb425 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -163,8 +163,7 @@ theorem exists_kraus (Φ : MatrixMap A B R) : (M₀ ∘ e) x * Matrix.single i₁ i₂ (1 : R) * ((N₀ ∘ e) x).conjTranspose) j₁ j₂ = ∑ y : K, (M₀ y * Matrix.single i₁ i₂ (1 : R) * (N₀ y).conjTranspose) j₁ j₂ := by - rw [Matrix.sum_apply] - exact e.sum_comp + simpa [Matrix.sum_apply] using e.sum_comp (fun y : K => (M₀ y * Matrix.single i₁ i₂ (1 : R) * (N₀ y).conjTranspose) j₁ j₂) rw [hsum_reindex, Fintype.sum_prod_type, Fintype.sum_prod_type, Fintype.sum_prod_type] simp [M₀, N₀, Matrix.mul_apply, Matrix.single, ite_and] diff --git a/QuantumInfo/ForMathlib/LimSupInf.lean b/QuantumInfo/ForMathlib/LimSupInf.lean index a2377881c..bfeb2ec01 100644 --- a/QuantumInfo/ForMathlib/LimSupInf.lean +++ b/QuantumInfo/ForMathlib/LimSupInf.lean @@ -265,8 +265,7 @@ lemma tendsto_of_block_sequence {α : Type*} [TopologicalSpace α] {x : ℕ → obtain ⟨k, hk⟩ : ∃ k, T k ≤ n ∧ n < T (k + 1) := by -- Since $T$ is strictly increasing, the set $\{k \mid T k \leq n\}$ is finite and non-empty. have h_finite : Set.Finite {k | T k ≤ n} := by - rw [Set.finite_iff_bddAbove] - exact ⟨_, (hT.id_le · |>.trans)⟩ + exact Set.finite_iff_bddAbove.mpr ⟨_, (hT.id_le · |>.trans)⟩ use h_finite.toFinset.max' ⟨a, h_finite.mem_toFinset.mpr hn⟩ constructor · exact h_finite.mem_toFinset.mp (Finset.max'_mem _ _) diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index 6aaa75f3f..044785b65 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -285,8 +285,7 @@ theorem singularValues_le_opNorm [DecidableEq n] (A : Matrix n n ℂ) (i : n) : let hH : (Aᴴ * A).IsHermitian := by simpa using (Matrix.isHermitian_mul_conjTranspose_self A.conjTranspose) have hmem : hH.eigenvalues i ∈ spectrum ℝ (Aᴴ * A) := by - rw [hH.spectrum_real_eq_range_eigenvalues] - exact ⟨i, rfl⟩ + simp [hH.spectrum_real_eq_range_eigenvalues] have hsq : singularValues A i * singularValues A i ≤ ‖A‖ * ‖A‖ := by have hsv_sq : singularValues A i * singularValues A i = hH.eigenvalues i := by dsimp [singularValues] From 8007dc5f5864a0252758bc40e9dea082f7741fe6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:33:12 -0700 Subject: [PATCH 275/498] refactor: golf local rewrite proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Fin/Involutions.lean | 4 ++-- Physlib/Mathematics/InnerProductSpace/Submodule.lean | 3 +-- Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean | 6 ++---- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 3 +-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Fin/Involutions.lean b/Physlib/Mathematics/Fin/Involutions.lean index c65067e45..96a1caf24 100644 --- a/Physlib/Mathematics/Fin/Involutions.lean +++ b/Physlib/Mathematics/Fin/Involutions.lean @@ -332,8 +332,8 @@ def involutionNoFixedSetOne {n : ℕ} : have hf' (i : Fin n) : f' i ≠ 0 := (f_succ_succ_ne_zero_one i).1 let f'' := fun i => (f' i).pred (hf' i) have hf'' (i : Fin n) : f'' i ≠ 0 := by - rw [ne_eq, Fin.pred_eq_iff_eq_succ, Fin.succ_zero_eq_one] - exact (f_succ_succ_ne_zero_one i).2 + simpa [f'', f', ne_eq, Fin.pred_eq_iff_eq_succ, Fin.succ_zero_eq_one] using + (f_succ_succ_ne_zero_one i).2 let f''' := fun i => (f'' i).pred (hf'' i) refine ⟨f''', ?_, ?_⟩ · intro i diff --git a/Physlib/Mathematics/InnerProductSpace/Submodule.lean b/Physlib/Mathematics/InnerProductSpace/Submodule.lean index 4a6957fac..eaf4dfd79 100644 --- a/Physlib/Mathematics/InnerProductSpace/Submodule.lean +++ b/Physlib/Mathematics/InnerProductSpace/Submodule.lean @@ -81,8 +81,7 @@ lemma mem_submodule_adjoint_iff_mem_submoduleToLp_orthogonal : intro u hu rw [mem_adjoint_iff] at h have h' : inner ℂ u.snd g.1 = inner ℂ u.fst g.2 := by - rw [← sub_eq_zero] - exact h u.fst u.snd hu + simpa [sub_eq_zero] using h u.fst u.snd hu simp [h'] · rw [mem_adjoint_iff] intro a b hab diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index 47ddb9aed..185c678a7 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -171,11 +171,9 @@ lemma koszulSign_insertIdx [Std.Total le] [IsTrans 𝓕 le] (φ : 𝓕) : simp only [Function.comp_apply, Equiv.symm_apply_apply, List.get_eq_getElem, ni] simp_all only [List.length_cons, add_le_add_iff_right, List.getElem_insertIdx_self] have hc1 (hninro : ni.castSucc < nro) : ¬ le φ1 φ := by - rw [← hns] - exact lt_orderedInsertPos_rel le φ1 rs ni hninro + simpa [← hns] using lt_orderedInsertPos_rel le φ1 rs ni hninro have hc2 (hninro : ¬ ni.castSucc < nro) : le φ1 φ := by - rw [← hns] - exact gt_orderedInsertPos_rel le φ1 rs + simpa [← hns] using gt_orderedInsertPos_rel le φ1 rs (List.pairwise_insertionSort le (List.insertIdx φs n φ)) ni hninro by_cases hn : ni.castSucc < nro · simp only [hn, ↓reduceIte, Fin.val_castSucc] diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index 9ceffe498..8af879647 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -1164,8 +1164,7 @@ lemma distDiv_norm_zpow_smul_repr_self_eq_smul exact Int.toNat_of_nonneg (le_of_lt hq) have hp_pos : 0 < p := by have : (0 : ℤ) < (p : ℤ) := by - rw [hp_int] - exact hq + simpa [hp_int] using hq exact_mod_cast this have hcoef : (((q + d : ℤ) : ℝ)) = (p : ℝ) := by exact_mod_cast hp_int.symm From 3f367b4cf505443a5a375a975441a8b0f7966b32 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:36:52 -0700 Subject: [PATCH 276/498] refactor: golf top-level rewrite wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean | 4 ++-- .../SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean | 4 ++-- QuantumInfo/Entropy/DPI.lean | 3 +-- QuantumInfo/ForMathlib/Matrix.lean | 4 ++-- QuantumInfo/ForMathlib/SionMinimax.lean | 3 +-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index 347e2bc7e..eae945e3c 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -828,8 +828,8 @@ lemma hamiltonian_eq_energy (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : funext t have hsymm : (toCanonicalMomentum S t (xₜ t)).symm (S.m • ∂ₜ xₜ t) = ∂ₜ xₜ t := by - rw [← toCanonicalMomentum_eq (S := S) (t := t) (x := xₜ t) (v := ∂ₜ xₜ t)] - exact LinearEquiv.symm_apply_apply (toCanonicalMomentum S t (xₜ t)) (∂ₜ xₜ t) + simpa [toCanonicalMomentum_eq (S := S) (t := t) (x := xₜ t) (v := ∂ₜ xₜ t)] using + LinearEquiv.symm_apply_apply (toCanonicalMomentum S t (xₜ t)) (∂ₜ xₜ t) unfold hamiltonian lagrangian energy kineticEnergy potentialEnergy simp only [toCanonicalMomentum_eq, inner_smul_left, one_div, smul_eq_mul] rw [hsymm] diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean index 6769f8402..d17c4057a 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean @@ -173,8 +173,8 @@ lemma minimallyAllowsTerm_iff_powerset_countP_eq_one : simp · intro h have h1 : (Multiset.filter (fun y => y.AllowsTerm T) x.powerset.val).card = 1 := by - rw [← h] - exact Eq.symm (Multiset.countP_eq_card_filter (fun y => y.AllowsTerm T) x.powerset.val) + simpa [h] using + Eq.symm (Multiset.countP_eq_card_filter (fun y => y.AllowsTerm T) x.powerset.val) rw [Multiset.card_eq_one] at h1 obtain ⟨a, ha⟩ := h1 have haMem : a ∈ Multiset.filter (fun y => y.AllowsTerm T) x.powerset.val := by diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index b331865a4..6ce6f323c 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -1062,8 +1062,7 @@ This follows from `ker_conj` (which expresses `(A.conj B).ker` as a `comap`) and lemma ker_conj_le_of_ker_le {n : Type*} [Fintype n] [DecidableEq n] {A B : HermitianMat n ℂ} (hA : 0 ≤ A) (hB : 0 ≤ B) (h : A.ker ≤ B.ker) (C : Matrix n n ℂ) : (A.conj C).ker ≤ (B.conj C).ker := by - rw [ker_conj hA, ker_conj hB] - exact Submodule.comap_mono h + simpa [ker_conj hA, ker_conj hB] using Submodule.comap_mono h /-- Unitary conjugation preserves the kernel ordering between MStates. If `σ.M.ker ≤ ρ.M.ker`, then `(σ.conjTensorUnitary V).M.ker ≤ (ρ.conjTensorUnitary V).M.ker`. -/ diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index b0d20ea9b..8ebf7cce8 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -1433,8 +1433,8 @@ theorem IsHermitian.spectrum_subset_of_mem_Icc {d 𝕜 : Type*} [Fintype d] [Dec {A B x : Matrix d d 𝕜} (hA : A.IsHermitian) (hB : B.IsHermitian) (hl : (x - A).PosSemidef) (hr : (B - x).PosSemidef) : spectrum ℝ x ⊆ Set.Icc (⨅ i, hA.eigenvalues i) (⨆ i, hB.eigenvalues i) := by - rw [← Set.Ici_inter_Iic] - exact Set.subset_inter (hA.spectrum_subset_Ici_of_sub hl) (hB.spectrum_subset_Iic_of_sub hr) + simpa [Set.Ici_inter_Iic] using + Set.subset_inter (hA.spectrum_subset_Ici_of_sub hl) (hB.spectrum_subset_Iic_of_sub hr) /-- The right partial trace of a matrix is equal to the left partial trace of the matrix reindexed by swapping the tensor factors. diff --git a/QuantumInfo/ForMathlib/SionMinimax.lean b/QuantumInfo/ForMathlib/SionMinimax.lean index 550eaa145..fec305d99 100644 --- a/QuantumInfo/ForMathlib/SionMinimax.lean +++ b/QuantumInfo/ForMathlib/SionMinimax.lean @@ -172,8 +172,7 @@ theorem lowerSemicontinuousOn_iff_isClosed_preimage {f : α → γ} [IsClosed s] theorem segment.isConnected {E : Type u_1} [AddCommGroup E] [Module ℝ E] [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul ℝ E] (a b : E) : IsConnected (segment ℝ a b) := by - rw [← Path.range_segment a b] - exact isConnected_range (Path.segment a b).continuous + simpa [Path.range_segment a b] using isConnected_range (Path.segment a b).continuous theorem BddAbove.range_inf_of_image2 {M N α : Type*} {f : M → N → α} [ConditionallyCompleteLinearOrder α] {S : Set M} {T : Set N} (h_bddA : BddAbove (Set.image2 f S T)) (h_bddB : BddBelow (Set.image2 f S T)) : From 961a95c0c44f2d7b2f659f8e72b8f18d9730f00d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:41:55 -0700 Subject: [PATCH 277/498] refactor: golf singleton and continuity wrappers Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean | 3 +-- .../PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean | 4 ++-- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Schatten.lean | 4 ++-- QuantumInfo/States/Mixed/MState.lean | 3 +-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean index 4d13b02f6..3c80e41f0 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean @@ -43,8 +43,7 @@ lemma ofCrAnListF_bosonic_or_fermionic (φs : List 𝓕.CrAnFieldOp) : lemma ofCrAnOpF_bosonic_or_fermionic (φ : 𝓕.CrAnFieldOp) : ofCrAnOpF φ ∈ statisticSubmodule bosonic ∨ ofCrAnOpF φ ∈ statisticSubmodule fermionic := by - rw [← ofCrAnListF_singleton] - exact ofCrAnListF_bosonic_or_fermionic [φ] + simpa [ofCrAnListF_singleton] using ofCrAnListF_bosonic_or_fermionic [φ] /-- The projection of an element of `FieldOpFreeAlgebra` onto it's bosonic part. -/ def bosonicProjF : 𝓕.FieldOpFreeAlgebra →ₗ[ℂ] statisticSubmodule (𝓕 := 𝓕) bosonic := diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 65f67b7ee..9d1fe6cf3 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -744,8 +744,8 @@ lemma superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic (φs φs' : Lis lemma superCommuteF_ofCrAnOpF_ofCrAnOpF_bosonic_or_fermionic (φ φ' : 𝓕.CrAnFieldOp) : [ofCrAnOpF φ, ofCrAnOpF φ']ₛF ∈ statisticSubmodule bosonic ∨ [ofCrAnOpF φ, ofCrAnOpF φ']ₛF ∈ statisticSubmodule fermionic := by - rw [← ofCrAnListF_singleton, ← ofCrAnListF_singleton] - exact superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic [φ] [φ'] + simpa [ofCrAnListF_singleton] using + superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic [φ] [φ'] lemma superCommuteF_superCommuteF_ofCrAnOpF_bosonic_or_fermionic (φ1 φ2 φ3 : 𝓕.CrAnFieldOp) : [ofCrAnOpF φ1, [ofCrAnOpF φ2, ofCrAnOpF φ3]ₛF]ₛF ∈ statisticSubmodule bosonic ∨ diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 543584872..8f70579d2 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -40,8 +40,7 @@ theorem isSelfAdjoint : IsSelfAdjoint A.mat := @[fun_prop] theorem continuousOn_finite {α β : Type*} (f : α → β) (S : Set α) [TopologicalSpace α] [TopologicalSpace β] [T1Space α] [Finite S] : ContinuousOn f S := by - rw [continuousOn_iff_continuous_restrict] - exact continuous_of_discreteTopology + simpa [continuousOn_iff_continuous_restrict] using continuous_of_discreteTopology @[simp] theorem conjTranspose_cfc : (cfc f A.mat).conjTranspose = cfc f A.mat := diff --git a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean index d06ad1b27..8d47bc21c 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean @@ -120,8 +120,8 @@ lemma schattenNorm_eq_sum_singularValues_rpow (A : Matrix d d ℂ) {p : ℝ} (hp lemma schattenNorm_rpow_eq_sum_sorted (A : Matrix d d ℂ) {p : ℝ} (hp : 0 < p) : schattenNorm A p ^ p = ∑ i : Fin (Fintype.card d), singularValuesSorted A i ^ p := by - rw [schattenNorm_rpow_eq_sum_singularValues A hp] - exact sum_singularValues_rpow_eq_sum_sorted A p + simpa [schattenNorm_rpow_eq_sum_singularValues A hp] using + sum_singularValues_rpow_eq_sum_sorted A p open InnerProductSpace in /-- diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 834267097..5ecff92bd 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -1346,8 +1346,7 @@ theorem uniform_posDef {d : Type*} [Nonempty d] [Fintype d] [DecidableEq d] : exact Fintype.card_pos theorem posDef_of_unique {d : Type*} [Fintype d] [DecidableEq d] (ρ : MState d) [Unique d] : ρ.m.PosDef := by - rw [Subsingleton.allEq ρ uniform] - exact uniform_posDef + simpa [Subsingleton.allEq ρ uniform] using uniform_posDef end posdef From 471fa0e5c3179f8f039f002a9ebad92f3967dbf0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:50:34 -0700 Subject: [PATCH 278/498] refactor: audit and golf adjoint wrappers Co-authored-by: Claude Opus 4.8 --- .../HarmonicOscillator/Basic.lean | 4 ++-- .../VariationalCalculus/HasVarAdjoint.lean | 16 ++++------------ .../RealTensor/Vector/MinkowskiProduct.lean | 3 +-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index eae945e3c..347e2bc7e 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -828,8 +828,8 @@ lemma hamiltonian_eq_energy (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : funext t have hsymm : (toCanonicalMomentum S t (xₜ t)).symm (S.m • ∂ₜ xₜ t) = ∂ₜ xₜ t := by - simpa [toCanonicalMomentum_eq (S := S) (t := t) (x := xₜ t) (v := ∂ₜ xₜ t)] using - LinearEquiv.symm_apply_apply (toCanonicalMomentum S t (xₜ t)) (∂ₜ xₜ t) + rw [← toCanonicalMomentum_eq (S := S) (t := t) (x := xₜ t) (v := ∂ₜ xₜ t)] + exact LinearEquiv.symm_apply_apply (toCanonicalMomentum S t (xₜ t)) (∂ₜ xₜ t) unfold hamiltonian lagrangian energy kineticEnergy potentialEnergy simp only [toCanonicalMomentum_eq, inner_smul_left, one_div, smul_eq_mul] rw [hsymm] diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean index 01f99c50d..f02f60995 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean @@ -99,13 +99,9 @@ lemma comp {F : (Y → V) → (Z → W)} {G : (X → U) → (Y → V)} {F' G'} lemma congr_fun {F G : (X → U) → (Y → V)} {F' : (Y → V) → (X → U)} (h : HasVarAdjoint G F') (h' : ∀ φ, IsTestFunction φ → F φ = G φ) : HasVarAdjoint F F' where - test_fun_preserving φ hφ := by - rw[h' _ hφ] - exact h.test_fun_preserving φ hφ + test_fun_preserving φ hφ := by simpa [h' φ hφ] using h.test_fun_preserving φ hφ test_fun_preserving' φ hφ := h.test_fun_preserving' φ hφ - adjoint φ ψ hφ hψ := by - rw [h' φ hφ] - exact h.adjoint φ ψ hφ hψ + adjoint φ ψ hφ hψ := by simpa [h' φ hφ] using h.adjoint φ ψ hφ hψ ext' := h.ext' lemma of_eq {F : (X → U) → (Y → V)} {F' G' : (Y → V) → (X → U)} @@ -113,12 +109,8 @@ lemma of_eq {F : (X → U) → (Y → V)} {F' G' : (Y → V) → (X → U)} (hlin : IsLocalizedFunctionTransform G') : HasVarAdjoint F G' where test_fun_preserving φ hφ := hF'.test_fun_preserving φ hφ - test_fun_preserving' φ hφ := by - rw [← h φ hφ] - exact hF'.test_fun_preserving' φ hφ - adjoint φ ψ hφ hψ := by - rw [← h ψ hψ] - exact hF'.adjoint φ ψ hφ hψ + test_fun_preserving' φ hφ := by simpa [← h φ hφ] using hF'.test_fun_preserving' φ hφ + adjoint φ ψ hφ hψ := by simpa [← h ψ hψ] using hF'.adjoint φ ψ hφ hψ ext' := hlin /-- Variational adjoint is unique only when applied to test functions. -/ diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean index 4dc3e8655..26261b0ce 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/MinkowskiProduct.lean @@ -253,8 +253,7 @@ def IsLorentz {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : Prop := ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ lemma isLorentz_iff {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : - IsLorentz f ↔ ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ := by - rfl + IsLorentz f ↔ ∀ p q : Vector d, ⟪f p, f q⟫ₘ = ⟪p, q⟫ₘ := Iff.rfl lemma isLorentz_iff_basis {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) : IsLorentz f ↔ ∀ μ ν : Fin 1 ⊕ Fin d, ⟪f (basis μ), f (basis ν)⟫ₘ = ⟪basis μ, basis ν⟫ₘ := by From a93b9f7f279f123124402d54f242827302b610bf Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:53:57 -0700 Subject: [PATCH 279/498] refactor: golf variance and geometry wrappers Co-authored-by: Claude Opus 4.8 --- .../Geometry/Metric/PseudoRiemannian/Defs.lean | 4 +--- Physlib/QFT/QED/AnomalyCancellation/Basic.lean | 4 +--- .../DDimensions/Operators/StateObservables/Variance.lean | 9 +++------ Physlib/SpaceAndTime/Space/Derivatives/Grad.lean | 3 +-- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean index 977e3f461..0db0ba85f 100644 --- a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean @@ -120,9 +120,7 @@ lemma neg_weight_implies_neg_value {E : Type*} [AddCommGroup E] [Module ℝ E] intro h have : f v = f 0 := by rw [h] have : f (f.symm v_std) = f 0 := by rw [← this] - have : v_std = 0 := by - rw [← f.apply_symm_apply v_std] - exact Eq.trans this (map_zero f) + have : v_std = 0 := by simpa using this have : v_std i = 0 := by rw [this]; rfl simp only [↓reduceIte, one_ne_zero, v_std] at this have hq_neg : q v < 0 := by diff --git a/Physlib/QFT/QED/AnomalyCancellation/Basic.lean b/Physlib/QFT/QED/AnomalyCancellation/Basic.lean index 593e4f8f8..3c4a5bbb8 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Basic.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Basic.lean @@ -128,9 +128,7 @@ lemma pureU1_linear {n : ℕ} (S : (PureU1 n).LinSols) : /-- A solution to the pure U(1) accs satisfies the cubic ACCs. -/ lemma pureU1_cube {n : ℕ} (S : (PureU1 n).Sols) : - ∑ i, (S.val i) ^ 3 = 0 := by - rw [← PureU1.accCube_explicit] - exact S.cubicSol + ∑ i, (S.val i) ^ 3 = 0 := (PureU1.accCube_explicit n S.val) ▸ S.cubicSol /-- The last charge of a solution to the linear ACCs is equal to the negation of the sum of the other charges. -/ diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean index 8cbf85f9f..e74e95504 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean @@ -88,9 +88,7 @@ lemma variance_eq_norm_sq_sub_expectedValue_sq (T : H →ₗ.[ℂ] H) /-- Variance is nonnegative. -/ lemma variance_nonneg (T : H →ₗ.[ℂ] H) (ψ : T.domain) : - 0 ≤ variance T ψ := by - rw [variance_eq_centered_norm_sq] - exact sq_nonneg _ + 0 ≤ variance T ψ := by simp [variance_eq_centered_norm_sq] /-- Zero variance is the same as a zero centered vector. -/ lemma variance_eq_zero_iff_centered_eq_zero (T : H →ₗ.[ℂ] H) (ψ : T.domain) : @@ -131,9 +129,8 @@ lemma standardDeviation_eq_sqrt_variance (T : H →ₗ.[ℂ] H) (ψ : T.domain) /-- Standard deviation is nonnegative. -/ lemma standardDeviation_nonneg (T : H →ₗ.[ℂ] H) (ψ : T.domain) : - 0 ≤ standardDeviation T ψ := by - rw [standardDeviation_eq_sqrt_variance] - exact Real.sqrt_nonneg _ + 0 ≤ standardDeviation T ψ := + Real.sqrt_nonneg _ @[simp] lemma standardDeviation_sq (T : H →ₗ.[ℂ] H) (ψ : T.domain) : diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean index 31343c32b..e37b61716 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean @@ -193,8 +193,7 @@ lemma grad_inner_eq {d} (f : Space d → ℝ) (x : Space d) (y : EuclideanSpace lemma inner_grad_eq {d} (f : Space d → ℝ) (x : EuclideanSpace ℝ (Fin d)) (y : Space d) : ⟪x, ∇ f y⟫_ℝ = ∑ i, x i * ∂[i] f y := by - rw [← grad_inner_eq] - exact real_inner_comm (∇ f y) x + simpa [← grad_inner_eq] using real_inner_comm (∇ f y) x lemma grad_inner_repr_eq {d} (f : Space d → ℝ) (x y : Space d) : ⟪∇ f x, (Space.basis).repr y⟫_ℝ = fderiv ℝ f x y := by From 2066781526a37f55324c060077dc30cb5859e8c4 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 00:57:51 -0700 Subject: [PATCH 280/498] refactor: golf direct wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean | 3 +-- .../OneDimension/HarmonicOscillator/Basic.lean | 3 +-- Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 4 +--- QuantumInfo/States/Mixed/MState.lean | 4 +--- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean index 388a31624..30d8172e5 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean @@ -257,8 +257,7 @@ lemma getDual?_isSome_iff (i : Fin n) : (c.getDual? i).isSome ↔ ∃ (a : c.1), simpa using hy ▸ a.2 lemma getDual?_isSome_of_mem (a : c.1) (i : a.1) : (c.getDual? i).isSome := by - rw [getDual?_isSome_iff] - exact ⟨⟨a.1, a.2⟩, Finset.coe_mem ..⟩ + exact (getDual?_isSome_iff (c := c) i).2 ⟨a, Finset.coe_mem i⟩ @[simp] lemma getDual?_getDual?_get_get (i : Fin n) (h : (c.getDual? i).isSome) : diff --git a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean index 96d5f644a..6aa981278 100644 --- a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean @@ -132,8 +132,7 @@ lemma one_over_ξ : 1/Q.ξ = √(Q.m * Q.ω / ℏ) := by field_simp lemma ξ_inverse : Q.ξ⁻¹ = √(Q.m * Q.ω / ℏ) := by - rw [inv_eq_one_div] - exact one_over_ξ Q + simpa only [inv_eq_one_div] using one_over_ξ Q lemma one_over_ξ_sq : (1/Q.ξ)^2 = Q.m * Q.ω / ℏ := by rw [one_over_ξ] diff --git a/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean b/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean index 93388c825..065e0eaeb 100644 --- a/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean +++ b/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean @@ -197,8 +197,7 @@ lemma succSuccAbove_ne_fst (i j : Fin (n + 1 + 1)) (m : Fin n) : @[simp] lemma snd_ne_succSuccAbove_pre (i j : Fin (n + 1 + 1)) (m : Fin n) : ¬ j = (succSuccAbove i j) m := by - rw [succSuccAbove_symm] - exact fst_ne_succSuccAbove_pre j i m + simpa [succSuccAbove_symm] using fst_ne_succSuccAbove_pre j i m @[simp] lemma succSuccAbove_ne_snd (i j : Fin (n + 1 + 1)) (m : Fin n) : diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index aa31c0d08..21c6e31d5 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -42,9 +42,7 @@ theorem le_iff_mulVec_le : A ≤ B ↔ simp [le_iff, Matrix.posSemidef_iff_dotProduct_mulVec, B.H.sub A.H, Matrix.sub_mulVec] instance [DecidableEq n] : ZeroLEOneClass (HermitianMat n 𝕜) where - zero_le_one := by - rw [zero_le_iff] - exact Matrix.PosSemidef.one + zero_le_one := by simpa [zero_le_iff] using Matrix.PosSemidef.one omit [Fintype n] in theorem lt_iff_posdef : A < B ↔ (B - A).mat.PosSemidef ∧ A ≠ B := diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 5ecff92bd..6a10757ef 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -1290,9 +1290,7 @@ def piProd (ρi : (i:ι) → MState (dI i)) : MState ((i:ι) → dI i) where val := Matrix.piProd (fun i ↦ (ρi i).m) property := Matrix.IsHermitian.piProd (fun i ↦ (ρi i).Hermitian) } - nonneg := by - rw [zero_le_iff] - exact Matrix.PosSemidef.piProd (fun i => psd (ρi i)) + nonneg := by simpa [zero_le_iff] using Matrix.PosSemidef.piProd (fun i => psd (ρi i)) tr := by simp [trace, Matrix.trace_piProd] /-- The n-copy "power" of a mixed state, with the standard basis indexed by pi types. -/ From c487d0a7d89051b2c3984bc718713640a65dd11b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:00:55 -0700 Subject: [PATCH 281/498] refactor: golf hermitian order wrappers Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/StateObservables/Variance.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Proj.lean | 9 +++------ QuantumInfo/States/Mixed/MState.lean | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean index e74e95504..7e76e33d2 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean @@ -135,8 +135,7 @@ lemma standardDeviation_nonneg (T : H →ₗ.[ℂ] H) (ψ : T.domain) : @[simp] lemma standardDeviation_sq (T : H →ₗ.[ℂ] H) (ψ : T.domain) : standardDeviation T ψ ^ 2 = variance T ψ := by - rw [standardDeviation_eq_sqrt_variance, Real.sq_sqrt] - exact variance_nonneg T ψ + simpa [standardDeviation_eq_sqrt_variance] using Real.sq_sqrt (variance_nonneg T ψ) /-- Zero standard deviation is the same as a zero centered vector. -/ lemma standardDeviation_eq_zero_iff_centered_eq_zero (T : H →ₗ.[ℂ] H) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 21c6e31d5..52cba3901 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -494,8 +494,7 @@ theorem ker_conj [DecidableEq n] (hA : 0 ≤ A) (B : Matrix n n 𝕜) : · exact Eq.symm (LinearMap.map_zero (Matrix.toEuclideanLin B)) theorem ker_le_of_le_smul {α : ℝ} [DecidableEq n] (hα : α ≠ 0) (hA : 0 ≤ A) (hAB : A ≤ α • B) : B.ker ≤ A.ker := by - rw [← ker_pos_smul B hα] - exact ker_antitone hA hAB + simpa [← ker_pos_smul B hα] using ker_antitone hA hAB /-- If a Hermitian matrix is bounded by `M * I`, then all its eigenvalues are at most `M`. -/ theorem le_smul_one_imp_eigenvalues_le [DecidableEq n] (A : HermitianMat n ℂ) (M : ℝ) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean index f9c1ca789..5cc340ff5 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean @@ -295,8 +295,7 @@ theorem projLE_mul_nonneg : 0 ≤ {A ≤ₚ B}.mat * (B - A).mat := by open MatrixOrder in theorem projLE_mul_le : {A ≤ₚ B}.mat * A.mat ≤ {A ≤ₚ B}.mat * B.mat := by - rw [← sub_nonneg, ← mul_sub_left_distrib] - exact projLE_mul_nonneg A B + simpa [← sub_nonneg, ← mul_sub_left_distrib] using projLE_mul_nonneg A B @[simp] theorem proj_le_add_lt : {A <ₚ B} + {B ≤ₚ A} = 1 := by @@ -405,8 +404,7 @@ theorem projLE_inner_nonneg : 0 ≤ ⟪{A ≤ₚ B}, (B - A)⟫ := inner_mul_nonneg (projLE_mul_nonneg A B) theorem projLE_inner_le : ⟪{A ≤ₚ B}, A⟫ ≤ ⟪{A ≤ₚ B}, B⟫ := by - rw [← sub_nonneg, ← inner_sub_right] - exact projLE_inner_nonneg A B + simpa [← sub_nonneg, ← inner_sub_right] using projLE_inner_nonneg A B open RealInnerProductSpace in theorem inner_projLE_nonneg : 0 ≤ ⟪{A ≤ₚ B}, (B - A)⟫ := @@ -458,8 +456,7 @@ theorem projLT_mul_nonneg : 0 ≤ {A <ₚ B}.mat * (B - A).mat := by open MatrixOrder ComplexOrder in theorem proj_lt_mul_lt : {A <ₚ B}.mat * A.mat ≤ {A <ₚ B}.mat * B.mat := by - rw [← sub_nonneg, ← mul_sub_left_distrib] - exact A.projLT_mul_nonneg B + simpa [← sub_nonneg, ← mul_sub_left_distrib] using A.projLT_mul_nonneg B theorem inner_negPart_nonpos : ⟪A, A⁻⟫ ≤ 0 := by rw [← neg_le_neg_iff, neg_zero, ← inner_neg_right] diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 6a10757ef..89dd2da41 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -158,8 +158,7 @@ def nonempty : Nonempty d := by -- Could have used properties of ρ.spectrum theorem eigenvalue_nonneg : ∀ i, 0 ≤ ρ.Hermitian.eigenvalues i := by - rw [← Matrix.PosSemidef.nonneg_iff_eigenvalue_nonneg ρ.Hermitian] - exact ρ.nonneg + exact (zero_le_iff.mp ρ.nonneg).eigenvalues_nonneg set_option backward.isDefEq.respectTransparency false in -- Could have used properties of ρ.spectrum From 58faacfbd22909e83467e1dd3dca8a64763248b3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:03:06 -0700 Subject: [PATCH 282/498] refactor: golf QFT and oscillator wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean | 3 +-- Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean | 3 +-- Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index 347e2bc7e..9c43be37b 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -155,8 +155,7 @@ lemma ω_pos : 0 < S.ω := sqrt_pos.mpr (div_pos S.k_pos S.m_pos) /-- The square of the angular frequency of the classical harmonic oscillator is equal to `k/m`. -/ lemma ω_sq : S.ω^2 = S.k / S.m := by - rw [ω, sq_sqrt] - exact div_nonneg (le_of_lt S.k_pos) (le_of_lt S.m_pos) + simpa only [ω] using sq_sqrt (div_nonneg (le_of_lt S.k_pos) (le_of_lt S.m_pos)) /-- The angular frequency of the classical harmonic oscillator is not equal to zero. -/ lemma ω_ne_zero : S.ω ≠ 0 := Ne.symm (ne_of_lt S.ω_pos) diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean index 79a92eece..42b733966 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean @@ -201,8 +201,7 @@ lemma ofList_append_eq_mul (s : 𝓕 → FieldStatistic) (φs φs' : List 𝓕) lemma ofList_perm (s : 𝓕 → FieldStatistic) {l l' : List 𝓕} (h : l.Perm l') : ofList s l = ofList s l' := by - rw [ofList_eq_prod, ofList_eq_prod] - exact List.Perm.prod_eq (List.Perm.map s h) + simpa [ofList_eq_prod] using List.Perm.prod_eq (List.Perm.map s h) lemma ofList_orderedInsert (s : 𝓕 → FieldStatistic) (le1 : 𝓕 → 𝓕 → Prop) [DecidableRel le1] (φs : List 𝓕) (φ : 𝓕) : ofList s (List.orderedInsert le1 φ φs) = ofList s (φ :: φs) := diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean index 30d8172e5..4dfea99f0 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean @@ -372,8 +372,7 @@ lemma fstFieldOfContract_mem (c : WickContraction n) (a : c.1) : lemma fstFieldOfContract_getDual?_isSome (c : WickContraction n) (a : c.1) : (c.getDual? (c.fstFieldOfContract a)).isSome := by - rw [getDual?_isSome_iff] - exact ⟨a, fstFieldOfContract_mem ..⟩ + exact (getDual?_isSome_iff (c := c) _).2 ⟨a, fstFieldOfContract_mem ..⟩ @[simp] lemma fstFieldOfContract_getDual? (c : WickContraction n) (a : c.1) : @@ -387,8 +386,7 @@ lemma sndFieldOfContract_mem (c : WickContraction n) (a : c.1) : lemma sndFieldOfContract_getDual?_isSome (c : WickContraction n) (a : c.1) : (c.getDual? (c.sndFieldOfContract a)).isSome := by - rw [getDual?_isSome_iff] - exact ⟨a, sndFieldOfContract_mem ..⟩ + exact (getDual?_isSome_iff (c := c) _).2 ⟨a, sndFieldOfContract_mem ..⟩ @[simp] lemma sndFieldOfContract_getDual? (c : WickContraction n) (a : c.1) : diff --git a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean index 537837d68..17e652376 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean @@ -41,8 +41,7 @@ lemma constAbs_perm (S : (PureU1 n).Charges) (M :(FamilyPermutations n).group) : exact h2 lemma constAbs_sort {S : (PureU1 n).Charges} (CA : ConstAbs S) : ConstAbs (sort S) := by - rw [sort] - exact (constAbs_perm S _).mpr CA + simpa [sort] using (constAbs_perm S _).mpr CA /-- The condition for a set of charges to be `sorted`, and have `constAbs`-/ def ConstAbsSorted (S : (PureU1 n).Charges) : Prop := ConstAbs S ∧ Sorted S From ad7ef9f6769c9f3d7f7452cf88ea1dcf37a450b3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:08:58 -0700 Subject: [PATCH 283/498] refactor: golf closure and exponent proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/InnerProductSpace/Basic.lean | 3 +-- .../RHN/AnomalyCancellation/PlusU1/BMinusL.lean | 3 +-- Physlib/Relativity/Special/ProperTime.lean | 3 +-- QuantumInfo/Entropy/DPI.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean | 3 +-- QuantumInfo/ForMathlib/SionMinimax.lean | 6 ++---- 7 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/Mathematics/InnerProductSpace/Basic.lean b/Physlib/Mathematics/InnerProductSpace/Basic.lean index cb7c5d000..4b671692e 100644 --- a/Physlib/Mathematics/InnerProductSpace/Basic.lean +++ b/Physlib/Mathematics/InnerProductSpace/Basic.lean @@ -513,8 +513,7 @@ instance {ι : Type*} [Fintype ι] : InnerProductSpace' 𝕜 (ι → E) where use i simp have hj : ∀ j, ‖x j‖ ≤ ‖x i‖ := by - rw [← hi] - exact fun j => norm_le_pi_norm x j + simpa [← hi] using fun j => norm_le_pi_norm x j rw [hi] constructor · apply le_trans (h (x i)).1 diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/BMinusL.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/BMinusL.lean index a3f4f6a30..9fe36df8c 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/BMinusL.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/BMinusL.lean @@ -79,8 +79,7 @@ lemma add_AFL_quad (S : (PlusU1 n).LinSols) (a b : ℚ) : lemma add_quad (S : (PlusU1 n).QuadSols) (a b : ℚ) : accQuad (a • S.val + b • (BL n).val) = 0 := by - rw [add_AFL_quad, quadSol S] - exact Rat.mul_zero (a ^ 2) + rw [add_AFL_quad, quadSol S]; simp /-- The `QuadSol` obtained by adding $B-L$ to a `QuadSol`. -/ def addQuad (S : (PlusU1 n).QuadSols) (a b : ℚ) : (PlusU1 n).QuadSols := diff --git a/Physlib/Relativity/Special/ProperTime.lean b/Physlib/Relativity/Special/ProperTime.lean index a924adf81..0771bc087 100644 --- a/Physlib/Relativity/Special/ProperTime.lean +++ b/Physlib/Relativity/Special/ProperTime.lean @@ -36,8 +36,7 @@ def properTime {d : ℕ} (q p : SpaceTime d) : ℝ := lemma properTime_pos_ofTimeLike {d : ℕ} (q p : SpaceTime d) (h : causalCharacter (p - q) = .timeLike) : 0 < properTime q p := by - rw [properTime] - exact sqrt_pos_of_pos ((timeLike_iff_norm_sq_pos (p - q)).mp h) + simpa [properTime] using sqrt_pos_of_pos ((timeLike_iff_norm_sq_pos (p - q)).mp h) lemma properTime_zero_ofLightLike {d : ℕ} (q p : SpaceTime d) (h : causalCharacter (p - q) = .lightLike) : diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 6ce6f323c..9c6edb504 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -848,8 +848,7 @@ theorem sandwichedTraceFunctional_self (hα : 0 < α) (ρ : MState d) : · nlinarith [mul_div_cancel₀ (1 - α) (by positivity : (2 * α) ≠ 0)] have h_simp : (ρ.M ^ (1 + 2 * ((1 - α) / (2 * α)))) ^ α = ρ.M ^ ((1 + 2 * ((1 - α) / (2 * α))) * α) := by - rw [← rpow_mul] - exact le_of_lt this + exact (HermitianMat.rpow_mul (le_of_lt this)).symm field_simp at * simp_all only [add_sub_cancel, one_div, rpow_one, MState.tr] diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index a6cc21db9..9ca4a97a6 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -67,8 +67,7 @@ instance nonSingular_exp : NonSingular A.exp := /-- The matrix exponential of a Hermitian matrix is nonnegative. -/ theorem exp_nonneg (A : HermitianMat d 𝕜) : 0 ≤ A.exp := by - rw [exp, HermitianMat.cfc_nonneg_iff] - exact fun i ↦ le_of_lt (Real.exp_pos _) + simpa [exp, HermitianMat.cfc_nonneg_iff] using fun i ↦ le_of_lt (Real.exp_pos _) /-- The matrix exponential of a Hermitian matrix is strictly positive (Loewner order). Requires `Nonempty` since over an empty index type every matrix equals zero and `0 < 0` diff --git a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean index c33ea17fb..840e36aff 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean @@ -136,8 +136,7 @@ theorem nonSingular_iff_neg : NonSingular (-A) ↔ NonSingular A := by @[simp] theorem nonSingular_iff_inv : NonSingular (A⁻¹) ↔ NonSingular A := by - rw [nonsingular_iff_isUnit, nonsingular_iff_isUnit] - exact Matrix.isUnit_nonsing_inv_iff + simp [nonsingular_iff_isUnit] @[simp] theorem nonSingular_iff_kronecker [Nonempty n] [Nonempty m] : diff --git a/QuantumInfo/ForMathlib/SionMinimax.lean b/QuantumInfo/ForMathlib/SionMinimax.lean index fec305d99..963334f48 100644 --- a/QuantumInfo/ForMathlib/SionMinimax.lean +++ b/QuantumInfo/ForMathlib/SionMinimax.lean @@ -471,8 +471,7 @@ private lemma sion_exists_min_2 (y₁ y₂ : N) (hy₁ : y₁ ∈ T) (hy₂ : y replace ⟨hzI, hzI2⟩ := And.intro (hzI · |>.left) (hzI · |>.right) have hz_mem : z ∈ segment ℝ y₁ y₂ := have cloL : IsClosed (segment ℝ y₁ y₂) := by - rw [← closure_openSegment] - exact isClosed_closure + simp [← closure_openSegment] cloL.isSeqClosed hzI hzs let x := (hC_nonempty z hz_mem).some have hx : x ∈ C z := (hC_nonempty z hz_mem).some_mem @@ -509,8 +508,7 @@ private lemma sion_exists_min_2 (y₁ y₂ : N) (hy₁ : y₁ ∈ T) (hy₂ : y replace ⟨hzI, hzI2⟩ := And.intro (hzI · |>.left) (hzI · |>.right) have hz_mem : z ∈ segment ℝ y₁ y₂ := have cloL : IsClosed (segment ℝ y₁ y₂) := by - rw [← closure_openSegment] - exact isClosed_closure + simp [← closure_openSegment] cloL.isSeqClosed hzI hzs let x := (hC_nonempty z hz_mem).some have hx : x ∈ C z := (hC_nonempty z hz_mem).some_mem From ec58073d197a86b23418c6fb698d2f8ae17a1d25 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:14:11 -0700 Subject: [PATCH 284/498] refactor: golf rewrite wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../ClassicalMechanics/DampedHarmonicOscillator/Basic.lean | 3 +-- .../RHN/AnomalyCancellation/PlusU1/BMinusL.lean | 2 +- Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean | 6 ++---- Physlib/Relativity/LorentzGroup/Boosts/Basic.lean | 3 +-- Physlib/Relativity/LorentzGroup/Rotations.lean | 3 +-- Physlib/Relativity/Tensors/Contraction/Pure.lean | 3 +-- Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean | 3 +-- QuantumInfo/Channels/Pinching.lean | 6 ++---- 8 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 433dee9a6..55533f7ef 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -266,8 +266,7 @@ lemma discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq : /-- The decay rate is nonnegative. -/ lemma decayRate_nonneg : 0 ≤ S.decayRate := by - rw [decayRate] - exact div_nonneg S.γ_nonneg (by nlinarith [S.m_pos]) + simpa [decayRate] using div_nonneg S.γ_nonneg (by nlinarith [S.m_pos]) /-- An undamped oscillator lies in the underdamped regime. -/ lemma isUnderdamped_of_gamma_eq_zero (hγ : S.γ = 0) : S.IsUnderdamped := by diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/BMinusL.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/BMinusL.lean index 9fe36df8c..5bbf06c83 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/BMinusL.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/BMinusL.lean @@ -79,7 +79,7 @@ lemma add_AFL_quad (S : (PlusU1 n).LinSols) (a b : ℚ) : lemma add_quad (S : (PlusU1 n).QuadSols) (a b : ℚ) : accQuad (a • S.val + b • (BL n).val) = 0 := by - rw [add_AFL_quad, quadSol S]; simp + exact (add_AFL_quad S.1 a b).trans (mul_eq_zero_of_right (a ^ 2) (quadSol S)) /-- The `QuadSol` obtained by adding $B-L$ to a `QuadSol`. -/ def addQuad (S : (PlusU1 n).QuadSols) (a b : ℚ) : (PlusU1 n).QuadSols := diff --git a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean index 17e652376..a20f1113f 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean @@ -226,8 +226,7 @@ lemma AFL_even_below' {A : (PureU1 (2 * n.succ)).LinSols} (h : ConstAbsSorted A. apply lt_eq h (le_of_lt hk.left) rw [Fin.le_def] simp only [Fin.val_cast, Fin.val_castAdd, mul_eq, Fin.val_castSucc] - rw [AFL_even_Boundary h hA hk] - exact Fin.is_le i + simpa [AFL_even_Boundary h hA hk] using Fin.is_le i lemma AFL_even_below (A : (PureU1 (2 * n.succ)).LinSols) (h : ConstAbsSorted A.val) (i : Fin n.succ) : @@ -247,8 +246,7 @@ lemma AFL_even_above' {A : (PureU1 (2 * n.succ)).LinSols} (h : ConstAbsSorted A. apply gt_eq h (le_of_lt hk.right) rw [Fin.le_def] simp only [mul_eq, Fin.val_succ, Fin.val_cast, Fin.val_natAdd] - rw [AFL_even_Boundary h hA hk] - exact Nat.le_add_right (n + 1) ↑i + simp [AFL_even_Boundary h hA hk] lemma AFL_even_above (A : (PureU1 (2 * n.succ)).LinSols) (h : ConstAbsSorted A.val) (i : Fin n.succ) : diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean index 2baefb0f6..a6db4d5e6 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean @@ -242,8 +242,7 @@ lemma boost_inr_inr_other {i j k : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j (boost i β hβ).1 (Sum.inr k) (Sum.inr j) = if j = k then 1 else 0:= by rw [← boost_transpose_eq_self] simp only [transpose, transpose_apply] - rw [boost_inr_other_inr] - exact hij + exact boost_inr_other_inr hβ hij /-! ## Properties of boosts in the zero-direction diff --git a/Physlib/Relativity/LorentzGroup/Rotations.lean b/Physlib/Relativity/LorentzGroup/Rotations.lean index f97280370..ec9d42a77 100644 --- a/Physlib/Relativity/LorentzGroup/Rotations.lean +++ b/Physlib/Relativity/LorentzGroup/Rotations.lean @@ -178,8 +178,7 @@ lemma rotations_subset_restricted (d) : Rotations d ≤ LorentzGroup.restricted @[simp] lemma toVector_rotation {d} (Λ : Rotations d) : LorentzGroup.toVector Λ.1= Lorentz.Vector.basis (Sum.inl 0) := by - rw [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] - exact Λ.2.1 + simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] using Λ.2.1 end LorentzGroup diff --git a/Physlib/Relativity/Tensors/Contraction/Pure.lean b/Physlib/Relativity/Tensors/Contraction/Pure.lean index 36c18b868..0ac69959d 100644 --- a/Physlib/Relativity/Tensors/Contraction/Pure.lean +++ b/Physlib/Relativity/Tensors/Contraction/Pure.lean @@ -88,8 +88,7 @@ lemma dropPair_update_fst {n : ℕ} [inst : DecidableEq (Fin (n + 1 +1))] {c : F dropPair i j hij (p.update i x) = dropPair i j hij p := by ext m simp only [Function.comp_apply, dropPair, update] - rw [Function.update_of_ne] - exact Ne.symm (fst_ne_succSuccAbove_pre i j m) + simp [Function.update_of_ne, Ne.symm (fst_ne_succSuccAbove_pre i j m)] @[simp] lemma dropPair_update_snd {n : ℕ} [inst : DecidableEq (Fin (n + 1 +1))] {c : Fin (n + 1 + 1) → C} diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 0b8959a42..cda465c4f 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -285,8 +285,7 @@ instance [NeZero 𝓒.μ] [NeZero 𝓒1.μ] : NeZero (𝓒 + 𝓒1).μ := by (𝓒.μ Set.univ) * (𝓒1.μ Set.univ) := by rw [← @Measure.prod_prod] simp - rw [h1] - exact NeZero.pos (𝓒.μ Set.univ * 𝓒1.μ Set.univ) + simpa [h1] using NeZero.pos (𝓒.μ Set.univ * 𝓒1.μ Set.univ) instance μ_neZero_congr [NeZero 𝓒.μ] (e : ι1 ≃ᵐ ι) : NeZero (𝓒.congr e).μ := by diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index a0fddf7a3..0d8e1bed4 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -223,8 +223,7 @@ theorem pinching_bound (ρ σ : MState d) : ρ.M ≤ (↑(Fintype.card (spectrum rw [Complex.mul_conj, Complex.norm_real, Real.norm_of_nonneg (Complex.normSq_nonneg _)] simp_rw [← Complex.mul_conj, map_sum, Finset.mul_sum, Finset.sum_mul] congr! with x _ y _ - rw [← Matrix.mul_assoc] - exact h_mul x y + simpa [← Matrix.mul_assoc] using h_mul x y · simp · have hc (c d : ℂ) : d = starRingEnd ℂ d → c = d → c = d.re := by rintro h rfl; simp [Complex.ext_iff] at h ⊢; linarith @@ -239,8 +238,7 @@ theorem ker_le_ker_pinching_of_PosDef (ρ σ : MState d) (hpos : σ.m.PosDef) : simp [LinearMap.ker_eq_bot', HermitianMat.ker] at this ⊢ intro m hm simpa only [WithLp.ofLp_eq_zero] using this m congr($hm) - rw [h_ker] - exact bot_le + simp [h_ker] theorem pinching_idempotent (ρ σ : MState d) : (pinching_map σ) (pinching_map σ ρ) = (pinching_map σ ρ) := by From ae5e60953ec8cbf5d4515face874b9170f96df0c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:16:51 -0700 Subject: [PATCH 285/498] refactor: golf basis evaluation proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean | 6 ++---- .../Tensors/RealTensor/Vector/Pre/Modules.lean | 12 ++++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean index be9572a62..6db77c551 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean @@ -87,8 +87,7 @@ def coordinateMap : (PureU1 n.succ).LinSols ≃ₗ[ℚ] Fin n →₀ ℚ where rw [Finset.sum_eq_single j] · simp only [asCharges, ↓reduceIte, mul_one] · intro k _ hkj - erw [asCharges_ne_castSucc hkj] - exact Rat.mul_zero (S.val k.castSucc) + exact mul_eq_zero_of_right (S.val k.castSucc) (asCharges_ne_castSucc hkj) · simp right_inv f := by simp only @@ -101,8 +100,7 @@ def coordinateMap : (PureU1 n.succ).LinSols ≃ₗ[ℚ] Fin n →₀ ℚ where rw [Finset.sum_eq_single j] · simp only [asCharges, ↓reduceIte, mul_one] · intro k _ hkj - erw [asCharges_ne_castSucc hkj] - exact Rat.mul_zero (f k) + exact mul_eq_zero_of_right (f k) (asCharges_ne_castSucc hkj) · simp /-- The basis of `LinSols`. -/ diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index ccd607f57..8e6a68bfc 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -87,8 +87,7 @@ lemma stdBasis_toFin1dℝEquiv_apply_same (μ : Fin 1 ⊕ Fin d) : toFin1dℝEquiv (stdBasis μ) μ = 1 := by simp only [stdBasis, Basis.ofEquivFun, Basis.coe_ofRepr, LinearEquiv.trans_symm, LinearEquiv.symm_symm, LinearEquiv.trans_apply, Finsupp.linearEquivFunOnFinite_single] - rw [@LinearEquiv.apply_symm_apply] - exact Pi.single_eq_same μ 1 + simp @[simp] lemma stdBasis_apply_same (μ : Fin 1 ⊕ Fin d) : (stdBasis μ).val μ = 1 := @@ -98,8 +97,7 @@ lemma stdBasis_toFin1dℝEquiv_apply_ne {μ ν : Fin 1 ⊕ Fin d} (h : μ ≠ ν toFin1dℝEquiv (stdBasis μ) ν = 0 := by simp only [stdBasis, Basis.ofEquivFun, Basis.coe_ofRepr, LinearEquiv.trans_symm, LinearEquiv.symm_symm, LinearEquiv.trans_apply, Finsupp.linearEquivFunOnFinite_single] - rw [@LinearEquiv.apply_symm_apply] - exact Pi.single_eq_of_ne' h 1 + simpa using Pi.single_eq_of_ne' h 1 @[simp] lemma stdBasis_inl_apply_inr (i : Fin d) : (stdBasis (Sum.inl 0)).val (Sum.inr i) = 0 := by @@ -349,8 +347,7 @@ lemma stdBasis_toFin1dℝEquiv_apply_same (μ : Fin 1 ⊕ Fin d) : toFin1dℝEquiv (stdBasis μ) μ = 1 := by simp only [stdBasis, Basis.ofEquivFun, Basis.coe_ofRepr, LinearEquiv.trans_symm, LinearEquiv.symm_symm, LinearEquiv.trans_apply, Finsupp.linearEquivFunOnFinite_single] - rw [@LinearEquiv.apply_symm_apply] - exact Pi.single_eq_same μ 1 + simp @[simp] lemma stdBasis_apply_same (μ : Fin 1 ⊕ Fin d) : (stdBasis μ).val μ = 1 := @@ -360,8 +357,7 @@ lemma stdBasis_toFin1dℝEquiv_apply_ne {μ ν : Fin 1 ⊕ Fin d} (h : μ ≠ ν toFin1dℝEquiv (stdBasis μ) ν = 0 := by simp only [stdBasis, Basis.ofEquivFun, Basis.coe_ofRepr, LinearEquiv.trans_symm, LinearEquiv.symm_symm, LinearEquiv.trans_apply, Finsupp.linearEquivFunOnFinite_single] - rw [@LinearEquiv.apply_symm_apply] - exact Pi.single_eq_of_ne' h 1 + simpa using Pi.single_eq_of_ne' h 1 lemma stdBasis_apply (μ ν : Fin 1 ⊕ Fin d) : (stdBasis μ).val ν = if μ = ν then 1 else 0 := by simp only [stdBasis, Basis.coe_ofEquivFun] From 08748f4aca424ce9c01a0e00d479f37bae5cb58d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:19:38 -0700 Subject: [PATCH 286/498] refactor: golf QED basis component proofs Co-authored-by: Claude Opus 4.8 --- .../AnomalyCancellation/Even/BasisLinear.lean | 18 +++++--------- .../AnomalyCancellation/Odd/BasisLinear.lean | 24 +++++++------------ 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index 80ff7bac3..c7f4339fc 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -357,11 +357,9 @@ lemma P_evenFst (f : Fin n.succ → ℚ) (j : Fin n.succ) : P f (evenFst j) = f rw [P, sum_of_charges] simp only [succ_eq_add_one, HSMul.hSMul, SMul.smul] rw [Finset.sum_eq_single j] - · rw [basis_on_evenFst_self] - exact Rat.mul_one (f j) + · simp [basis_on_evenFst_self] · intro k _ hkj - rw [basis_on_evenFst_other hkj] - exact Rat.mul_zero (f k) + exact mul_eq_zero_of_right (f k) (basis_on_evenFst_other hkj) · simp only [mem_univ, not_true_eq_false, _root_.mul_eq_zero, IsEmpty.forall_iff] lemma P_evenSnd (f : Fin n.succ → ℚ) (j : Fin n.succ) : P f (evenSnd j) = - f j := by @@ -640,22 +638,18 @@ lemma P!_evenShiftFst (f : Fin n → ℚ) (j : Fin n) : P! f (evenShiftFst j) = rw [P!, sum_of_charges] simp only [HSMul.hSMul, SMul.smul] rw [Finset.sum_eq_single j] - · rw [basis!_on_evenShiftFst_self] - exact Rat.mul_one (f j) + · simp [basis!_on_evenShiftFst_self] · intro k _ hkj - rw [basis!_on_evenShiftFst_other hkj] - exact Rat.mul_zero (f k) + exact mul_eq_zero_of_right (f k) (basis!_on_evenShiftFst_other hkj) · simp only [mem_univ, not_true_eq_false, _root_.mul_eq_zero, IsEmpty.forall_iff] lemma P!_evenShiftSnd (f : Fin n → ℚ) (j : Fin n) : P! f (evenShiftSnd j) = - f j := by rw [P!, sum_of_charges] simp only [HSMul.hSMul, SMul.smul] rw [Finset.sum_eq_single j] - · rw [basis!_on_evenShiftSnd_self] - exact mul_neg_one (f j) + · simp [basis!_on_evenShiftSnd_self] · intro k _ hkj - rw [basis!_on_evenShiftSnd_other hkj] - exact Rat.mul_zero (f k) + exact mul_eq_zero_of_right (f k) (basis!_on_evenShiftSnd_other hkj) · simp lemma P!_evenShiftZero (f : Fin n → ℚ) : P! f (evenShiftZero) = 0 := by diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 1ab47f5d2..eafe31f79 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -406,22 +406,18 @@ lemma P_oddFst (f : Fin n → ℚ) (j : Fin n) : P f (oddFst j) = f j := by rw [P, sum_of_charges] simp only [HSMul.hSMul, SMul.smul] rw [Finset.sum_eq_single j] - · rw [basis_on_oddFst_self] - exact Rat.mul_one (f j) + · simp [basis_on_oddFst_self] · intro k _ hkj - rw [basis_on_oddFst_other hkj] - exact Rat.mul_zero (f k) + exact mul_eq_zero_of_right (f k) (basis_on_oddFst_other hkj) · simp only [mem_univ, not_true_eq_false, _root_.mul_eq_zero, IsEmpty.forall_iff] lemma P_oddSnd (f : Fin n → ℚ) (j : Fin n) : P f (oddSnd j) = - f j := by rw [P, sum_of_charges] simp only [HSMul.hSMul, SMul.smul] rw [Finset.sum_eq_single j] - · rw [basis_on_oddSnd_self] - exact mul_neg_one (f j) + · simp [basis_on_oddSnd_self] · intro k _ hkj - rw [basis_on_oddSnd_other hkj] - exact Rat.mul_zero (f k) + exact mul_eq_zero_of_right (f k) (basis_on_oddSnd_other hkj) · simp lemma P_oddMid (f : Fin n → ℚ) : P f oddMid = 0 := by @@ -654,22 +650,18 @@ lemma P!_oddShiftFst (f : Fin n → ℚ) (j : Fin n) : P! f (oddShiftFst j) = f rw [P!, sum_of_charges] simp only [HSMul.hSMul, SMul.smul] rw [Finset.sum_eq_single j] - · rw [basis!_on_oddShiftFst_self] - exact Rat.mul_one (f j) + · simp [basis!_on_oddShiftFst_self] · intro k _ hkj - rw [basis!_on_oddShiftFst_other hkj] - exact Rat.mul_zero (f k) + exact mul_eq_zero_of_right (f k) (basis!_on_oddShiftFst_other hkj) · simp only [mem_univ, not_true_eq_false, _root_.mul_eq_zero, IsEmpty.forall_iff] lemma P!_oddShiftSnd (f : Fin n → ℚ) (j : Fin n) : P! f (oddShiftSnd j) = - f j := by rw [P!, sum_of_charges] simp only [HSMul.hSMul, SMul.smul] rw [Finset.sum_eq_single j] - · rw [basis!_on_oddShiftSnd_self] - exact mul_neg_one (f j) + · simp [basis!_on_oddShiftSnd_self] · intro k _ hkj - rw [basis!_on_oddShiftSnd_other hkj] - exact Rat.mul_zero (f k) + exact mul_eq_zero_of_right (f k) (basis!_on_oddShiftSnd_other hkj) · simp lemma P!_oddShiftZero (f : Fin n → ℚ) : P! f oddShiftZero = 0 := by From 03f36467ccfbeb5aa5dc2a09eb6250ca29493911 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:22:33 -0700 Subject: [PATCH 287/498] refactor: golf QED anomaly wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/QED/AnomalyCancellation/Basic.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Basic.lean b/Physlib/QFT/QED/AnomalyCancellation/Basic.lean index 3c4a5bbb8..2d916725b 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Basic.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Basic.lean @@ -149,8 +149,7 @@ lemma pureU1_anomalyFree_ext {n : ℕ} {S T : (PureU1 n.succ).LinSols} · obtain ⟨j, hj⟩ := hi subst hj exact h j - · rw [hi, pureU1_last, pureU1_last] - exact neg_inj.mpr (Finset.sum_congr rfl fun j _ => h j) + · simpa [hi, pureU1_last] using neg_inj.mpr (Finset.sum_congr rfl fun j _ => h j) namespace PureU1 diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index c7f4339fc..ad2a9e64a 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -970,8 +970,7 @@ lemma Pa'_elim_eq_iff (g g' : Fin n.succ → ℚ) (f f' : Fin n → ℚ) : lemma Pa_eq (g g' : Fin n.succ → ℚ) (f f' : Fin n → ℚ) : Pa g f = Pa g' f' ↔ g = g' ∧ f = f' := by - rw [← Pa'_elim_eq_iff, ← Sum.elim_eq_iff] - exact Pa'_eq _ _ + simpa [← Pa'_elim_eq_iff, ← Sum.elim_eq_iff] using Pa'_eq _ _ /-! @@ -1036,8 +1035,7 @@ lemma span_basis_swap! {S : (PureU1 (2 * n.succ)).LinSols} (j : Fin n) change P! f' = _ at hf' erw [hf'] simp only [and_self, and_true, X] - rw [← add_assoc, ← h] - exact swap!_as_add j hS + simpa [← add_assoc, ← h] using swap!_as_add j hS end VectorLikeEvenPlane diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index eafe31f79..679fdccca 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -927,8 +927,7 @@ lemma Pa'_elim_eq_iff (g g' : Fin n.succ → ℚ) (f f' : Fin n.succ → ℚ) : lemma Pa_eq (g g' : Fin n.succ → ℚ) (f f' : Fin n.succ → ℚ) : Pa g f = Pa g' f' ↔ g = g' ∧ f = f' := by - rw [← Pa'_elim_eq_iff, ← Sum.elim_eq_iff] - exact Pa'_eq _ _ + simpa [← Pa'_elim_eq_iff, ← Sum.elim_eq_iff] using Pa'_eq _ _ /-! @@ -1004,8 +1003,7 @@ lemma span_basis_swap! {S : (PureU1 (2 * n.succ + 1)).LinSols} (j : Fin n.succ) change P! f' = _ at hf' erw [hf'] simp only [and_self, and_true, X] - rw [← add_assoc, ← hS1] - exact swap!_as_add j hS + simpa [← add_assoc, ← hS1] using swap!_as_add j hS end VectorLikeOddPlane From 9e87d7803157eacfd4d4b7db8a3d0ae77847ff24 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:24:59 -0700 Subject: [PATCH 288/498] refactor: golf anomaly plane wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/PlusU1/PlaneNonSols.lean | 3 +-- .../AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean | 6 ++---- .../MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean | 6 ++---- Physlib/Relativity/Tensors/Basic.lean | 6 ++---- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/PlaneNonSols.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/PlaneNonSols.lean index 519735102..a286cc98e 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/PlaneNonSols.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/PlaneNonSols.lean @@ -87,8 +87,7 @@ lemma Bi_sum_quad (i : Fin 11) (f : Fin 11 → ℚ) : rw [quadBiLin.map_sum₂, Fintype.sum_eq_single i] · rw [quadBiLin.map_smul₂] · intro k hij - rw [quadBiLin.map_smul₂, Bi_Bj_quad hij.symm] - exact Rat.mul_zero (f k) + simpa [quadBiLin.map_smul₂] using mul_eq_zero_of_right (f k) (Bi_Bj_quad hij.symm) /-- The coefficients of the quadratic equation in our basis. -/ @[simp] diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean index 9a57d775d..0931185ae 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean @@ -195,13 +195,11 @@ lemma α₁_proj (T : MSSMACC.Sols) : α₁ (proj T.1.1) = lemma α₁_proj_zero (T : MSSMACC.Sols) (h1 : α₃ (proj T.1.1) = 0) : α₁ (proj T.1.1) = 0 := by - rw [α₁_proj, h1] - exact mul_eq_zero_of_left rfl ((dot B₃.val) T.val - (dot Y₃.val) T.val) + simp [α₁_proj, h1] lemma α₂_proj_zero (T : MSSMACC.Sols) (h1 : α₃ (proj T.1.1) = 0) : α₂ (proj T.1.1) = 0 := by - rw [α₂_proj, h1] - exact mul_eq_zero_of_left rfl ((dot Y₃.val) T.val - 2 * (dot B₃.val) T.val) + simp [α₂_proj, h1] end proj diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean index d424426b1..4101c3322 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean @@ -70,8 +70,7 @@ lemma linEqPropSol_iff_proj_linEqProp (R : MSSMACC.Sols) : simp only [mul_eq_zero, OfNat.ofNat_ne_zero, false_or] at h rw [α₁_proj, α₂_proj, h] simp only [neg_zero, zero_mul, and_self] - · rw [h.2.2] - exact Rat.mul_zero ((dot Y₃.val) B₃.val) + · simp [h.2.2] /-- A condition which is satisfied if the plane spanned by `R`, `Y₃` and `B₃` lies entirely in the quadratic surface. -/ @@ -353,8 +352,7 @@ lemma inQuadCubeToSol_proj (T : InQuadCubeSol) : simp only [zero_smul, add_zero, zero_add] rw [← SemigroupAction.mul_smul, mul_comm, mul_inv_cancel₀] · exact MulAction.one_smul (T.1).val - · rw [show dot Y₃.val B₃.val = 108 by with_unfolding_all rfl] - exact Ne.symm (OfNat.zero_ne_ofNat 108) + · simp [show dot Y₃.val B₃.val = 108 by with_unfolding_all rfl] /-- A solution from an element of `MSSMACC.AnomalyFreePerp × ℚ × ℚ × ℚ`. We will show that this map is a surjection. -/ diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index 351ee0edf..f51fe81cd 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -147,8 +147,7 @@ lemma update_succAbove_apply {n : ℕ} {c : Fin (n + 1) → C} [inst : Decidable (p : Pure S c) (i : Fin (n + 1)) (j : Fin n) (x : V (c (i.succAbove j))) : update p (i.succAbove j) x i = p i := by simp only [update] - rw [Function.update_of_ne] - exact Fin.ne_succAbove i j + simp [Function.update_of_ne, Fin.ne_succAbove i j] @[simp] lemma toTensor_update_add {n : ℕ} {c : Fin n → C} [inst : DecidableEq (Fin n)] (p : Pure S c) @@ -190,8 +189,7 @@ lemma update_drop_self {n : ℕ} {c : Fin (n + 1) → C} [inst : DecidableEq (Fi (update p i x).drop i = p.drop i := by ext k simp only [Function.comp_apply, drop, update] - rw [Function.update_of_ne] - exact Fin.succAbove_ne i k + simp [Function.update_of_ne, Fin.succAbove_ne i k] /-! From 56f2ab7101cd1706e65a03ad3e744374fb3f89a6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:27:22 -0700 Subject: [PATCH 289/498] refactor: golf family map wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/FamilyMaps.lean | 3 +-- .../StandardModel/AnomalyCancellation/FamilyMaps.lean | 3 +-- .../SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean | 3 +-- Physlib/Relativity/Tensors/Basic.lean | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean index a9725b545..2a7277f93 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean @@ -76,8 +76,7 @@ def speciesEmbed (m n : ℕ) : eq_ratCast, Rat.cast_eq_id, id_eq] by_cases hi : i.val < m · rw [dif_pos hi, dif_pos hi] - · rw [dif_neg hi, dif_neg hi] - exact Eq.symm (Rat.mul_zero a) + · simp [dif_neg hi] /-- The embedding of the `m`-family charges onto the `n`-family charges, with all other charges zero. -/ diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/FamilyMaps.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/FamilyMaps.lean index a0730be03..6e5eed1fc 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/FamilyMaps.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/FamilyMaps.lean @@ -73,8 +73,7 @@ def speciesEmbed (m n : ℕ) : simp only [HSMul.hSMul, ACCSystemCharges.chargesModule_smul, eq_ratCast, Rat.cast_eq_id, id_eq] by_cases hi : i.val < m · rw [dif_pos hi, dif_pos hi] - · rw [dif_neg hi, dif_neg hi] - exact Eq.symm (Rat.mul_zero a) + · simp [dif_neg hi] /-- The embedding of the `m`-family charges onto the `n`-family charges, with all other charges zero. -/ diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean index c16ffa53b..f642ddfe9 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/OfPotentialTerm.lean @@ -398,8 +398,7 @@ lemma ofPotentialTerm'_mono [DecidableEq 𝓩] {x y : ChargeSpectrum 𝓩} (h : x ⊆ y) (T : PotentialTerm) : x.ofPotentialTerm' T ⊆ y.ofPotentialTerm' T := by intro i - rw [← mem_ofPotentialTerm_iff_mem_ofPotentialTerm, ← mem_ofPotentialTerm_iff_mem_ofPotentialTerm] - exact fun a => ofPotentialTerm_mono h T a + simpa [← mem_ofPotentialTerm_iff_mem_ofPotentialTerm] using fun a => ofPotentialTerm_mono h T a end ChargeSpectrum diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index f51fe81cd..d854538aa 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -180,8 +180,7 @@ lemma update_succAbove_drop {n : ℕ} {c : Fin (n + 1) → C} [inst : DecidableE · rw [Function.update_of_ne h, Function.update_of_ne] · rfl · simp only [ne_eq] - rw [Function.Injective.eq_iff (Fin.succAbove_right_injective (p := i))] - exact h + simpa [Function.Injective.eq_iff (Fin.succAbove_right_injective (p := i))] using h @[simp] lemma update_drop_self {n : ℕ} {c : Fin (n + 1) → C} [inst : DecidableEq (Fin (n + 1))] @@ -282,8 +281,7 @@ lemma component_basisVector {n : ℕ} (c : Fin n → C) (b1 b2 : ComponentIdx (S simp_all only [not_forall] obtain ⟨w, h⟩ := h refine Finset.prod_eq_zero (Finset.mem_univ i) ?_ - rw [Finsupp.single_eq_of_ne] - exact fun a => hi (id (Eq.symm a)) + exact Finsupp.single_eq_of_ne fun a => hi (id (Eq.symm a)) end Pure From 43e96436b6a3f34405d4a0580d75599b72c0b213 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:31:29 -0700 Subject: [PATCH 290/498] refactor: golf Wick list wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../WickContraction/UncontractedList.lean | 9 +++------ .../DDimensions/Operators/StateObservables/Variance.lean | 3 +-- .../Tensors/ComplexTensor/Vector/Pre/Contraction.lean | 4 +--- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index f54256b5a..4f473c772 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -58,8 +58,7 @@ lemma fin_finset_sort_map_monotone {n m : ℕ} (a : Finset (Fin n)) (f : Fin n have h3 : ((a.sort (· ≤ ·)).map f).toFinset = (a.map f) := by ext a simp - rw [← h3] - exact ((List.toFinset_sort (· ≤ ·) h2).mpr h1).symm + simpa [← h3] using ((List.toFinset_sort (· ≤ ·) h2).mpr h1).symm lemma fin_list_sorted_split : (l : List (Fin n)) → (hl : l.Pairwise (· ≤ ·)) → (i : ℕ) → @@ -217,8 +216,7 @@ lemma uncontractedList_sorted : List.Pairwise (· ≤ ·) c.uncontractedList := lemma uncontractedList_sorted_lt : List.Pairwise (· < ·) c.uncontractedList := by rw [uncontractedList] apply List.Pairwise.filter - rw [← List.ofFn_id] - exact List.pairwise_ofFn.mpr fun ⦃i j⦄ a => a + simp [← List.ofFn_id] lemma uncontractedList_nodup : c.uncontractedList.Nodup := by rw [uncontractedList] @@ -600,8 +598,7 @@ lemma take_uncontractedListOrderPos_eq_filter_sort (c : WickContraction n) (i : (c.uncontracted.filter (fun x => x.1 < i.1)) := by rw [uncontractedList_eq_sort] simp - rw [← h3] - exact ((List.toFinset_sort (α := Fin n) (· ≤ ·) h2).mpr h1).symm + simpa [← h3] using ((List.toFinset_sort (α := Fin n) (· ≤ ·) h2).mpr h1).symm lemma orderedInsert_succAboveEmb_uncontractedList_eq_insertIdx (c : WickContraction n) (i : Fin n.succ) : diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean index 7e76e33d2..28e7ffd8c 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean @@ -93,8 +93,7 @@ lemma variance_nonneg (T : H →ₗ.[ℂ] H) (ψ : T.domain) : /-- Zero variance is the same as a zero centered vector. -/ lemma variance_eq_zero_iff_centered_eq_zero (T : H →ₗ.[ℂ] H) (ψ : T.domain) : variance T ψ = 0 ↔ centered T ψ = 0 := by - rw [variance_eq_centered_norm_sq] - exact sq_eq_zero_iff.trans norm_eq_zero + simp [variance_eq_centered_norm_sq] /-- Zero variance is the same as `Tψ = ⟨T⟩_ψ ψ`. -/ lemma variance_eq_zero_iff (T : H →ₗ.[ℂ] H) (ψ : T.domain) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean index 889fe4377..3776bd696 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean @@ -108,9 +108,7 @@ lemma contrCoContraction_basis' (i j : Fin 1 ⊕ Fin 3) : if i = j then (1 : ℂ) else 0 := by rw [contrCoContraction_hom_tmul] simp only [complexContrBasis_toFin13ℂ, complexCoBasis_toFin13ℂ, dotProduct_single, mul_one] - rw [Pi.single_apply] - exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) - (congrFun rfl) (congrFun rfl) + simp [Pi.single_apply, eq_comm] /-- The linear map from complexCo ⊗ complexContr to ℂ given by summing over components of covariant Lorentz vector and From 5cb24c3e819451d5cda5ae5155114d66e971776c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:38:47 -0700 Subject: [PATCH 291/498] refactor: remove neutral proof-golf churn Co-authored-by: Claude Opus 4.8 --- .../DampedHarmonicOscillator/Basic.lean | 4 +- Physlib/ClassicalMechanics/EulerLagrange.lean | 2 +- .../HarmonicOscillator/Solution.lean | 12 +- .../TotalDerivativeEquivalence.lean | 8 +- .../TightBindingChain/Basic.lean | 2 +- .../Distributional/FieldStrength.lean | 2 +- Physlib/Electromagnetism/Dynamics/Basic.lean | 4 +- .../Dynamics/CurrentDensity.lean | 4 +- .../Dynamics/KineticTerm.lean | 2 +- .../Electromagnetism/Dynamics/Lagrangian.lean | 8 +- .../Kinematics/EMPotential.lean | 14 +- .../Kinematics/FieldStrength.lean | 2 +- .../Kinematics/MagneticField.lean | 24 ++-- Physlib/FluidDynamics/NavierStokes/Basic.lean | 12 +- Physlib/Mathematics/Calculus/AdjFDeriv.lean | 4 +- .../DataStructures/Matrix/LieTrace.lean | 8 +- Physlib/Mathematics/Distribution/Basic.lean | 6 +- Physlib/Mathematics/FDerivCurry.lean | 4 +- Physlib/Mathematics/Fin.lean | 2 +- Physlib/Mathematics/Fin/Involutions.lean | 4 +- .../Metric/PseudoRiemannian/Defs.lean | 2 +- .../Mathematics/InnerProductSpace/Basic.lean | 8 +- .../InnerProductSpace/Submodule.lean | 6 +- Physlib/Mathematics/LinearMaps.lean | 2 +- Physlib/Mathematics/List.lean | 4 +- Physlib/Mathematics/List/InsertIdx.lean | 8 +- Physlib/Mathematics/List/InsertionSort.lean | 14 +- .../SpecialFunctions/PhysHermite.lean | 4 +- .../VariationalCalculus/HasVarAdjDeriv.lean | 8 +- .../VariationalCalculus/HasVarAdjoint.lean | 4 +- .../IsLocalizedfunctionTransform.lean | 28 ++-- .../RHN/AnomalyCancellation/PlusU1/Basic.lean | 4 +- .../AnomalyCancellation/Basic.lean | 14 +- .../NoGrav/One/LinearParameterization.lean | 2 +- .../StandardModel/HiggsBoson/Potential.lean | 4 +- .../MSSMNu/AnomalyCancellation/Basic.lean | 12 +- .../MinimallyAllowsTerm/Basic.lean | 4 +- .../MinimallyAllowsTerm/OfFinset.lean | 8 +- .../SU5/ChargeSpectrum/PhenoClosed.lean | 6 +- .../FieldOpFreeAlgebra/SuperCommute.lean | 4 +- .../FieldOpFreeAlgebra/TimeOrder.lean | 4 +- .../FieldSpecification/NormalOrder.lean | 4 +- .../FieldSpecification/TimeOrder.lean | 20 +-- .../FieldStatistics/ExchangeSign.lean | 4 +- .../NormalOrder/WickContractions.lean | 8 +- .../WickAlgebra/SuperCommute.lean | 8 +- .../WickAlgebra/TimeContraction.lean | 2 +- .../WickAlgebra/TimeOrder.lean | 8 +- .../WickAlgebra/Universality.lean | 4 +- .../WickAlgebra/WicksTheoremNormal.lean | 8 +- .../WickContraction/Basic.lean | 4 +- .../WickContraction/ExtractEquiv.lean | 4 +- .../WickContraction/InsertAndContractNat.lean | 4 +- .../WickContraction/Join.lean | 4 +- .../WickContraction/Sign/InsertNone.lean | 4 +- .../WickContraction/Sign/InsertSome.lean | 8 +- .../WickContraction/Sign/Join.lean | 8 +- .../WickContraction/SubContraction.lean | 12 +- .../WickContraction/TimeCond.lean | 10 +- .../WickContraction/UncontractedList.lean | 14 +- .../AnomalyCancellation/Even/BasisLinear.lean | 8 +- .../Even/Parameterization.lean | 4 +- .../AnomalyCancellation/Odd/BasisLinear.lean | 8 +- .../Odd/Parameterization.lean | 4 +- .../QED/AnomalyCancellation/Permutations.lean | 24 ++-- .../DDimensions/Operators/Commutation.lean | 6 +- .../DDimensions/Operators/Multiplication.lean | 10 +- .../DDimensions/Operators/Position.lean | 24 ++-- .../Operators/SpectralTheory/Basic.lean | 14 +- .../Operators/SpectralTheory/Symmetric.lean | 8 +- .../DDimensions/Operators/Uncertainty.lean | 12 +- .../PolyBddSchwartzSubmodule.lean | 8 +- .../OneDimension/GeneralPotential/Basic.lean | 4 +- .../HarmonicOscillator/Basic.lean | 8 +- .../OneDimension/HilbertSpace/Basic.lean | 4 +- .../ReflectionlessPotential/Basic.lean | 4 +- .../LorentzAlgebra/ExponentialMap.lean | 4 +- .../Relativity/LorentzGroup/Boosts/Basic.lean | 4 +- .../LorentzGroup/Boosts/Generalized.lean | 12 +- Physlib/Relativity/LorentzGroup/Proper.lean | 12 +- .../LorentzGroup/Restricted/Basic.lean | 6 +- .../Relativity/LorentzGroup/Rotations.lean | 8 +- Physlib/Relativity/MinkowskiMatrix.lean | 2 +- Physlib/Relativity/SL2C/Basic.lean | 10 +- Physlib/Relativity/Tensors/Basic.lean | 2 +- .../Tensors/ComplexTensor/Matrix/Pre.lean | 16 +-- .../Tensors/ComplexTensor/Metrics/Lemmas.lean | 24 ++-- .../Tensors/ComplexTensor/Metrics/Pre.lean | 8 +- .../ComplexTensor/Vector/Pre/Contraction.lean | 4 +- .../ComplexTensor/Weyl/Contraction.lean | 28 ++-- .../Tensors/ComplexTensor/Weyl/Metric.lean | 4 +- .../Tensors/ComplexTensor/Weyl/Two.lean | 40 +++--- Physlib/Relativity/Tensors/Constructors.lean | 2 +- .../Relativity/Tensors/Contraction/Pure.lean | 2 +- Physlib/Relativity/Tensors/MetricTensor.lean | 8 +- .../Tensors/RealTensor/CoVector/Basic.lean | 6 +- .../RealTensor/CoVector/Representation.lean | 2 +- .../Tensors/RealTensor/Metrics/Basic.lean | 4 +- .../Tensors/RealTensor/ToComplex.lean | 18 +-- .../Tensors/RealTensor/Vector/Basic.lean | 10 +- .../RealTensor/Vector/Causality/TimeLike.lean | 12 +- .../Tensors/RealTensor/Vector/Pre/Basic.lean | 8 +- .../RealTensor/Vector/Pre/Contraction.lean | 2 +- .../RealTensor/Vector/Pre/Modules.lean | 14 +- .../RealTensor/Vector/Representation.lean | 2 +- .../Tensors/RealTensor/Velocity/Basic.lean | 6 +- Physlib/Relativity/Tensors/UnitTensor.lean | 4 +- Physlib/SpaceAndTime/Space/Basic.lean | 2 +- .../SpaceAndTime/Space/ConstantSliceDist.lean | 8 +- .../SpaceAndTime/Space/Derivatives/Basic.lean | 8 +- .../SpaceAndTime/Space/Derivatives/Curl.lean | 12 +- .../SpaceAndTime/Space/Derivatives/Grad.lean | 2 +- .../SpaceAndTime/Space/DistOfFunction.lean | 4 +- .../Space/EuclideanGroup/Basic.lean | 2 +- .../SpaceAndTime/Space/Integrals/Basic.lean | 4 +- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 24 ++-- Physlib/SpaceAndTime/Space/Module.lean | 26 ++-- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 16 +-- Physlib/SpaceAndTime/Space/Slice.lean | 2 +- Physlib/SpaceAndTime/SpaceTime/Basic.lean | 6 +- Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean | 4 +- Physlib/SpaceAndTime/Time/Basic.lean | 36 ++--- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 2 +- Physlib/SpaceAndTime/Time/TimeUnit.lean | 4 +- Physlib/SpaceAndTime/TimeAndSpace/Basic.lean | 10 +- .../TimeAndSpace/ConstantTimeDist.lean | 18 +-- .../CanonicalEnsemble/Basic.lean | 8 +- .../CanonicalEnsemble/Finite.lean | 4 +- .../CanonicalEnsemble/Lemmas.lean | 8 +- .../MicroCanonicalEnsemble/IdealGas.lean | 6 +- .../FTheory/SU5/Charges/Viable.lean | 4 +- .../FTheory/SU5/Quanta/FiveQuanta.lean | 10 +- .../FTheory/SU5/Quanta/TenQuanta.lean | 6 +- Physlib/Units/Basic.lean | 2 +- Physlib/Units/Dimension.lean | 20 +-- Physlib/Units/Integral.lean | 2 +- Physlib/Units/WithDim/Speed.lean | 4 +- QuantumInfo/Capacity/Capacity.lean | 4 +- QuantumInfo/Channels/Bundled.lean | 16 +-- QuantumInfo/Channels/CPTP.lean | 4 +- QuantumInfo/Channels/Dual.lean | 20 +-- QuantumInfo/Channels/Pinching.lean | 10 +- QuantumInfo/Channels/Unbundled.lean | 8 +- QuantumInfo/ClassicalInfo/Distribution.lean | 8 +- QuantumInfo/Entropy/DPI.lean | 44 +++--- QuantumInfo/Entropy/Relative.lean | 136 +++++++++--------- QuantumInfo/Entropy/SSA.lean | 56 ++++---- QuantumInfo/Entropy/VonNeumann.lean | 4 +- .../ForMathlib/ComplexLaplaceTransform.lean | 4 +- .../JensenOperatorInequality.lean | 16 +-- .../JensenOperatorInequalityIImpIV.lean | 32 ++--- .../JensenOperatorInequalityIVtoV.lean | 8 +- .../TraceInequality/LiebAndoTrace.lean | 90 ++++++------ .../TraceInequality/LownerHeinzCore.lean | 24 ++-- .../TraceInequality/LownerHeinzTheorem.lean | 8 +- .../OperatorGeometricMean.lean | 6 +- .../ForMathlib/HermitianMat/Basic.lean | 4 +- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 110 +++++++------- .../HermitianMat/LiebConcavity.lean | 16 +-- .../ForMathlib/HermitianMat/LogExp.lean | 32 ++--- .../ForMathlib/HermitianMat/NonSingular.lean | 12 +- .../ForMathlib/HermitianMat/Order.lean | 16 +-- .../ForMathlib/HermitianMat/Peierls.lean | 16 +-- QuantumInfo/ForMathlib/HermitianMat/Proj.lean | 4 +- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 88 ++++++------ .../ForMathlib/HermitianMat/Schatten.lean | 8 +- QuantumInfo/ForMathlib/Isometry.lean | 8 +- QuantumInfo/ForMathlib/LimSupInf.lean | 12 +- QuantumInfo/ForMathlib/Majorization.lean | 36 ++--- QuantumInfo/ForMathlib/Matrix.lean | 16 +-- .../ForMathlib/MatrixNorm/TraceNorm.lean | 12 +- QuantumInfo/ForMathlib/Minimax.lean | 4 +- QuantumInfo/ForMathlib/Misc.lean | 4 +- QuantumInfo/ForMathlib/SionMinimax.lean | 4 +- QuantumInfo/ResourceTheory/SteinsLemma.lean | 24 ++-- QuantumInfo/States/Entanglement.lean | 16 +-- QuantumInfo/States/Mixed/MState.lean | 38 ++--- 177 files changed, 1046 insertions(+), 1046 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 55533f7ef..459c4035c 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -296,8 +296,8 @@ lemma isCriticallyDamped_decayRate (hS : S.IsCriticallyDamped) : S.ω = S.decayR nlinarith exact ne_of_gt hm_sq_pos have hsq : S.decayRate^2 = S.ω^2 := by - have hsub : S.decayRate^2 - S.ω^2 = 0 := - (mul_eq_zero.mp hS).resolve_left hm_sq_ne_zero + have hsub : S.decayRate^2 - S.ω^2 = 0 := by + exact (mul_eq_zero.mp hS).resolve_left hm_sq_ne_zero linarith nlinarith [S.decayRate_nonneg, S.ω_pos] diff --git a/Physlib/ClassicalMechanics/EulerLagrange.lean b/Physlib/ClassicalMechanics/EulerLagrange.lean index bc5a9a3e4..2340d6825 100644 --- a/Physlib/ClassicalMechanics/EulerLagrange.lean +++ b/Physlib/ClassicalMechanics/EulerLagrange.lean @@ -33,7 +33,7 @@ noncomputable def eulerLagrangeOp (L : Time → X → X → ℝ) (q : Time → X lemma eulerLagrangeOp_eq (L : Time → X → X → ℝ) (q : Time → X) : eulerLagrangeOp L q = fun t => gradient (L t · (∂ₜ q t)) (q t) - - ∂ₜ (fun t' => gradient (L t' (q t') ·) (∂ₜ q t')) t := rfl + - ∂ₜ (fun t' => gradient (L t' (q t') ·) (∂ₜ q t')) t := by rfl lemma eulerLagrangeOp_zero (q : Time → X) : eulerLagrangeOp (fun _ _ _ => 0) q = fun _ => 0 := by simp [eulerLagrangeOp_eq, Time.deriv_eq] diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index 01a95151e..7e74046af 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -1220,14 +1220,14 @@ lemma return_time (IC : InitialConditions) (non_trivial : IC.x₀ ≠ 0 ∨ IC.v 0 < xx * S.ω^2 := by bound _ ≤ ‖IC.v₀‖^2 + xx * S.ω^2 := by bound _ = vv + xx * S.ω^2 := by rw [← real_inner_self_eq_norm_sq IC.v₀] - _ = det := rfl + _ = det := by rfl | inr hv => have vv_gt_zero : 0 < vv := real_inner_self_pos.mpr hv calc 0 < vv := vv_gt_zero _ ≤ vv + ‖IC.x₀‖^2 * S.ω^2 := by bound _ = vv + xx * S.ω^2 := by rw [← real_inner_self_eq_norm_sq IC.x₀] - _ = det := rfl + _ = det := by rfl have det_ne_zero : det ≠ 0 := by bound have hxx : c * xx + (s / S.ω) * xv = xx := by calc @@ -1253,20 +1253,20 @@ lemma return_time (IC : InitialConditions) (non_trivial : IC.x₀ ≠ 0 ∨ IC.v have hcos : 1 = cos (S.ω * t) := by calc 1 = det / det := by simp only [ne_eq, det_ne_zero, not_false_eq_true, div_self] - _ = (vv + xx * S.ω^2 ) / det := rfl + _ = (vv + xx * S.ω^2 ) / det := by rfl _ = c * ((vv + xx * S.ω^2) / det) + s * xv *S.ω* (S.ω/S.ω-1 ) / det := by nth_rewrite 1 [← hvv, ← hxx] ring_nf _ = c * ((vv + xx * S.ω^2) / det ) := by simp only [ne_eq, S.ω_ne_zero, not_false_eq_true, div_self, sub_self, mul_zero, zero_div, add_zero] - _ = c * (det / det) := rfl + _ = c * (det / det) := by rfl _ = c := by simp only [ne_eq, det_ne_zero, not_false_eq_true, div_self, mul_one] - _ = _ := rfl + _ = _ := by rfl let ⟨n, hn⟩ := (Real.cos_eq_one_iff (S.ω * t)).mp (Eq.symm hcos) use n calc - (n : ℝ) * (T S) = (n : ℝ) * (2 * π / S.ω) := rfl + (n : ℝ) * (T S) = (n : ℝ) * (2 * π / S.ω) := by rfl _ = ((n : ℝ) * (2 * π)) / S.ω := by ring_nf _ = (S.ω * t) / S.ω := by rw [hn] _ = t * (S.ω / S.ω) := by ring_nf diff --git a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean index 965652131..9463f2147 100644 --- a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean +++ b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean @@ -107,7 +107,7 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : calc (1 : Time) = fderiv ℝ (fun (t' : Time) => t') t 1 := by simp only [fderiv_fun_id, ContinuousLinearMap.coe_id', id_eq] - _ = fderiv ℝ (fun (t' : Time) => (tq q t').1) t 1 := rfl + _ = fderiv ℝ (fun (t' : Time) => (tq q t').1) t 1 := by rfl _ = (∂ₜ (tq q) t).1 := by rw [fderiv.fst] · simp @@ -118,7 +118,7 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : rcases this apply Eq.symm calc - (1, ∂ₜ q t).2 = fderiv ℝ (fun t' => (tq q t').2) t 1 := rfl + (1, ∂ₜ q t).2 = fderiv ℝ (fun t' => (tq q t').2) t 1 := by rfl _ = (∂ₜ (tq q) t).2 := by rw [fderiv.snd] · simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.coe_snd'] @@ -158,11 +158,11 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : fun_prop have h_qv_t : qv t = q₀ := by calc - qv t = (q₀ - t.val • v) + t.val • v := rfl + qv t = (q₀ - t.val • v) + t.val • v := by rfl _ = q₀ := by module have h_qv_der : ∂ₜ qv t = v := by calc - ∂ₜ qv t = fderiv ℝ (fun t' => (q₀ - t.val • v) + t'.val • v) t 1 := rfl + ∂ₜ qv t = fderiv ℝ (fun t' => (q₀ - t.val • v) + t'.val • v) t 1 := by rfl _ = v := by rw [fderiv_const_add,fderiv_smul_const] · simp only [ContinuousLinearMap.smulRight_apply, fderiv_val, one_smul] diff --git a/Physlib/CondensedMatter/TightBindingChain/Basic.lean b/Physlib/CondensedMatter/TightBindingChain/Basic.lean index a06b0885a..60bd6a73d 100644 --- a/Physlib/CondensedMatter/TightBindingChain/Basic.lean +++ b/Physlib/CondensedMatter/TightBindingChain/Basic.lean @@ -431,7 +431,7 @@ lemma quantaWaveNumber_exp_sub_one (n : Fin T.N) (k : T.QuantaWaveNumber) : lemma quantaWaveNumber_exp_add_one (n : Fin T.N) (k : T.QuantaWaveNumber) : Complex.exp (Complex.I * k * (n + 1).val * T.a) = Complex.exp (Complex.I * k * n * T.a) * Complex.exp (Complex.I * k * T.a) := by - have hn : n = (n + 1) - 1 := Eq.symm (add_sub_cancel_right n 1) + have hn : n = (n + 1) - 1 := by exact Eq.symm (add_sub_cancel_right n 1) conv_rhs => rw [hn, quantaWaveNumber_exp_sub_one, mul_assoc, ← Complex.exp_add] simp diff --git a/Physlib/Electromagnetism/Distributional/FieldStrength.lean b/Physlib/Electromagnetism/Distributional/FieldStrength.lean index 4c0526df0..ba0f947ef 100644 --- a/Physlib/Electromagnetism/Distributional/FieldStrength.lean +++ b/Physlib/Electromagnetism/Distributional/FieldStrength.lean @@ -232,7 +232,7 @@ noncomputable def fieldStrength {d} : lemma fieldStrength_eq_fieldStrengthAux {d} (A : DistElectromagneticPotential d) (ε : 𝓢(SpaceTime d, ℝ)) : - A.fieldStrength ε = A.fieldStrengthAux ε := rfl + A.fieldStrength ε = A.fieldStrengthAux ε := by rfl /-! ### A.3. Field strength written in terms of a basis diff --git a/Physlib/Electromagnetism/Dynamics/Basic.lean b/Physlib/Electromagnetism/Dynamics/Basic.lean index 2cf4ca05f..513934f8d 100644 --- a/Physlib/Electromagnetism/Dynamics/Basic.lean +++ b/Physlib/Electromagnetism/Dynamics/Basic.lean @@ -102,8 +102,8 @@ lemma c_sq : (𝓕.c : ℝ) ^ 2 = 1 / (𝓕.ε₀ * 𝓕.μ₀) := by · positivity @[simp] -lemma c_abs : abs (𝓕.c : ℝ) = 𝓕.c := - abs_of_pos (SpeedOfLight.val_pos 𝓕.c) +lemma c_abs : abs (𝓕.c : ℝ) = 𝓕.c := by + rw [abs_of_pos (SpeedOfLight.val_pos 𝓕.c)] end FreeSpace diff --git a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean index 7429735a4..a5879a637 100644 --- a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean @@ -80,7 +80,7 @@ noncomputable def chargeDensity (c : SpeedOfLight := 1) fun t x => (1 / (c : ℝ)) * J ((toTimeAndSpace c).symm (t, x)) (Sum.inl 0) lemma chargeDensity_eq_timeSlice {d : ℕ} {c : SpeedOfLight} {J : LorentzCurrentDensity d} : - J.chargeDensity c = timeSlice c (fun x => (1 / (c : ℝ)) • J x (Sum.inl 0)) := rfl + J.chargeDensity c = timeSlice c (fun x => (1 / (c : ℝ)) • J x (Sum.inl 0)) := by rfl /-! @@ -135,7 +135,7 @@ noncomputable def currentDensity (c : SpeedOfLight := 1) (J : LorentzCurrentDens lemma currentDensity_eq_timeSlice {d : ℕ} {J : LorentzCurrentDensity d} : J.currentDensity c = timeSlice c (fun x => WithLp.toLp 2 - fun i => J x (Sum.inr i)) := rfl + fun i => J x (Sum.inr i)) := by rfl /-! diff --git a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean index 73f98f4f7..0f2f984ed 100644 --- a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean @@ -340,7 +340,7 @@ lemma kineticTerm_eq_electricMatrix_magneticFieldMatrix_time_space {𝓕 : FreeS simp only [Fin.isValue, Finset.sum_neg_distrib] have h1 : ∑ i, ∑ j, magneticFieldMatrix 𝓕.c A t x (i, j) ^ 2 = ∑ i, ∑ j, (A.fieldStrengthMatrix ((toTimeAndSpace 𝓕.c).symm (t, x))) - (Sum.inr i, Sum.inr j) ^ 2 := rfl + (Sum.inr i, Sum.inr j) ^ 2 := by rfl rw [h1] ring_nf have h2 : ‖electricField 𝓕.c A t x‖ ^ 2 = 𝓕.c.val ^ 2 * diff --git a/Physlib/Electromagnetism/Dynamics/Lagrangian.lean b/Physlib/Electromagnetism/Dynamics/Lagrangian.lean index 3728da388..eefd5262d 100644 --- a/Physlib/Electromagnetism/Dynamics/Lagrangian.lean +++ b/Physlib/Electromagnetism/Dynamics/Lagrangian.lean @@ -163,8 +163,8 @@ noncomputable def gradFreeCurrentPotential {d} (A : ElectromagneticPotential d) lemma gradFreeCurrentPotential_eq_sum_basis {d} (A : ElectromagneticPotential d) (hA : ContDiff ℝ ∞ A) (J : LorentzCurrentDensity d) (hJ : ContDiff ℝ ∞ J) : - A.gradFreeCurrentPotential J = (∑ μ, fun x => (η μ μ * J x μ) • Lorentz.Vector.basis μ) := - (freeCurrentPotential_hasVarGradientAt A hA J hJ).varGradient + A.gradFreeCurrentPotential J = (∑ μ, fun x => (η μ μ * J x μ) • Lorentz.Vector.basis μ) := by + exact (freeCurrentPotential_hasVarGradientAt A hA J hJ).varGradient lemma gradFreeCurrentPotential_eq_chargeDensity_currentDensity {d} (𝓕 : FreeSpace) (A : ElectromagneticPotential d) @@ -285,8 +285,8 @@ noncomputable def gradLagrangian {d} (𝓕 : FreeSpace) (A : ElectromagneticPote lemma gradLagrangian_eq_kineticTerm_sub {𝓕 : FreeSpace} (A : ElectromagneticPotential d) (hA : ContDiff ℝ ∞ A) (J : LorentzCurrentDensity d) (hJ : ContDiff ℝ ∞ J) : - A.gradLagrangian 𝓕 J = A.gradKineticTerm 𝓕 - A.gradFreeCurrentPotential J := - (lagrangian_hasVarGradientAt_eq_add_gradKineticTerm A hA J hJ).varGradient + A.gradLagrangian 𝓕 J = A.gradKineticTerm 𝓕 - A.gradFreeCurrentPotential J := by + exact (lagrangian_hasVarGradientAt_eq_add_gradKineticTerm A hA J hJ).varGradient /-! diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index 9dabc877d..677cfdb92 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -280,7 +280,7 @@ noncomputable instance {d} : simp smul_add Λ A B := by ext x μ - simp + simp [Lorentz.Vector.smul_add] /-! @@ -319,8 +319,8 @@ lemma differentiable_deriv {d} {A : ElectromagneticPotential d} @[fun_prop] lemma differentiable_deriv_of_smooth {d} {A : ElectromagneticPotential d} (hA : ContDiff ℝ ∞ A) (μ ν : Fin 1 ⊕ Fin d) : - Differentiable ℝ (fun x => ∂_ μ A x ν) := - differentiable_deriv (hA.of_le (ENat.LEInfty.out)) μ ν + Differentiable ℝ (fun x => ∂_ μ A x ν) := by + apply differentiable_deriv (hA.of_le (ENat.LEInfty.out)) μ ν @[fun_prop] lemma contDiff_deriv {n} {d} {A : ElectromagneticPotential d} @@ -345,7 +345,7 @@ lemma differentiable_ofScalarPotential {d} (c : SpeedOfLight) (φ : Time → Spa intro μ match μ with | Sum.inl 0 => fun_prop - | Sum.inr i => fun_prop + | Sum.inr _ => fun_prop lemma contDiff_ofScalarPotential {n} {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (hϕ : ContDiff ℝ n ↿φ) : ContDiff ℝ n (ofScalarPotential c φ) := by @@ -354,7 +354,7 @@ lemma contDiff_ofScalarPotential {n} {d} (c : SpeedOfLight) (φ : Time → Space intro μ match μ with | Sum.inl 0 => fun_prop - | Sum.inr i => fun_prop + | Sum.inr _ => fun_prop lemma differentiable_ofVectorPotential {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) @@ -364,7 +364,7 @@ lemma differentiable_ofVectorPotential {d} (c : SpeedOfLight) intro μ match μ with | Sum.inl 0 => fun_prop - | Sum.inr _ => fun_prop + | Sum.inr i => fun_prop lemma contDiff_ofVectorPotential {n} {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) @@ -374,7 +374,7 @@ lemma contDiff_ofVectorPotential {n} {d} (c : SpeedOfLight) intro μ match μ with | Sum.inl 0 => fun_prop - | Sum.inr _ => fun_prop + | Sum.inr i => fun_prop lemma differentiable_ofPotentials {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) (hϕ : Differentiable ℝ ↿φ) diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index eae09cd4a..a4eeb96ee 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -421,7 +421,7 @@ noncomputable abbrev fieldStrengthMatrix {d} (A : ElectromagneticPotential d) (x lemma fieldStrengthMatrix_eq {d} (A : ElectromagneticPotential d) (x : SpaceTime d) : A.fieldStrengthMatrix x = - (Lorentz.CoVector.basis.tensorProduct Lorentz.Vector.basis).repr (A.toFieldStrength x) := rfl + (Lorentz.CoVector.basis.tensorProduct Lorentz.Vector.basis).repr (A.toFieldStrength x) := by rfl /-- Index evaluation of the field strength tensor agrees with the corresponding component of the field strength matrix. -/ diff --git a/Physlib/Electromagnetism/Kinematics/MagneticField.lean b/Physlib/Electromagnetism/Kinematics/MagneticField.lean index 214feeea6..1d88db0dd 100644 --- a/Physlib/Electromagnetism/Kinematics/MagneticField.lean +++ b/Physlib/Electromagnetism/Kinematics/MagneticField.lean @@ -319,18 +319,18 @@ lemma magneticFieldMatrix_eq_vectorPotential {c : SpeedOfLight} (A : Electromagn lemma magneticFieldMatrix_contDiff {n} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ (n + 1) A) (ij) : - ContDiff ℝ n ↿(fun t x => A.magneticFieldMatrix c t x ij) := - (fieldStrengthMatrix_contDiff hA).comp (toTimeAndSpace c).symm.contDiff + ContDiff ℝ n ↿(fun t x => A.magneticFieldMatrix c t x ij) := by + exact (fieldStrengthMatrix_contDiff hA).comp (toTimeAndSpace c).symm.contDiff lemma magneticFieldMatrix_space_contDiff {n} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ (n + 1) A) (t : Time) (ij) : - ContDiff ℝ n (fun x => A.magneticFieldMatrix c t x ij) := - (magneticFieldMatrix_contDiff A hA ij).comp (f := fun x => (t, x)) (by fun_prop) + ContDiff ℝ n (fun x => A.magneticFieldMatrix c t x ij) := by + exact (magneticFieldMatrix_contDiff A hA ij).comp (f := fun x => (t, x)) (by fun_prop) lemma magneticFieldMatrix_time_contDiff {n} {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ (n + 1) A) (x : Space d) (ij) : - ContDiff ℝ n (fun t => A.magneticFieldMatrix c t x ij) := - (magneticFieldMatrix_contDiff A hA ij).comp (f := fun t => (t, x)) (by fun_prop) + ContDiff ℝ n (fun t => A.magneticFieldMatrix c t x ij) := by + exact (magneticFieldMatrix_contDiff A hA ij).comp (f := fun t => (t, x)) (by fun_prop) /-! @@ -339,18 +339,18 @@ lemma magneticFieldMatrix_time_contDiff {n} {c : SpeedOfLight} (A : Electromagne -/ lemma magneticFieldMatrix_differentiable {c : SpeedOfLight} (A : ElectromagneticPotential d) - (hA : ContDiff ℝ 2 A) (ij) : Differentiable ℝ ↿(fun t x => A.magneticFieldMatrix c t x ij) := - (fieldStrengthMatrix_differentiable hA).comp (toTimeAndSpace c).symm.differentiable + (hA : ContDiff ℝ 2 A) (ij) : Differentiable ℝ ↿(fun t x => A.magneticFieldMatrix c t x ij) := by + exact (fieldStrengthMatrix_differentiable hA).comp (toTimeAndSpace c).symm.differentiable lemma magneticFieldMatrix_differentiable_space {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ 2 A) (t : Time) (ij) : - Differentiable ℝ (fun x => A.magneticFieldMatrix c t x ij) := - (magneticFieldMatrix_differentiable A hA ij).comp (f := fun x => (t, x)) (by fun_prop) + Differentiable ℝ (fun x => A.magneticFieldMatrix c t x ij) := by + exact (magneticFieldMatrix_differentiable A hA ij).comp (f := fun x => (t, x)) (by fun_prop) lemma magneticFieldMatrix_differentiable_time {c : SpeedOfLight} (A : ElectromagneticPotential d) (hA : ContDiff ℝ 2 A) (x : Space d) (ij) : - Differentiable ℝ (fun t => A.magneticFieldMatrix c t x ij) := - (magneticFieldMatrix_differentiable A hA ij).comp (f := fun t => (t, x)) (by fun_prop) + Differentiable ℝ (fun t => A.magneticFieldMatrix c t x ij) := by + exact (magneticFieldMatrix_differentiable A hA ij).comp (f := fun t => (t, x)) (by fun_prop) /-! diff --git a/Physlib/FluidDynamics/NavierStokes/Basic.lean b/Physlib/FluidDynamics/NavierStokes/Basic.lean index a309beebe..89fa5e940 100644 --- a/Physlib/FluidDynamics/NavierStokes/Basic.lean +++ b/Physlib/FluidDynamics/NavierStokes/Basic.lean @@ -67,12 +67,12 @@ theorem navierStokes_iff_convectiveNavierStokes NavierStokes d data ↔ ConvectiveNavierStokes d data := by constructor · intro hConservative - exact ⟨hConservative.1, - (FluidDynamics.NavierStokes.momentumEquation_iff_convectiveMomentumEquation d data - hConservative.1 hRhoTime hVelocityTime hMomentumDensity hVelocitySpace).mp hConservative.2⟩ + refine ⟨hConservative.1, ?_⟩ + exact (FluidDynamics.NavierStokes.momentumEquation_iff_convectiveMomentumEquation d data + hConservative.1 hRhoTime hVelocityTime hMomentumDensity hVelocitySpace).mp hConservative.2 · intro hConvective - exact ⟨hConvective.1, - (FluidDynamics.NavierStokes.momentumEquation_iff_convectiveMomentumEquation d data - hConvective.1 hRhoTime hVelocityTime hMomentumDensity hVelocitySpace).mpr hConvective.2⟩ + refine ⟨hConvective.1, ?_⟩ + exact (FluidDynamics.NavierStokes.momentumEquation_iff_convectiveMomentumEquation d data + hConvective.1 hRhoTime hVelocityTime hMomentumDensity hVelocitySpace).mpr hConvective.2 end FluidDynamics diff --git a/Physlib/Mathematics/Calculus/AdjFDeriv.lean b/Physlib/Mathematics/Calculus/AdjFDeriv.lean index dc4311ba5..bb4991bd1 100644 --- a/Physlib/Mathematics/Calculus/AdjFDeriv.lean +++ b/Physlib/Mathematics/Calculus/AdjFDeriv.lean @@ -144,8 +144,8 @@ lemma adjFDeriv_id : adjFDeriv 𝕜 (fun x : E => x) = fun _ dx => dx := by funext x rw[HasAdjFDerivAt.adjFDeriv (hasAdjFDerivAt_id x)] -lemma adjFDeriv_id' : adjFDeriv 𝕜 (id : E → E) = fun _ dx => dx := - adjFDeriv_id +lemma adjFDeriv_id' : adjFDeriv 𝕜 (id : E → E) = fun _ dx => dx := by + exact adjFDeriv_id lemma hasAdjFDerivAt_const (x : E) (y : F) : HasAdjFDerivAt 𝕜 (fun _ : E => y) (fun _ => 0) x where diff --git a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean index 400f8e7f9..36271a94d 100644 --- a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean +++ b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean @@ -133,8 +133,8 @@ lemma exp_series_diag_term_eq {A : Matrix m m 𝕂} (hA : BlockTriangular A id) /-- The diagonal of the matrix exponential series equals the scalar exponential series -/ lemma matrix_exp_series_diag_eq_scalar_series {A : Matrix m m 𝕂} (hA : BlockTriangular A id) (i : m) : - (∑' n, ((n.factorial : 𝕂)⁻¹ • (A ^ n)) i i) = ∑' n, (n.factorial : 𝕂)⁻¹ • (A i i) ^ n := - tsum_congr (exp_series_diag_term_eq hA · i) + (∑' n, ((n.factorial : 𝕂)⁻¹ • (A ^ n)) i i) = ∑' n, (n.factorial : 𝕂)⁻¹ • (A i i) ^ n := by + exact tsum_congr (exp_series_diag_term_eq hA · i) /-- The diagonal of the exponential of an upper-triangular matrix `A` consists of the exponentials of the diagonal entries of `A`. -/ @@ -241,8 +241,8 @@ lemma exp_map_algebraMap {n : Type*} [Fintype n] [DecidableEq n] letI : NormedAlgebra ℂ (Matrix n n ℂ) := Matrix.linftyOpNormedAlgebra letI : CompleteSpace (Matrix n n ℂ) := inferInstance simp only [exp_eq_tsum ℝ] - have hs : Summable (fun k => (k.factorial : ℝ)⁻¹ • A ^ k) := - NormedSpace.expSeries_summable' A + have hs : Summable (fun k => (k.factorial : ℝ)⁻¹ • A ^ k) := by + exact NormedSpace.expSeries_summable' A erw [Matrix.map_tsum (algebraMap ℝ ℂ).toAddMonoidHom RCLike.continuous_ofReal hs] apply tsum_congr intro k diff --git a/Physlib/Mathematics/Distribution/Basic.lean b/Physlib/Mathematics/Distribution/Basic.lean index 5993ad028..2f6b8201c 100644 --- a/Physlib/Mathematics/Distribution/Basic.lean +++ b/Physlib/Mathematics/Distribution/Basic.lean @@ -238,8 +238,8 @@ def fderivD [FiniteDimensional ℝ E] : (E →d[𝕜] F) →ₗ[𝕜] (E →d[ simp lemma fderivD_apply [FiniteDimensional ℝ E] (u : E →d[𝕜] F) (η : 𝓢(E, 𝕜)) (v : E) : - fderivD 𝕜 u η v = - - u (SchwartzMap.evalCLM (𝕜 := 𝕜) E 𝕜 v (SchwartzMap.fderivCLM 𝕜 E 𝕜 η)) := rfl + fderivD 𝕜 u η v = - u (SchwartzMap.evalCLM (𝕜 := 𝕜) E 𝕜 v (SchwartzMap.fderivCLM 𝕜 E 𝕜 η)) := by + rfl TODO "For distributions, prove that the derivative fderivD commutes with integrals and sums. This may require defining the integral of families of distributions @@ -349,7 +349,7 @@ def const [hμ : Measure.HasTemperateGrowth (volume (α := E))] (c : F) : E →d lemma const_apply [hμ : Measure.HasTemperateGrowth (volume (α := E))] (c : F) (η : 𝓢(E, 𝕜)) : - const 𝕜 E c η = ∫ x, η x • c ∂MeasureTheory.volume := rfl + const 𝕜 E c η = ∫ x, η x • c ∂MeasureTheory.volume := by rfl end section diff --git a/Physlib/Mathematics/FDerivCurry.lean b/Physlib/Mathematics/FDerivCurry.lean index 203a669d3..225ca965b 100644 --- a/Physlib/Mathematics/FDerivCurry.lean +++ b/Physlib/Mathematics/FDerivCurry.lean @@ -24,8 +24,8 @@ lemma fderiv_uncurry (f : X → Y → Z) (xy dxy : X × Y) fderiv 𝕜 ↿f xy dxy = fderiv 𝕜 (f · xy.2) xy.1 dxy.1 + fderiv 𝕜 (f xy.1 ·) xy.2 dxy.2 := by - have hx : (f · xy.2) = ↿f ∘ (fun x' => (x',xy.2)) := rfl - have hy : (f xy.1 ·) = ↿f ∘ (fun y' => (xy.1,y')) := rfl + have hx : (f · xy.2) = ↿f ∘ (fun x' => (x',xy.2)) := by rfl + have hy : (f xy.1 ·) = ↿f ∘ (fun y' => (xy.1,y')) := by rfl rw [hx,hy] repeat rw [fderiv_comp (hg := by fun_prop) (hf := by fun_prop)] dsimp diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index cc621c151..4211e20c0 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -218,7 +218,7 @@ lemma finExtractTwo_symm_inl_inr_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin @[simp] lemma finExtractTwo_symm_inl_inl_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : - (finExtractTwo i j).symm (Sum.inl (Sum.inl 0)) = i := rfl + (finExtractTwo i j).symm (Sum.inl (Sum.inl 0)) = i := by rfl @[simp] lemma finExtractTwo_apply_snd {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : diff --git a/Physlib/Mathematics/Fin/Involutions.lean b/Physlib/Mathematics/Fin/Involutions.lean index 96a1caf24..c65067e45 100644 --- a/Physlib/Mathematics/Fin/Involutions.lean +++ b/Physlib/Mathematics/Fin/Involutions.lean @@ -332,8 +332,8 @@ def involutionNoFixedSetOne {n : ℕ} : have hf' (i : Fin n) : f' i ≠ 0 := (f_succ_succ_ne_zero_one i).1 let f'' := fun i => (f' i).pred (hf' i) have hf'' (i : Fin n) : f'' i ≠ 0 := by - simpa [f'', f', ne_eq, Fin.pred_eq_iff_eq_succ, Fin.succ_zero_eq_one] using - (f_succ_succ_ne_zero_one i).2 + rw [ne_eq, Fin.pred_eq_iff_eq_succ, Fin.succ_zero_eq_one] + exact (f_succ_succ_ne_zero_one i).2 let f''' := fun i => (f'' i).pred (hf'' i) refine ⟨f''', ?_, ?_⟩ · intro i diff --git a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean index 0db0ba85f..ef6aeef83 100644 --- a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean @@ -343,7 +343,7 @@ def flat (g : PseudoRiemannianMetric E H M n I) (x : M) : @[simp] lemma flat_apply (g : PseudoRiemannianMetric E H M n I) (x : M) (v w : TangentSpace I x) : - (flat g x v) w = g.val x v w := rfl + (flat g x v) w = g.val x v w := by rfl /-- The musical isomorphism as a continuous linear map. -/ def flatL (g : PseudoRiemannianMetric E H M n I) (x : M) : diff --git a/Physlib/Mathematics/InnerProductSpace/Basic.lean b/Physlib/Mathematics/InnerProductSpace/Basic.lean index 4b671692e..f71dcb65e 100644 --- a/Physlib/Mathematics/InnerProductSpace/Basic.lean +++ b/Physlib/Mathematics/InnerProductSpace/Basic.lean @@ -220,13 +220,13 @@ def fromL2 : WithLp 2 E →L[𝕜] E where lemma fromL2_inner_left (x : WithLp 2 E) (y : E) : ⟪fromL2 𝕜 x, y⟫ = ⟪x, toL2 𝕜 y⟫ := rfl -lemma ofLp_inner_left (x : E) (y : WithLp 2 E) : ⟪WithLp.ofLp y, x⟫ = ⟪y, WithLp.toLp 2 x⟫ := - fromL2_inner_left y x +lemma ofLp_inner_left (x : E) (y : WithLp 2 E) : ⟪WithLp.ofLp y, x⟫ = ⟪y, WithLp.toLp 2 x⟫ := by + exact fromL2_inner_left y x lemma toL2_inner_left (x : E) (y : WithLp 2 E) : ⟪toL2 𝕜 x, y⟫ = ⟪x, fromL2 𝕜 y⟫ := rfl -lemma toLp_inner_left (x : WithLp 2 E) (y : E) : ⟪WithLp.toLp 2 y, x⟫ = ⟪y, WithLp.ofLp x⟫ := - toL2_inner_left y x +lemma toLp_inner_left (x : WithLp 2 E) (y : E) : ⟪WithLp.toLp 2 y, x⟫ = ⟪y, WithLp.ofLp x⟫ := by + exact toL2_inner_left y x @[simp] lemma toL2_fromL2 (x : WithLp 2 E) : toL2 𝕜 (fromL2 𝕜 x) = x := rfl diff --git a/Physlib/Mathematics/InnerProductSpace/Submodule.lean b/Physlib/Mathematics/InnerProductSpace/Submodule.lean index eaf4dfd79..09f27f89c 100644 --- a/Physlib/Mathematics/InnerProductSpace/Submodule.lean +++ b/Physlib/Mathematics/InnerProductSpace/Submodule.lean @@ -61,9 +61,9 @@ lemma submoduleToLp_closure : · intro h t ht apply mem_nhds_iff.mp at ht rcases ht with ⟨t1, ht1, ht1', hx⟩ - have : ∃ t' ∈ nhds x, (∀ y ∈ t', y.ofLp ∈ t1) := - Filter.eventually_iff_exists_mem.mp - (ContinuousAt.eventually_mem (by fun_prop) (IsOpen.mem_nhds ht1' hx)) + have : ∃ t' ∈ nhds x, (∀ y ∈ t', y.ofLp ∈ t1) := by + refine Filter.eventually_iff_exists_mem.mp ?_ + exact ContinuousAt.eventually_mem (by fun_prop) (IsOpen.mem_nhds ht1' hx) rcases this with ⟨t2, ht2, ht2'⟩ rcases h t2 ht2 with ⟨w, hw⟩ use w.ofLp diff --git a/Physlib/Mathematics/LinearMaps.lean b/Physlib/Mathematics/LinearMaps.lean index 118c410c5..fca70f242 100644 --- a/Physlib/Mathematics/LinearMaps.lean +++ b/Physlib/Mathematics/LinearMaps.lean @@ -190,7 +190,7 @@ def mk₃ (f : V × V × V→ ℚ) (map_smul : ∀ a S T L, f (a • S, T, L) = (by intro S1 S2 T rw [swap₁, map_add, swap₁, swap₁ S2 S T]) - (fun L T ↦ swap₂ S L T)).toLinearMap + (by exact fun L T ↦ swap₂ S L T)).toLinearMap map_add' S1 S2 := LinearMap.ext fun T ↦ LinearMap.ext fun L => map_add S1 S2 T L map_smul' a S := LinearMap.ext fun T => LinearMap.ext fun L => map_smul a S T L diff --git a/Physlib/Mathematics/List.lean b/Physlib/Mathematics/List.lean index f642c8e32..bb2ead5b4 100644 --- a/Physlib/Mathematics/List.lean +++ b/Physlib/Mathematics/List.lean @@ -186,8 +186,8 @@ lemma orderedInsertPos_drop_eq_orderedInsert {I : Type} (le1 : I → I → Prop) List.drop (orderedInsertPos le1 r r0).succ (List.orderedInsert le1 r0 r) := by conv_rhs => simp [orderedInsertPos, List.orderedInsert_eq_take_drop] have hr : r = List.takeWhile (fun b => !decide (le1 r0 b)) r ++ - List.dropWhile (fun b => !decide (le1 r0 b)) r := - Eq.symm (List.takeWhile_append_dropWhile) + List.dropWhile (fun b => !decide (le1 r0 b)) r := by + exact Eq.symm (List.takeWhile_append_dropWhile) conv_lhs => rhs rw [hr] diff --git a/Physlib/Mathematics/List/InsertIdx.lean b/Physlib/Mathematics/List/InsertIdx.lean index 5ec53f7a2..044eb9302 100644 --- a/Physlib/Mathematics/List/InsertIdx.lean +++ b/Physlib/Mathematics/List/InsertIdx.lean @@ -98,7 +98,7 @@ lemma insertIdx_length_fin {I : Type} (i : I) : lemma insertIdx_getElem_fin {I : Type} (i : I) : (r : List I) → (k : Fin r.length.succ) → (m : Fin r.length) → (List.insertIdx r k i)[(k.succAbove m).val] = r[m.val] - | [], 0, m => Fin.elim0 m + | [], 0, m => by exact Fin.elim0 m | a :: as, 0, m => by simp | a :: as, ⟨n + 1, h⟩, ⟨0, h0⟩ => by simp [Fin.succAbove, Fin.lt_def] @@ -116,7 +116,7 @@ lemma insertIdx_getElem_fin {I : Type} (i : I) : lemma insertIdx_eraseIdx_fin {I : Type} : (r : List I) → (k : Fin r.length) → (List.eraseIdx r k).insertIdx k r[k] = r - | [], k => Fin.elim0 k + | [], k => by exact Fin.elim0 k | a :: as, ⟨0, h⟩ => by simp | a :: as, ⟨n + 1, h⟩ => by simp only [List.length_cons, Fin.getElem_fin, List.getElem_cons_succ, List.eraseIdx_cons_succ, @@ -186,8 +186,8 @@ lemma take_insert_let {I : Type} (i : I) : simp at hm | n + 1, m + 1, h, a::as, hm => by simp only [List.insertIdx_succ_cons, List.take_succ_cons] - have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := - List.Perm.swap a i (List.take n as) + have hp : (i :: a :: List.take n as).Perm (a :: i :: List.take n as) := by + exact List.Perm.swap a i (List.take n as) refine List.Perm.trans ?_ hp.symm refine List.Perm.cons a ?_ exact take_insert_let i n m (Nat.le_of_succ_le_succ h) as (Nat.le_of_succ_le_succ hm) diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index 2df2d97ba..1dae13dd6 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -294,8 +294,8 @@ lemma insertionSortEquiv_orderedInsert_append {α : Type} (r : α → α → Pro conv_lhs => simp [insertionSortEquiv] rw [insertionSortEquiv_orderedInsert_append r a] have hl : (List.insertionSort r (List.orderedInsert r a l1 ++ a2 :: l2)) = - List.insertionSort r (a :: l1 ++ a2 :: l2) := - insertionSort_orderedInsert_append r a l1 (a2 :: l2) + List.insertionSort r (a :: l1 ++ a2 :: l2) := by + exact insertionSort_orderedInsert_append r a l1 (a2 :: l2) rw [orderedInsertEquiv_congr _ _ _ hl] conv_lhs => enter [2, 1, 2, 1] @@ -331,8 +331,8 @@ lemma insertionSortEquiv_insertionSort_append {α : Type} (r : α → α → Pro equivCons_succ] erw [ih] have hl : (List.insertionSort r (List.insertionSort r l1 ++ a :: l2)) = - (List.insertionSort r (l1 ++ a :: l2)) := - insertionSort_insertionSort_append r l1 (a :: l2) + (List.insertionSort r (l1 ++ a :: l2)) := by + exact insertionSort_insertionSort_append r l1 (a :: l2) erw [orderedInsertEquiv_congr _ _ _ hl] simp only [List.foldr_cons, finCongr_apply] rfl @@ -379,8 +379,8 @@ lemma orderedInsert_filter_of_pos {α : Type} (r : α → α → Prop) [Decidabl simp only [List.pairwise_cons] at hl apply hl.1 have hlf : (List.filter (fun b => decide (p b)) l)[0] ∈ - (List.filter (fun b => decide (p b)) l) := - List.getElem_mem c + (List.filter (fun b => decide (p b)) l) := by + exact List.getElem_mem c simp only [List.mem_filter, decide_eq_true_eq] at hlf exact hlf.1 rw [hl] @@ -505,7 +505,7 @@ lemma filter_rel_eq_insertionSort {α : Type} (r : α → α → Prop) [Decidabl simp only [List.insertionSort] by_cases h : r a b ∧ r b a · have hl := orderedInsert_filter_of_pos r b (fun c => r a c ∧ r c a) h - (List.insertionSort r l) (List.pairwise_insertionSort r l) + (List.insertionSort r l) (by exact List.pairwise_insertionSort r l) simp only [Bool.decide_and] at hl ⊢ erw [hl] rw [List.orderedInsert_eq_take_drop] diff --git a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean index 61d76d42f..9692646e5 100644 --- a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean +++ b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean @@ -481,8 +481,8 @@ lemma cos_mem_physHermite_span_topologicalClosure (c : ℝ) : simp only [HasSum] at h1 have h1 : Filter.Tendsto (fun s => fun y => ∑ x ∈ s, (-1) ^ x * (c * y) ^ (2 * x) / ((2 * x)! : ℝ)) - Filter.atTop (nhds (fun x => Real.cos (c * x))) := - tendsto_pi_nhds.mpr fun x => h1 (c * x) + Filter.atTop (nhds (fun x => Real.cos (c * x))) := by + exact tendsto_pi_nhds.mpr fun x => h1 (c * x) have h2 (z : Finset ℕ) : (fun y => ∑ x ∈ z, (-1) ^ x * (c * y) ^ (2 * x) / ↑(2 * x)!) ∈ ↑(Submodule.span ℝ (Set.range (fun n => (physHermite n : ℝ → ℝ)))) := by have h0 : (fun y => ∑ x ∈ z, (-1) ^ x * (c * y) ^ (2 * x) / ↑(2 * x)!) = diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index 917312547..cb28adaf7 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -66,8 +66,8 @@ lemma apply_smooth_of_smooth {F : (X → U) → (X → V)} {F' : (X → V) → ( fun_prop lemma apply_smooth_self {F : (X → U) → (X → V)} {F' : (X → V) → (X → U)} {u : X → U} - (h : HasVarAdjDerivAt F F' u) : ContDiff ℝ ∞ (F u) := - h.apply_smooth_of_smooth (h.smooth_at) + (h : HasVarAdjDerivAt F F' u) : ContDiff ℝ ∞ (F u) := by + exact h.apply_smooth_of_smooth (h.smooth_at) lemma smooth_R {F : (X → U) → (X → V)} {F' : (X → V) → (X → U)} {u : X → U} (h : HasVarAdjDerivAt F F' u) {φ : ℝ → X → U} (hφ : ContDiff ℝ ∞ ↿φ) (x : X) : @@ -96,8 +96,8 @@ lemma smooth_adjoint {F : (X → U) → (X → V)} {F' : (X → V) → (X → U) lemma differentiable_linear {F : (X → U) → (X → V)} {F' : (X → V) → (X → U)} {u : X → U} (h : HasVarAdjDerivAt F F' u) {φ : ℝ → X → U} (hφ : ContDiff ℝ ∞ ↿φ) (x : X) : - Differentiable ℝ (fun s' : ℝ => F (fun x => φ 0 x + s' • deriv (φ · x) 0) x) := - fun x => (h.smooth_linear hφ).differentiable (by simp) x + Differentiable ℝ (fun s' : ℝ => F (fun x => φ 0 x + s' • deriv (φ · x) 0) x) := by + exact fun x => (h.smooth_linear hφ).differentiable (by simp) x omit [MeasureSpace X] [InnerProductSpace' ℝ U] [InnerProductSpace' ℝ V] in lemma linearize_of_linear {F : (X → U) → (X → V)} diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean index f02f60995..d9d9e2ee3 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean @@ -512,8 +512,8 @@ lemma adjFDeriv_apply rw [(DifferentiableAt.hasAdjFDerivAt (hφ.differentiable y)).hasAdjoint_fderiv.adjoint_inner_left] _ = ∑ i, ∫ (y : X), bX.repr (ψ y) i * fderiv ℝ (fun y' => ⟪dy, φ y' ⟫_ℝ) y (bX i) := by - have h (y : X) : ψ y = ∑ i, bX.repr (ψ y) i • bX i := - Eq.symm (Basis.sum_equivFun bX (ψ y)) + have h (y : X) : ψ y = ∑ i, bX.repr (ψ y) i • bX i := by + exact Eq.symm (Basis.sum_equivFun bX (ψ y)) conv_lhs => enter [2, y] rw [h] diff --git a/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean b/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean index 54a7a8eb3..3f9345b23 100644 --- a/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean +++ b/Physlib/Mathematics/VariationalCalculus/IsLocalizedfunctionTransform.lean @@ -135,8 +135,8 @@ lemma div {d} : IsLocalizedFunctionTransform fun (φ : Space d → EuclideanSpac (fun x => (φ x) i) =ᶠ[nhds x] fun x => (φ' x) i := by intro i x hx apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · exact Metric.isOpen_thickening.mem_nhds - (Metric.self_subset_thickening one_pos K hx) + · apply Metric.isOpen_thickening.mem_nhds + exact Metric.self_subset_thickening one_pos K hx · intro y hy dsimp only rw [hφ y (Metric.thickening_subset_cthickening 1 K hy)] @@ -156,8 +156,8 @@ lemma div_comp_repr {d} : IsLocalizedFunctionTransform fun (φ : Space d → Spa (fun x => (φ x) i) =ᶠ[nhds x] fun x => (φ' x) i := by intro i x hx apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · exact Metric.isOpen_thickening.mem_nhds - (Metric.self_subset_thickening one_pos K hx) + · apply Metric.isOpen_thickening.mem_nhds + exact Metric.self_subset_thickening one_pos K hx · intro y hy dsimp only rw [hφ y (Metric.thickening_subset_cthickening 1 K hy)] @@ -179,8 +179,8 @@ lemma grad : IsLocalizedFunctionTransform fun (ψ : Space d → ℝ) x => Space. congr 2 have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · exact Metric.isOpen_thickening.mem_nhds - (Metric.self_subset_thickening one_pos K hx) + · apply Metric.isOpen_thickening.mem_nhds + exact Metric.self_subset_thickening one_pos K hx · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) exact Filter.EventuallyEq.fderiv_eq h @@ -198,8 +198,8 @@ lemma gradient : IsLocalizedFunctionTransform fun (ψ : Space d → ℝ) x => gr congr 2 have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · exact Metric.isOpen_thickening.mem_nhds - (Metric.self_subset_thickening one_pos K hx) + · apply Metric.isOpen_thickening.mem_nhds + exact Metric.self_subset_thickening one_pos K hx · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) exact Filter.EventuallyEq.fderiv_eq h @@ -219,8 +219,8 @@ lemma deriv [NormedAddCommGroup U] [NormedSpace ℝ U] : dsimp have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · exact Metric.isOpen_thickening.mem_nhds - (Metric.self_subset_thickening one_pos K hx) + · apply Metric.isOpen_thickening.mem_nhds + exact Metric.self_subset_thickening one_pos K hx · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) exact h.deriv_eq @@ -236,8 +236,8 @@ lemma fderiv [NormedAddCommGroup U] [NormedSpace ℝ U] dsimp; congr 1 have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · exact Metric.isOpen_thickening.mem_nhds - (Metric.self_subset_thickening one_pos K hx) + · apply Metric.isOpen_thickening.mem_nhds + exact Metric.self_subset_thickening one_pos K hx · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) rw [Filter.EventuallyEq.fderiv_eq h] @@ -282,8 +282,8 @@ lemma adjFDeriv {dy} [NormedSpace ℝ X] [ProperSpace X] simp only [DFunLike.coe_fn_eq] have h : φ =ᶠ[nhds x] φ' := by apply Filter.eventuallyEq_of_mem (s := Metric.thickening 1 K) - · exact Metric.isOpen_thickening.mem_nhds - (Metric.self_subset_thickening one_pos K hx) + · apply Metric.isOpen_thickening.mem_nhds + exact Metric.self_subset_thickening one_pos K hx · intro y hy exact hφ y (Metric.thickening_subset_cthickening 1 K hy) exact Filter.EventuallyEq.fderiv_eq h diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean index 0f0acdf23..8fb0b8bcd 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean @@ -66,8 +66,8 @@ lemma quadSol (S : (PlusU1 n).QuadSols) : accQuad S.val = 0 := by simp only [PlusU1_quadraticACCs] at hS exact hS ⟨0, by simp⟩ -lemma cubeSol (S : (PlusU1 n).Sols) : accCube S.val = 0 := - S.cubicSol +lemma cubeSol (S : (PlusU1 n).Sols) : accCube S.val = 0 := by + exact S.cubicSol /-- An element of `charges` which satisfies the linear ACCs gives us a element of `LinSols`. -/ diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index a0f7efd39..bfddec06f 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -49,17 +49,17 @@ def toSpeciesEquiv : (SMCharges n).Charges ≃ (Fin 5 → Fin (SMSpecies n).numb @[simps!] def toSpecies (i : Fin 5) : (SMCharges n).Charges →ₗ[ℚ] (SMSpecies n).Charges where toFun S := toSpeciesEquiv S i - map_add' _ _ := rfl - map_smul' _ _ := rfl + map_add' _ _ := by rfl + map_smul' _ _ := by rfl lemma toSpecies_apply_eq (i : Fin 5) (S : (SMCharges n).Charges) : - toSpecies i S = fun j => toSpeciesEquiv S i j := rfl + toSpecies i S = fun j => toSpeciesEquiv S i j := by rfl lemma charges_eq_toSpecies_eq (S T : (SMCharges n).Charges) : - S = T ↔ ∀ i, toSpecies i S = toSpecies i T := - Iff.intro (fun a i => congrArg (⇑(toSpecies i)) a) fun h => - toSpeciesEquiv.injective - ((Set.eqOn_univ (toSpeciesEquiv S) (toSpeciesEquiv T)).mp fun ⦃x⦄ _ => h x) + S = T ↔ ∀ i, toSpecies i S = toSpecies i T := by + refine Iff.intro (fun a i => congrArg (⇑(toSpecies i)) a) (fun h => ?_) + apply toSpeciesEquiv.injective + exact (Set.eqOn_univ (toSpeciesEquiv S) (toSpeciesEquiv T)).mp fun ⦃x⦄ _ => h x lemma toSMSpecies_toSpecies_inv (i : Fin 5) (f : Fin 5 → Fin n → ℚ) : (toSpecies i) (toSpeciesEquiv.symm f) = f i := by diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean index 3201fe0b4..cc6ee4f0d 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean @@ -303,7 +303,7 @@ lemma cubic (S : linearParametersQENeqZero) : lemma cubic_v_or_w_zero (S : linearParametersQENeqZero) (h : accCube (bijection S).1.val = 0) : S.v = 0 ∨ S.w = 0 := by rw [S.cubic] at h - have h1 : (-1)^3 = (-1 : ℚ) := rfl + have h1 : (-1)^3 = (-1 : ℚ) := by rfl rw [← h1] at h by_contra hn rw [not_or] at hn diff --git a/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean b/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean index 5ab279b1f..d0dc88789 100644 --- a/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean +++ b/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean @@ -77,10 +77,10 @@ lemma toFun_neg (φ : HiggsField) (x : SpaceTime) : P.neg.toFun φ x = - P.toFun ring @[simp] -lemma μ2_neg : P.neg.μ2 = - P.μ2 := rfl +lemma μ2_neg : P.neg.μ2 = - P.μ2 := by rfl @[simp] -lemma 𝓵_neg : P.neg.𝓵 = - P.𝓵 := rfl +lemma 𝓵_neg : P.neg.𝓵 = - P.𝓵 := by rfl /-! diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean index b53ac86ae..b69a5c1cd 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean @@ -75,8 +75,8 @@ corresponding SM species of charges. -/ @[simps!] def toSMSpecies (i : Fin 6) : MSSMCharges.Charges →ₗ[ℚ] MSSMSpecies.Charges where toFun S := (Prod.fst ∘ toSpecies) S i - map_add' _ _ := rfl - map_smul' _ _ := rfl + map_add' _ _ := by rfl + map_smul' _ _ := by rfl lemma toSMSpecies_toSpecies_inv (i : Fin 6) (f : (Fin 6 → Fin 3 → ℚ) × (Fin 2 → ℚ)) : (toSMSpecies i) (toSpecies.symm f) = f.1 i := by @@ -100,15 +100,15 @@ abbrev N := toSMSpecies 5 @[simps!] def Hd : MSSMCharges.Charges →ₗ[ℚ] ℚ where toFun S := S ⟨18, Nat.lt_of_sub_eq_succ rfl⟩ - map_add' _ _ := rfl - map_smul' _ _ := rfl + map_add' _ _ := by rfl + map_smul' _ _ := by rfl /-- The charge `Hu`. -/ @[simps!] def Hu : MSSMCharges.Charges →ₗ[ℚ] ℚ where toFun S := S ⟨19, Nat.lt_of_sub_eq_succ rfl⟩ - map_add' _ _ := rfl - map_smul' _ _ := rfl + map_add' _ _ := by rfl + map_smul' _ _ := by rfl lemma charges_eq_toSpecies_eq (S T : MSSMCharges.Charges) : S = T ↔ (∀ i, toSMSpecies i S = toSMSpecies i T) ∧ Hd S = Hd T ∧ Hu S = Hu T := by diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean index d17c4057a..6769f8402 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean @@ -173,8 +173,8 @@ lemma minimallyAllowsTerm_iff_powerset_countP_eq_one : simp · intro h have h1 : (Multiset.filter (fun y => y.AllowsTerm T) x.powerset.val).card = 1 := by - simpa [h] using - Eq.symm (Multiset.countP_eq_card_filter (fun y => y.AllowsTerm T) x.powerset.val) + rw [← h] + exact Eq.symm (Multiset.countP_eq_card_filter (fun y => y.AllowsTerm T) x.powerset.val) rw [Multiset.card_eq_one] at h1 obtain ⟨a, ha⟩ := h1 have haMem : a ∈ Multiset.filter (fun y => y.AllowsTerm T) x.powerset.val := by diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/OfFinset.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/OfFinset.lean index 770d182a9..9a42d6399 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/OfFinset.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/OfFinset.lean @@ -180,8 +180,8 @@ lemma mem_toMultisetsThree_iff [DecidableEq 𝓩] {s : Finset 𝓩} (X : Multise simpa using hsub · right simp [@Finset.insert_subset_iff] at hsub - exact ⟨c, hsub.2, a, (Multiset.mem_erase_of_ne hac).mpr hsub.1, - congrArg (a ::ₘ ·) (Multiset.pair_comm c a)⟩ + refine ⟨c, hsub.2, a, (Multiset.mem_erase_of_ne hac).mpr hsub.1, ?_⟩ + exact congrArg (a ::ₘ ·) (Multiset.pair_comm c a) · rw [or_assoc] right by_cases hac : a = c @@ -193,8 +193,8 @@ lemma mem_toMultisetsThree_iff [DecidableEq 𝓩] {s : Finset 𝓩} (X : Multise · subst hbc left simp [@Finset.insert_subset_iff] at hsub - exact ⟨a, hsub.1, b, (Multiset.mem_erase_of_ne (Ne.symm hac)).mpr hsub.2, - Multiset.cons_swap b a {b}⟩ + refine ⟨a, hsub.1, b, (Multiset.mem_erase_of_ne (Ne.symm hac)).mpr hsub.2, ?_⟩ + exact Multiset.cons_swap b a {b} · right refine (Multiset.le_iff_subset ?_).mpr ?_ · simpa using ⟨⟨hab, hac⟩, hbc⟩ diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean index f3efe403a..50135936b 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoClosed.lean @@ -230,9 +230,9 @@ def completeMinSubset (S5 S10 : Finset 𝓩) : Multiset (ChargeSpectrum 𝓩) := lemma completeMinSubset_nodup {S5 S10 : Finset 𝓩} : (completeMinSubset S5 S10).Nodup := by simp [completeMinSubset] - exact Multiset.Nodup.filter _ - (Multiset.nodup_dedup - ((minimallyAllowsTermsOfFinset S5 S10 topYukawa).bind (completionsTopYukawa S5))) + apply Multiset.Nodup.filter + exact Multiset.nodup_dedup + ((minimallyAllowsTermsOfFinset S5 S10 topYukawa).bind (completionsTopYukawa S5)) /-! diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 9d1fe6cf3..65f67b7ee 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -744,8 +744,8 @@ lemma superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic (φs φs' : Lis lemma superCommuteF_ofCrAnOpF_ofCrAnOpF_bosonic_or_fermionic (φ φ' : 𝓕.CrAnFieldOp) : [ofCrAnOpF φ, ofCrAnOpF φ']ₛF ∈ statisticSubmodule bosonic ∨ [ofCrAnOpF φ, ofCrAnOpF φ']ₛF ∈ statisticSubmodule fermionic := by - simpa [ofCrAnListF_singleton] using - superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic [φ] [φ'] + rw [← ofCrAnListF_singleton, ← ofCrAnListF_singleton] + exact superCommuteF_ofCrAnListF_ofCrAnListF_bosonic_or_fermionic [φ] [φ'] lemma superCommuteF_superCommuteF_ofCrAnOpF_bosonic_or_fermionic (φ1 φ2 φ3 : 𝓕.CrAnFieldOp) : [ofCrAnOpF φ1, [ofCrAnOpF φ2, ofCrAnOpF φ3]ₛF]ₛF ∈ statisticSubmodule bosonic ∨ diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean index 0d9adc40a..6123a105d 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean @@ -307,8 +307,8 @@ lemma timeOrderF_eq_maxTimeField_mul (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldO 𝓣ᶠ(ofFieldOpListF (φ :: φs)) = 𝓢(𝓕 |>ₛ maxTimeField φ φs, 𝓕 |>ₛ (φ :: φs).take (maxTimeFieldPos φ φs)) • ofFieldOpF (maxTimeField φ φs) * 𝓣ᶠ(ofFieldOpListF (eraseMaxTimeField φ φs)) := by - rw [timeOrderF_ofFieldOpListF, timeOrderList_eq_maxTimeField_timeOrderList, - ofFieldOpListF_cons, timeOrderF_ofFieldOpListF] + rw [timeOrderF_ofFieldOpListF, timeOrderList_eq_maxTimeField_timeOrderList] + rw [ofFieldOpListF_cons, timeOrderF_ofFieldOpListF] simp only [Algebra.mul_smul_comm, Algebra.smul_mul_assoc, smul_smul] congr rw [timerOrderSign_of_eraseMaxTimeField, mul_assoc] diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index b388fde09..e5bb82c66 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -179,8 +179,8 @@ lemma normalOrderSign_swap_create_create (φc φc' : 𝓕.CrAnFieldOp) dsimp only [normalOrderSign, Wick.koszulSign] rw [← normalOrderSign] simp only [mul_eq_mul_right_iff] - exact Or.inl (Wick.koszulSignInsert_eq_perm _ _ _ _ _ - (List.Perm.append_left φs (List.Perm.swap φc' φc φs'))) + apply Or.inl (Wick.koszulSignInsert_eq_perm _ _ _ _ _ _) + exact List.Perm.append_left φs (List.Perm.swap φc' φc φs') lemma normalOrderSign_swap_annihilate_annihilate_fst (φa φa' : 𝓕.CrAnFieldOp) (hφa : 𝓕 |>ᶜ φa = CreateAnnihilate.annihilate) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean index 0c7f31bbe..490fed244 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean @@ -120,13 +120,13 @@ def maxTimeFieldPosFin (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : lemma lt_maxTimeFieldPosFin_not_timeOrder (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) (i : Fin (eraseMaxTimeField φ φs).length) (hi : (maxTimeFieldPosFin φ φs).succAbove i < maxTimeFieldPosFin φ φs) : - ¬ timeOrderRel ((eraseMaxTimeField φ φs)[i.val]) (maxTimeField φ φs) := - insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt timeOrderRel φ φs i hi + ¬ timeOrderRel ((eraseMaxTimeField φ φs)[i.val]) (maxTimeField φ φs) := by + exact insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt timeOrderRel φ φs i hi lemma timeOrder_maxTimeField (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) (i : Fin (eraseMaxTimeField φ φs).length) : - timeOrderRel (maxTimeField φ φs) ((eraseMaxTimeField φ φs)[i.val]) := - insertionSortMin_lt_mem_insertionSortDropMinPos timeOrderRel φ φs _ + timeOrderRel (maxTimeField φ φs) ((eraseMaxTimeField φ φs)[i.val]) := by + exact insertionSortMin_lt_mem_insertionSortDropMinPos timeOrderRel φ φs _ /-- The sign associated with putting a list of states into time order (with the state of greatest time to the left). @@ -182,8 +182,8 @@ lemma timeOrderList_nil : timeOrderList (𝓕 := 𝓕) [] = [] := by simp [timeOrderList] lemma timeOrderList_eq_maxTimeField_timeOrderList (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : - timeOrderList (φ :: φs) = maxTimeField φ φs :: timeOrderList (eraseMaxTimeField φ φs) := - insertionSort_eq_insertionSortMin_cons timeOrderRel φ φs + timeOrderList (φ :: φs) = maxTimeField φ φs :: timeOrderList (eraseMaxTimeField φ φs) := by + exact insertionSort_eq_insertionSortMin_cons timeOrderRel φ φs /-! @@ -226,8 +226,8 @@ instance : IsTrans 𝓕.CrAnFieldOp 𝓕.crAnTimeOrderRel where trans a b c := IsTrans.trans (r := 𝓕.timeOrderRel) a.1 b.1 c.1 @[simp] -lemma crAnTimeOrderRel_refl (φ : 𝓕.CrAnFieldOp) : crAnTimeOrderRel φ φ := - (Std.Total.to_refl (r := 𝓕.crAnTimeOrderRel)).refl φ +lemma crAnTimeOrderRel_refl (φ : 𝓕.CrAnFieldOp) : crAnTimeOrderRel φ φ := by + exact (Std.Total.to_refl (r := 𝓕.crAnTimeOrderRel)).refl φ /-- For a field specification `𝓕`, and a list `φs` of `𝓕.CrAnFieldOp`, `𝓕.crAnTimeOrderSign φs` is the sign corresponding to the number of `ferimionic`-`fermionic` @@ -255,8 +255,8 @@ lemma crAnTimeOrderSign_pair_not_ordered {φ ψ : 𝓕.CrAnFieldOp} (h : ¬ crAn lemma crAnTimeOrderSign_swap_eq_time {φ ψ : 𝓕.CrAnFieldOp} (h1 : crAnTimeOrderRel φ ψ) (h2 : crAnTimeOrderRel ψ φ) (φs φs' : List 𝓕.CrAnFieldOp) : - crAnTimeOrderSign (φs ++ φ :: ψ :: φs') = crAnTimeOrderSign (φs ++ ψ :: φ :: φs') := - Wick.koszulSign_swap_eq_rel _ _ h1 h2 _ _ + crAnTimeOrderSign (φs ++ φ :: ψ :: φs') = crAnTimeOrderSign (φs ++ ψ :: φ :: φs') := by + exact Wick.koszulSign_swap_eq_rel _ _ h1 h2 _ _ /-- For a field specification `𝓕`, and a list `φs` of `𝓕.CrAnFieldOp`, `𝓕.crAnTimeOrderList φs` is the list `φs` time-ordered using the insertion sort algorithm. -/ diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean index ed1efb6ad..64be719ac 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean @@ -77,8 +77,8 @@ lemma exchangeSign_bosonic (a : FieldStatistic) : 𝓢(a, bosonic) = 1 := by fin_cases a <;> rfl @[simp] -lemma bosonic_exchangeSign (a : FieldStatistic) : 𝓢(bosonic, a) = 1 := - (exchangeSign_symm bosonic a).trans (exchangeSign_bosonic a) +lemma bosonic_exchangeSign (a : FieldStatistic) : 𝓢(bosonic, a) = 1 := by + rw [exchangeSign_symm, exchangeSign_bosonic] @[simp] lemma fermionic_exchangeSign_fermionic : 𝓢(fermionic, fermionic) = - 1 := rfl diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/WickContractions.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/WickContractions.lean index 6d9017141..6fe714d63 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/WickContractions.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/WickContractions.lean @@ -59,11 +59,11 @@ lemma normalOrder_uncontracted_none (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp congr rw [uncontractedList_eq_sort] have hdup : (List.filter (fun x => decide (x.1 < i.1)) - (φsΛ.uncontracted.sort (fun x1 x2 => x1 ≤ x2))).Nodup := - List.Nodup.filter _ (φsΛ.uncontracted.sort_nodup (fun x1 x2 => x1 ≤ x2)) + (φsΛ.uncontracted.sort (fun x1 x2 => x1 ≤ x2))).Nodup := by + exact List.Nodup.filter _ (φsΛ.uncontracted.sort_nodup (fun x1 x2 => x1 ≤ x2)) have hsort : (List.filter (fun x => decide (x.1 < i.1)) - (φsΛ.uncontracted.sort (fun x1 x2 => x1 ≤ x2))).Pairwise (· ≤ ·) := - List.Pairwise.filter _ (φsΛ.uncontracted.pairwise_sort (fun x1 x2 => x1 ≤ x2)) + (φsΛ.uncontracted.sort (fun x1 x2 => x1 ≤ x2))).Pairwise (· ≤ ·) := by + exact List.Pairwise.filter _ (φsΛ.uncontracted.pairwise_sort (fun x1 x2 => x1 ≤ x2)) rw [← (List.toFinset_sort (· ≤ ·) hdup).mpr hsort] congr ext a diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 7df5a1a1a..5d8ea6e99 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -69,10 +69,10 @@ noncomputable def superCommuteRight (a : 𝓕.FieldOpFreeAlgebra) : simp lemma superCommuteRight_apply_ι (a b : 𝓕.FieldOpFreeAlgebra) : - superCommuteRight a (ι b) = ι [a, b]ₛF := rfl + superCommuteRight a (ι b) = ι [a, b]ₛF := by rfl lemma superCommuteRight_apply_quot (a b : 𝓕.FieldOpFreeAlgebra) : - superCommuteRight a ⟦b⟧= ι [a, b]ₛF := rfl + superCommuteRight a ⟦b⟧= ι [a, b]ₛF := by rfl lemma superCommuteRight_eq_of_equiv (a1 a2 : 𝓕.FieldOpFreeAlgebra) (h : a1 ≈ a2) : superCommuteRight a1 = superCommuteRight a2 := by @@ -180,8 +180,8 @@ lemma superCommute_anPart_ofFieldOpF_diff_grade_zero (φ ψ : 𝓕.FieldOp) lemma superCommute_ofCrAnOp_ofCrAnOp_mem_center (φ φ' : 𝓕.CrAnFieldOp) : [ofCrAnOp φ, ofCrAnOp φ']ₛ ∈ Subalgebra.center ℂ (WickAlgebra 𝓕) := by - simpa [ofCrAnOp, superCommute_eq_ι_superCommuteF] using - ι_superCommuteF_ofCrAnOpF_ofCrAnOpF_mem_center φ φ' + rw [ofCrAnOp, ofCrAnOp, superCommute_eq_ι_superCommuteF] + exact ι_superCommuteF_ofCrAnOpF_ofCrAnOpF_mem_center φ φ' lemma superCommute_ofCrAnOp_ofCrAnOp_commute (φ φ' : 𝓕.CrAnFieldOp) (a : WickAlgebra 𝓕) : diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean index 58dfc0e7c..2447327aa 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean @@ -33,7 +33,7 @@ def timeContract (φ ψ : 𝓕.FieldOp) : 𝓕.WickAlgebra := 𝓣(ofFieldOp φ * ofFieldOp ψ) - 𝓝(ofFieldOp φ * ofFieldOp ψ) lemma timeContract_eq_smul (φ ψ : 𝓕.FieldOp) : timeContract φ ψ = - 𝓣(ofFieldOp φ * ofFieldOp ψ) + (-1 : ℂ) • 𝓝(ofFieldOp φ * ofFieldOp ψ) := rfl + 𝓣(ofFieldOp φ * ofFieldOp ψ) + (-1 : ℂ) • 𝓝(ofFieldOp φ * ofFieldOp ψ) := by rfl /-- For a field specification `𝓕`, and `φ` and `ψ` elements of `𝓕.FieldOp`, if `φ` and `ψ` are time-ordered then diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 029ef3c51..6994c0651 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -180,7 +180,7 @@ lemma ι_timeOrderF_superCommuteF_superCommuteF {φ1 φ2 φ3 : 𝓕.CrAnFieldOp} simp_all [pb] example (c1 c2 : ℂ) (a : 𝓕.WickAlgebra) : c1 • c2 • a = - c2 • c1 • a := smul_comm c1 c2 a + c2 • c1 • a := by exact smul_comm c1 c2 a lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp} (hφψ : crAnTimeOrderRel φ ψ) (hψφ : crAnTimeOrderRel ψ φ) (a b : 𝓕.FieldOpFreeAlgebra) : ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * b) = @@ -225,7 +225,7 @@ lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp} trans crAnTimeOrderSign (φs' ++ [φ, ψ] ++ φs) simp only [List.append_assoc, List.cons_append, List.nil_append] rw [crAnTimeOrderSign] - have hp : List.Perm [φ,ψ] [ψ,φ] := List.Perm.swap ψ φ [] + have hp : List.Perm [φ,ψ] [ψ,φ] := by exact List.Perm.swap ψ φ [] rw [Wick.koszulSign_perm_eq _ _ φ _ _ _ _ _ hp] simp only [List.append_assoc, List.cons_append] rfl @@ -328,8 +328,8 @@ lemma ι_timeOrderF_superCommuteF_ne_time {φ ψ : 𝓕.CrAnFieldOp} (hφψ : ¬ (crAnTimeOrderRel φ ψ ∧ crAnTimeOrderRel ψ φ)) (a b : 𝓕.FieldOpFreeAlgebra) : ι 𝓣ᶠ(a * [ofCrAnOpF φ, ofCrAnOpF ψ]ₛF * b) = 0 := by rw [timeOrderF_timeOrderF_mid] - have hφψ : ¬ (crAnTimeOrderRel φ ψ) ∨ ¬ (crAnTimeOrderRel ψ φ) := - Decidable.not_and_iff_or_not.mp hφψ + have hφψ : ¬ (crAnTimeOrderRel φ ψ) ∨ ¬ (crAnTimeOrderRel ψ φ) := by + exact Decidable.not_and_iff_or_not.mp hφψ rcases hφψ with hφψ | hφψ · rw [timeOrderF_superCommuteF_ofCrAnOpF_ofCrAnOpF_not_crAnTimeOrderRel] simp_all only [false_and, not_false_eq_true, mul_zero, zero_mul, map_zero] diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean index 0c435b782..85ef247f5 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean @@ -40,7 +40,7 @@ def universalLiftMap {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnField @[simp] lemma universalLiftMap_ι {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp → A) (h1 : ∀ a ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet, FreeAlgebra.lift ℂ f a = 0) : - universalLiftMap f h1 (ι a) = FreeAlgebra.lift ℂ f a := rfl + universalLiftMap f h1 (ι a) = FreeAlgebra.lift ℂ f a := by rfl /-- For a field specification, `𝓕`, given an algebra `A` and a function `f : 𝓕.CrAnFieldOp → A` such that the lift of `f` to `FreeAlgebra.lift ℂ f : FreeAlgebra ℂ 𝓕.CrAnFieldOp → A` is @@ -74,7 +74,7 @@ def universalLift {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp @[simp] lemma universalLift_ι {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp → A) (h1 : ∀ a ∈ TwoSidedIdeal.span 𝓕.fieldOpIdealSet, FreeAlgebra.lift ℂ f a = 0) : - universalLift f h1 (ι a) = FreeAlgebra.lift ℂ f a := rfl + universalLift f h1 (ι a) = FreeAlgebra.lift ℂ f a := by rfl /-- For a field specification, `𝓕`, the algebra `𝓕.WickAlgebra` satisfies the following universal diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean index 5d2dec371..3ffe501b8 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/WicksTheoremNormal.lean @@ -90,7 +90,7 @@ lemma timeOrder_ofFieldOpList_eq_eqTimeOnly_empty (φs : List 𝓕.FieldOp) : · let e2 : { φsΛ : {φsΛ : WickContraction φs.length // φsΛ.EqTimeOnly} // ¬ φsΛ.1 = empty } ≃ {φsΛ // φsΛ.EqTimeOnly ∧ φsΛ ≠ empty} := { toFun := fun x => ⟨x, ⟨x.1.2, x.2⟩⟩, invFun := fun x => ⟨⟨x.1, x.2.1⟩, x.2.2⟩, - left_inv a := rfl, right_inv a := rfl } + left_inv a := by rfl, right_inv a := by rfl } rw [← e2.symm.sum_comp] rfl @@ -140,8 +140,8 @@ lemma timeOrder_haveEqTime_split (φs : List 𝓕.FieldOp) : φssucΛ.1.wickTerm) := by rw [wicks_theorem] simp only [wickTerm] - let e1 : WickContraction φs.length ≃ {φsΛ // HaveEqTime φsΛ} ⊕ {φsΛ // ¬ HaveEqTime φsΛ} := - (Equiv.sumCompl HaveEqTime).symm + let e1 : WickContraction φs.length ≃ {φsΛ // HaveEqTime φsΛ} ⊕ {φsΛ // ¬ HaveEqTime φsΛ} := by + exact (Equiv.sumCompl HaveEqTime).symm rw [← e1.symm.sum_comp] simp only [Equiv.symm_symm, Algebra.smul_mul_assoc, Fintype.sum_sum_type, Equiv.sumCompl_apply_inl, Equiv.sumCompl_apply_inr, ne_eq, e1] @@ -211,7 +211,7 @@ lemma wicks_theorem_normal_order_empty : 𝓣(𝓝(ofFieldOpList [])) = simp only [Finset.univ_unique, PUnit.default_eq_unit, List.length_nil, Equiv.coe_fn_symm_mk, sign_empty, timeContract_empty, OneMemClass.coe_one, one_smul, uncontractedListGet_empty, one_mul, Finset.sum_const, Finset.card_singleton, e2] - have h1' : ofFieldOpList (𝓕 := 𝓕) [] = ofCrAnList [] := rfl + have h1' : ofFieldOpList (𝓕 := 𝓕) [] = ofCrAnList [] := by rfl rw [h1'] rw [normalOrder_ofCrAnList] simp only [normalOrderSign_nil, normalOrderList_nil, one_smul] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean index 4dfea99f0..fa3f2a33c 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean @@ -129,8 +129,8 @@ lemma congrLift_surjective {n m : ℕ} {c : WickContraction n} (h : n = m) : simp [Function.surjective_id] lemma congrLift_bijective {n m : ℕ} {c : WickContraction n} (h : n = m) : - Function.Bijective (c.congrLift h) := - ⟨c.congrLift_injective h, c.congrLift_surjective h⟩ + Function.Bijective (c.congrLift h) := by + exact ⟨c.congrLift_injective h, c.congrLift_surjective h⟩ /-- Given a contracted pair in `c : WickContraction n` the contracted pair in `congr h c`. -/ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean b/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean index b791c770d..b992630d7 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean @@ -58,8 +58,8 @@ def extractEquiv (i : Fin n.succ) : WickContraction n.succ ≃ 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)) := - insertAndContractNat_none_uncontracted c i + (Insert.insert i (c.uncontracted.map i.succAboveEmb)) := by + exact insertAndContractNat_none_uncontracted c i @[simp] lemma extractEquiv_apply_congr_symm_apply {n m : ℕ} (k : ℕ) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean index 3e732f9cf..9cbcfdb06 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean @@ -649,8 +649,8 @@ lemma insertLift_none_surjective {c : WickContraction n} (i : Fin n.succ) : exact Subtype.ext ha'' lemma insertLift_none_bijective {c : WickContraction n} (i : Fin n.succ) : - Function.Bijective (c.insertLift i none) := - ⟨insertLift_injective i none, insertLift_none_surjective i⟩ + Function.Bijective (c.insertLift i none) := by + exact ⟨insertLift_injective i none, insertLift_none_surjective i⟩ @[simp] lemma insertAndContractNat_fstFieldOfContract (c : WickContraction n) (i : Fin n.succ) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean index d7a6864f6..8762e045a 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean @@ -267,8 +267,8 @@ lemma join_card {φs : List 𝓕.FieldOp} {φsΛ : WickContraction φs.length} simp only [Finset.mem_map, RelEmbedding.coe_toEmbedding, not_exists, not_and] intro x hx by_contra hn - have hdis : Disjoint (Finset.map uncontractedListEmd x) a := - uncontractedListEmd_finset_disjoint_left x a ha + have hdis : Disjoint (Finset.map uncontractedListEmd x) a := by + exact uncontractedListEmd_finset_disjoint_left x a ha rw [Finset.mapEmbedding_apply] at hn rw [hn] at hdis simp only [disjoint_self, Finset.bot_eq_empty] at hdis diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean index 4da8ebd33..dd36be363 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertNone.lean @@ -170,8 +170,8 @@ lemma signInsertNone_eq_prod_getDual?_Some (φ : 𝓕.FieldOp) (φs : List 𝓕. · rw [Finset.prod_sigma'] rfl rw [← φsΛ.sigmaContractedEquiv.symm.prod_comp] - let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := - (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm + let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := by + exact (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm rw [← e2.symm.prod_comp] simp only [Fin.getElem_fin, Fintype.prod_sum_type] conv_rhs => diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean index d1c9f38d9..8087002ef 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/InsertSome.lean @@ -38,8 +38,8 @@ lemma stat_ofFinset_eq_one_of_gradingCompliant (φs : List 𝓕.FieldOp) (hsom : ∀ i, (h : (φsΛ.getDual? i).isSome) → i ∈ a → (φsΛ.getDual? i).get h ∈ a) : (𝓕 |>ₛ ⟨φs.get, a⟩) = 1 := by rw [ofFinset_eq_prod] - let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := - (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm + let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := by + exact (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm rw [← e2.symm.prod_comp] simp only [Fin.getElem_fin, Fintype.prod_sum_type] conv_lhs => @@ -367,8 +367,8 @@ lemma signInsertSomeProd_eq_prod_fin (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldO else 1 := by rw [signInsertSomeProd_eq_prod_prod, Finset.prod_sigma'] erw [← φsΛ.sigmaContractedEquiv.symm.prod_comp] - let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := - (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm + let e2 : Fin φs.length ≃ {x // (φsΛ.getDual? x).isSome} ⊕ {x // ¬ (φsΛ.getDual? x).isSome} := by + exact (Equiv.sumCompl fun a => (φsΛ.getDual? a).isSome = true).symm rw [← e2.symm.prod_comp] simp only [Fin.getElem_fin, Fintype.prod_sum_type] conv_rhs => diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean index 0ff3bacfd..4ec1e24c5 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean @@ -131,8 +131,8 @@ lemma join_singleton_signFinset_eq_filter {φs : List 𝓕.FieldOp} · intro h1 h2 rcases h1 with h1 | h1 · simp only [h1, Option.isSome_none, Bool.false_eq_true, IsEmpty.exists_iff] - have h2' : ¬ (((singleton h).join φsucΛ).getDual? a).isSome := - Option.not_isSome_iff_eq_none.mpr h1 + have h2' : ¬ (((singleton h).join φsucΛ).getDual? a).isSome := by + exact Option.not_isSome_iff_eq_none.mpr h1 exact h2' h2 use h2 have h1 := h1 h2 @@ -303,8 +303,8 @@ lemma joinSignLeftExtra_eq_joinSignRightExtra {φs : List 𝓕.FieldOp} joinSignLeftExtra h φsucΛ = joinSignRightExtra h φsucΛ := by /- Simplifying joinSignLeftExtra. -/ let e2 : Fin φs.length ≃ {x // (((singleton h).join φsucΛ).getDual? x).isSome} ⊕ - {x // ¬ (((singleton h).join φsucΛ).getDual? x).isSome} := - (Equiv.sumCompl fun a => (((singleton h).join φsucΛ).getDual? a).isSome = true).symm + {x // ¬ (((singleton h).join φsucΛ).getDual? x).isSome} := by + exact (Equiv.sumCompl fun a => (((singleton h).join φsucΛ).getDual? a).isSome = true).symm rw [joinSignLeftExtra, ofFinset_eq_prod, map_prod, ← e2.symm.prod_comp] simp only [Fin.getElem_fin, Fintype.prod_sum_type] conv_lhs => diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean index 7463bc4a4..e0b2db5cd 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean @@ -33,8 +33,8 @@ def subContraction (S : Finset (Finset (Fin φs.length))) (ha : S ⊆ φsΛ.1) : exact φsΛ.2.2 i (ha hi) j (ha hj)⟩ lemma mem_of_mem_subContraction {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} - {a : Finset (Fin φs.length)} (ha : a ∈ (φsΛ.subContraction S hs).1) : a ∈ φsΛ.1 := - hs ha + {a : Finset (Fin φs.length)} (ha : a ∈ (φsΛ.subContraction S hs).1) : a ∈ φsΛ.1 := by + exact hs ha /-- Given a Wick contraction `φsΛ`, and a subset `S` of `φsΛ.1`, the Wick contraction on the uncontracted list `[φsΛ.subContraction S ha]ᵘᶜ` @@ -158,8 +158,8 @@ lemma quotContraction_fstFieldOfContract_uncontractedListEmd {S : Finset (Finset (uncontractedListEmd ((quotContraction S hs).sndFieldOfContract a)) · simp only [Finset.mem_map', fstFieldOfContract_mem] · simp - · exact uncontractedListEmd_strictMono - (fstFieldOfContract_lt_sndFieldOfContract (quotContraction S hs) a) + · apply uncontractedListEmd_strictMono + exact fstFieldOfContract_lt_sndFieldOfContract (quotContraction S hs) a @[simp] lemma quotContraction_sndFieldOfContract_uncontractedListEmd {S : Finset (Finset (Fin φs.length))} @@ -172,8 +172,8 @@ lemma quotContraction_sndFieldOfContract_uncontractedListEmd {S : Finset (Finset (uncontractedListEmd ((quotContraction S hs).fstFieldOfContract a)) · simp only [Finset.mem_map', fstFieldOfContract_mem] · simp - · exact uncontractedListEmd_strictMono - (fstFieldOfContract_lt_sndFieldOfContract (quotContraction S hs) a) + · apply uncontractedListEmd_strictMono + exact fstFieldOfContract_lt_sndFieldOfContract (quotContraction S hs) a lemma quotContraction_gradingCompliant {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} (hsΛ : φsΛ.GradingCompliant) : diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean index d8950b581..4ffbac4bb 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean @@ -191,8 +191,8 @@ lemma timeOrder_timeContract_mul_of_eqTimeOnly_mid_induction {φs : List 𝓕.Fi lemma timeOrder_timeContract_mul_of_eqTimeOnly_mid {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) (hl : φsΛ.EqTimeOnly) (a b : 𝓕.WickAlgebra) : - 𝓣(a * φsΛ.timeContract.1 * b) = φsΛ.timeContract.1 * 𝓣(a * b) := - timeOrder_timeContract_mul_of_eqTimeOnly_mid_induction φsΛ hl a b φsΛ.1.card rfl + 𝓣(a * φsΛ.timeContract.1 * b) = φsΛ.timeContract.1 * 𝓣(a * b) := by + exact timeOrder_timeContract_mul_of_eqTimeOnly_mid_induction φsΛ hl a b φsΛ.1.card rfl /-- Let `φs` be a list of `𝓕.FieldOp`, `φsΛ` a `WickContraction` of `φs` within which every contraction involves two `𝓕.FieldOp`s that have the same time and @@ -384,7 +384,7 @@ lemma join_eqTimeContractSet {φs : List 𝓕.FieldOp} (φsΛ : WickContraction · intro h' have h2 := h1.2 h1.1 have hj : ⟨(Finset.mapEmbedding uncontractedListEmd) b, h'⟩ - = joinLiftRight ⟨b, h1.1⟩ := rfl + = joinLiftRight ⟨b, h1.1⟩ := by rfl simp only [hj, join_fstFieldOfContract_joinLiftRight, getElem_uncontractedListEmd, join_sndFieldOfContract_joinLiftRight] simpa using h2 @@ -472,8 +472,8 @@ lemma quotContraction_eqTimeContractSet_not_haveEqTime {φs : List 𝓕.FieldOp} quotContraction_sndFieldOfContract_uncontractedListEmd] simp only [quotContraction, Finset.mem_filter, Finset.mem_univ, true_and] at ha have hn' : Finset.map uncontractedListEmd a ∉ - (φsΛ.subContraction (eqTimeContractSet φsΛ) (eqTimeContractSet_subset φsΛ)).1 := - uncontractedListEmd_finset_not_mem a + (φsΛ.subContraction (eqTimeContractSet φsΛ) (eqTimeContractSet_subset φsΛ)).1 := by + exact uncontractedListEmd_finset_not_mem a simp only [subContraction, eqTimeContractSet, Fin.getElem_fin, Finset.mem_filter, Finset.mem_univ, true_and, not_and, not_forall] at hn' have hn'' := hn' ha diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index 4f473c772..ae51b46af 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -381,8 +381,8 @@ lemma uncontractedListEmd_surjective_mem_uncontracted {φs : List 𝓕.FieldOp} ∃ j, φsΛ.uncontractedListEmd j = i := by simp only [uncontractedListEmd, Equiv.trans_toEmbedding, Function.Embedding.trans_apply, Equiv.coe_toEmbedding, finCongr_apply, Function.Embedding.coe_subtype] - have hj : ∃ j, φsΛ.uncontractedIndexEquiv j = ⟨i, hi⟩ := - φsΛ.uncontractedIndexEquiv.surjective ⟨i, hi⟩ + have hj : ∃ j, φsΛ.uncontractedIndexEquiv j = ⟨i, hi⟩ := by + exact φsΛ.uncontractedIndexEquiv.surjective ⟨i, hi⟩ generalize_proofs h1 obtain ⟨j, hj⟩ := hj have hj' : ∃ j', Fin.cast h1 j' = j := (finCongr h1).surjective j @@ -444,8 +444,8 @@ lemma uncontractedList_succAboveEmb_nodup (c : WickContraction n) (i : Fin n.suc lemma uncontractedList_succAbove_orderedInsert_nodup (c : WickContraction n) (i : Fin n.succ) : (List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).Nodup := by have h1 : (List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).Perm - (i :: List.map i.succAboveEmb c.uncontractedList) := - List.perm_orderedInsert (fun x1 x2 => x1 ≤ x2) i _ + (i :: List.map i.succAboveEmb c.uncontractedList) := by + exact List.perm_orderedInsert (fun x1 x2 => x1 ≤ x2) i _ apply List.Perm.nodup h1.symm simp only [Nat.succ_eq_add_one, List.nodup_cons, List.mem_map, not_exists, not_and] @@ -456,9 +456,9 @@ lemma uncontractedList_succAbove_orderedInsert_nodup (c : WickContraction n) (i lemma uncontractedList_succAbove_orderedInsert_sorted (c : WickContraction n) (i : Fin n.succ) : (List.orderedInsert (· ≤ ·) i - (List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := - List.Pairwise.orderedInsert i (List.map (⇑i.succAboveEmb) c.uncontractedList) - (uncontractedList_succAboveEmb_sorted c i) + (List.map i.succAboveEmb c.uncontractedList)).Pairwise (· ≤ ·) := by + refine List.Pairwise.orderedInsert i (List.map (⇑i.succAboveEmb) c.uncontractedList) ?_ + exact uncontractedList_succAboveEmb_sorted c i lemma uncontractedList_succAbove_orderedInsert_toFinset (c : WickContraction n) (i : Fin n.succ) : (List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)).toFinset = diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index ad2a9e64a..28e56c01a 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -908,8 +908,8 @@ def Pa' (f : (Fin n.succ) ⊕ (Fin n) → ℚ) : (PureU1 (2 * n.succ)).LinSols : ∑ i, f i • basisa i lemma Pa'_P'_P!' (f : (Fin n.succ) ⊕ (Fin n) → ℚ) : - Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := - Fintype.sum_sum_type _ + Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := by + exact Fintype.sum_sum_type _ /-! @@ -951,8 +951,8 @@ lemma Pa'_eq (f f' : (Fin n.succ) ⊕ (Fin n) → ℚ) : Pa' f = Pa' f' ↔ f = rw [h] rw [← Finset.sum_add_distrib] simp - have h2 : ∀ i, (f i + (- f' i)) = 0 := - Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) + have h2 : ∀ i, (f i + (- f' i)) = 0 := by + exact Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) (fun i => f i + -f' i) h1 have h2i := h2 i linarith diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean index 62cbbaf6f..5c469ac08 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean @@ -108,8 +108,8 @@ lemma generic_or_special (S : (PureU1 (2 * n.succ)).Sols) : GenericCase S ∨ SpecialCase S := by obtain ⟨g, f, h⟩ := span_basis S.1.1 have h1 : accCubeTriLinSymm (P g) (P g) (P! f) ≠ 0 ∨ - accCubeTriLinSymm (P g) (P g) (P! f) = 0 := - ne_or_eq _ _ + accCubeTriLinSymm (P g) (P g) (P! f) = 0 := by + exact ne_or_eq _ _ rcases h1 with h1 | h1 · exact Or.inl (genericCase_exists S ⟨g, f, h, h1⟩) · exact Or.inr (specialCase_exists S ⟨g, f, h, h1⟩) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 679fdccca..8e3b9cb56 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -863,8 +863,8 @@ def Pa' (f : (Fin n) ⊕ (Fin n) → ℚ) : (PureU1 (2 * n + 1)).LinSols := ∑ i, f i • basisa i lemma Pa'_P'_P!' (f : (Fin n) ⊕ (Fin n) → ℚ) : - Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := - Fintype.sum_sum_type _ + Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := by + exact Fintype.sum_sum_type _ /-! @@ -908,8 +908,8 @@ lemma Pa'_eq (f f' : (Fin n.succ) ⊕ (Fin n.succ) → ℚ) : Pa' f = Pa' f' ↔ rw [h] rw [← Finset.sum_add_distrib] simp - have h2 : ∀ i, (f i + (- f' i)) = 0 := - Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) + have h2 : ∀ i, (f i + (- f' i)) = 0 := by + exact Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) (fun i => f i + -f' i) h1 have h2i := h2 i linarith diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean index 8a502f6df..567fbb4a6 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean @@ -110,8 +110,8 @@ lemma generic_or_special (S : (PureU1 (2 * n.succ + 1)).Sols) : GenericCase S ∨ SpecialCase S := by obtain ⟨g, f, h⟩ := span_basis S.1.1 have h1 : accCubeTriLinSymm (P g) (P g) (P! f) ≠ 0 ∨ - accCubeTriLinSymm (P g) (P g) (P! f) = 0 := - ne_or_eq _ _ + accCubeTriLinSymm (P g) (P g) (P! f) = 0 := by + exact ne_or_eq _ _ cases h1 <;> rename_i h1 · exact Or.inl (genericCase_exists S ⟨g, f, h, h1⟩) · exact Or.inr (specialCase_exists S ⟨g, f, h, h1⟩) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean index 40ef5f38f..f5b278d4a 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean @@ -43,8 +43,8 @@ def chargeMap {n : ℕ} (f : PermGroup n) : @[simp] def permCharges {n : ℕ} : Representation ℚ (PermGroup n) (PureU1 n).Charges where toFun f := chargeMap f⁻¹ - map_mul' _ _ := rfl - map_one' := rfl + map_mul' f g := by rfl + map_one' := by rfl lemma accGrav_invariant {n : ℕ} (f : (PermGroup n)) (S : (PureU1 n).Charges) : PureU1.accGrav n (permCharges f S) = accGrav n S := by @@ -108,8 +108,8 @@ lemma permTwoInj_fst : i ∈ Set.range ⇑(permTwoInj hij) := by rfl lemma permTwoInj_fst_apply : - (Function.Embedding.toEquivRange (permTwoInj hij)).symm ⟨i, permTwoInj_fst hij⟩ = 0 := - (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permTwoInj hij))).mpr rfl + (Function.Embedding.toEquivRange (permTwoInj hij)).symm ⟨i, permTwoInj_fst hij⟩ = 0 := by + exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permTwoInj hij))).mpr rfl lemma permTwoInj_snd : j ∈ Set.range ⇑(permTwoInj hij) := by simp only [Set.mem_range] @@ -118,8 +118,8 @@ lemma permTwoInj_snd : j ∈ Set.range ⇑(permTwoInj hij) := by lemma permTwoInj_snd_apply : (Function.Embedding.toEquivRange (permTwoInj hij)).symm - ⟨j, permTwoInj_snd hij⟩ = 1 := - (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permTwoInj hij))).mpr rfl + ⟨j, permTwoInj_snd hij⟩ = 1 := by + exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permTwoInj hij))).mpr rfl /-- A permutation which swaps `i` with `i'` and `j` with `j'`. -/ noncomputable def permTwo : (FamilyPermutations n).group := @@ -166,8 +166,8 @@ lemma permThreeInj_fst : i ∈ Set.range ⇑(permThreeInj hij hjk hik) := by lemma permThreeInj_fst_apply : (Function.Embedding.toEquivRange (permThreeInj hij hjk hik)).symm - ⟨i, permThreeInj_fst hij hjk hik⟩ = 0 := - (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl + ⟨i, permThreeInj_fst hij hjk hik⟩ = 0 := by + exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl lemma permThreeInj_snd : j ∈ Set.range ⇑(permThreeInj hij hjk hik) := by simp only [Set.mem_range] @@ -176,8 +176,8 @@ lemma permThreeInj_snd : j ∈ Set.range ⇑(permThreeInj hij hjk hik) := by lemma permThreeInj_snd_apply : (Function.Embedding.toEquivRange (permThreeInj hij hjk hik)).symm - ⟨j, permThreeInj_snd hij hjk hik⟩ = 1 := - (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl + ⟨j, permThreeInj_snd hij hjk hik⟩ = 1 := by + exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl lemma permThreeInj_thd : k ∈ Set.range ⇑(permThreeInj hij hjk hik) := by simp only [Set.mem_range] @@ -186,8 +186,8 @@ lemma permThreeInj_thd : k ∈ Set.range ⇑(permThreeInj hij hjk hik) := by lemma permThreeInj_thd_apply : (Function.Embedding.toEquivRange (permThreeInj hij hjk hik)).symm - ⟨k, permThreeInj_thd hij hjk hik⟩ = 2 := - (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl + ⟨k, permThreeInj_thd hij hjk hik⟩ = 2 := by + exact (Equiv.symm_apply_eq (Function.Embedding.toEquivRange (permThreeInj hij hjk hik))).mpr rfl /-- A permutation which swaps three distinct elements with another three. -/ noncomputable def permThree : (FamilyPermutations n).group := diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean index 6b0e19055..689ea9080 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Commutation.lean @@ -186,9 +186,9 @@ lemma radiusRegPow_commutation_momentum : ⁅𝐫₀[d] ε s, 𝐩 i⁆ = (s * I * ℏ) • 𝐫₀ ε (s-2) ∘L 𝐱 i := by ext ψ x have hne := Ne.symm (ne_of_lt <| Space.norm_sq_add_unit_sq_pos ε x) - have hdiff1 : DifferentiableAt ℝ (fun x => (‖x‖ ^ 2 + ↑ε ^ 2) ^ (s / 2)) x := - DifferentiableAt.rpow_const (Differentiable.differentiableAt (by fun_prop)) - (Or.intro_left _ hne) + have hdiff1 : DifferentiableAt ℝ (fun x => (‖x‖ ^ 2 + ↑ε ^ 2) ^ (s / 2)) x := by + refine DifferentiableAt.rpow_const ?_ (Or.intro_left _ hne) + exact Differentiable.differentiableAt (by fun_prop) have hdiff2 := Real.differentiableAt_rpow_const_of_ne (s / 2) hne have hdiff3 : DifferentiableAt ℝ (fun x ↦ ‖x‖ ^ 2 + ε ^ 2) x := Differentiable.differentiableAt (by fun_prop) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean index d20b5d1a1..090a9a5ab 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean @@ -200,8 +200,8 @@ private lemma exists_monotone_sets_hasFiniteIntegral simp_rw [norm_pow, norm_norm, RCLike.norm_natCast] refine pow_le_pow_left₀ (norm_nonneg _) ?_ 2 rcases hk <;> simp_all - · exact ENNReal.mul_lt_top (by norm_num) - (measure_inter_lt_top_of_left_ne_top measure_closedBall_lt_top.ne) + · refine ENNReal.mul_lt_top (by norm_num) ?_ + exact measure_inter_lt_top_of_left_ne_top measure_closedBall_lt_top.ne open Complex InnerProductSpace in lemma mulOperator_adjoint_domain_le {f : Space d → ℂ} (hf : AEStronglyMeasurable f) : @@ -305,9 +305,9 @@ lemma mulOperator_isSelfAdjoint_ofReal -/ lemma mulOperator_isClosable {f : Space d → ℂ} (hf : AEStronglyMeasurable f) : - (𝓜 f).IsClosable := - isClosable_of_exists_dense_formalAdjoint (mulOperator_hasDenseDomain hf) - ⟨𝓜 (conj ∘ f), mulOperator_hasDenseDomain (by measurability), + (𝓜 f).IsClosable := by + refine isClosable_of_exists_dense_formalAdjoint (mulOperator_hasDenseDomain hf) ?_ + exact ⟨𝓜 (conj ∘ f), mulOperator_hasDenseDomain (by measurability), mulOperator_adjoint_eq_conj hf ▸ adjoint_isFormalAdjoint (mulOperator_hasDenseDomain hf)⟩ lemma mulOperator_isUnbounded {f : Space d → ℂ} (hf : AEStronglyMeasurable f) : diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean index 55b3f918f..e6d2308c2 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean @@ -111,8 +111,8 @@ lemma radiusRegPowCLM_apply_fun {d : ℕ} (ε : ℝˣ) (s : ℝ) (ψ : 𝓢(Spac 𝐫₀ ε s ψ = fun x ↦ (‖x‖ ^ 2 + ε ^ 2) ^ (s / 2) • ψ x := by ext x dsimp [radiusRegPowCLM] - exact smulLeftCLM_apply_apply - (HasTemperateGrowth.comp (by fun_prop) (normRegularizedPow_hasTemperateGrowth d ε s)) ψ x + refine smulLeftCLM_apply_apply ?_ ψ x + exact HasTemperateGrowth.comp (by fun_prop) (normRegularizedPow_hasTemperateGrowth d ε s) @[simp] lemma radiusRegPowCLM_apply {d : ℕ} (ε : ℝˣ) (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (x : Space d) : @@ -237,17 +237,17 @@ lemma radiusPowLM_apply_memHS {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (a : rw [Real.rpow_neg hx'.le] exact (le_mul_inv_iff₀' <| Real.rpow_pos_of_pos hx' _).mpr (hC x) calc - _ ≤ (C * ‖x‖ ^ (-(⌈s⌉.toNat + d) : ℝ)) ^ 2 * ‖x‖ ^ (2 * s) := - mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (norm_nonneg _) hψ 2) - (Real.rpow_nonneg hx'.le _) + _ ≤ (C * ‖x‖ ^ (-(⌈s⌉.toNat + d) : ℝ)) ^ 2 * ‖x‖ ^ (2 * s) := by + refine mul_le_mul_of_nonneg_right ?_ (Real.rpow_nonneg hx'.le _) + exact pow_le_pow_left₀ (norm_nonneg _) hψ 2 _ = C ^ 2 * ‖x‖ ^ (-2 * d : ℝ) * ‖x‖ ^ (2 * (s - ⌈s⌉.toNat) : ℝ) := by simp_rw [mul_pow, ← Real.rpow_mul_natCast hx'.le, mul_assoc, ← Real.rpow_add hx'] ring_nf suffices s ≤ ⌈s⌉.toNat by have h' : 0 < C ^ 2 * ‖x‖ ^ (-2 * d : ℝ) := mul_pos (sq_pos_of_pos hC_pos) (Real.rpow_pos_of_pos hx' _) - exact (mul_le_iff_le_one_right h').mpr - (Real.rpow_le_one_of_one_le_of_nonpos hx (by linarith)) + apply (mul_le_iff_le_one_right h').mpr + exact Real.rpow_le_one_of_one_le_of_nonpos hx (by linarith) exact (Int.le_ceil s).trans (by exact_mod_cast Int.self_le_toNat ⌈s⌉) /-! @@ -270,9 +270,9 @@ lemma radiusRegPow_tendsto_radiusPow {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ have hpow : ‖x‖ ^ s = (‖x‖ ^ 2 + 0 ^ 2) ^ (s / 2) := by simp [← Real.rpow_natCast_mul, mul_div_cancel₀] simp only [radiusRegPowCLM_apply, radiusPowLM_apply, Complex.real_smul, hpow] - exact Tendsto.mul_const (ψ x) <| Tendsto.ofReal - (Tendsto.rpow_const (Tendsto.const_add _ <| Tendsto.pow tendsto_comap 2) - (Or.inl <| by simp [hx])) + refine Tendsto.mul_const (ψ x) <| Tendsto.ofReal ?_ + refine Tendsto.rpow_const ?_ (Or.inl <| by simp [hx]) + exact Tendsto.const_add _ <| Tendsto.pow tendsto_comap 2 /-- `𝐫[ε,s] ψ` converges pointwise to `𝐫[s] ψ` as `ε → 0` provided `𝐫[ε,s] ψ 0` is bounded. -/ lemma radiusRegPow_tendsto_radiusPow' {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (h : 0 ≤ s ∨ ψ 0 = 0) : @@ -285,8 +285,8 @@ lemma radiusRegPow_tendsto_radiusPow' {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, have : (0 : ℝ) ^ s = (0 ^ 2) ^ (s / 2) := by rw [← Real.rpow_natCast_mul (le_refl 0), Nat.cast_ofNat, mul_div_cancel₀ s (by norm_num)] rw [this] - exact Tendsto.mul_const (ψ 0) <| Tendsto.ofReal - (Tendsto.rpow_const (Tendsto.pow tendsto_comap 2) (Or.inr <| by linarith)) + refine Tendsto.mul_const (ψ 0) <| Tendsto.ofReal ?_ + exact Tendsto.rpow_const (Tendsto.pow tendsto_comap 2) (Or.inr <| by linarith) · simp [hψ] · exact radiusRegPow_tendsto_radiusPow s ψ hx.ne diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean index da9259ec6..23c95332c 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean @@ -225,9 +225,9 @@ lemma regularityDomain_isOpen (T : H →ₗ.[ℂ] H) : IsOpen T.regularityDomain /-- `T` and `T.closure` have the same regularity domain. -/ lemma regularityDomain_closure (T : H →ₗ.[ℂ] H) : - T.closure.regularityDomain = T.regularityDomain := - eq_of_le_of_ge (regularityDomain_antitone T.le_closure) - fun _ ⟨c, hc, h⟩ ↦ ⟨c, hc, isLowerBound_closure h⟩ + T.closure.regularityDomain = T.regularityDomain := by + refine eq_of_le_of_ge (regularityDomain_antitone T.le_closure) ?_ + exact fun _ ⟨c, hc, h⟩ ↦ ⟨c, hc, isLowerBound_closure h⟩ lemma IsClosable.closure_range_sub_eq_range_closure_sub [CompleteSpace H] {T : H →ₗ.[ℂ] H} (hT : T.IsClosable) {z : ℂ} (hz : z ∈ T.regularityDomain) : @@ -688,8 +688,8 @@ lemma IsClosed.resolventSet_eq [CompleteSpace H] {T : H →ₗ.[ℂ] H} (hT : T. rw [mem_resolventSet_iff, mem_setOf_eq, and_congr_right_iff, and_iff_left_iff_imp] intro h_ker h_range refine continuous_of_isClosed_domain ?_ ?_ - · exact (inverse_closed_iff h_ker).mpr - (hT.sub_continuous (Continuous.const_smul (by fun_prop) _) (by simp)) + · apply (inverse_closed_iff h_ker).mpr + exact hT.sub_continuous (Continuous.const_smul (by fun_prop) _) (by simp) · simp [inverse_domain, h_range] /-- For a closed operator the resolvent set consists of those regular points for which @@ -833,8 +833,8 @@ lemma IsClosed.spectrum_eq [CompleteSpace H] {T : H →ₗ.[ℂ] H} (hT : T.IsCl rw [mem_continuousSpectrum_iff, ← inverse_domain] refine fun h ↦ h_cont ?_ refine continuous_of_isClosed_domain ?_ h - exact (inverse_closed_iff h_ker).mpr - (hT.sub_continuous (Continuous.const_smul (by fun_prop) _) le_top) + apply (inverse_closed_iff h_ker).mpr + exact hT.sub_continuous (Continuous.const_smul (by fun_prop) _) le_top · left; left; exact h_ker · refine union_subset ?_ T.continuousSpectrum_subset_spectrum exact union_subset T.pointSpectrum_subset_spectrum T.residualSpectrum_subset_spectrum diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Symmetric.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Symmetric.lean index ac855bc56..75725cab5 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Symmetric.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Symmetric.lean @@ -186,15 +186,15 @@ lemma regularityDomain_isConnected_iff : lemma regularityDomain_isConnected_of_bddBelow (h : BddBelow (Θᵣₑ T)) : IsConnected T.regularityDomain := by obtain ⟨m, hm⟩ := h - exact hT.regularityDomain_isConnected_iff.mpr - ⟨m - 1, hT.Iio_subset_regularityDomain hm ⟨m - 1, by simp⟩⟩ + apply hT.regularityDomain_isConnected_iff.mpr + exact ⟨m - 1, hT.Iio_subset_regularityDomain hm ⟨m - 1, by simp⟩⟩ /-- The regularity domain of an upper semibounded symmetric operator is connected. -/ lemma regularityDomain_isConnected_of_bddAbove (h : BddAbove (Θᵣₑ T)) : IsConnected T.regularityDomain := by obtain ⟨m, hm⟩ := h - exact hT.regularityDomain_isConnected_iff.mpr - ⟨m + 1, hT.Ioi_subset_regularityDomain hm ⟨m + 1, by simp⟩⟩ + apply hT.regularityDomain_isConnected_iff.mpr + exact ⟨m + 1, hT.Ioi_subset_regularityDomain hm ⟨m + 1, by simp⟩⟩ /-! ## C. Point spectrum diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean index 637e9bdcc..372e833c1 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean @@ -115,11 +115,11 @@ lemma raw_commutator_eq_of_symmetric (h_raw : ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩ - B ⟨A ψ, hBA⟩⟫_ℂ = Complex.I * c) : ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = Complex.I * c := by have ha_pairing : - ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ := - hA ψ ⟨B ⟨ψ, hψB⟩, hAB⟩ + ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ := by + exact hA ψ ⟨B ⟨ψ, hψB⟩, hAB⟩ have hb_pairing : - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), B ⟨A ψ, hBA⟩⟫_ℂ := - hB ⟨ψ, hψB⟩ ⟨A ψ, hBA⟩ + ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), B ⟨A ψ, hBA⟩⟫_ℂ := by + exact hB ⟨ψ, hψB⟩ ⟨A ψ, hBA⟩ calc ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ - @@ -145,7 +145,7 @@ def rawCommutatorExpectation (A B : H →ₗ.[ℂ] H) lemma commutator_half_sq_le_mul_norm_sq {u v : H} {c : ℝ} (h_comm : ⟪u, v⟫_ℂ - ⟪v, u⟫_ℂ = Complex.I * c) : (|c| / 2) ^ 2 ≤ (‖u‖ * ‖v‖) ^ 2 := by - suffices (|c| / 2) ^ 2 ≤ (‖u‖ * ‖v‖) ^ 2 from this + suffices (|c| / 2) ^ 2 ≤ (‖u‖ * ‖v‖) ^ 2 by exact this have h_sq : |c / 2| ^ 2 ≤ (‖u‖ * ‖v‖) ^ 2 := by have h_bound : |c / 2| ≤ ‖u‖ * ‖v‖ := by have h_im : |(⟪u, v⟫_ℂ).im| ≤ ‖u‖ * ‖v‖ := @@ -158,7 +158,7 @@ lemma commutator_half_sq_le_mul_norm_sq {u v : H} {c : ℝ} private lemma sqrt_mul_le_of_sq_le {x y z : ℝ} (hx : 0 ≤ x) (hz : 0 ≤ z) (hxy : z ^ 2 ≤ x * y) : z ≤ Real.sqrt x * Real.sqrt y := by - suffices z ≤ Real.sqrt x * Real.sqrt y from this + suffices z ≤ Real.sqrt x * Real.sqrt y by exact this have hs : Real.sqrt (z ^ 2) ≤ Real.sqrt (x * y) := Real.sqrt_le_sqrt hxy rw [Real.sqrt_sq hz, Real.sqrt_mul hx] at hs simpa [mul_comm] using hs diff --git a/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean b/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean index 0b0c01b1c..c2644baa3 100644 --- a/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean +++ b/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean @@ -233,8 +233,8 @@ lemma dense_top (d : ℕ) : Dense (polyBddSchwartzSubmodule d ⊤ : Set (SpaceDH refine mk (f := s n) ⟨?_, ?_⟩ · exact (continuous_ofReal.comp (b n).continuous).aestronglyMeasurable.mul ξ.val.aestronglyMeasurable - · exact lt_of_le_of_lt (eLpNorm_mono_enorm (enorm_bump_mul_le_enorm (b n) ξ)) - (coe_hilbertSpace_memHS ξ).2 + · refine lt_of_le_of_lt ?_ (coe_hilbertSpace_memHS ξ).2 + exact eLpNorm_mono_enorm (enorm_bump_mul_le_enorm (b n) ξ) have hψ_ae (n : ℕ) : ψ n =ᵐ[volume] f n := (schwartzEquiv_symm_coe_ae ⟨ψ n, hψ n⟩).symm have hφ_ae (n : ℕ) : φ n =ᵐ[volume] g n := schwartzEquiv_coe_ae (g n) have hσ_ae (n : ℕ) : σ n =ᵐ[volume] s n := coe_mk_ae _ @@ -260,8 +260,8 @@ lemma dense_top (d : ℕ) : Dense (polyBddSchwartzSubmodule d ⊤ : Set (SpaceDH ENNReal.ofReal_pow (b n).rOut_pos.le] simp_rw [hvolB, ← ENNReal.ofReal_zero, b, ← one_div, mul_pow, ← mul_assoc] rw [← mul_zero (C * 2 ^ d), ← zero_pow (M₀ := ℝ) hd.ne'] - exact ENNReal.tendsto_ofReal <| Tendsto.const_mul (C * 2 ^ d) - (tendsto_one_div_add_atTop_nhds_zero_nat.pow d) + refine ENNReal.tendsto_ofReal <| Tendsto.const_mul (C * 2 ^ d) ?_ + exact tendsto_one_div_add_atTop_nhds_zero_nat.pow d refine Tendsto.squeeze tendsto_const_nhds hξB (zero_le) (fun n ↦ ?_) suffices ∫⁻ x, ‖σ n x‖ₑ ^ 2 = ∫⁻ x in B n, ‖σ n x‖ₑ ^ 2 by rw [this] diff --git a/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean b/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean index 1a4ebb4d4..7c3a4b8fa 100644 --- a/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean @@ -24,8 +24,8 @@ open HilbertSpace Constants private lemma fun_add {α : Type*} (f g : α → ℂ) : (fun x ↦ f x) + (fun x ↦ g x) = fun x ↦ f x + g x := rfl -private lemma fun_smul (a1: ℂ) (f : ℝ → ℂ) : (a1 • fun x ↦ f x) = (fun x ↦ a1*(f x)) := - rfl +private lemma fun_smul (a1: ℂ) (f : ℝ → ℂ) : (a1 • fun x ↦ f x) = (fun x ↦ a1*(f x)) := by + rfl lemma momentumOperator_linear (a1 a2 : ℂ) (ψ1 ψ2 : ℝ → ℂ) (hψ1_x: Differentiable ℝ ψ1) (hψ2_x: Differentiable ℝ ψ2) : diff --git a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean index 6aa981278..e9c20051a 100644 --- a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean @@ -42,12 +42,12 @@ lemma Complex.ofReal_hasDerivAt : HasDerivAt Complex.ofReal 1 x := by exact hasDerivAt_id _ @[simp] -lemma Complex.deriv_ofReal : deriv Complex.ofReal x = 1 := - HasDerivAt.deriv Complex.ofReal_hasDerivAt +lemma Complex.deriv_ofReal : deriv Complex.ofReal x = 1 := by + exact HasDerivAt.deriv Complex.ofReal_hasDerivAt @[fun_prop] -lemma Complex.differentiableAt_ofReal : DifferentiableAt ℝ Complex.ofReal x := - HasFDerivAt.differentiableAt Complex.ofReal_hasDerivAt +lemma Complex.differentiableAt_ofReal : DifferentiableAt ℝ Complex.ofReal x := by + exact HasFDerivAt.differentiableAt Complex.ofReal_hasDerivAt /-! diff --git a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean index 8ff5cea18..67623e9d4 100644 --- a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean @@ -156,8 +156,8 @@ lemma mk_eq_iff {f g : ℝ → ℂ} {hf : MemHS f} {hg : MemHS g} : simp [mk] lemma ext_iff {f g : HilbertSpace} : - f = g ↔ (f : ℝ → ℂ) =ᶠ[ae volume] (g : ℝ → ℂ) := - Lp.ext_iff + f = g ↔ (f : ℝ → ℂ) =ᶠ[ae volume] (g : ℝ → ℂ) := by + exact Lp.ext_iff end HilbertSpace end diff --git a/Physlib/QuantumMechanics/OneDimension/ReflectionlessPotential/Basic.lean b/Physlib/QuantumMechanics/OneDimension/ReflectionlessPotential/Basic.lean index 9bc48f59a..9151f8a44 100644 --- a/Physlib/QuantumMechanics/OneDimension/ReflectionlessPotential/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/ReflectionlessPotential/Basic.lean @@ -77,8 +77,8 @@ noncomputable def mulByTemperateGrowth {g : ℝ → ℂ} (hg : g.HasTemperateGro -- First, you need a theorem that the scaled tanh has temperate growth lemma scaled_tanh_hasTemperateGrowth (κ : ℝ) : - Function.HasTemperateGrowth (fun x => (Real.tanh (κ * x))) := - tanh_const_mul_hasTemperateGrowth κ + Function.HasTemperateGrowth (fun x => (Real.tanh (κ * x))) := by + exact tanh_const_mul_hasTemperateGrowth κ /-- This is a helper lemma to show that the embedding of a real function with temperate growth in ℂ also has temperate growth -/ diff --git a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean index d1eccdbd0..e23ddb96d 100644 --- a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean +++ b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean @@ -176,5 +176,5 @@ theorem exp_isOrthochronous (A : lorentzAlgebra) : restricted Lorentz group. -/ theorem exp_mem_restricted_lorentzGroup (A : lorentzAlgebra) : (⟨NormedSpace.exp A.1, exp_mem_lorentzGroup A⟩ : LorentzGroup 3) ∈ - LorentzGroup.restricted 3 := - ⟨exp_isProper A, exp_isOrthochronous A⟩ + LorentzGroup.restricted 3 := by + exact ⟨exp_isProper A, exp_isOrthochronous A⟩ diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean index a6db4d5e6..bc226a563 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean @@ -95,8 +95,8 @@ where ring · simp only [hk', ↓reduceIte, Fin.isValue] rw [one_apply_ne fun a => hk (id (Eq.symm a))] - rw [if_neg fun a => hk (id (Eq.symm a))] - rw [if_neg fun a => hk' (id (Eq.symm a))] + rw [if_neg (by exact fun a => hk (id (Eq.symm a)))] + rw [if_neg (by exact fun a => hk' (id (Eq.symm a)))] simp · intro b _ hb simp [hb] diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean index 47ac256ed..bcd0414a6 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean @@ -111,8 +111,8 @@ lemma genBoostAux₂_basis_minkowskiProduct (u v : Velocity d) (μ ν : Fin 1 rw [minkowskiProduct_symm] ring dsimp - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := - Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by + exact Velocity.one_add_minkowskiProduct_ne_zero u v field_simp [h2] have h2 : (minkowskiProduct ↑v) u.1 = ⟪u.1, v.1⟫ₘ := by rw [minkowskiProduct_symm] simp only [map_add, _root_.smul_add, _root_.neg_smul, add_apply, _root_.neg_apply, smul_apply, @@ -130,8 +130,8 @@ lemma genBoostAux₁_basis_genBoostAux₂_minkowskiProduct (u v : Velocity d) ( ring simp only [smul_apply, map_add, Velocity.minkowskiProduct_self_eq_one, smul_eq_mul, neg_mul, neg_inj] - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := - Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by + exact Velocity.one_add_minkowskiProduct_ne_zero u v field_simp [h2] rw [minkowskiProduct_symm] ring @@ -172,8 +172,8 @@ lemma basis_minkowskiProduct_genBoostAux₁_add_genBoostAux₂ (u v : Velocity d rw [genBoostAux₁_apply_basis, genBoostAux₂_apply_basis] rw [map_smul, map_smul] simp - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := - Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by + exact Velocity.one_add_minkowskiProduct_ne_zero u v field_simp ring diff --git a/Physlib/Relativity/LorentzGroup/Proper.lean b/Physlib/Relativity/LorentzGroup/Proper.lean index 9bd5c603d..98bbc1201 100644 --- a/Physlib/Relativity/LorentzGroup/Proper.lean +++ b/Physlib/Relativity/LorentzGroup/Proper.lean @@ -43,8 +43,8 @@ local notation "ℤ₂" => Multiplicative (ZMod 2) instance : TopologicalSpace ℤ₂ := instTopologicalSpaceFin /-- The topological space defined by `ℤ₂` is discrete. -/ -instance : DiscreteTopology ℤ₂ := - discreteTopology_iff_forall_isOpen.mpr fun _ => trivial +instance : DiscreteTopology ℤ₂ := by + exact discreteTopology_iff_forall_isOpen.mpr fun _ => trivial /-- The instance of a topological group on `ℤ₂` defined via the discrete topology. -/ instance : IsTopologicalGroup ℤ₂ := IsTopologicalGroup.mk @@ -60,10 +60,10 @@ def coeForℤ₂ : C(({-1, 1} : Set ℝ), ℤ₂) where def detContinuous : C(𝓛 d, ℤ₂) := ContinuousMap.comp coeForℤ₂ { toFun := fun Λ => ⟨Λ.1.det, Or.symm (LorentzGroup.det_eq_one_or_neg_one _)⟩, - continuous_toFun := - Continuous.subtype_mk - (Continuous.matrix_det <| - Continuous.comp' (continuous_iff_le_induced.mpr fun _ a => a) continuous_id') _ + continuous_toFun := by + refine Continuous.subtype_mk ?_ _ + exact Continuous.matrix_det $ + Continuous.comp' (continuous_iff_le_induced.mpr fun U a => a) continuous_id' } lemma detContinuous_eq_one (Λ : LorentzGroup d) : diff --git a/Physlib/Relativity/LorentzGroup/Restricted/Basic.lean b/Physlib/Relativity/LorentzGroup/Restricted/Basic.lean index 4baebe772..f42a69c9a 100644 --- a/Physlib/Relativity/LorentzGroup/Restricted/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Restricted/Basic.lean @@ -34,12 +34,12 @@ def restricted (d : ℕ) : Subgroup (LorentzGroup d) where mul_mem' := by rintro Λ₁ Λ₂ ⟨Λ₁_proper, Λ₁_ortho⟩ ⟨Λ₂_proper, Λ₂_ortho⟩ exact ⟨ - isProper_mul Λ₁_proper Λ₂_proper, - isOrthochronous_mul Λ₁_ortho Λ₂_ortho⟩ + by exact isProper_mul Λ₁_proper Λ₂_proper, + by exact isOrthochronous_mul Λ₁_ortho Λ₂_ortho⟩ inv_mem' := by rintro Λ ⟨Λ_proper, Λ_ortho⟩ - have h_η₀₀ : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := rfl + have h_η₀₀ : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := by rfl have h_dual : (dual Λ.1) (Sum.inl 0) (Sum.inl 0) = Λ.1 (Sum.inl 0) (Sum.inl 0) := by rw [dual_apply, h_η₀₀, one_mul, mul_one] diff --git a/Physlib/Relativity/LorentzGroup/Rotations.lean b/Physlib/Relativity/LorentzGroup/Rotations.lean index ec9d42a77..301b454e9 100644 --- a/Physlib/Relativity/LorentzGroup/Rotations.lean +++ b/Physlib/Relativity/LorentzGroup/Rotations.lean @@ -80,8 +80,8 @@ def ofSpecialOrthogonal {d} : simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] using h.1 have h2 : LorentzGroup.toVector (LorentzGroup.transpose Λ) = Lorentz.Vector.basis (Sum.inl 0) := by - simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one, - LorentzGroup.transpose_val] using h.1 + rw [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] + exact h.1 funext i j match i, j with | .inl 0, .inl 0 => simp [h.1] @@ -132,8 +132,8 @@ def ofSpecialOrthogonal {d} : simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] using h.1 have h2 : LorentzGroup.toVector (LorentzGroup.transpose Λ) = Lorentz.Vector.basis (Sum.inl 0) := by - simpa [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one, - LorentzGroup.transpose_val] using h.1 + rw [LorentzGroup.toVector_eq_basis_iff_timeComponent_eq_one] + exact h.1 funext i j match i, j with | .inl 0, .inl 0 => simp [h.1] diff --git a/Physlib/Relativity/MinkowskiMatrix.lean b/Physlib/Relativity/MinkowskiMatrix.lean index ae81cac22..75b2e3766 100644 --- a/Physlib/Relativity/MinkowskiMatrix.lean +++ b/Physlib/Relativity/MinkowskiMatrix.lean @@ -113,7 +113,7 @@ We prove some simple properties related to the components of the Minkowski matri /-- The `time-time` component of the Minkowski matrix is `1`. -/ @[simp] -lemma inl_0_inl_0 : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := +lemma inl_0_inl_0 : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := by rfl /-- The space diagonal components of the Minkowski matrix are `-1`. -/ diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index 89738d925..e8f415116 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -198,9 +198,9 @@ lemma toSelfAdjointMap_pauliBasis (i : Fin 1 ⊕ Fin 3) : apply congrArg funext j rw [smul_smul, PauliMatrix.pauliBasis_minkowskiMetric_pauliBasis', smul_smul] - exact congrFun - (congrArg _ (Eq.symm (minkowskiMatrix.dual_apply_minkowskiMatrix ((toLorentzGroup M).1) i j))) - _ + apply congrFun + apply congrArg + exact Eq.symm (minkowskiMatrix.dual_apply_minkowskiMatrix ((toLorentzGroup M).1) i j) /-- The first column of the Lorentz matrix formed from an element of `SL(2, ℂ)`. -/ lemma toLorentzGroup_fst_col (M : SL(2, ℂ)) : @@ -240,8 +240,8 @@ lemma toLorentzGroup_fst_col (M : SL(2, ℂ)) : /-- The first element of the image of `SL(2, ℂ)` in the Lorentz group. -/ lemma toLorentzGroup_inl_inl (M : SL(2, ℂ)) : (toLorentzGroup M).1 (Sum.inl 0) (Sum.inl 0) = - ((‖M.1 0 0‖ ^ 2 + ‖M.1 0 1‖ ^ 2 + ‖M.1 1 0‖ ^ 2 + ‖M.1 1 1‖ ^ 2) / 2) := - congrFun (toLorentzGroup_fst_col M) (Sum.inl 0) + ((‖M.1 0 0‖ ^ 2 + ‖M.1 0 1‖ ^ 2 + ‖M.1 1 0‖ ^ 2 + ‖M.1 1 1‖ ^ 2) / 2) := by + exact congrFun (toLorentzGroup_fst_col M) (Sum.inl 0) /-- The image of `SL(2, ℂ)` in the Lorentz group is orthochronous. -/ lemma toLorentzGroup_isOrthochronous (M : SL(2, ℂ)) : diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index d854538aa..3688860b1 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -206,7 +206,7 @@ noncomputable def component {n : ℕ} {c : Fin n → C} (p : Pure S c) ∏ i, (b (c i)).repr (p i) (φ i) lemma component_eq {n : ℕ} {c : Fin n → C} (p : Pure S c) (φ : ComponentIdx c) : - p.component φ = ∏ i, (b (c i)).repr (p i) (φ i) := rfl + p.component φ = ∏ i, (b (c i)).repr (p i) (φ i) := by rfl lemma component_eq_drop {n : ℕ} {c : Fin (n + 1) → C} (p : Pure S c) (i : Fin (n + 1)) (φ : ComponentIdx c) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean index 2bd29322d..d0175eb43 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean @@ -38,8 +38,8 @@ lemma contrContrToMatrix_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin 3) (Fin 1 Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply complexContrBasis complexContrBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply complexContrBasis complexContrBasis i j) · simp /-- Equivalence of `complexCo ⊗ complexCo` to `4 x 4` complex matrices. -/ @@ -55,8 +55,8 @@ lemma coCoToMatrix_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin 3) (Fin 1 ⊕ Fin simp only [coCoToMatrix, LinearEquiv.trans_symm, LinearEquiv.trans_apply, Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply complexCoBasis complexCoBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply complexCoBasis complexCoBasis i j) · simp /-- Equivalence of `complexContr ⊗ complexCo` to `4 x 4` complex matrices. -/ @@ -73,8 +73,8 @@ lemma contrCoToMatrix_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin 3) (Fin 1 ⊕ Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply complexContrBasis complexCoBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply complexContrBasis complexCoBasis i j) · simp /-- Equivalence of `complexCo ⊗ complexContr` to `4 x 4` complex matrices. -/ @@ -91,8 +91,8 @@ lemma coContrToMatrix_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin 3) (Fin 1 ⊕ Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply complexCoBasis complexContrBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply complexCoBasis complexContrBasis i j) · simp /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Lemmas.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Lemmas.lean index 8944c699b..0f6fa5fe7 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Lemmas.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Lemmas.lean @@ -105,38 +105,38 @@ lemma dualRightMetric_antisymm : {εR' | α α' = - (εR' | α' α)}ᵀ := by /-- The contraction of the covariant metric with the contravariant metric is the unit `{η' | μ ρ ⊗ η | ρ ν = δ' | μ ν}ᵀ`. -/ -lemma coMetric_contr_contrMetric : {η' | μ ρ ⊗ η | ρ ν = δ' | μ ν}ᵀ := - contrT_metricTensor_metricTensor_eq_dual_unit +lemma coMetric_contr_contrMetric : {η' | μ ρ ⊗ η | ρ ν = δ' | μ ν}ᵀ := by + exact contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the contravariant metric with the covariant metric is the unit `{η | μ ρ ⊗ η' | ρ ν = δ | μ ν}ᵀ`. -/ -lemma contrMetric_contr_coMetric : {η | μ ρ ⊗ η' | ρ ν = δ | μ ν}ᵀ := - contrT_metricTensor_metricTensor_eq_dual_unit +lemma contrMetric_contr_coMetric : {η | μ ρ ⊗ η' | ρ ν = δ | μ ν}ᵀ := by + exact contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the left metric with the dual-left metric is the unit `{εL | α β ⊗ εL' | β γ = δL | α γ}ᵀ`. -/ -lemma leftMetric_contr_dualLeftMetric : {εL | α β ⊗ εL' | β γ = δL | α γ}ᵀ := - contrT_metricTensor_metricTensor_eq_dual_unit +lemma leftMetric_contr_dualLeftMetric : {εL | α β ⊗ εL' | β γ = δL | α γ}ᵀ := by + exact contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the right metric with the dual-right metric is the unit `{εR | α β ⊗ εR' | β γ = δR | α γ}ᵀ`. -/ -lemma rightMetric_contr_dualRightMetric : {εR | α β ⊗ εR' | β γ = δR | α γ}ᵀ := - contrT_metricTensor_metricTensor_eq_dual_unit +lemma rightMetric_contr_dualRightMetric : {εR | α β ⊗ εR' | β γ = δR | α γ}ᵀ := by + exact contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the dual-left metric with the left metric is the unit `{εL' | α β ⊗ εL | β γ = δL' | α γ}ᵀ`. -/ -lemma dualLeftMetric_contr_leftMetric : {εL' | α β ⊗ εL | β γ = δL' | α γ}ᵀ := - contrT_metricTensor_metricTensor_eq_dual_unit +lemma dualLeftMetric_contr_leftMetric : {εL' | α β ⊗ εL | β γ = δL' | α γ}ᵀ := by + exact contrT_metricTensor_metricTensor_eq_dual_unit /-- The contraction of the dual-right metric with the right metric is the unit `{εR' | α β ⊗ εR | β γ = δR' | α γ}ᵀ`. -/ -lemma dualRightMetric_contr_rightMetric : {εR' | α β ⊗ εR | β γ = δR' | α γ}ᵀ := - contrT_metricTensor_metricTensor_eq_dual_unit +lemma dualRightMetric_contr_rightMetric : {εR' | α β ⊗ εR | β γ = δR' | α γ}ᵀ := by + exact contrT_metricTensor_metricTensor_eq_dual_unit /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean index e281fcf3f..0be7cec11 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean @@ -138,8 +138,8 @@ lemma contrCoContraction_apply_metric : (TensorProduct.assoc ℂ _ _ _).symm.toLinearMap.lTensor _<| TensorProduct.assoc ℂ _ _ (_ ⊗[ℂ] _) <| (contrMetric 1) ⊗ₜ[ℂ] (coMetric 1)) = coContrUnit (1 : ℝ) := by - rw [contrMetric_apply_one, coMetric_apply_one, contrMetricVal_expand_tmul, - coMetricVal_expand_tmul] + rw [contrMetric_apply_one, coMetric_apply_one] + rw [contrMetricVal_expand_tmul, coMetricVal_expand_tmul] simp [Fin.isValue, tmul_sub, sub_tmul, map_sub] simp only [← Representation.IntertwiningMap.toLinearMap_apply] repeat erw [contrCoContraction_basis'] @@ -154,8 +154,8 @@ lemma coContrContraction_apply_metric : (TensorProduct.assoc ℂ _ _ _).symm.toLinearMap.lTensor _<| TensorProduct.assoc ℂ _ _ (_ ⊗[ℂ] _) <| (coMetric 1) ⊗ₜ[ℂ] (contrMetric 1)) = contrCoUnit (1 : ℝ) := by - rw [coMetric_apply_one, contrMetric_apply_one, coMetricVal_expand_tmul, - contrMetricVal_expand_tmul] + rw [coMetric_apply_one, contrMetric_apply_one] + rw [coMetricVal_expand_tmul, contrMetricVal_expand_tmul] simp [Fin.isValue, tmul_sub, sub_tmul, map_sub] simp only [← Representation.IntertwiningMap.toLinearMap_apply] repeat erw [coContrContraction_basis'] diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean index 3776bd696..24f54ab9d 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean @@ -89,7 +89,7 @@ def contrCoContraction : (ContrℂModule.SL2CRep.tprod CoℂModule.SL2CRep).Inte simp lemma contrCoContraction_hom_tmul (ψ : ContrℂModule) (φ : CoℂModule) : - contrCoContraction (ψ ⊗ₜ φ) = ψ.toFin13ℂ ⬝ᵥ φ.toFin13ℂ := + contrCoContraction (ψ ⊗ₜ φ) = ψ.toFin13ℂ ⬝ᵥ φ.toFin13ℂ := by rfl lemma contrCoContraction_basis (i j : Fin 4) : @@ -126,7 +126,7 @@ def coContrContraction : (CoℂModule.SL2CRep.tprod ContrℂModule.SL2CRep).Inte simp lemma coContrContraction_hom_tmul (φ : CoℂModule) (ψ : ContrℂModule) : - coContrContraction (φ ⊗ₜ ψ) = φ.toFin13ℂ ⬝ᵥ ψ.toFin13ℂ := + coContrContraction (φ ⊗ₜ ψ) = φ.toFin13ℂ ⬝ᵥ ψ.toFin13ℂ := by rfl lemma coContrContraction_basis (i j : Fin 4) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean index 0c75ea68e..4748e2992 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean @@ -140,7 +140,7 @@ def leftDualContraction : (leftHandedRep.tprod dualLeftHandedRep).IntertwiningMa lemma leftDualContraction_hom_tmul (ψ : LeftHandedWeyl) (φ : DualLeftHandedWeyl) : - leftDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := + leftDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := by rfl lemma leftDualContraction_basis (i j : Fin 2) : @@ -149,8 +149,8 @@ lemma leftDualContraction_basis (i j : Fin 2) : simp only [leftBasis_toFin2ℂ, dualLeftBasis_toFin2ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] simp only [Fin.ext_iff] - exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) - (congrFun rfl) (congrFun rfl) + refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) + exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) /-- The linear map from DualLeftHandedWeyl ⊗ leftHandedWeyl to ℂ given by summing over components of DualLeftHandedWeyl and leftHandedWeyl in the @@ -166,7 +166,7 @@ def dualLeftContraction : (dualLeftHandedRep.tprod leftHandedRep).IntertwiningMa simp lemma dualLeftContraction_hom_tmul (φ : DualLeftHandedWeyl) (ψ : LeftHandedWeyl) : - dualLeftContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := + dualLeftContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := by rfl lemma dualLeftContraction_basis (i j : Fin 2) : @@ -175,8 +175,8 @@ lemma dualLeftContraction_basis (i j : Fin 2) : simp only [dualLeftBasis_toFin2ℂ, leftBasis_toFin2ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] simp only [Fin.ext_iff] - exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) - (congrFun rfl) (congrFun rfl) + refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) + exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) /-- The linear map from `rightHandedWeyl ⊗ DualRightHandedWeyl` to `ℂ` given by @@ -191,7 +191,7 @@ def rightDualContraction : (rightHandedRep.tprod dualRightHandedRep).Intertwinin isIntertwining' M := TensorProduct.ext' fun ψ φ => by change (M.1.map star *ᵥ ψ.toFin2ℂ) ⬝ᵥ (M.1⁻¹.conjTranspose *ᵥ φ.toFin2ℂ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ - have h1 : (M.1)⁻¹ᴴ = ((M.1)⁻¹.map star)ᵀ := rfl + have h1 : (M.1)⁻¹ᴴ = ((M.1)⁻¹.map star)ᵀ := by rfl rw [dotProduct_mulVec, h1, vecMul_transpose, mulVec_mulVec] have h2 : ((M.1)⁻¹.map star * (M.1).map star) = 1 := by refine transpose_inj.mp ?_ @@ -206,7 +206,7 @@ def rightDualContraction : (rightHandedRep.tprod dualRightHandedRep).Intertwinin lemma rightDualContraction_hom_tmul (ψ : RightHandedWeyl) (φ : DualRightHandedWeyl) : - rightDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := + rightDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := by rfl lemma rightDualContraction_basis (i j : Fin 2) : @@ -216,8 +216,8 @@ lemma rightDualContraction_basis (i j : Fin 2) : simp only [rightBasis_toFin2ℂ, dualRightBasis_toFin2ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] simp only [Fin.ext_iff] - exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) - (congrFun rfl) (congrFun rfl) + refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) + exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) /-- The linear map from DualRightHandedWeyl ⊗ rightHandedWeyl to ℂ given by @@ -232,7 +232,7 @@ def dualRightContraction : (dualRightHandedRep.tprod rightHandedRep).Intertwinin isIntertwining' M := TensorProduct.ext' fun φ ψ => by change (M.1⁻¹.conjTranspose *ᵥ φ.toFin2ℂ) ⬝ᵥ (M.1.map star *ᵥ ψ.toFin2ℂ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ - have h1 : (M.1)⁻¹ᴴ = ((M.1)⁻¹.map star)ᵀ := rfl + have h1 : (M.1)⁻¹ᴴ = ((M.1)⁻¹.map star)ᵀ := by rfl rw [dotProduct_mulVec, h1, mulVec_transpose, vecMul_vecMul] have h2 : ((M.1)⁻¹.map star * (M.1).map star) = 1 := by refine transpose_inj.mp ?_ @@ -247,7 +247,7 @@ def dualRightContraction : (dualRightHandedRep.tprod rightHandedRep).Intertwinin lemma dualRightContraction_hom_tmul (φ : DualRightHandedWeyl) (ψ : RightHandedWeyl) : - dualRightContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := + dualRightContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := by rfl lemma dualRightContraction_basis (i j : Fin 2) : @@ -257,8 +257,8 @@ lemma dualRightContraction_basis (i j : Fin 2) : simp only [dualRightBasis_toFin2ℂ, rightBasis_toFin2ℂ, dotProduct_single, mul_one] rw [Pi.single_apply] simp only [Fin.ext_iff] - exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) - (congrFun rfl) (congrFun rfl) + refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) + exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean index c80c3966a..377d28433 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean @@ -276,8 +276,8 @@ lemma leftDualContraction_apply_metric : (TensorProduct.assoc ℂ _ _ _).symm.toLinearMap.lTensor _<| TensorProduct.assoc ℂ _ _ (_ ⊗[ℂ] _) <| (leftMetric 1) ⊗ₜ[ℂ] (dualLeftMetric 1)) = dualLeftLeftUnit (1 : ℂ) := by - rw [leftMetric_apply_one, dualLeftMetric_apply_one, leftMetricVal_expand_tmul', - dualLeftMetricVal_expand_tmul] + rw [leftMetric_apply_one, dualLeftMetric_apply_one] + rw [leftMetricVal_expand_tmul', dualLeftMetricVal_expand_tmul] simp only [Fin.isValue, tmul_sub, sub_tmul, map_sub, assoc_tmul, LinearMap.lTensor_tmul, LinearEquiv.coe_coe, assoc_symm_tmul, LinearMap.rTensor_tmul, Representation.IntertwiningMap.coe_toLinearMap, LinearEquiv.lTensor_tmul, lid_tmul, tmul_smul, diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean index e7e2ff315..d6ef3db03 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Two.lean @@ -42,8 +42,8 @@ lemma leftLeftToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply leftBasis leftBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply leftBasis leftBasis i j) · simp /-- Equivalence of `dualLeftHanded ⊗ dualLeftHanded` to `2 x 2` complex matrices. -/ @@ -61,8 +61,8 @@ lemma dualLeftdualLeftToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply dualLeftBasis dualLeftBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply dualLeftBasis dualLeftBasis i j) · simp /-- Equivalence of `leftHanded ⊗ dualLeftHanded` to `2 x 2` complex matrices. -/ @@ -79,8 +79,8 @@ lemma leftDualLeftToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply leftBasis dualLeftBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply leftBasis dualLeftBasis i j) · simp /-- Equivalence of `dualLeftHanded ⊗ leftHanded` to `2 x 2` complex matrices. -/ @@ -97,8 +97,8 @@ lemma dualLeftLeftToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply dualLeftBasis leftBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply dualLeftBasis leftBasis i j) · simp /-- Equivalence of `rightHanded ⊗ rightHanded` to `2 x 2` complex matrices. -/ @@ -115,8 +115,8 @@ lemma rightRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply rightBasis rightBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply rightBasis rightBasis i j) · simp /-- Equivalence of `dualRightHanded ⊗ dualRightHanded` to `2 x 2` complex matrices. -/ @@ -134,8 +134,8 @@ lemma dualRightDualRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply dualRightBasis dualRightBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply dualRightBasis dualRightBasis i j) · simp /-- Equivalence of `rightHanded ⊗ dualRightHanded` to `2 x 2` complex matrices. -/ @@ -152,8 +152,8 @@ lemma rightDualRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply rightBasis dualRightBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply rightBasis dualRightBasis i j) · simp /-- Equivalence of `dualRightHanded ⊗ rightHanded` to `2 x 2` complex matrices. -/ @@ -170,8 +170,8 @@ lemma dualRightRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply dualRightBasis rightBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply dualRightBasis rightBasis i j) · simp /-- Equivalence of `dualLeftHanded ⊗ dualRightHanded` to `2 x 2` complex matrices. -/ @@ -189,8 +189,8 @@ lemma dualLeftDualRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply dualLeftBasis dualRightBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply dualLeftBasis dualRightBasis i j) · simp /-- Equivalence of `leftHanded ⊗ rightHanded` to `2 x 2` complex matrices. -/ @@ -206,8 +206,8 @@ lemma leftRightToMatrix_symm_expand_tmul (M : Matrix (Fin 2) (Fin 2) ℂ) : Basis.repr_symm_apply] rw [Finsupp.linearCombination_apply_of_mem_supported ℂ (s := Finset.univ)] · rw [Fintype.sum_prod_type] - exact Finset.sum_congr rfl fun i _ => Finset.sum_congr rfl fun j _ => - congrArg _ (Basis.tensorProduct_apply leftBasis rightBasis i j) + refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) + exact congrArg _ (Basis.tensorProduct_apply leftBasis rightBasis i j) · simp /-- The coercion of `Finsupp.linearEquivFunOnFinite` to a function is the underlying diff --git a/Physlib/Relativity/Tensors/Constructors.lean b/Physlib/Relativity/Tensors/Constructors.lean index f305510e0..39f223f63 100644 --- a/Physlib/Relativity/Tensors/Constructors.lean +++ b/Physlib/Relativity/Tensors/Constructors.lean @@ -46,7 +46,7 @@ noncomputable def Pure.fromSingleP {c : C} : V c ≃ₗ[k] Pure S ![c] where ext i fin_cases i rfl - left_inv x := rfl + left_inv x := by rfl right_inv x := by ext i fin_cases i diff --git a/Physlib/Relativity/Tensors/Contraction/Pure.lean b/Physlib/Relativity/Tensors/Contraction/Pure.lean index 0ac69959d..c17ec33d9 100644 --- a/Physlib/Relativity/Tensors/Contraction/Pure.lean +++ b/Physlib/Relativity/Tensors/Contraction/Pure.lean @@ -223,7 +223,7 @@ lemma contrPCoeff_dropPair {n : ℕ} {c : Fin (n + 1 + 1) → C} (i j : Fin n) (hij : i ≠ j ∧ S.τ (c (succSuccAbove a b i)) = (c (succSuccAbove a b j))) (p : Pure S c) : (p.dropPair a b hab).contrPCoeff i j hij = p.contrPCoeff (succSuccAbove a b i) (succSuccAbove a b j) - (by simpa using hij) := rfl + (by simpa using hij) := by rfl lemma contrPCoeff_symm {n : ℕ} {c : Fin n → C} {i j : Fin n} {hij : i ≠ j ∧ S.τ (c i) = c j} {p : Pure S c} : diff --git a/Physlib/Relativity/Tensors/MetricTensor.lean b/Physlib/Relativity/Tensors/MetricTensor.lean index 3c485bc62..d2ca771d4 100644 --- a/Physlib/Relativity/Tensors/MetricTensor.lean +++ b/Physlib/Relativity/Tensors/MetricTensor.lean @@ -36,8 +36,8 @@ lemma metricTensor_congr {c c1 : C} (h : c = c1) : @[simp] lemma metricTensor_invariant {c : C} (g : G) : - g • S.metricTensor c = metricTensor c := - actionT_fromConstPair (S.metric c) g + g • S.metricTensor c = metricTensor c := by + rw [metricTensor, actionT_fromConstPair] lemma permT_fromPairTContr_metric_metric {c : C} : permT ![1, 0] (And.intro (by decide) (fun i => by fin_cases i <;> rfl)) @@ -65,8 +65,8 @@ lemma contrT_metricTensor_metricTensor {c : C} : contrT 2 1 2 (by simp; rfl) (prodT (metricTensor c) (metricTensor (S.τ c))) = permT ![1, 0] (And.intro (by decide) (fun i => by fin_cases i <;> rfl)) (unitTensor (S := S) c) := by - rw [metricTensor, metricTensor, fromConstPair, fromConstPair, - fromPairT_contr_fromPairT_eq_fromPairTContr] + rw [metricTensor, metricTensor, fromConstPair, fromConstPair] + rw [fromPairT_contr_fromPairT_eq_fromPairTContr] erw [fromPairTContr_metric_metric_eq_permT_unit] rw [permT_permT] rfl diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean index b7cd4902f..e9636635c 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean @@ -120,7 +120,7 @@ lemma apply_add {d : ℕ} (v w : CoVector d) (i : Fin 1 ⊕ Fin d) : @[simp] lemma apply_sub {d : ℕ} (v w : CoVector d) (i : Fin 1 ⊕ Fin d) : - (v - w) i = v i - w i := rfl + (v - w) i = v i - w i := by rfl @[simp] lemma apply_sum {d : ℕ} {ι : Type} [Fintype ι] (f : ι → CoVector d) (i : Fin 1 ⊕ Fin d) : @@ -158,8 +158,8 @@ lemma basis_repr_apply {d : ℕ} (p : CoVector d) (μ : Fin 1 ⊕ Fin d) : erw [Pi.basisFun_repr] lemma map_apply_eq_basis_mulVec {d : ℕ} (f : CoVector d →ₗ[ℝ] CoVector d) (p : CoVector d) : - (f p) = (LinearMap.toMatrix basis basis) f *ᵥ p := - Eq.symm (LinearMap.toMatrix_mulVec_repr basis basis f p) + (f p) = (LinearMap.toMatrix basis basis) f *ᵥ p := by + exact Eq.symm (LinearMap.toMatrix_mulVec_repr basis basis f p) end CoVector diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean index 0babc590a..a79c5cbc6 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean @@ -46,7 +46,7 @@ def rep {d : ℕ} : Representation ℝ (LorentzGroup d) (CoVector d) where -/ lemma rep_apply_eq_mulVec (d : ℕ) (Λ : LorentzGroup d) (v : CoVector d) : - rep Λ v = (LorentzGroup.transpose Λ⁻¹) *ᵥ v := rfl + rep Λ v = (LorentzGroup.transpose Λ⁻¹) *ᵥ v := by rfl lemma rep_apply_eq_sum (d : ℕ) (Λ : LorentzGroup d) (v : CoVector d) (k : Fin 1 ⊕ Fin d) : rep Λ v k = ∑ j, (Λ⁻¹).1 j k • v j := rfl diff --git a/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean index f3453e400..dddd3b1b1 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Metrics/Basic.lean @@ -89,8 +89,8 @@ lemma actionT_coMetric {d : ℕ} (g : LorentzGroup d) : /-- The tensor `contrMetric` is invariant under the action of `LorentzGroup d`. -/ @[simp] -lemma actionT_contrMetric {d} (g : LorentzGroup d) : g • η d = η d := - TensorSpecies.metricTensor_invariant g +lemma actionT_contrMetric {d} (g : LorentzGroup d) : g • η d = η d := by + erw [TensorSpecies.metricTensor_invariant] /- diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index 069d1bb2c..3a1dfb51d 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -411,7 +411,7 @@ lemma toComplexPure_component {c : Fin n → Color} (p : Pure realLorentzTensor ↑(((b' c).repr px) φx) - suffices h : P (c x) px φx h2 from h + suffices h : P (c x) px φx h2 by exact h generalize c x = c at * fin_cases c · simp only [colorToComplex, toComplexVector, Nat.reduceAdd, Fin.cast_eq_self, P, b, b'] @@ -469,24 +469,24 @@ lemma actionP_toComplexPure {n : ℕ} (c : Fin n → Color) (p : Pure realLorent · simp_all [P, b, b', colorToComplex] calc (Lorentz.ContrℂModule.SL2CRep Λ) ((toComplexVector Color.up) p) - = (Lorentz.ContrℂModule.SL2CRep Λ) (Lorentz.inclCongrRealLorentz p) := - congrArg (Lorentz.ContrℂModule.SL2CRep Λ) + = (Lorentz.ContrℂModule.SL2CRep Λ) (Lorentz.inclCongrRealLorentz p) := by + exact congrArg (Lorentz.ContrℂModule.SL2CRep Λ) (toComplexVector_up_eq_inclCongrRealLorentz p) _ = Lorentz.inclCongrRealLorentz ((Lorentz.Contr 3).ρ (toLorentzGroup Λ) p) := by rw [Lorentz.inclCongrRealLorentz_ρ] - _ = (toComplexVector Color.up) ((Lorentz.ContrMod.rep (toLorentzGroup Λ)) p) := - (toComplexVector_up_eq_inclCongrRealLorentz + _ = (toComplexVector Color.up) ((Lorentz.ContrMod.rep (toLorentzGroup Λ)) p) := by + exact (toComplexVector_up_eq_inclCongrRealLorentz ((Lorentz.ContrMod.rep (toLorentzGroup Λ)) p)).symm · simp_all [P, b, b', colorToComplex] calc (Lorentz.CoℂModule.SL2CRep Λ) ((toComplexVector Color.down) p) - = (Lorentz.CoℂModule.SL2CRep Λ) (Lorentz.inclCoRealLorentz p) := - congrArg (Lorentz.CoℂModule.SL2CRep Λ) + = (Lorentz.CoℂModule.SL2CRep Λ) (Lorentz.inclCoRealLorentz p) := by + exact congrArg (Lorentz.CoℂModule.SL2CRep Λ) (toComplexVector_down_eq_inclCoRealLorentz p) _ = Lorentz.inclCoRealLorentz ((Lorentz.Co 3).ρ (toLorentzGroup Λ) p) := by rw [Lorentz.inclCoRealLorentz_ρ] - _ = (toComplexVector Color.down) ((Lorentz.CoMod.rep (toLorentzGroup Λ)) p) := - (toComplexVector_down_eq_inclCoRealLorentz + _ = (toComplexVector Color.down) ((Lorentz.CoMod.rep (toLorentzGroup Λ)) p) := by + exact (toComplexVector_down_eq_inclCoRealLorentz ((Lorentz.CoMod.rep (toLorentzGroup Λ)) p)).symm lemma toComplex_pure {n : ℕ} (c : Fin n → Color) (p : Pure realLorentzTensor c) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean index c0dcc239b..529398ff4 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean @@ -137,7 +137,7 @@ lemma apply_add {d : ℕ} (v w : Vector d) (i : Fin 1 ⊕ Fin d) : @[simp] lemma apply_sub {d : ℕ} (v w : Vector d) (i : Fin 1 ⊕ Fin d) : - (v - w) i = v i - w i := rfl + (v - w) i = v i - w i := by rfl lemma apply_sum {d : ℕ} {ι : Type} [Fintype ι] (f : ι → Vector d) (i : Fin 1 ⊕ Fin d) : (∑ j, f j) i = ∑ j, f j i := by @@ -288,8 +288,8 @@ lemma basis_repr_apply {d : ℕ} (p : Vector d) (μ : Fin 1 ⊕ Fin d) : erw [Pi.basisFun_repr] lemma map_apply_eq_basis_mulVec {d : ℕ} (f : Vector d →ₗ[ℝ] Vector d) (p : Vector d) : - (f p) = (LinearMap.toMatrix basis basis) f *ᵥ p := - Eq.symm (LinearMap.toMatrix_mulVec_repr basis basis f p) + (f p) = (LinearMap.toMatrix basis basis) f *ᵥ p := by + exact Eq.symm (LinearMap.toMatrix_mulVec_repr basis basis f p) lemma sum_basis_eq_zero_iff {d : ℕ} (f : Fin 1 ⊕ Fin d → ℝ) : (∑ μ, f μ • basis μ) = 0 ↔ ∀ μ, f μ = 0 := by @@ -340,8 +340,8 @@ lemma spatialPart_basis_sum_inl {d : ℕ} (i : Fin d) : /-- The spatial part of a Lorentz vector as a continuous linear map. -/ def spatialCLM (d : ℕ) : Vector d →L[ℝ] EuclideanSpace ℝ (Fin d) where toFun v := WithLp.toLp 2 fun i => v (Sum.inr i) - map_add' v1 v2 := rfl - map_smul' c v := rfl + map_add' v1 v2 := by rfl + map_smul' c v := by rfl cont := by fun_prop lemma spatialCLM_apply_eq_spatialPart {d : ℕ} (v : Vector d) (i : Fin d) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean index 9d55500cd..1febf830f 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean @@ -27,8 +27,8 @@ namespace Vector @[simp] lemma timelike_neg_time_component_product {d : ℕ} (v w : Vector d) (hv_neg : v (Sum.inl 0) < 0) (hw_neg : w (Sum.inl 0) < 0) : - v (Sum.inl 0) * w (Sum.inl 0) > 0 := - mul_pos_of_neg_of_neg hv_neg hw_neg + v (Sum.inl 0) * w (Sum.inl 0) > 0 := by + exact mul_pos_of_neg_of_neg hv_neg hw_neg /-- For timelike vectors, the Minkowski inner product is positive -/ lemma timeLike_iff_norm_sq_pos {d : ℕ} (p : Vector d) : @@ -60,8 +60,8 @@ lemma timelike_time_dominates_space {d : ℕ} {v : Vector d} ∑ i, v (Sum.inr i) * v (Sum.inr i) := hv -- Rearrange the inequality have h : ∑ i, v (Sum.inr i) * v (Sum.inr i) < - v (Sum.inl 0) * v (Sum.inl 0) := - lt_of_sub_pos h_norm_pos + v (Sum.inl 0) * v (Sum.inl 0) := by + exact lt_of_sub_pos h_norm_pos exact h /-- For nonzero timelike vectors, the time component is nonzero -/ @@ -102,8 +102,8 @@ lemma timeLike_iff_time_lt_space {d : ℕ} {v : Vector d} : @[simp] lemma timeComponent_squared_pos_of_timelike {d : ℕ} {v : Vector d} (hv : causalCharacter v = .timeLike) : - 0 < (timeComponent v)^2 := - pow_two_pos_of_ne_zero (time_component_ne_zero_of_timelike hv) + 0 < (timeComponent v)^2 := by + exact pow_two_pos_of_ne_zero (time_component_ne_zero_of_timelike hv) /-- For timelike vectors, the spatial norm squared is strictly less than the time component squared -/ diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index 5879219bf..ab8149a5d 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -63,7 +63,7 @@ lemma contrBasisFin_toFin1dℝ {d : ℕ} (i : Fin (1 + d)) : simp only [contrBasisFin, Basis.reindex_apply, contrBasis_toFin1dℝ] lemma contrBasisFin_repr_apply {d : ℕ} (p : ContrMod d) (i : Fin (1 + d)) : - (contrBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := rfl + (contrBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := by rfl /-- The representation of contravariant Lorentz vectors forms a topological space, induced by its equivalence to `Fin 1 ⊕ Fin d → ℝ`. -/ @@ -71,8 +71,8 @@ instance : TopologicalSpace (Contr d) := TopologicalSpace.induced ContrMod.toFin1dℝEquiv (Pi.topologicalSpace) lemma continuous_contr {T : Type} [TopologicalSpace T] (f : T → Contr d) - (h : Continuous (fun i => (f i).toFin1dℝ)) : Continuous f := - continuous_induced_rng.mpr h + (h : Continuous (fun i => (f i).toFin1dℝ)) : Continuous f := by + exact continuous_induced_rng.mpr h set_option backward.isDefEq.respectTransparency false in lemma contr_continuous {T : Type} [TopologicalSpace T] (f : Contr d → T) @@ -119,7 +119,7 @@ lemma coBasisFin_toFin1dℝ {d : ℕ} (i : Fin (1 + d)) : simp only [coBasisFin, Basis.reindex_apply, coBasis_toFin1dℝ] lemma coBasisFin_repr_apply {d : ℕ} (p : Co d) (i : Fin (1 + d)) : - (coBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := rfl + (coBasisFin d).repr p i = p.val (finSumFinEquiv.symm i) := by rfl open CategoryTheory.MonoidalCategory diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 635aa9b2f..3678ae947 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -170,7 +170,7 @@ def coCoContract : ((CoMod.rep (d := d)).tprod (CoMod.rep (d := d))).Intertwinin local notation "⟪" ψ "," φ "⟫ₘ" => coCoContract (ψ ⊗ₜ φ) lemma coCoContract_hom_tmul (φ : Co d) (ψ : Co d) : - ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ := rfl + ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ := by rfl /-! diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index 8e6a68bfc..f4a41789a 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -72,7 +72,7 @@ def toFin1dℝEquiv : ContrMod d ≃ₗ[ℝ] (Fin 1 ⊕ Fin d → ℝ) := through the linear equivalence `toFin1dℝEquiv`. -/ abbrev toFin1dℝ (ψ : ContrMod d) := toFin1dℝEquiv ψ -lemma toFin1dℝ_eq_val (ψ : ContrMod d) : ψ.toFin1dℝ = ψ.val := rfl +lemma toFin1dℝ_eq_val (ψ : ContrMod d) : ψ.toFin1dℝ = ψ.val := by rfl /-! ## The standard basis. @@ -108,8 +108,8 @@ lemma stdBasis_apply (μ ν : Fin 1 ⊕ Fin d) : (stdBasis μ).val ν = if μ = simp only [stdBasis, Basis.coe_ofEquivFun] change Pi.single μ 1 ν = _ simp only [Pi.single_apply] - exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) - (congrFun rfl) (congrFun rfl) + refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) + exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) /-- Decomposition of a contravariant Lorentz vector into the standard basis. -/ lemma stdBasis_decomp (v : ContrMod d) : v = ∑ i, v.toFin1dℝ i • stdBasis i := by @@ -284,8 +284,8 @@ instance : TopologicalSpace (ContrMod d) := TopologicalSpace.induced open Topology -lemma toFin1dℝEquiv_isInducing : IsInducing (@ContrMod.toFin1dℝEquiv d) := - { eq_induced := rfl } +lemma toFin1dℝEquiv_isInducing : IsInducing (@ContrMod.toFin1dℝEquiv d) := by + exact { eq_induced := rfl } lemma toFin1dℝEquiv_symm_isInducing : IsInducing ((@ContrMod.toFin1dℝEquiv d).symm) := by let x := Equiv.toHomeomorphOfIsInducing (@ContrMod.toFin1dℝEquiv d).toEquiv @@ -363,8 +363,8 @@ lemma stdBasis_apply (μ ν : Fin 1 ⊕ Fin d) : (stdBasis μ).val ν = if μ = simp only [stdBasis, Basis.coe_ofEquivFun] change Pi.single μ 1 ν = _ simp only [Pi.single_apply] - exact ite_congr (Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a)) - (congrFun rfl) (congrFun rfl) + refine ite_congr ?h₁ (congrFun rfl) (congrFun rfl) + exact Eq.propIntro (fun a => id (Eq.symm a)) fun a => id (Eq.symm a) /-- Decomposition of a covariant Lorentz vector into the standard basis. -/ lemma stdBasis_decomp (v : CoMod d) : v = ∑ i, v.toFin1dℝ i • stdBasis i := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean index 3b650d4f3..d0a2d609b 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Representation.lean @@ -43,7 +43,7 @@ def rep {d : ℕ} : Representation ℝ (LorentzGroup d) (Vector d) where -/ lemma rep_apply_eq_mulVec (d : ℕ) (Λ : LorentzGroup d) (v : Vector d) : - rep Λ v = Λ *ᵥ v := rfl + rep Λ v = Λ *ᵥ v := by rfl lemma rep_apply_eq_sum (d : ℕ) (Λ : LorentzGroup d) (v : Vector d) (k : Fin 1 ⊕ Fin d) : rep Λ v k = ∑ j, Λ.1 k j • v j := rfl diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index cd7ea0a61..867df55c2 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -35,8 +35,8 @@ variable {d : ℕ} noncomputable instance : TopologicalSpace (Velocity d) := instTopologicalSpaceSubtype @[ext] -lemma ext {v w : Velocity d} (h : v.1 = w.1) : v = w := - SetCoe.ext h +lemma ext {v w : Velocity d} (h : v.1 = w.1) : v = w := by + exact SetCoe.ext h lemma mem_iff {v : Vector d} : v ∈ Velocity d ↔ ⟪v, v⟫ₘ = (1 : ℝ) ∧ 0 < v.timeComponent := Iff.rfl @@ -128,7 +128,7 @@ noncomputable def pathFromZero (u : Velocity d) : Path zero u where apply And.intro · let x := (√(1 + t ^ 2 * ‖u.1.spatialPart‖ ^ 2) - u.1 (Sum.inl 0) * t) calc _ - _ = ⟪x • zero.1 + (t : ℝ) • u.1, x • zero.1 + (t : ℝ) • u.1⟫ₘ := rfl + _ = ⟪x • zero.1 + (t : ℝ) • u.1, x • zero.1 + (t : ℝ) • u.1⟫ₘ := by rfl _ = x ^ 2 + (t : ℝ) ^ 2 + 2 * x * (t : ℝ) * u.1 (Sum.inl 0) := by simp only [zero, Fin.isValue, map_add, map_smul, _root_.add_apply, FunLike.coe_smul, Pi.smul_apply, minkowskiProduct_basis_right, diff --git a/Physlib/Relativity/Tensors/UnitTensor.lean b/Physlib/Relativity/Tensors/UnitTensor.lean index 931df8928..fa197d681 100644 --- a/Physlib/Relativity/Tensors/UnitTensor.lean +++ b/Physlib/Relativity/Tensors/UnitTensor.lean @@ -105,7 +105,7 @@ lemma contrT_unitTensor_dual_single {c : C} (x : Tensor S ![S.τ c]) : @[simp] lemma unitTensor_invariant {c : C} (g : G) : - g • S.unitTensor c = S.unitTensor c := - actionT_fromConstPair (S.unit c) g + g • S.unitTensor c = S.unitTensor c := by + rw [unitTensor, actionT_fromConstPair] end TensorSpecies diff --git a/Physlib/SpaceAndTime/Space/Basic.lean b/Physlib/SpaceAndTime/Space/Basic.lean index ee2ee428d..0a600dbdf 100644 --- a/Physlib/SpaceAndTime/Space/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Basic.lean @@ -151,7 +151,7 @@ lemma vadd_val {d} (v : EuclideanSpace ℝ (Fin d)) (s : Space d) : @[simp] lemma vadd_apply {d} (v : EuclideanSpace ℝ (Fin d)) (s : Space d) (i : Fin d) : - (v +ᵥ s) i = v i + s i := rfl + (v +ᵥ s) i = v i + s i := by rfl lemma vadd_transitive {d} (s1 s2 : Space d) : ∃ v : EuclideanSpace ℝ (Fin d), v +ᵥ s1 = s2 := by diff --git a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean index 59f70c1e3..b8ea3bd4e 100644 --- a/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean +++ b/Physlib/SpaceAndTime/Space/ConstantSliceDist.lean @@ -275,11 +275,11 @@ lemma schwartzMap_slice_integral_hasFDerivAt {d : ℕ} (η : 𝓢(Space d.succ, have hF : ∀ t, ∀ x, HasFDerivAt (F · t) (F' x t) x := by intro t x dsimp only [F, F'] - exact - ((η.smooth'.differentiable (by simp)).comp (by fun_prop)).differentiableAt.hasFDerivAt + refine DifferentiableAt.hasFDerivAt ?_ + exact ((η.smooth'.differentiable (by simp)).comp (by fun_prop)).differentiableAt obtain ⟨rt, hrt⟩ := schwartzMap_slice_bound (m := 0) (n := 1) (d := d) i obtain ⟨k, hrt, hbound, k_eq⟩ := hrt η - suffices HasFDerivAt (fun x => ∫ (a : ℝ), F x a) (∫ (a : ℝ), F' x₀ a) x₀ from this + suffices h1 : HasFDerivAt (fun x => ∫ (a : ℝ), F x a) (∫ (a : ℝ), F' x₀ a) x₀ by exact h1 apply hasFDerivAt_integral_of_dominated_of_fderiv_le (bound := fun t => (k * ‖(slice i).symm.toContinuousLinearMap.comp (ContinuousLinearMap.prod (0 : Space d →L[ℝ] ℝ) (ContinuousLinearMap.id ℝ (Space d)))‖) @@ -610,7 +610,7 @@ lemma distDeriv_constantSliceDist_same {M : Type} [NormedAddCommGroup M] [Normed ext x simp [sliceSchwartz_apply] calc _ - _ = ∫ r, fderiv ℝ η ((slice i).symm (r, x)) (basis i) := rfl + _ = ∫ r, fderiv ℝ η ((slice i).symm (r, x)) (basis i) := by rfl _ = ∫ r, fderiv ℝ (fun r => η ((slice i).symm (r, x))) r 1 := by congr funext r diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index b379d46a7..3c82110c3 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -80,15 +80,15 @@ macro "∂[" i:term "]" : term => `(deriv $i) lemma deriv_eq [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (μ : Fin d) (f : Space d → M) (x : Space d) : - deriv μ f x = fderiv ℝ f x (basis μ) := rfl + deriv μ f x = fderiv ℝ f x (basis μ) := by rfl lemma deriv_eq_fderiv_fun [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (μ : Fin d) (f : Space d → M) : - deriv μ f = fun x => fderiv ℝ (fun x => f x) x (basis μ) := rfl + deriv μ f = fun x => fderiv ℝ (fun x => f x) x (basis μ) := by rfl lemma deriv_eq_fderiv_basis [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (μ : Fin d) (f : Space d → M) (x : Space d) : - deriv μ f x = fderiv ℝ f x (basis μ) := rfl + deriv μ f x = fderiv ℝ f x (basis μ) := by rfl lemma fderiv_eq_sum_deriv {M d} [AddCommGroup M] [Module ℝ M] [TopologicalSpace M] (f : Space d → M) (x y : Space d) : @@ -458,7 +458,7 @@ lemma deriv_differentiable {M} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : ℕ} {f : Space d → M} (hf : ContDiff ℝ 2 f) (i : Fin d) : Differentiable ℝ (deriv i f) := by - suffices Differentiable ℝ (fun x => fderiv ℝ f x (basis i)) from this + suffices h1 : Differentiable ℝ (fun x => fderiv ℝ f x (basis i)) by exact h1 fun_prop open ContDiff diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean b/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean index 40fca4c7a..fb3eedc74 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Curl.lean @@ -280,7 +280,7 @@ private noncomputable def homotopyOperatorIntegrand (f : Space → EuclideanSpac Space → ℝ → EuclideanSpace ℝ (Fin 3) := fun x t => (t • basis.repr x) ⨯ₑ₃ f (t • x) private lemma homotopyOperatorIntegrand_eq (f : Space → EuclideanSpace ℝ (Fin 3)) : - homotopyOperatorIntegrand f = fun x t => (t • basis.repr x) ⨯ₑ₃ f (t • x) := rfl + homotopyOperatorIntegrand f = fun x t => (t • basis.repr x) ⨯ₑ₃ f (t • x) := by rfl @[fun_prop] private lemma differentiable_homotopyOperatorIntegrand_space {f : Space → EuclideanSpace ℝ (Fin 3)} (hf : Differentiable ℝ f) (t : ℝ) : @@ -451,11 +451,11 @@ private lemma deriv_intervalIntegral_homotopyOperatorIntegrand_sub fderiv ℝ (homotopyOperatorIntegrand f · t) x₀ (basis j) m) ∂(volume) := by let F : Space → ℝ → EuclideanSpace ℝ (Fin 3) := homotopyOperatorIntegrand f let F' : Space → ℝ → Space →L[ℝ] EuclideanSpace ℝ (Fin 3) := fun x t => fderiv ℝ (F · t) x - have F'_continuous : Continuous (Function.uncurry F') := - continuous_uncurry_fderiv_homotopyOperatorIntegrand (hf) + have F'_continuous : Continuous (Function.uncurry F') := by + exact continuous_uncurry_fderiv_homotopyOperatorIntegrand (hf) have hfderiv (x₀ : Space) : HasFDerivAt (fun (x : Space) => ∫ (t : ℝ) in 0..1, F x t ∂(volume)) - (∫ (t : ℝ) in 0..1, F' x₀ t ∂(volume)) x₀ := - hasFDerivAt_intervalIntegral_homotopyOperatorIntegrand (hf) x₀ + (∫ (t : ℝ) in 0..1, F' x₀ t ∂(volume)) x₀ := by + exact hasFDerivAt_intervalIntegral_homotopyOperatorIntegrand (hf) x₀ have F'_apply_apply (x₀ : Space) (y : Space) (i : Fin 3) : ((∫ (t : ℝ) in 0..1, F' x₀ t) y).ofLp i = (∫ (t : ℝ) in 0..1, F' x₀ t y i) := by @@ -632,7 +632,7 @@ lemma exists_grad_of_curl_zero (f : Space → EuclideanSpace ℝ (Fin 3)) (hf : ⟪(basis.repr.symm (fderiv ℝ f a x)), y⟫_ℝ:= by calc _ _ = (fderiv ℝ (InnerProductSpace.toDual ℝ _ ∘ - fun a => (basis.repr.symm (f a))) a x) y := rfl + fun a => (basis.repr.symm (f a))) a x) y := by rfl rw [fderiv_comp _ (by exact (InnerProductSpace.toDual ℝ (Space)).differentiable.differentiableAt) (by fun_prop)] erw [(InnerProductSpace.toDual ℝ (Space)).fderiv] diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean index e37b61716..74da1de5c 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean @@ -274,7 +274,7 @@ lemma grad_inner_space_unit_vector {d} (x : Space d) (f : Space d → ℝ) (hd : simp symm calc _ - _ = fderiv ℝ (f ∘ (fun r => r • ‖x‖⁻¹ • x)) ‖x‖ 1 := rfl + _ = fderiv ℝ (f ∘ (fun r => r • ‖x‖⁻¹ • x)) ‖x‖ 1 := by rfl _ = (fderiv ℝ f (‖x‖ • ‖x‖⁻¹ • x)) (_root_.deriv (fun r => r • ‖x‖⁻¹ • x) ‖x‖) := by rw [fderiv_comp _ (by fun_prop) (by fun_prop)] simp diff --git a/Physlib/SpaceAndTime/Space/DistOfFunction.lean b/Physlib/SpaceAndTime/Space/DistOfFunction.lean index 7234f56e3..8fbc194ba 100644 --- a/Physlib/SpaceAndTime/Space/DistOfFunction.lean +++ b/Physlib/SpaceAndTime/Space/DistOfFunction.lean @@ -116,8 +116,8 @@ lemma distOfFunction_smul_fun {d : ℕ} (f : Space d → F) lemma distOfFunction_mul_fun {d : ℕ} (f : Space d → ℝ) (hf : IsDistBounded f) (c : ℝ) : - distOfFunction (fun x => c * f x) (by fun_prop) = c • distOfFunction f hf := - distOfFunction_smul_fun f hf c + distOfFunction (fun x => c * f x) (by fun_prop) = c • distOfFunction f hf := by + exact distOfFunction_smul_fun f hf c lemma distOfFunction_neg {d : ℕ} (f : Space d → F) (hf : IsDistBounded (fun x => - f x)) : diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean index 119b848e9..170ce4cf5 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean @@ -125,7 +125,7 @@ noncomputable def TranslationGroup.incl (n : ℕ) : def translationVector.incl (n : ℕ) : Multiplicative (EuclideanSpace ℝ (Fin n)) →* EuclideanGroup n where toFun v := ⟨v.toAdd, 1⟩ - map_one' := rfl + map_one' := by rfl map_mul' x y := by refine EuclideanGroup.ext ?_ ?_ · show Multiplicative.toAdd (x * y) = diff --git a/Physlib/SpaceAndTime/Space/Integrals/Basic.lean b/Physlib/SpaceAndTime/Space/Integrals/Basic.lean index 974453ab8..bdc863bfb 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/Basic.lean @@ -42,8 +42,8 @@ open InnerProductSpace MeasureTheory -/ -lemma volume_eq_addHaar {d} : (volume (α := Space d)) = Space.basis.toBasis.addHaar := - (OrthonormalBasis.addHaar_eq_volume _).symm +lemma volume_eq_addHaar {d} : (volume (α := Space d)) = Space.basis.toBasis.addHaar := by + exact (OrthonormalBasis.addHaar_eq_volume _).symm @[simp] lemma volume_metricBall_three : diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index 614ff5490..3973fcf04 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -235,20 +235,20 @@ lemma integrable_space {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) @[fun_prop] lemma integrable_space_mul {d : ℕ} {f : Space d → ℝ} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) : - Integrable (fun x : Space d => η x * f x) volume := - hf.integrable_space η + Integrable (fun x : Space d => η x * f x) volume := by + exact hf.integrable_space η @[fun_prop] lemma integrable_space_fderiv {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) (y : Space d) : - Integrable (fun x : Space d => fderiv ℝ η x y • f x) volume := - hf.integrable_space (LineDeriv.lineDerivOpCLM ℝ _ y η) + Integrable (fun x : Space d => fderiv ℝ η x y • f x) volume := by + exact hf.integrable_space (LineDeriv.lineDerivOpCLM ℝ _ y η) @[fun_prop] lemma integrable_space_fderiv_mul {d : ℕ} {f : Space d → ℝ} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) (y : Space d) : - Integrable (fun x : Space d => fderiv ℝ η x y * f x) volume := - hf.integrable_space (LineDeriv.lineDerivOpCLM ℝ _ y η) + Integrable (fun x : Space d => fderiv ℝ η x y * f x) volume := by + exact hf.integrable_space (LineDeriv.lineDerivOpCLM ℝ _ y η) /-! @@ -634,8 +634,8 @@ lemma add {d : ℕ} {f g : Space d → F} @[fun_prop] lemma fun_add {d : ℕ} {f g : Space d → F} - (hf : IsDistBounded f) (hg : IsDistBounded g) : IsDistBounded (fun x => f x + g x) := - hf.add hg + (hf : IsDistBounded f) (hg : IsDistBounded g) : IsDistBounded (fun x => f x + g x) := by + exact hf.add hg /-! @@ -915,8 +915,8 @@ lemma inv_shift {d : ℕ} (g : Space d) (hd : 2 ≤ d := by omega) : simp @[fun_prop] lemma nat_pow {d : ℕ} (n : ℕ) : - IsDistBounded (d := d) (fun x => ‖x‖ ^ n) := - IsDistBounded.pow (d := d) (n : ℤ) (by omega) + IsDistBounded (d := d) (fun x => ‖x‖ ^ n) := by + exact IsDistBounded.pow (d := d) (n : ℤ) (by omega) @[fun_prop] lemma norm_add_nat_pow {d : ℕ} (n : ℕ) (a : ℝ) : @@ -948,8 +948,8 @@ lemma norm_add_pos_nat_zpow {d : ℕ} (n : ℤ) (a : ℝ) (ha : 0 < a) : @[fun_prop] lemma nat_pow_shift {d : ℕ} (n : ℕ) (g : Space d) : - IsDistBounded (d := d) (fun x => ‖x - g‖ ^ n) := - IsDistBounded.pow_shift (d := d) (n : ℤ) g (by omega) + IsDistBounded (d := d) (fun x => ‖x - g‖ ^ n) := by + exact IsDistBounded.pow_shift (d := d) (n : ℤ) g (by omega) @[fun_prop] lemma norm_sub {d : ℕ} (g : Space d) : diff --git a/Physlib/SpaceAndTime/Space/Module.lean b/Physlib/SpaceAndTime/Space/Module.lean index 5ae376bbb..a71e2e4f7 100644 --- a/Physlib/SpaceAndTime/Space/Module.lean +++ b/Physlib/SpaceAndTime/Space/Module.lean @@ -80,7 +80,7 @@ lemma nsmul_val {d : ℕ} (n : ℕ) (a : Space d) : @[simp] lemma nsmul_apply {d : ℕ} (n : ℕ) (a : Space d) (i : Fin d) : - (n • a) i = n • (a i) := rfl + (n • a) i = n • (a i) := by rfl lemma eq_vadd_zero {d} (s : Space d) : ∃ v : EuclideanSpace ℝ (Fin d), s = v +ᵥ (0 : Space d) := by @@ -108,7 +108,7 @@ lemma smul_val {d : ℕ} (c : ℝ) (p : Space d) : @[simp] lemma smul_apply {d : ℕ} (c : ℝ) (p : Space d) (i : Fin d) : - (c • p) i = c * (p i) := rfl + (c • p) i = c * (p i) := by rfl @[simp] lemma smul_vadd_zero {d} (k : ℝ) (v : EuclideanSpace ℝ (Fin d)) : @@ -166,7 +166,7 @@ lemma neg_val {d : ℕ} (p : Space d) : @[simp] lemma neg_apply {d : ℕ} (p : Space d) (i : Fin d) : - (-p) i = - (p i) := rfl + (-p) i = - (p i) := by rfl noncomputable instance {d} : AddCommGroup (Space d) where zsmul z p := ⟨fun i => z * p.val i⟩ @@ -189,7 +189,7 @@ lemma sub_apply {d} (p q : Space d) (i : Fin d) : @[simp] lemma sub_val {d} (p q : Space d) : - (p - q).val = fun i => p.val i - q.val i := rfl + (p - q).val = fun i => p.val i - q.val i := by rfl @[simp] lemma vadd_zero_sub_vadd_zero {d} (v1 v2 : EuclideanSpace ℝ (Fin d)) : @@ -226,7 +226,7 @@ lemma inner_vadd_zero {d} (v1 v2 : EuclideanSpace ℝ (Fin d)) : ring lemma inner_apply {d} (p q : Space d) : - inner ℝ p q = ∑ i, p i * q i := rfl + inner ℝ p q = ∑ i, p i * q i := by rfl instance {d} : InnerProductSpace ℝ (Space d) where norm_smul_le a x := by @@ -267,7 +267,7 @@ lemma norm_smul_sphere {d : ℕ} (n : ↑(Metric.sphere (0 : Space d) 1)) noncomputable instance {d : ℕ} : MeasurableSpace (Space d) := borel (Space d) instance {d : ℕ} : BorelSpace (Space d) where - measurable_eq := rfl + measurable_eq := by rfl /-! @@ -341,7 +341,7 @@ lemma basis_repr_apply {d} (p : Space d) (i : Fin d) : @[simp] lemma basis_repr_symm_apply {d} (v : EuclideanSpace ℝ (Fin d)) (i : Fin d) : - basis.repr.symm v i = v i := rfl + basis.repr.symm v i = v i := by rfl lemma basis_apply {d} (i j : Fin d) : basis i j = if i = j then 1 else 0 := by @@ -363,8 +363,8 @@ lemma basis_inner {d} (i : Fin d) (p : Space d) : open InnerProductSpace lemma basis_repr_inner_eq {d} (p : Space d) (v : EuclideanSpace ℝ (Fin d)) : - ⟪basis.repr p, v⟫_ℝ = ⟪p, basis.repr.symm v⟫_ℝ := - LinearIsometryEquiv.inner_map_eq_flip basis.repr p v + ⟪basis.repr p, v⟫_ℝ = ⟪p, basis.repr.symm v⟫_ℝ := by + exact LinearIsometryEquiv.inner_map_eq_flip basis.repr p v instance {d : ℕ} : FiniteDimensional ℝ (Space d) := Module.Basis.finiteDimensional_of_finite (h := basis.toBasis) @@ -590,8 +590,8 @@ noncomputable def oneEquiv : Space 1 ≃ₗᵢ[ℝ] ℝ where left_inv x := by ext i; fin_cases i; simp right_inv x := by simp - map_add' x y := rfl - map_smul' c x := rfl + map_add' x y := by rfl + map_smul' c x := by rfl norm_map' x := by simp only [Fin.isValue, LinearEquiv.coe_mk, LinearMap.coe_mk, AddHom.coe_mk, Real.norm_eq_abs] rw [norm_eq] @@ -653,8 +653,8 @@ lemma oneEquiv_symm_measurableEmbedding : MeasurableEmbedding oneEquiv.symm wher lemma oneEquiv_measurePreserving : MeasurePreserving oneEquiv volume volume := LinearIsometryEquiv.measurePreserving oneEquiv -lemma oneEquiv_symm_measurePreserving : MeasurePreserving oneEquiv.symm volume volume := - LinearIsometryEquiv.measurePreserving oneEquiv.symm +lemma oneEquiv_symm_measurePreserving : MeasurePreserving oneEquiv.symm volume volume := by + exact LinearIsometryEquiv.measurePreserving oneEquiv.symm /-! diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index 8af879647..ed78e4b8e 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -1012,8 +1012,8 @@ private lemma radial_power_deriv_integral_by_parts ∂(.comap Subtype.val volume) = ∫ (x : ℝ) in Set.Ioi (0 : ℝ), - x ^ p * _root_.deriv (fun a => η (a • n.1)) x := - MeasureTheory.integral_subtype_comap (μ := volume) + x ^ p * _root_.deriv (fun a => η (a • n.1)) x := by + exact MeasureTheory.integral_subtype_comap (μ := volume) (s := Set.Ioi (0 : ℝ)) measurableSet_Ioi (fun x : ℝ => x ^ p * _root_.deriv (fun a => η (a • n.1)) x) have hright_subtype : @@ -1022,8 +1022,8 @@ private lemma radial_power_deriv_integral_by_parts ∂(.comap Subtype.val volume) = ∫ (x : ℝ) in Set.Ioi (0 : ℝ), - x ^ (p - 1) * η (x • n.1) := - MeasureTheory.integral_subtype_comap (μ := volume) + x ^ (p - 1) * η (x • n.1) := by + exact MeasureTheory.integral_subtype_comap (μ := volume) (s := Set.Ioi (0 : ℝ)) measurableSet_Ioi (fun x : ℝ => x ^ (p - 1) * η (x • n.1)) rw [hleft_subtype, hright_subtype] @@ -1174,8 +1174,8 @@ lemma distDiv_norm_zpow_smul_repr_self_eq_smul = - ∫ n, (∫ (r : Set.Ioi (0 : ℝ)), r.1 ^ p * (_root_.deriv (fun a => η (a • n.1)) r.1) ∂(.comap Subtype.val volume)) - ∂(volume (α := Space d).toSphere) := - distDiv_norm_zpow_smul_repr_self_apply_eq_radial_deriv q hq hp_int η + ∂(volume (α := Space d).toSphere) := by + exact distDiv_norm_zpow_smul_repr_self_apply_eq_radial_deriv q hq hp_int η _ = ∫ n, (p : ℝ) * ∫ (r : Set.Ioi (0 : ℝ)), r.1 ^ (p - 1) * η (r.1 • n.1) ∂(.comap Subtype.val volume) @@ -1439,8 +1439,8 @@ lemma distLaplacian_fundamentalSolution_norm_zpow {d : ℕ} : ‖x‖ ^ (- (d : ℤ)) • basis.repr x) (IsDistBounded.zpow_smul_repr_self (- (d : ℤ)) (by omega))) = (d * (volume (α := Space d)).real - (Metric.ball 0 1)) • diracDelta ℝ 0 := - distDiv_inv_pow_eq_dim (d := d) + (Metric.ball 0 1)) • diracDelta ℝ 0 := by + exact distDiv_inv_pow_eq_dim (d := d) rw [hdiv] rw [smul_smul] ring_nf diff --git a/Physlib/SpaceAndTime/Space/Slice.lean b/Physlib/SpaceAndTime/Space/Slice.lean index 0fd5eed09..4487e19d3 100644 --- a/Physlib/SpaceAndTime/Space/Slice.lean +++ b/Physlib/SpaceAndTime/Space/Slice.lean @@ -101,7 +101,7 @@ def slice {d} (i : Fin d.succ) : Space d.succ ≃L[ℝ] ℝ × Space d where lemma slice_symm_apply {d : ℕ} (i : Fin d.succ) (r : ℝ) (x : Space d) : (slice i).symm (r, x) = fun j => - Fin.insertNthEquiv (fun _ => ℝ) i (r, x) j := rfl + Fin.insertNthEquiv (fun _ => ℝ) i (r, x) j := by rfl @[simp] lemma slice_symm_apply_self {d : ℕ} (i : Fin d.succ) (r : ℝ) (x : Space d) : diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index 639898e7e..5798908e5 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -140,7 +140,7 @@ instance {d : ℕ} : MeasurableSpace (SpaceTime d) := borel (SpaceTime d) -/ instance {d : ℕ} : BorelSpace (SpaceTime d) where - measurable_eq := rfl + measurable_eq := by rfl /-! @@ -315,12 +315,12 @@ lemma time_toTimeAndSpace_symm {d : ℕ} {c : SpeedOfLight} (t : Time) (s : Spac @[simp] lemma toTimeAndSpace_symm_apply_inl {d : ℕ} {c : SpeedOfLight} (t : Time) (s : Space d) : - (toTimeAndSpace c).symm (t, s) (Sum.inl 0) = c * t := rfl + (toTimeAndSpace c).symm (t, s) (Sum.inl 0) = c * t := by rfl @[simp] lemma toTimeAndSpace_symm_apply_inr {d : ℕ} {c : SpeedOfLight} (t : Time) (x : Space d) (i : Fin d) : - (toTimeAndSpace c).symm (t, x) (Sum.inr i) = x i := rfl + (toTimeAndSpace c).symm (t, x) (Sum.inr i) = x i := by rfl /-! #### B.3.1. Derivative of `toTimeAndSpace` diff --git a/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean b/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean index 052c5b396..e4efdaa9f 100644 --- a/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean +++ b/Physlib/SpaceAndTime/SpaceTime/TimeSlice.lean @@ -144,12 +144,12 @@ noncomputable def distTimeSlice {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] lemma distTimeSlice_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (c : SpeedOfLight) (f : (SpaceTime d) →d[ℝ] M) (κ : 𝓢(Time × Space d, ℝ)) : distTimeSlice c f κ = - f (compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c) κ) := rfl + f (compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c) κ) := by rfl lemma distTimeSlice_symm_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (c : SpeedOfLight) (f : (Time × (Space d)) →d[ℝ] M) (κ : 𝓢(SpaceTime d, ℝ)) : (distTimeSlice c).symm f κ = - f (compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c).symm κ) := rfl + f (compCLMOfContinuousLinearEquiv ℝ (toTimeAndSpace c).symm κ) := by rfl /-! diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 5f2bc9227..5c8296f21 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -247,10 +247,10 @@ lemma smul_real_val (k : ℝ) (t : Time) : -/ instance : AddGroup Time where - add_assoc t1 t2 t3 := Time.ext (by simp [add_assoc]) - zero_add t := Time.ext (by simp) - add_zero t := Time.ext (by simp) - neg_add_cancel t := Time.ext (by simp) + add_assoc t1 t2 t3 := by ext; simp [add_assoc] + zero_add t := by ext; simp [zero_add] + add_zero t := by ext; simp [add_zero] + neg_add_cancel t := by ext; simp [neg_add_cancel] nsmul := nsmulRec zsmul := zsmulRec @@ -284,7 +284,7 @@ lemma dist_eq_val (t1 t2 : Time) : dist t1 t2 = ‖t1.val - t2.val‖ := rfl lemma dist_eq_real_dist (t1 t2 : Time) : - dist t1 t2 = dist t1.val t2.val := rfl + dist t1 t2 = dist t1.val t2.val := by rfl instance : SeminormedAddCommGroup Time where dist_self t := by simp [dist_eq_real_dist] @@ -348,7 +348,7 @@ noncomputable instance : DecidableEq Time := fun t1 t2 => instance : MeasurableSpace Time := borel Time instance : BorelSpace Time where - measurable_eq := rfl + measurable_eq := by rfl /-! @@ -421,8 +421,8 @@ instance : FiniteDimensional ℝ Time := Module.finite_of_rank_eq_one rank_eq_one lemma volume_eq_basis_addHaar : - (volume (α := Time)) = basis.toBasis.addHaar := - (OrthonormalBasis.addHaar_eq_volume _).symm + (volume (α := Time)) = basis.toBasis.addHaar := by + exact (OrthonormalBasis.addHaar_eq_volume _).symm /-! @@ -434,28 +434,28 @@ lemma volume_eq_basis_addHaar : noncomputable def toRealCLM : Time →L[ℝ] ℝ := LinearMap.toContinuousLinearMap { toFun := Time.val - map_add' _ _ := rfl - map_smul' _ _ := rfl } + map_add' := by simp + map_smul' := by simp } /-- The continuous linear equivalence from `Time` to `ℝ`. -/ noncomputable def toRealCLE : Time ≃L[ℝ] ℝ := LinearEquiv.toContinuousLinearEquiv { toFun := Time.val invFun := fun x => ⟨x⟩ - left_inv _ := rfl - right_inv _ := rfl - map_add' _ _ := rfl - map_smul' _ _ := rfl + left_inv x := by rfl + right_inv x := by rfl + map_add' := by simp + map_smul' := by simp } /-- The linear isometry equivalence from `Time` to `ℝ`. -/ noncomputable def toRealLIE : Time ≃ₗᵢ[ℝ] ℝ where toFun := Time.val invFun := fun x => ⟨x⟩ - left_inv _ := rfl - right_inv _ := rfl - map_add' _ _ := rfl - map_smul' _ _ := rfl + left_inv x := by rfl + right_inv x := by rfl + map_add' := by simp + map_smul' := by simp norm_map' _ := rfl lemma eq_one_smul (t : Time) : diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index fd14f6989..36ad4c971 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -364,7 +364,7 @@ lemma toTime_symm_zero_add (zero : TimeTransMan) (x : TimeUnit) : ext_of (by simp [toTime, addTime_val, diff_eq_val]) lemma toTime_val (zero : TimeTransMan) (x : TimeUnit) (t : TimeTransMan) : - (toTime zero x t).val = diff x t zero := rfl + (toTime zero x t).val = diff x t zero := by rfl lemma toTime_symm_val (zero : TimeTransMan) (x : TimeUnit) (r : Time) : (toTime zero x).symm r = addTime x r zero := rfl diff --git a/Physlib/SpaceAndTime/Time/TimeUnit.lean b/Physlib/SpaceAndTime/Time/TimeUnit.lean index 8f5ebdcca..2999c6db0 100644 --- a/Physlib/SpaceAndTime/Time/TimeUnit.lean +++ b/Physlib/SpaceAndTime/Time/TimeUnit.lean @@ -41,8 +41,8 @@ structure TimeUnit : Type where namespace TimeUnit @[simp] -lemma val_ne_zero (x : TimeUnit) : x.val ≠ 0 := - Ne.symm (ne_of_lt x.property) +lemma val_ne_zero (x : TimeUnit) : x.val ≠ 0 := by + exact Ne.symm (ne_of_lt x.property) lemma val_pos (x : TimeUnit) : 0 < x.val := x.property diff --git a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean index ab2b368cc..4dfdca279 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean @@ -377,9 +377,9 @@ noncomputable def distTimeDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] map_smul' _ _ := rfl } ev.comp (Distribution.fderivD ℝ f) - map_add' _ _ := by + map_add' f1 f2 := by simp - map_smul' _ _ := by simp + map_smul' a f := by simp lemma distTimeDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : @@ -425,9 +425,9 @@ noncomputable def distSpaceDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M map_smul' _ _ := rfl } ev.comp (Distribution.fderivD ℝ f) - map_add' _ _ := by + map_add' f1 f2 := by simp - map_smul' _ _ := by simp + map_smul' a f := by simp lemma distSpaceDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (i : Fin d) (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : @@ -554,7 +554,7 @@ noncomputable def distSpaceDiv {d} : lemma distSpaceDiv_apply_eq_sum_distSpaceDeriv {d} (f : (Time × Space d) →d[ℝ] EuclideanSpace ℝ (Fin d)) (η : 𝓢(Time ×Space d, ℝ)) : - distSpaceDiv f η = ∑ i, distSpaceDeriv i f η i := rfl + distSpaceDiv f η = ∑ i, distSpaceDeriv i f η i := by rfl /-! diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 69fab2fdf..57fe0448b 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -659,13 +659,13 @@ lemma time_integral_iteratedFDeriv_apply {d : ℕ} (n : ℕ) (η : 𝓢(Time × intro m refine ContDiff.differentiable_iteratedFDeriv (n := (m + 1 : ℕ)) ?_ ?_ · exact Nat.cast_lt.mpr (by omega) - · exact η.smooth'.of_le ENat.LEInfty.out + · exact η.smooth'.of_le (by exact ENat.LEInfty.out) have hη_diff' : ∀ (m : ℕ) (t : Time), Differentiable ℝ (iteratedFDeriv ℝ m (fun x => η (t, x))) := by intro m t refine ContDiff.differentiable_iteratedFDeriv (n := (m + 1 : ℕ)) ?_ ?_ · exact Nat.cast_lt.mpr (by omega) - · exact (η.smooth'.of_le ENat.LEInfty.out).comp (by fun_prop) + · exact (η.smooth'.of_le (by exact ENat.LEInfty.out)).comp (by fun_prop) induction n with | zero => simp @@ -797,9 +797,9 @@ lemma time_integral_mul_pow_iteratedFDeriv_norm_le {d : ℕ} (n m : ℕ) : have hk' : 0 ≤ k := by rw [← hk]; positivity calc _ _ ≤ ‖x‖ ^ m * ((∫ (t : Time), ‖iteratedFDeriv ℝ n η (t, x)‖) * - ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n) := - mul_le_mul_of_nonneg (by rfl) (time_integral_iteratedFDeriv_norm_le n η x) - (by positivity) (by positivity) + ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n) := by + refine mul_le_mul_of_nonneg (by rfl) ?_ (by positivity) (by positivity) + exact time_integral_iteratedFDeriv_norm_le n η x _ ≤ (∫ (t : Time), ‖x‖ ^ m * ‖iteratedFDeriv ℝ n η (t, x)‖) * ‖((0 : Space d →L[ℝ] Time).prod (.id ℝ (Space d)))‖ ^ n := by apply le_of_eq @@ -869,7 +869,7 @@ def timeIntegralSchwartz {d : ℕ} : rfl lemma timeIntegralSchwartz_apply {d : ℕ} (η : 𝓢(Time × Space d, ℝ)) (x : Space d) : - timeIntegralSchwartz η x = ∫ (t : Time), η (t, x) := rfl + timeIntegralSchwartz η x = ∫ (t : Time), η (t, x) := by rfl /-! @@ -892,7 +892,7 @@ def constantTime {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : ℕ} lemma constantTime_apply {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] {d : ℕ} (f : (Space d) →d[ℝ] M) (η : 𝓢(Time × Space d, ℝ)) : - constantTime f η = f (timeIntegralSchwartz η) := rfl + constantTime f η = f (timeIntegralSchwartz η) := by rfl /-! @@ -912,7 +912,7 @@ lemma constantTime_distSpaceDeriv {M : Type} {d : ℕ} [NormedAddCommGroup M] [N symm change fderiv ℝ (timeIntegralSchwartz η) x (basis i) = _ calc _ - _ = fderiv ℝ (fun x => ∫ t, η (t, x) ∂volume) x (basis i) := rfl + _ = fderiv ℝ (fun x => ∫ t, η (t, x) ∂volume) x (basis i) := by rfl _ = (∫ t, fderiv ℝ (fun x => η (t, x)) x) (basis i) := by have h1 := time_integral_hasFDerivAt (η) x rw [h1.fderiv] @@ -995,7 +995,7 @@ lemma constantTime_distTimeDeriv {M : Type} [NormedAddCommGroup M] [NormedSpace ext x rw [timeIntegralSchwartz_apply] calc _ - _ = ∫ (t : Time), fderiv ℝ η (t, x) (1, 0) := rfl + _ = ∫ (t : Time), fderiv ℝ η (t, x) (1, 0) := by rfl _ = ∫ (t : Time), fderiv ℝ (fun t => η (t, x)) t 1 := by congr funext t diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index cda465c4f..62d794775 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -267,9 +267,9 @@ lemma nsmul_succ (n : ℕ) [SigmaFinite 𝓒.μ] : nsmul n.succ 𝓒 = (𝓒 + n exact Fin.sum_univ_succAbove (fun i => 𝓒.energy (x i)) 0 · simp [Nat.succ_eq_add_one, Nat.succ_mul, dof_nsmul, add_comm] · simp - · exact Eq.symm (MeasureTheory.MeasurePreserving.map_eq - (MeasurePreserving.symm _ - (MeasureTheory.measurePreserving_piFinSuccAbove (n := n) (fun _ => 𝓒.μ) 0))) + · refine Eq.symm (MeasureTheory.MeasurePreserving.map_eq ?_) + refine MeasurePreserving.symm _ ?_ + exact MeasureTheory.measurePreserving_piFinSuccAbove (n := n) (fun _ => 𝓒.μ) 0 /-! @@ -930,7 +930,7 @@ lemma physicalProbability_nonneg (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] [NeZero 𝓒.μ] (i : ι) : 0 ≤ 𝓒.physicalProbability T i := by have hp := 𝓒.probability_nonneg (T:=T) i - exact mul_nonneg hp (pow_nonneg (le_of_lt 𝓒.hPos) _) + exact mul_nonneg hp (by exact pow_nonneg (le_of_lt 𝓒.hPos) _) lemma physicalProbability_pos (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] [NeZero 𝓒.μ] (i : ι) : diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index 8e24d7ea1..3a0e4ec64 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -222,8 +222,8 @@ lemma probability_le_one [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] (T : Temperature) (i : ι) : 𝓒.probability T i ≤ 1 := by have hZpos : 0 < 𝓒.mathematicalPartitionFunction T := by - simpa [mathematicalPartitionFunction_of_fintype] using - Finset.sum_pos (fun j _ => Real.exp_pos _) Finset.univ_nonempty + rw [mathematicalPartitionFunction_of_fintype] + exact Finset.sum_pos (fun j _ => Real.exp_pos _) Finset.univ_nonempty rw [probability, div_le_one hZpos, mathematicalPartitionFunction_of_fintype] simpa [neg_mul] using Finset.single_le_sum (f := fun j : ι => Real.exp (- β T * 𝓒.energy j)) (fun j _ => Real.exp_nonneg _) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index 1afd0491a..f08cee5bf 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -408,8 +408,8 @@ to the energy observable. -/ lemma integral_energy_bolt {ι} [MeasurableSpace ι] (𝓒 : CanonicalEnsemble ι) (T : Temperature) : ∫ x, 𝓒.energy x ∂ 𝓒.μBolt T - = ∫ x, 𝓒.energy x * Real.exp (-T.β * 𝓒.energy x) ∂ 𝓒.μ := - integral_bolt_eq_integral_mul_exp 𝓒 T 𝓒.energy + = ∫ x, 𝓒.energy x * Real.exp (-T.β * 𝓒.energy x) ∂ 𝓒.μ := by + exact integral_bolt_eq_integral_mul_exp 𝓒 T 𝓒.energy /-- The mean energy can be expressed as a ratio of integrals. -/ lemma meanEnergy_eq_ratio_of_integrals @@ -426,8 +426,8 @@ lemma meanEnergy_eq_ratio_of_integrals integral_energy_bolt (𝓒:=𝓒) (T:=T) have h_den : (𝓒.μBolt T Set.univ).toReal - = ∫ x, Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ := - mathematicalPartitionFunction_eq_integral (𝓒:=𝓒) (T:=T) + = ∫ x, Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ := by + exact (mathematicalPartitionFunction_eq_integral (𝓒:=𝓒) (T:=T)) have h_inv_toReal : ((𝓒.μBolt T Set.univ)⁻¹).toReal = 1 / (𝓒.μBolt T Set.univ).toReal := by diff --git a/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean b/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean index 3ec6397fc..ce13bf5eb 100644 --- a/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean +++ b/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean @@ -94,9 +94,9 @@ lemma partitionZ_eq (hV : 0 < V) (hβ : 0 < β) : Measurable.exists fun i => Measurable.exists fun j => measurable_const.lt (by fun_prop) have h_measurability : Measurable fun x : (Fin n × Fin 3 → ℝ) × (Fin n × Fin 3 → ℝ) => if ∃ x_1 x_2, V ^ (3⁻¹:ℝ) / 2 < |x.1 (x_1, x_2)| then 0 - else Real.exp (-(β * ∑ x_1 : Fin n × Fin 3, x.2 (x_1.1, x_1.2) ^ 2 / 2)) := - Measurable.ite (measurableSet_setOf.mpr (h_measurable_box.comp measurable_fst)) - (by fun_prop) (by fun_prop) + else Real.exp (-(β * ∑ x_1 : Fin n × Fin 3, x.2 (x_1.1, x_1.2) ^ 2 / 2)) := by + refine Measurable.ite (measurableSet_setOf.mpr ?_) (by fun_prop) (by fun_prop) + exact h_measurable_box.comp measurable_fst rw [MeasureTheory.integral_eq_lintegral_of_nonneg_ae] rotate_left · exact Filter.Eventually.of_forall fun _ => by positivity diff --git a/Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean b/Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean index 1220ec901..b9a90ad86 100644 --- a/Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean +++ b/Physlib/StringTheory/FTheory/SU5/Charges/Viable.lean @@ -595,8 +595,8 @@ lemma mem_viableCharges_iff' {I} {x : ChargeSpectrum} : ¬ IsPhenoConstrained x ∧ ¬ YukawaGeneratesDangerousAtLevel x 1 ∧ IsComplete x := by constructor · intro h - have h1 : x ∈ ofFinset I.allowedBarFiveCharges I.allowedTenCharges := - viableCharges_mem_ofFinset I x h + have h1 : x ∈ ofFinset I.allowedBarFiveCharges I.allowedTenCharges := by + exact viableCharges_mem_ofFinset I x h rw [mem_viableCharges_iff h1] at h exact ⟨h1, h⟩ · rintro ⟨h1, h⟩ diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean index 5d9d9ccdc..7d3fb4490 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean @@ -162,8 +162,8 @@ def reduce (x : FiveQuanta 𝓩) : FiveQuanta 𝓩 := lemma reduce_nodup (x : FiveQuanta 𝓩) : x.reduce.Nodup := by rw [reduce] - exact Multiset.Nodup.map (fun q1 q2 h => congrArg Prod.fst h) - (Multiset.nodup_dedup x.toCharges) + refine Multiset.Nodup.map (fun q1 q2 h => ?_) (Multiset.nodup_dedup x.toCharges) + exact congrArg Prod.fst h @[simp] lemma reduce_dedup (x : FiveQuanta 𝓩) : x.reduce.dedup = x.reduce := @@ -281,9 +281,9 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : FiveQuanta 𝓩) (f · have h_mem_dedup : p.1 ∈ (x.map Prod.fst).dedup := by rwa [Multiset.mem_dedup] rw [Multiset.sum_map_eq_nsmul_single p.1] simp only [↓reduceIte, smul_eq_mul] - have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := - Multiset.count_eq_one_of_mem (Multiset.nodup_dedup (Multiset.map Prod.fst x)) - h_mem_dedup + have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := by + refine Multiset.count_eq_one_of_mem ?_ h_mem_dedup + exact Multiset.nodup_dedup (Multiset.map Prod.fst x) simp [h_count_one] intro q5' h h2 simp_all [eq_comm] diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean index 52366c0d7..2d4a8347e 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean @@ -295,9 +295,9 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : TenQuanta 𝓩) (f · have h_mem_dedup : p.1 ∈ (x.map Prod.fst).dedup := by rwa [Multiset.mem_dedup] rw [Multiset.sum_map_eq_nsmul_single p.1] simp only [↓reduceIte, smul_eq_mul] - have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := - Multiset.count_eq_one_of_mem (Multiset.nodup_dedup (Multiset.map Prod.fst x)) - h_mem_dedup + have h_count_one : Multiset.count p.1 (Multiset.map Prod.fst x).dedup = 1 := by + refine Multiset.count_eq_one_of_mem ?_ h_mem_dedup + exact Multiset.nodup_dedup (Multiset.map Prod.fst x) simp [h_count_one] intro q5' h h2 simp_all [eq_comm] diff --git a/Physlib/Units/Basic.lean b/Physlib/Units/Basic.lean index 55b4243d8..12c6bdd3b 100644 --- a/Physlib/Units/Basic.lean +++ b/Physlib/Units/Basic.lean @@ -364,4 +364,4 @@ noncomputable def CarriesDimension.toDimensionful {M : Type} [CarriesDimension M lemma CarriesDimension.toDimensionful_apply_apply {M : Type} [CarriesDimension M] (u1 u2 : UnitChoices) (m : M) : - (toDimensionful u1 m).1 u2 = (u1.dimScale u2 (dim M)) • m := rfl + (toDimensionful u1 m).1 u2 = (u1.dimScale u2 (dim M)) • m := by rfl diff --git a/Physlib/Units/Dimension.lean b/Physlib/Units/Dimension.lean index 042535620..4e5b4da29 100644 --- a/Physlib/Units/Dimension.lean +++ b/Physlib/Units/Dimension.lean @@ -190,37 +190,37 @@ instance : Pow Dimension ℚ where def L𝓭 : Dimension := ⟨1, 0, 0, 0, 0⟩ @[simp] -lemma L𝓭_length : L𝓭.length = 1 := rfl +lemma L𝓭_length : L𝓭.length = 1 := by rfl @[simp] -lemma L𝓭_time : L𝓭.time = 0 := rfl +lemma L𝓭_time : L𝓭.time = 0 := by rfl @[simp] -lemma L𝓭_mass : L𝓭.mass = 0 := rfl +lemma L𝓭_mass : L𝓭.mass = 0 := by rfl @[simp] -lemma L𝓭_charge : L𝓭.charge = 0 := rfl +lemma L𝓭_charge : L𝓭.charge = 0 := by rfl @[simp] -lemma L𝓭_temperature : L𝓭.temperature = 0 := rfl +lemma L𝓭_temperature : L𝓭.temperature = 0 := by rfl /-- The dimension corresponding to time. -/ def T𝓭 : Dimension := ⟨0, 1, 0, 0, 0⟩ @[simp] -lemma T𝓭_length : T𝓭.length = 0 := rfl +lemma T𝓭_length : T𝓭.length = 0 := by rfl @[simp] -lemma T𝓭_time : T𝓭.time = 1 := rfl +lemma T𝓭_time : T𝓭.time = 1 := by rfl @[simp] -lemma T𝓭_mass : T𝓭.mass = 0 := rfl +lemma T𝓭_mass : T𝓭.mass = 0 := by rfl @[simp] -lemma T𝓭_charge : T𝓭.charge = 0 := rfl +lemma T𝓭_charge : T𝓭.charge = 0 := by rfl @[simp] -lemma T𝓭_temperature : T𝓭.temperature = 0 := rfl +lemma T𝓭_temperature : T𝓭.temperature = 0 := by rfl /-- The dimension corresponding to mass. -/ def M𝓭 : Dimension := ⟨0, 0, 1, 0, 0⟩ diff --git a/Physlib/Units/Integral.lean b/Physlib/Units/Integral.lean index 1f5eb481d..ae28cffb6 100644 --- a/Physlib/Units/Integral.lean +++ b/Physlib/Units/Integral.lean @@ -55,7 +55,7 @@ variable {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] [HasDim M] [NormedAddCommGroup G] [NormedSpace ℝ G] [HasDim G] lemma scaleUnit_measure (u1 u2 : UnitChoices) (μ : MeasureTheory.Measure M) : - scaleUnit u1 u2 μ = μ.map (fun m => scaleUnit u1 u2 m) := rfl + scaleUnit u1 u2 μ = μ.map (fun m => scaleUnit u1 u2 m) := by rfl /-- The statement that for a measure `μ` of dimension `d`, and a function `f : M → G` of dimension `(CarriesDimension.d G * d⁻¹)` (where `CarriesDimension.d G` diff --git a/Physlib/Units/WithDim/Speed.lean b/Physlib/Units/WithDim/Speed.lean index c12552e6b..efd69a55e 100644 --- a/Physlib/Units/WithDim/Speed.lean +++ b/Physlib/Units/WithDim/Speed.lean @@ -74,8 +74,8 @@ lemma oneMilePerHour_in_SI : oneMilePerHour SI = ⟨0.44704⟩ := by lemma oneKilometerPerHour_in_SI : oneKilometerPerHour SI = ⟨5/18⟩ := by ext - norm_num [oneKilometerPerHour, dimScale, LengthUnit.kilometers, TimeUnit.hours, - toDimensionful_apply_apply] + simp only [WithDim.smul_val, smul_eq_mul, mul_one, NNReal.coe_mul, coe_rpow, NNReal.coe_div, + NNReal.coe_ofNat] rw [toReal] norm_num diff --git a/QuantumInfo/Capacity/Capacity.lean b/QuantumInfo/Capacity/Capacity.lean index 18fd30adc..0cf72a267 100644 --- a/QuantumInfo/Capacity/Capacity.lean +++ b/QuantumInfo/Capacity/Capacity.lean @@ -166,8 +166,8 @@ end AristotleLemmas theorem not_achievesRate_gt_log_dim_out (Λ : CPTPMap d₁ d₂) {R : ℝ} (hR : Real.logb 2 (Fintype.card d₂) < R): ¬Λ.AchievesRate R := by intro h; -- We show that the identity channel on the output space `d₂` emulates `Λ`. Since capacity is monotonic under emulation, `Q(Λ) ≤ Q(id_{d₂})`. - have h_emulate : (CPTPMap.id (dIn := d₂)).Emulates Λ := - ⟨Λ, CPTPMap.id, by simp⟩ + have h_emulate : (CPTPMap.id (dIn := d₂)).Emulates Λ := by + exact ⟨Λ, CPTPMap.id, by simp⟩ -- If `Λ` achieves rate `R`, then `id_{d₂}` achieves rate `R`. This follows because if `Λ^{\otimes n}` emulates `B`, and `id^{\otimes n}` emulates `Λ^{\otimes n}` (by functoriality of tensor product), then `id^{\otimes n}` emulates `B`. have h_id_achieves : (CPTPMap.id (dIn := d₂)).AchievesRate R := by intro ε hε_pos diff --git a/QuantumInfo/Channels/Bundled.lean b/QuantumInfo/Channels/Bundled.lean index f9349a249..170a87735 100644 --- a/QuantumInfo/Channels/Bundled.lean +++ b/QuantumInfo/Channels/Bundled.lean @@ -205,8 +205,8 @@ instance instContinuousOrderHomClass : ContinuousOrderHomClass (PMap dIn dOut /-- Positive-presering maps also preserve positivity on, specifically, Hermitian matrices. -/ @[simp] -theorem pos_Hermitian (M : PMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := - map_nonneg M h +theorem pos_Hermitian (M : PMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := by + simpa only [map_zero] using ContinuousOrderHomClass.map_monotone M h end PMap @@ -257,8 +257,8 @@ instance instHContinuousOrderHomClass : ContinuousOrderHomClass (PTPMap dIn dOut /-- PTP maps also preserve positivity on Hermitian matrices. -/ @[simp] -theorem pos_Hermitian (M : PTPMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := - map_nonneg M h +theorem pos_Hermitian (M : PTPMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := by + simpa only [map_zero] using ContinuousOrderHomClass.map_monotone M h /-- `PTPMap`s are functions from `MState`s to `MState`s. -/ noncomputable instance instMFunLike [DecidableEq dIn] [DecidableEq dOut] : @@ -403,8 +403,8 @@ instance instOneHomClass : OneHomClass (PUMap dIn dOut ℂ) /-- CPTP maps also preserve positivity on Hermitian matrices. -/ @[simp] -theorem pos_Hermitian (M : PUMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := - map_nonneg M h +theorem pos_Hermitian (M : PUMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := by + simpa only [map_zero] using ContinuousOrderHomClass.map_monotone M h end PUMap @@ -444,8 +444,8 @@ instance instOneHomClass : OneHomClass (CPUMap dIn dOut ℂ) /-- CPTP maps also preserve positivity on Hermitian matrices. -/ @[simp] -theorem pos_Hermitian (M : CPUMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := - map_nonneg M h +theorem pos_Hermitian (M : CPUMap dIn dOut ℂ) {x : HermitianMat dIn ℂ} (h : 0 ≤ x) : 0 ≤ M x := by + simpa only [map_zero] using ContinuousOrderHomClass.map_monotone M h end CPUMap diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index 8a5b1e5c6..fa1667d7b 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -163,7 +163,7 @@ theorem id_MState (ρ : MState dIn) : CPTPMap.id (dIn := dIn) ρ = ρ := by /-- The map `CPTPMap.id` composed with any map is the same map. -/ @[simp] theorem id_compose [DecidableEq dOut] (Λ : CPTPMap dIn dOut) : id ∘ₘ Λ = Λ := by - ext ρ + apply funext simp /-- Any map composed with `CPTPMap.id` is the same map. -/ @@ -182,7 +182,7 @@ variable [DecidableEq dOut] def ofEquiv (σ : dIn ≃ dOut) : CPTPMap dIn dOut where toLinearMap := MatrixMap.submatrix ℂ σ.symm cp := .submatrix σ.symm - TP := MatrixMap.IsTracePreserving.submatrix σ.symm + TP x := by rw [MatrixMap.IsTracePreserving.submatrix] @[simp] theorem ofEquiv_apply (σ : dIn ≃ dOut) (ρ : MState dIn) : diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index 72fef778f..f697ef5d0 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -149,8 +149,8 @@ theorem IsPositive.dual {M : MatrixMap dIn dOut ℂ} (h : M.IsPositive) : M.dual /-- The dual of TracePreserving map is *not* trace-preserving, it's *unital*, that is, M*(I) = I. -/ theorem dual_Unital (h : M.IsTracePreserving) : M.dual.Unital := by -- By definition of dual, we know that for any matrix A, Tr(M(A) * I) = Tr(A * M*(I)). - have h_dual_trace : ∀ A : Matrix dIn dIn 𝕜, (M A * 1).trace = (A * M.dual 1).trace := - fun A => Dual.trace_eq M A 1 + have h_dual_trace : ∀ A : Matrix dIn dIn 𝕜, (M A * 1).trace = (A * M.dual 1).trace := by + exact fun A => Dual.trace_eq M A 1; ext i j specialize h_dual_trace ( Matrix.of ( fun k l => if k = j then if l = i then 1 else 0 else 0 ) ) simp_all [ Matrix.trace, Matrix.mul_apply ] ; @@ -206,8 +206,8 @@ lemma dual_choi_matrix_posSemidef_of_posSemidef (M : MatrixMap dIn dOut 𝕜) (h /-- The dual of the identity map is the identity map. -/ -lemma dual_id : (MatrixMap.id dIn 𝕜).dual = MatrixMap.id dIn 𝕜 := - dual_unique (id dIn 𝕜) (id dIn 𝕜) fun _ => congrFun rfl +lemma dual_id : (MatrixMap.id dIn 𝕜).dual = MatrixMap.id dIn 𝕜 := by + exact dual_unique (id dIn 𝕜) (id dIn 𝕜) fun A_1 => congrFun rfl private theorem matrix_mem_span_kronecker {A C : Type*} [Fintype A] [Fintype C] [DecidableEq A] [DecidableEq C] (X : Matrix (A × C) (A × C) 𝕜) : @@ -260,10 +260,10 @@ lemma dual_kron {A B C D : Type*} [Fintype A] [Fintype B] [Fintype C] [Fintype D theorem IsCompletelyPositive.dual {M : MatrixMap dIn dOut ℂ} (h : M.IsCompletelyPositive) : M.dual.IsCompletelyPositive := by intro n -- By definition of complete positivity, we know that $(M ⊗ₖₘ id) dually map = M.dual ⊗ₖₘ id.dual$. - convert IsPositive.dual (h n) using 1 - rw [show MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ) = - MatrixMap.dual M ⊗ₖₘ MatrixMap.dual (MatrixMap.id (Fin n) ℂ) by - convert dual_kron M (MatrixMap.id (Fin n) ℂ) using 1, dual_id] + have h_dual_kron : (MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ)) = (MatrixMap.dual M) ⊗ₖₘ (MatrixMap.dual (MatrixMap.id (Fin n) ℂ)) := by + convert dual_kron M ( MatrixMap.id ( Fin n ) ℂ ) using 1; + convert h_dual_pos using 1; + rw [ h_dual_kron, dual_id ] /-- The composition of the dual of the inverse of the dual basis isomorphism with the dual basis @@ -288,8 +288,8 @@ lemma Module.Basis.toDualEquiv_symm_comp_dualMap_toDualEquiv {ι R M : Type*} [F b.toDualEquiv.symm.toLinearMap ∘ₗ b.toDualEquiv.toLinearMap.dualMap = (Module.evalEquiv R M).symm.toLinearMap := by simp [ LinearMap.ext_iff ]; intro x - obtain ⟨y, hy⟩ : ∃ y, x = (Module.evalEquiv R M).toLinearMap y := - ⟨_, Eq.symm <| LinearEquiv.apply_symm_apply (Module.evalEquiv R M) x⟩ + obtain ⟨y, hy⟩ : ∃ y, x = (Module.evalEquiv R M).toLinearMap y := by + exact ⟨ _, Eq.symm <| LinearEquiv.apply_symm_apply ( Module.evalEquiv R M ) x ⟩; rw [ hy ]; simp [ Module.evalEquiv, LinearEquiv.symm_apply_eq ]; ext; simp [ Module.Dual.eval ] ; diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 0d8e1bed4..c7b4b5746 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -44,7 +44,7 @@ theorem pinching_kraus_commutes (ρ : MState d) (i : spectrum ℝ ρ.m) : theorem pinching_kraus_mul_self (ρ : MState d) (i : spectrum ℝ ρ.m) : (pinching_kraus ρ i).mat * ρ.m = i.val • pinching_kraus ρ i := by - unfold MState.m + dsimp [MState.m] nth_rw 1 [← ρ.M.cfc_id] rw [pinching_kraus] rw [← ρ.M.mat_cfc_mul, ← HermitianMat.mat_smul] @@ -123,7 +123,7 @@ theorem pinching_commutes_kraus (σ ρ : MState d) (i : spectrum ℝ σ.m) : theorem pinching_commutes (ρ σ : MState d) : Commute (pinching_map σ ρ).m σ.m := by - change (pinching_map σ ρ).M.mat * σ.M.mat = σ.M.mat * (pinching_map σ ρ).M.mat + dsimp [MState.m, Commute, SemiconjBy] rw [pinchingMap_apply_M] simp only [MatrixMap.of_kraus, Function.comp_apply] simp only [HermitianMat.conjTranspose_mat, MState.mat_M, LinearMap.coe_sum, @@ -190,7 +190,7 @@ theorem pinching_bound (ρ σ : MState d) : ρ.M ≤ (↑(Fintype.card (spectrum simp only [HermitianMat.mat_finset_sum] simp only [Matrix.mul_sum, Matrix.sum_mul, Matrix.sum_mulVec, dotProduct_sum] simp only [MState.pure] - unfold MState.m + dsimp [MState.m] --This out to be Cauchy-Schwarz. have hschwarz := inner_mul_inner_self_le (𝕜 := ℂ) (E := EuclideanSpace ℂ (↑(spectrum ℝ σ.m))) (x := .toLp 2 fun i ↦ 1) (y := .toLp 2 fun k ↦ ( @@ -294,8 +294,8 @@ theorem inner_cfc_pinching_right (ρ σ : MState d) (f : ℝ → ℝ) : convert pinching_sum σ using 1; simp [HermitianMat.ext_iff ]; -- Since each pinching_kraus is a projection, multiplying it by itself gives the same projection. Therefore, the sum of the squares is the same as the sum of the pinching_kraus themselves. - have h_proj : ∀ k : spectrum ℝ σ.m, (pinching_kraus σ k).mat * (pinching_kraus σ k).mat = (pinching_kraus σ k).mat := - fun k => by simpa [ sq, -pinching_sq_eq_self ] using congr_arg ( fun x : HermitianMat d ℂ => x.mat ) ( pinching_sq_eq_self σ k ) ; + have h_proj : ∀ k : spectrum ℝ σ.m, (pinching_kraus σ k).mat * (pinching_kraus σ k).mat = (pinching_kraus σ k).mat := by + exact fun k => by simpa [ sq, -pinching_sq_eq_self ] using congr_arg ( fun x : HermitianMat d ℂ => x.mat ) ( pinching_sq_eq_self σ k ) ; rw [ Finset.sum_congr rfl fun _ _ => h_proj _ ]; convert congr_arg ( fun x : Matrix d d ℂ => x.trace.re ) ( congr_arg ( fun x : Matrix d d ℂ => x * ( ρ.m * cfc f σ.m ) ) h_sum_kraus ) using 1; · simp [Matrix.sum_mul] diff --git a/QuantumInfo/Channels/Unbundled.lean b/QuantumInfo/Channels/Unbundled.lean index 7eb8b0df3..eec68ca52 100644 --- a/QuantumInfo/Channels/Unbundled.lean +++ b/QuantumInfo/Channels/Unbundled.lean @@ -455,8 +455,8 @@ def _root_.MatrixMap.conj (y : Matrix B A R) : MatrixMap A B R where map_smul' r x := by rw [RingHom.id_apply, Matrix.mul_smul, Matrix.smul_mul] omit [DecidableEq A] in -theorem conj_isPositive (M : Matrix B A 𝕜) : (conj M).IsPositive := - fun _ hX => hX.mul_mul_conjTranspose_same M +theorem conj_isPositive (M : Matrix B A 𝕜) : (conj M).IsPositive := by + exact fun X hX => hX.mul_mul_conjTranspose_same M omit [DecidableEq A] in theorem IsPositive_sum {ι : Type*} [Fintype ι] (f : ι → MatrixMap A B ℂ) (h : ∀ i, (f i).IsPositive) : @@ -535,8 +535,8 @@ theorem congruence_CP {A B : Type*} [Fintype A] [Fintype B] [DecidableEq A] [Dec convert conj_isPositive ( M ⊗ₖ ( 1 : Matrix ( Fin n ) ( Fin n ) 𝕜 ) ) using 1 theorem IsCompletelyPositive_sum {ι : Type*} [Fintype ι] (f : ι → MatrixMap A B ℂ) (h : ∀ i, (f i).IsCompletelyPositive) : - (∑ i, f i).IsCompletelyPositive := - IsCompletelyPositive.finset_sum h + (∑ i, f i).IsCompletelyPositive := by + convert IsCompletelyPositive.finset_sum h using 1 omit [Fintype B] [DecidableEq A] in theorem of_kraus_eq_sum_conj (K : κ → Matrix B A 𝕜) : diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 9bb050895..afb27e223 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -225,9 +225,9 @@ structure RandVar (α : Type*) [Fintype α] (T : Type*) where instance instFunctor : Functor (RandVar α) where map f e := ⟨f ∘ e.1, e.2⟩ instance instLawfulFunctor : LawfulFunctor (RandVar α) where - map_const {_} {_} := rfl - id_map _ := rfl - comp_map _ _ _ := rfl + map_const {α} {β} := by rfl + id_map _ := by rfl + comp_map _ _ _ := by rfl -- `U` is required to be a group just because mix below uses Convex.sum_mem, -- but it should be provable with just `AddCommMonoid U` @@ -300,7 +300,7 @@ def congrRandVar (σ : α ≃ β) : RandVar α T ≃ RandVar β T := by /-- Given a `T`-valued random variable `X` over `α`, mapping over `T` commutes with the equivalence over `α` -/ def map_congr_eq_congr_map {S : Type _} [Mixable U S] (f : T → S) (σ : α ≃ β) (X : RandVar α T) : - f <$> congrRandVar σ X = congrRandVar σ (f <$> X) := rfl + f <$> congrRandVar σ X = congrRandVar σ (f <$> X) := by rfl /-- The expectation value is invariant under equivalence of random variables -/ @[simp] diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 9c6edb504..e4d41665c 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -129,8 +129,8 @@ theorem sandwichedTraceFunctional_conj_unitary_hermitian (conj U.val A).conj ((conj U.val B).mat) = conj U.val (A.conj B.mat) := by intros A B U simp [conj] - have h_unitary : ∀ (U : Matrix.unitaryGroup d ℂ), U.val * U.val.conjTranspose = 1 := - fun U => U.2.2 + have h_unitary : ∀ (U : Matrix.unitaryGroup d ℂ), U.val * U.val.conjTranspose = 1 := by + exact fun U => U.2.2 simp [← mul_assoc] have := h_unitary U; simp_all [Matrix.mul_assoc, mul_eq_one_comm.mp this] simp_all [conj_apply_mat, rpow_conj_unitary] @@ -316,8 +316,8 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} simp [add_comm] simp [← Matrix.ext_iff] intro i j; exact (by - have h_support : A.kerProj + A.supportProj = 1 := - kerProj_add_supportProj A + have h_support : A.kerProj + A.supportProj = 1 := by + exact kerProj_add_supportProj A convert! congr_arg (fun f => f i j) h_support using 1) rw [← Matrix.add_mulVec, h_support, Matrix.one_mulVec] have hsup : B.mat *ᵥ (A.kerProj.mat *ᵥ x.ofLp) = 0 := by @@ -325,8 +325,8 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} have h_support : A.mat * A.kerProj.mat = 0 := by have h_support : A.mat * A.kerProj.mat = A.mat * (1 - A.supportProj.mat) := by congr - have h_support : A.kerProj + A.supportProj = 1 := - kerProj_add_supportProj A + have h_support : A.kerProj + A.supportProj = 1 := by + exact kerProj_add_supportProj A exact eq_sub_of_add_eq <| congr_arg Subtype.val h_support rw [h_support, mul_sub, mul_one, sub_eq_zero] exact Eq.symm (mul_supportProj_of_ker_le fun ⦃x⦄ a => a) @@ -341,8 +341,8 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} · simp [Matrix.mulVec, dotProduct] · simp [Matrix.mulVec, dotProduct] rfl - have h_support : B.mat = B.mat.conjTranspose := - B.2.symm + have h_support : B.mat = B.mat.conjTranspose := by + exact B.2.symm have h_support : (B.mat * A.supportProj.mat).conjTranspose = A.supportProj.mat * B.mat := by simp [Matrix.conjTranspose_mul] lia @@ -369,8 +369,8 @@ lemma inner_eq_inner_conj_of_ker_le (ρ σ : MState d) simp only [inner_def, conj_apply_mat] have h_support : σ.M.supportProj.mat * ρ.M.mat = ρ.M.mat ∧ - ρ.M.mat * σ.M.supportProj.mat = ρ.M.mat := - ⟨supportProj_mul_of_ker_le hker, mul_supportProj_of_ker_le hker⟩ + ρ.M.mat * σ.M.supportProj.mat = ρ.M.mat := by + exact ⟨supportProj_mul_of_ker_le hker, mul_supportProj_of_ker_le hker⟩ have h_trace_cyclic : Matrix.trace ((σ.M ^ γ).mat * ρ.M.mat * (σ.M ^ γ).mat * (σ.M ^ (-γ)).mat * H.mat * (σ.M ^ (-γ)).mat) = @@ -514,8 +514,8 @@ This follows from the variational formula: the supremum equals `Q̃_α(ρ‖σ)` which is a finite real number. -/ theorem f_alpha_bddAbove (hα : 1 < α) (ρ σ : MState d) (hker : σ.M.ker ≤ ρ.M.ker) : - BddAbove (Set.range (fun H : {H : HermitianMat d ℂ // 0 ≤ H} => f_alpha α H.1 ρ σ)) := - ⟨_, Set.forall_mem_range.mpr fun H => f_alpha_le_at_optimizer hα ρ σ _ H.2 hker⟩ + BddAbove (Set.range (fun H : {H : HermitianMat d ℂ // 0 ≤ H} => f_alpha α H.1 ρ σ)) := by + exact ⟨_, Set.forall_mem_range.mpr fun H => f_alpha_le_at_optimizer hα ρ σ _ H.2 hker⟩ /- **Step 5 (Sup preserves convexity)**: The supremum over `H ≥ 0` of the jointly @@ -571,8 +571,8 @@ theorem sandwichedTraceFunctional_jointly_convex (hα : 1 < α) {ι : Type*} [Fi (hker : ∀ i, (σs i).M.ker ≤ (ρs i).M.ker) : Q̃_ α(ρ_mix‖σ_mix) ≤ ∑ i, w i * Q̃_ α(ρs i‖σs i) := by have hker' : σ_mix.M.ker ≤ ρ_mix.M.ker := by - simpa [hρ_mix, hσ_mix] using - ker_weighted_sum_le w hw_nonneg _ _ (fun i => (ρs i).nonneg) (fun i => (σs i).nonneg) hker + rw [hρ_mix, hσ_mix] + exact ker_weighted_sum_le w hw_nonneg _ _ (fun i => (ρs i).nonneg) (fun i => (σs i).nonneg) hker rw [traceFunctional_eq_iSup_f_alpha hα ρ_mix σ_mix hker'] calc ⨆ H : {H : HermitianMat d ℂ // 0 ≤ H}, f_alpha α H.1 ρ_mix σ_mix ≤ ∑ i, w i * (⨆ H : {H : HermitianMat d ℂ // 0 ≤ H}, f_alpha α H.1 (ρs i) (σs i)) := @@ -824,8 +824,8 @@ The trace functional is multiplicative over tensor products: -/ theorem sandwichedTraceFunctional_mul (ρ₁ σ₁ : MState dA) (ρ₂ σ₂ : MState dB) : - Q̃_ α(ρ₁ ⊗ᴹ ρ₂‖σ₁ ⊗ᴹ σ₂) = Q̃_ α(ρ₁‖σ₁) * Q̃_ α(ρ₂‖σ₂) := - sandwiched_term_product ρ₁ σ₁ ρ₂ σ₂ α ((1 - α) / (2 * α)) + Q̃_ α(ρ₁ ⊗ᴹ ρ₂‖σ₁ ⊗ᴹ σ₂) = Q̃_ α(ρ₁‖σ₁) * Q̃_ α(ρ₂‖σ₂) := by + exact sandwiched_term_product ρ₁ σ₁ ρ₂ σ₂ α ((1 - α) / (2 * α)) /- The trace functional of a state with itself equals 1. @@ -879,8 +879,8 @@ theorem MState.conjTensorUnitary_M (ρ : MState (dA × dB)) (V : Matrix.unitaryG /-- The trace functional is invariant under `1_A ⊗ V` conjugation. -/ theorem sandwichedTraceFunctional_conj_tensorUnitary (ρ σ : MState (dA × dB)) (V : Matrix.unitaryGroup dB ℂ) : - Q̃_ α(ρ.conjTensorUnitary V‖σ.conjTensorUnitary V) = Q̃_ α(ρ‖σ) := - sandwichedTraceFunctional_conj_unitary_MState _ ρ σ + Q̃_ α(ρ.conjTensorUnitary V‖σ.conjTensorUnitary V) = Q̃_ α(ρ‖σ) := by + exact sandwichedTraceFunctional_conj_unitary_MState _ ρ σ section twirling @@ -1235,8 +1235,8 @@ theorem sandwichedRenyiEntropy_conj_unitary (hα : 0 < α) (ρ σ : MState d) · use (U.val.conjTranspose.toEuclideanLin x) simp_all [ker, Matrix.toEuclideanLin] simp_all [lin, Matrix.toLpLin] - have h_unitary : (U.val * U.val.conjTranspose) = 1 := - U.2.2 + have h_unitary : (U.val * U.val.conjTranspose) = 1 := by + exact U.2.2 generalize_proofs at *; ( apply_fun (U.val.conjTranspose *ᵥ ·) at hx simp_all [Matrix.mul_assoc, Matrix.mulVec_mulVec] @@ -1353,8 +1353,8 @@ theorem sandwichedRenyiEntropy_DPI_gt_one (hα : 1 < α) (ρ σ : MState d₁) ( calc D̃_ α(Φ ρ‖Φ σ) _ = D̃_ α((Φ.purify ((prep ∘ₘ append) ρ)).traceLeft.traceLeft‖ (Φ.purify ((prep ∘ₘ append) σ)).traceLeft.traceLeft) := by - have h_trace (ξ) : Φ ξ = (Φ.purify ((prep ∘ₘ append) ξ)).traceLeft.traceLeft := - congr($Φ.purify_trace ξ) + have h_trace (ξ) : Φ ξ = (Φ.purify ((prep ∘ₘ append) ξ)).traceLeft.traceLeft := by + exact congr($Φ.purify_trace ξ) rw [h_trace ρ, h_trace σ] _ = D̃_ α(((ρ ⊗ᴹ τ).U_conj U).traceLeft.traceLeft‖ ((σ ⊗ᴹ τ).U_conj U).traceLeft.traceLeft) := by diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 9b40edacc..d168bb412 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -274,12 +274,12 @@ lemma HermitianMat.supportProj_mul_self (A : HermitianMat d ℂ) : A.supportProj.mat * A.mat = A.mat := by have h_supportProj_mul_A : ∀ (v : d → ℂ), (A.supportProj.val.mulVec (A.val.mulVec v)) = (A.val.mulVec v) := by intro v - have h_range : WithLp.toLp 2 (A.val.mulVec v) ∈ LinearMap.range A.val.toEuclideanLin := - ⟨_, rfl⟩ + have h_range : WithLp.toLp 2 (A.val.mulVec v) ∈ LinearMap.range A.val.toEuclideanLin := by + exact ⟨ _, rfl ⟩ have h_supportProj_mul_A : ∀ (v : EuclideanSpace ℂ d), v ∈ LinearMap.range A.val.toEuclideanLin → (A.supportProj.val.toEuclideanLin v) = v := by intro v hv have h_supportProj_mul_A : (A.supportProj.val.toEuclideanLin v) = (Submodule.orthogonalProjectionOnto (LinearMap.range A.val.toEuclideanLin) v) := by - simp only [val_eq_coe] + simp only [val_eq_coe, Submodule.coe_orthogonalProjectionOnto_apply] simp [supportProj, projector] have key : ∀ (f : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d), Matrix.toEuclideanLin @@ -311,8 +311,8 @@ lemma HermitianMat.mul_supportProj_of_ker_le {A B : HermitianMat d ℂ} (h : LinearMap.ker B.lin.toLinearMap ≤ LinearMap.ker A.lin.toLinearMap) : A.mat * B.supportProj.mat = A.mat := by -- Since $B.supportProj$ is the projection onto $range B$, we have $B.supportProj * B.mat = B.mat$. - have h_supportProj_mul_B : B.supportProj.mat * B.mat = B.mat := - supportProj_mul_self B + have h_supportProj_mul_B : B.supportProj.mat * B.mat = B.mat := by + exact supportProj_mul_self B have h_range_A_subset_range_B : LinearMap.range A.lin.toLinearMap ≤ LinearMap.range B.lin.toLinearMap := by have h_orthogonal_complement : LinearMap.range (B.lin : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d) = (LinearMap.ker (B.lin : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d))ᗮ := by have h_orthogonal_complement : ∀ (T : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d), T = T.adjoint → LinearMap.range T = (LinearMap.ker T)ᗮ := by @@ -339,8 +339,8 @@ lemma HermitianMat.mul_supportProj_of_ker_le {A B : HermitianMat d ℂ} -- Since $B.supportProj$ is the projection onto $range B$, and $range A \subseteq range B$, we have $B.supportProj * A = A$. have h_supportProj_mul_A : ∀ (v : EuclideanSpace ℂ d), B.supportProj.mat.mulVec (A.mat.mulVec v) = A.mat.mulVec v := by intro v - obtain ⟨w, hw⟩ : WithLp.toLp 2 (A.mat.mulVec v) ∈ LinearMap.range B.lin.toLinearMap := - h_range_A_subset_range_B (Set.mem_range_self v) + obtain ⟨w, hw⟩ : WithLp.toLp 2 (A.mat.mulVec v) ∈ LinearMap.range B.lin.toLinearMap := by + exact h_range_A_subset_range_B ( Set.mem_range_self v ); replace h_supportProj_mul_B := congr(Matrix.mulVec $h_supportProj_mul_B w) replace hw := congr(WithLp.ofLp $hw) simp only [ContinuousLinearMap.coe_coe] at hw @@ -474,8 +474,8 @@ private lemma hasDerivAt_trace_rpow_at_one (B : HermitianMat d ℂ) (hB : 0 ≤ by_cases h_pos : 0 < B.H.eigenvalues i; · convert! HasDerivAt.rpow ( hasDerivAt_const _ _ ) ( hasDerivAt_id 1 ) h_pos using 1 simp only [id_eq, mul_one, sub_self, Real.rpow_zero, Real.rpow_one, one_mul, zero_add] - · have h_zero : B.H.eigenvalues i = 0 := - le_antisymm (le_of_not_gt h_pos) (by simpa using hB.eigenvalues_nonneg i) + · have h_zero : B.H.eigenvalues i = 0 := by + exact le_antisymm ( le_of_not_gt h_pos ) ( by simpa using hB.eigenvalues_nonneg i ) simp [h_zero] exact (hasDerivAt_const _ _).congr_of_eventuallyEq (Filter.eventuallyEq_of_mem ( Ioi_mem_nhds zero_lt_one ) fun x hx => Real.zero_rpow hx.out.ne' ) simp only [HermitianMat.trace_rpow_eq_sum, ← Finset.sum_apply] @@ -505,10 +505,10 @@ private lemma trace_conj_eq_inner_rpow {ρ σ : MState d} {t : ℝ} (ht : t ≠ rw [ h_cyclic, two_mul ] ring_nf have h_exp : (σ.M ^ (t + t)).mat = (σ.M ^ t).mat * (σ.M ^ t).mat := by - have h_nonneg : 0 ≤ σ.M := - σ.nonneg - have h_ne_zero : t + t ≠ 0 := - fun h => ht (by linarith) + have h_nonneg : 0 ≤ σ.M := by + exact σ.nonneg + have h_ne_zero : t + t ≠ 0 := by + exact fun h => ht ( by linarith ) exact HermitianMat.mat_rpow_add h_nonneg h_ne_zero rw [ mul_two, h_exp ] have h_inner : ⟪ρ.M, σ.M ^ (2 * t)⟫ = ((ρ.M.mat * (σ.M ^ (2 * t)).mat).trace).re := rfl @@ -653,8 +653,8 @@ private lemma B_of_one (ρ σ : MState d) : B_of ρ σ 1 = ρ.M := by simp [B_of, HermitianMat.rpow_zero, HermitianMat.conj_one] -- B(α) is nonneg for α > 0, because it's a conj of a nonneg matrix. -private lemma B_of_nonneg (ρ σ : MState d) (α : ℝ) : 0 ≤ B_of ρ σ α := - HermitianMat.conj_nonneg _ ρ.nonneg +private lemma B_of_nonneg (ρ σ : MState d) (α : ℝ) : 0 ≤ B_of ρ σ α := by + exact HermitianMat.conj_nonneg _ ρ.nonneg -- The function g(M) = Tr[M^s] - Tr[M] satisfies g(M) = 0 when s = 1. private lemma trace_rpow_sub_trace_at_one (M : HermitianMat d ℂ) : @@ -687,13 +687,13 @@ private lemma scalar_rpow_cross_term_of_continuous {b : ℝ → ℝ} {c : ℝ} ring_nf norm_num [ hc ] -- Use the fact that $b(1 + t) \to c$ as $t \to 0$. - have h_b : Filter.Tendsto (fun t => b (1 + t)) (nhdsWithin 0 {0}ᶜ) (nhds c) := - hc ▸ hb_cont.tendsto.comp ( tendsto_nhdsWithin_of_tendsto_nhds ( by norm_num [ Filter.Tendsto ] ) ); + have h_b : Filter.Tendsto (fun t => b (1 + t)) (nhdsWithin 0 {0}ᶜ) (nhds c) := by + exact hc ▸ hb_cont.tendsto.comp ( tendsto_nhdsWithin_of_tendsto_nhds ( by norm_num [ Filter.Tendsto ] ) ); -- Use the fact that $b(1 + t)^t - 1 \sim t \log(b(1 + t))$ as $t \to 0$. have h_exp : Filter.Tendsto (fun t => t⁻¹ * (b (1 + t) ^ t - 1)) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := by have h_exp : Filter.Tendsto (fun t => (b (1 + t) ^ t - 1) / t) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := by - have h_log : Filter.Tendsto (fun t => (Real.log (b (1 + t)) * t) / t) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := - Filter.Tendsto.congr' ( by filter_upwards [ self_mem_nhdsWithin ] with t ht using by rw [ mul_div_cancel_right₀ _ ht ] ) ( Filter.Tendsto.log h_b hc_pos.ne' ) + have h_log : Filter.Tendsto (fun t => (Real.log (b (1 + t)) * t) / t) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := by + exact Filter.Tendsto.congr' ( by filter_upwards [ self_mem_nhdsWithin ] with t ht using by rw [ mul_div_cancel_right₀ _ ht ] ) ( Filter.Tendsto.log h_b hc_pos.ne' ) have h_exp : Filter.Tendsto (fun t => (Real.exp (Real.log (b (1 + t)) * t) - 1) / t) (nhdsWithin 0 {0}ᶜ) (nhds (Real.log c)) := by have h_exp : HasDerivAt (fun t => Real.exp (Real.log (b (1 + t)) * t)) (Real.log c) 0 := by have h_log : HasDerivAt (fun t => Real.log (b (1 + t)) * t) (Real.log c) 0 := by @@ -748,8 +748,8 @@ private lemma scalar_rpow_cross_term_of_continuous_zero {b : ℝ → ℝ} have h_sqrt_log : Filter.Tendsto (fun x => Real.sqrt x * Real.log x) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by -- Let $y = \sqrt{x}$, so we can rewrite the limit as $\lim_{y \to 0^+} y \log(y^2) = \lim_{y \to 0^+} 2y \log(y)$. suffices h_log_y : Filter.Tendsto (fun y => 2 * y * Real.log y) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) by - have h_subst : Filter.Tendsto (fun x => 2 * Real.sqrt x * Real.log (Real.sqrt x)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := - h_log_y.comp <| Filter.Tendsto.inf ( Real.continuous_sqrt.tendsto' _ _ <| by norm_num ) <| Filter.tendsto_principal_principal.mpr fun x hx => Real.sqrt_pos.mpr hx; + have h_subst : Filter.Tendsto (fun x => 2 * Real.sqrt x * Real.log (Real.sqrt x)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by + exact h_log_y.comp <| Filter.Tendsto.inf ( Real.continuous_sqrt.tendsto' _ _ <| by norm_num ) <| Filter.tendsto_principal_principal.mpr fun x hx => Real.sqrt_pos.mpr hx; generalize_proofs at *; ( exact h_subst.congr' ( Filter.eventuallyEq_of_mem self_mem_nhdsWithin fun x hx => by rw [ Real.log_sqrt hx.out.le ] ; ring ) |> fun h => h.trans ( by norm_num ) ;); exact tendsto_nhdsWithin_of_tendsto_nhds ( by simpa [ mul_assoc ] using Filter.Tendsto.const_mul 2 ( Real.continuous_mul_log.tendsto 0 ) ) |> fun h => h.trans ( by norm_num ) ; @@ -852,8 +852,8 @@ private lemma eigenvalues_bounded_near {M : ℝ → HermitianMat d ℂ} (hM_nonneg : ∀ᶠ α in nhds 1, 0 ≤ M α) (hM_cont : ContinuousAt M 1) : ∃ K > 0, ∀ᶠ α in nhds 1, ∀ i, 0 ≤ (M α).H.eigenvalues i ∧ (M α).H.eigenvalues i ≤ K := by - have h_op_norm_bound : ∃ K > 0, ∀ᶠ α in nhds 1, ‖M α‖ ≤ K := - ⟨ ‖M 1‖ + 1, by positivity, hM_cont.norm.eventually ( ge_mem_nhds ( lt_add_one _ ) ) ⟩ + have h_op_norm_bound : ∃ K > 0, ∀ᶠ α in nhds 1, ‖M α‖ ≤ K := by + exact ⟨ ‖M 1‖ + 1, by positivity, hM_cont.norm.eventually ( ge_mem_nhds ( lt_add_one _ ) ) ⟩ have h_eigenvalue_bound : ∀ᶠ α in nhds 1, ∀ i, 0 ≤ (M α).H.eigenvalues i ∧ (M α).H.eigenvalues i ≤ ‖M α‖ := by have h_eigenvalue_bound : ∀ᶠ α in nhds 1, ∀ i, |(M α).H.eigenvalues i| ≤ ‖M α‖ := by filter_upwards [ hM_nonneg, h_op_norm_bound.choose_spec.2 ] with α hα₁ hα₂ i @@ -873,8 +873,8 @@ private lemma rpow_slope_tendsto_uniformly (K : ℝ) : intro ε ε_pos obtain ⟨δ₁, δ₁_pos, hδ₁⟩ : ∃ δ₁ > 0, ∀ x ∈ Set.Icc 0 K, 0 < x → x < δ₁ → |x * Real.log x| < ε / 4 ∧ ∀ h, 0 < |h| → |h| < 1 / 2 → |(x ^ (1 + h) - x) / h| < ε / 4 := by obtain ⟨δ₁, δ₁_pos, hδ₁⟩ : ∃ δ₁ > 0, ∀ x ∈ Set.Icc 0 K, 0 < x → x < δ₁ → |x * Real.log x| < ε / 4 := by - have h_cont : Filter.Tendsto (fun x => x * Real.log x) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := - tendsto_nhdsWithin_of_tendsto_nhds ( by simpa using Real.continuous_mul_log.tendsto 0 ); + have h_cont : Filter.Tendsto (fun x => x * Real.log x) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by + exact tendsto_nhdsWithin_of_tendsto_nhds ( by simpa using Real.continuous_mul_log.tendsto 0 ); have := Metric.tendsto_nhdsWithin_nhds.mp h_cont ( ε / 4 ) ( by linarith ); exact ⟨ this.choose, this.choose_spec.1, fun x hx₁ hx₂ hx₃ => by simpa [ abs_mul ] using this.choose_spec.2 hx₂ ( by simpa [ abs_of_pos hx₂ ] using hx₃ ) ⟩; have h_bound : ∃ δ₁ > 0, ∀ x ∈ Set.Icc 0 K, 0 < x → x < δ₁ → ∀ h, 0 < |h| → |h| < 1 / 2 → |x ^ (1 + h) - x| ≤ |h| * x * (|Real.log x| + 1) * Real.exp (|h| * (|Real.log x| + 1)) := by @@ -900,8 +900,8 @@ private lemma rpow_slope_tendsto_uniformly (K : ℝ) : have h_bound : Filter.Tendsto (fun x => x * (|Real.log x| + 1) * Real.exp (1 / 2 * (|Real.log x| + 1))) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by -- Let $y = -\log x$, so we can rewrite the limit as $y \to \infty$. suffices h_log : Filter.Tendsto (fun y => Real.exp (-y) * (y + 1) * Real.exp ((y + 1) / 2)) Filter.atTop (nhds 0) by - have h_subst : Filter.Tendsto (fun x => Real.exp (-(-Real.log x)) * ((-Real.log x) + 1) * Real.exp ((-Real.log x + 1) / 2)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := - h_log.comp ( Filter.tendsto_neg_atBot_atTop.comp ( Real.tendsto_log_nhdsNE_zero.mono_left <| nhdsWithin_mono _ <| by norm_num ) ); + have h_subst : Filter.Tendsto (fun x => Real.exp (-(-Real.log x)) * ((-Real.log x) + 1) * Real.exp ((-Real.log x + 1) / 2)) (nhdsWithin 0 (Set.Ioi 0)) (nhds 0) := by + exact h_log.comp ( Filter.tendsto_neg_atBot_atTop.comp ( Real.tendsto_log_nhdsNE_zero.mono_left <| nhdsWithin_mono _ <| by norm_num ) ); refine' h_subst.congr' _; filter_upwards [ Ioo_mem_nhdsGT_of_mem ⟨ le_rfl, zero_lt_one ⟩ ] with x hx rw [ abs_of_nonpos ( Real.log_nonpos hx.1.le hx.2.le ) ] @@ -952,8 +952,8 @@ private lemma rpow_slope_tendsto_uniformly (K : ℝ) : obtain ⟨δ₂, δ₂_pos, hδ₂⟩ : ∃ δ₂ > 0, ∀ x ∈ Set.Icc δ₁ K, ∀ h, 0 < |h| → |h| < δ₂ → |h| * x * (Real.log x) ^ 2 * Real.exp (|h| * |Real.log x|) < ε / 4 := by -- Since $x * (\log x)^2 * \exp(|h| * |\log x|)$ is continuous on the compact interval $[\delta₁, K]$, it is bounded. obtain ⟨M, hM⟩ : ∃ M > 0, ∀ x ∈ Set.Icc δ₁ K, ∀ h, 0 < |h| → |h| < 1 / 2 → x * (Real.log x) ^ 2 * Real.exp (|h| * |Real.log x|) ≤ M := by - have h_cont : ContinuousOn (fun x => x * (Real.log x) ^ 2 * Real.exp (1 / 2 * |Real.log x|)) (Set.Icc δ₁ K) := - ContinuousOn.mul ( ContinuousOn.mul continuousOn_id ( ContinuousOn.pow ( Real.continuousOn_log.mono ( by exact fun x hx => ne_of_gt <| lt_of_lt_of_le δ₁_pos hx.1 ) ) _ ) ) ( ContinuousOn.rexp <| ContinuousOn.mul continuousOn_const <| ContinuousOn.abs <| Real.continuousOn_log.mono ( by exact fun x hx => ne_of_gt <| lt_of_lt_of_le δ₁_pos hx.1 ) ); + have h_cont : ContinuousOn (fun x => x * (Real.log x) ^ 2 * Real.exp (1 / 2 * |Real.log x|)) (Set.Icc δ₁ K) := by + exact ContinuousOn.mul ( ContinuousOn.mul continuousOn_id ( ContinuousOn.pow ( Real.continuousOn_log.mono ( by exact fun x hx => ne_of_gt <| lt_of_lt_of_le δ₁_pos hx.1 ) ) _ ) ) ( ContinuousOn.rexp <| ContinuousOn.mul continuousOn_const <| ContinuousOn.abs <| Real.continuousOn_log.mono ( by exact fun x hx => ne_of_gt <| lt_of_lt_of_le δ₁_pos hx.1 ) ); obtain ⟨ M, hM ⟩ := IsCompact.exists_bound_of_continuousOn ( CompactIccSpace.isCompact_Icc ) h_cont; norm_num +zetaDelta at *; exact ⟨ Max.max M 1, by positivity, fun x hx₁ hx₂ h hh₁ hh₂ => le_trans ( by rw [ abs_of_nonneg ( by linarith : 0 ≤ x ) ] ; exact mul_le_mul_of_nonneg_left ( Real.exp_le_exp.mpr <| by nlinarith [ abs_nonneg ( Real.log x ) ] ) <| by nlinarith [ abs_nonneg ( Real.log x ) ] ) <| le_trans ( hM x hx₁ hx₂ ) <| le_max_left _ _ ⟩; @@ -986,8 +986,8 @@ private lemma trace_cfc_tendsto_of_tendsto (f : ℝ → ℝ) exact h_cont_cfc.mono fun A hA => h_spectrum_subset A hA exact h_cont_trace exact h_cont _ ( by simp [ ρ.2 ] ) |> ContinuousWithinAt.mono <| Set.Subset.refl _; - have h_trace_cont : Continuous (fun A : HermitianMat d ℂ => A.trace) := - HermitianMat.trace_Continuous + have h_trace_cont : Continuous (fun A : HermitianMat d ℂ => A.trace) := by + exact HermitianMat.trace_Continuous; have h_comp_cont : Filter.Tendsto (fun α => (M α).cfc f) (nhds 1) (nhds ((ρ : HermitianMat d ℂ).cfc f)) := by convert! h_cfc_cont.tendsto.comp _ using 2; exact tendsto_nhdsWithin_iff.mpr ⟨ hM_cont.tendsto.trans ( by simp [ hM_one ] ), hM_nonneg ⟩; @@ -1299,8 +1299,8 @@ lemma ker_le_of_ker_kron_le_left (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSta exact Fintype.sum_prod_type_right fun x => A i x.1 * (B j x.2 * (u x.1 * v x.2)); convert! congr_fun ( h_kronecker σ₁.1.mat σ₂.1.mat u v ) ( i, j ) using 1 ; simp exact Or.inl ( by exact congr(WithLp.ofLp $hu i) ); - have hz' : z ∈ (ρ₁ ⊗ᴹ ρ₂ : HermitianMat (d₁ × d₂) ℂ).ker := - h hz + have hz' : z ∈ (ρ₁ ⊗ᴹ ρ₂ : HermitianMat (d₁ × d₂) ℂ).ker := by + exact h hz; have hz'' : ∀ a b, (ρ₁.M.val.mulVec u) a * (ρ₂.M.val.mulVec v) b = 0 := by intro a b have hz'' : (ρ₁.M.val.mulVec u) a * (ρ₂.M.val.mulVec v) b = ((ρ₁ ⊗ᴹ ρ₂ : HermitianMat (d₁ × d₂) ℂ).val.mulVec z) (a, b) := by @@ -1349,8 +1349,8 @@ lemma ker_le_of_ker_kron_le_right (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSt obtain ⟨ u, hu₁, hu₂ ⟩ := h_union; have h_union : ∀ v : EuclideanSpace ℂ d₁, v ∈ U → v + u ∈ V := by intro v hv; specialize h_contra ( v + u ) ; simp_all [ Submodule.add_mem_iff_right ] ; - have h_union : ∀ v : EuclideanSpace ℂ d₁, v ∈ U → v ∈ V := - fun v hv => by simpa using V.sub_mem (h_union v hv) hu₂ + have h_union : ∀ v : EuclideanSpace ℂ d₁, v ∈ U → v ∈ V := by + exact fun v hv => by simpa using V.sub_mem ( h_union v hv ) hu₂; exact hV ( eq_top_iff.mpr fun x hx => by by_cases hxU : x ∈ U <;> aesop ); exact h_z _ _ ( by tauto ) ( by tauto ); exact ⟨ h_z.choose, by intro h; simpa [ h ] using h_z.choose_spec.1, h_z.choose_spec.1, h_z.choose_spec.2 ⟩; @@ -1372,8 +1372,8 @@ lemma ker_le_of_ker_kron_le_right (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSt convert! hz_mul using 1; simp_all only [zero_eq_mul] exact Or.inr ( by exact congr(WithLp.ofLp $hv b) ); - have hz' : z ∈ (ρ₁ ⊗ᴹ ρ₂).M.ker := - h hz + have hz' : z ∈ (ρ₁ ⊗ᴹ ρ₂).M.ker := by + exact h hz; have hz'' : ∀ i j, (ρ₁.M.val.mulVec u) i * (ρ₂.M.val.mulVec v) j = 0 := by intro i j; have hz'' : (ρ₁.M.val.kronecker ρ₂.M.val).mulVec (fun p => u p.1 * v p.2) (i, j) = (ρ₁.M.val.mulVec u) i * (ρ₂.M.val.mulVec v) j := by @@ -1640,8 +1640,8 @@ private theorem sandwichedRelRentropy.continuousOn_Ioi_1_aux (ρ σ : MState d) have h_cont : ContinuousOn (fun α : ℝ => (HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M) (Set.Ioi 1) := by have h_cont : ContinuousOn (fun α : ℝ => (σ.M ^ ((1 - α) / (2 * α))).mat) (Set.Ioi 1) := by have h_cont : ContinuousOn (fun α : ℝ => σ.M ^ ((1 - α) / (2 * α))) (Set.Ioi 1) := by - have h_cont : ContinuousOn (fun α : ℝ => (1 - α) / (2 * α)) (Set.Ioi 1) := - continuousOn_of_forall_continuousAt fun x hx => ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by linarith [ hx.out ] ) + have h_cont : ContinuousOn (fun α : ℝ => (1 - α) / (2 * α)) (Set.Ioi 1) := by + exact continuousOn_of_forall_continuousAt fun x hx => ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by linarith [ hx.out ] ) have h_cont : ContinuousOn (fun α : ℝ => (σ.M ^ α)) (Set.Iio 0) := by apply_rules [ HermitianMat.continuousOn_rpow_neg ]; exact h_cont.comp ‹_› fun x hx => by rw [ Set.mem_Iio ] ; rw [ div_lt_iff₀ ] <;> linarith [ hx.out ] ; @@ -1687,8 +1687,8 @@ private theorem sandwichedRelRentropy.continuousOn_Ioo_0_1_aux (ρ σ : MState d have h_cont : ContinuousOn (fun α : ℝ => (HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M) (Set.Ioo 0 1) := by have h_cont : ContinuousOn (fun α : ℝ => (σ.M ^ ((1 - α) / (2 * α))).mat) (Set.Ioo 0 1) := by have h_cont : ContinuousOn (fun α : ℝ => σ.M ^ ((1 - α) / (2 * α))) (Set.Ioo 0 1) := by - have h_exp_cont : ContinuousOn (fun α : ℝ => (1 - α) / (2 * α)) (Set.Ioo 0 1) := - continuousOn_of_forall_continuousAt fun x hx => ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by linarith [ hx.1 ] ) + have h_exp_cont : ContinuousOn (fun α : ℝ => (1 - α) / (2 * α)) (Set.Ioo 0 1) := by + exact continuousOn_of_forall_continuousAt fun x hx => ContinuousAt.div ( continuousAt_const.sub continuousAt_id ) ( continuousAt_const.mul continuousAt_id ) ( by linarith [ hx.1 ] ) have h_rpow_cont : ContinuousOn (fun α : ℝ => (σ.M ^ α)) (Set.Ioi 0) := by apply_rules [ HermitianMat.continuousOn_rpow_pos ] exact h_rpow_cont.comp h_exp_cont fun x hx => by rw [ Set.mem_Ioi ] ; apply div_pos <;> linarith [ hx.1, hx.2 ] @@ -1736,8 +1736,8 @@ private theorem sandwichedRelRentropy.continuousAt_1 (ρ σ : MState d) : · simp only [ContinuousWithinAt, SandwichedRelRentropy, dif_pos h, zero_lt_one, if_true] -- Use the fact that the limit of the real-valued function is the inner product. have h_real_limit : Filter.Tendsto (fun α : ℝ => if α = 1 then ⟪ρ.M, ρ.M.log - σ.M.log⟫ else Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1)) (nhdsWithin 1 (Set.Ioi 0)) (nhds ⟪ρ.M, ρ.M.log - σ.M.log⟫) := by - have h_real_limit : Filter.Tendsto (fun α : ℝ => Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1)) (nhdsWithin 1 (Set.Ioi 0 \ {1})) (nhds ⟪ρ.M, ρ.M.log - σ.M.log⟫) := - sandwichedRelRentropy.limit_at_one ρ σ h + have h_real_limit : Filter.Tendsto (fun α : ℝ => Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1)) (nhdsWithin 1 (Set.Ioi 0 \ {1})) (nhds ⟪ρ.M, ρ.M.log - σ.M.log⟫) := by + exact sandwichedRelRentropy.limit_at_one ρ σ h rw [ Metric.tendsto_nhdsWithin_nhds ] at * intro ε hε rcases h_real_limit ε hε with ⟨δ, hδ, H⟩ @@ -1745,8 +1745,8 @@ private theorem sandwichedRelRentropy.continuousAt_1 (ρ σ : MState d) : intro x hx₁ hx₂ by_cases hx₃ : x = 1 <;> simp [*] -- Since the real-valued function tends to the inner product, the ENNReal version should also tend to the same limit because the ENNReal conversion is continuous. - have h_ennreal_limit : Filter.Tendsto (fun α : ℝ => ENNReal.ofReal (if α = 1 then ⟪ρ.M, ρ.M.log - σ.M.log⟫ else Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1))) (nhdsWithin 1 (Set.Ioi 0)) (nhds (ENNReal.ofReal ⟪ρ.M, ρ.M.log - σ.M.log⟫)) := - (ENNReal.tendsto_ofReal h_real_limit).comp Filter.tendsto_id + have h_ennreal_limit : Filter.Tendsto (fun α : ℝ => ENNReal.ofReal (if α = 1 then ⟪ρ.M, ρ.M.log - σ.M.log⟫ else Real.log ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α).trace / (α - 1))) (nhdsWithin 1 (Set.Ioi 0)) (nhds (ENNReal.ofReal ⟪ρ.M, ρ.M.log - σ.M.log⟫)) := by + exact (ENNReal.tendsto_ofReal h_real_limit).comp Filter.tendsto_id convert h_ennreal_limit.congr' _ using 2 · symm apply ENNReal.ofReal_eq_coe_nnreal @@ -1933,8 +1933,8 @@ private lemma eigenWeight_eq_zero_iff (ρ x : MState d) (i : d) : intro v w have h_inner : star v ⬝ᵥ (ρ.M.mat.mulVec w) = star (star w ⬝ᵥ (ρ.M.mat.mulVec v)) := by have h_inner : star v ⬝ᵥ (ρ.M.mat.mulVec w) = star (star w ⬝ᵥ (ρ.M.mat.mulVec v)) := by - have h_inner : ρ.M.mat = star ρ.M.mat := - ρ.M.2.symm ▸ rfl + have h_inner : ρ.M.mat = star ρ.M.mat := by + exact ρ.M.2.symm ▸ rfl conv_rhs => rw [ h_inner ] simp [ Matrix.mulVec, dotProduct ] ring_nf @@ -1952,8 +1952,8 @@ private lemma eigenWeight_eq_zero_iff (ρ x : MState d) (i : d) : refine ⟨h_forward, fun h ↦ ?_⟩ -- Since ρ e_i = 0, we have e_i^* ρ e_i = 0. have h_zero : (Matrix.vecMul (star (x.M.H.eigenvectorBasis i : d → ℂ)) ρ.M.mat) ⬝ᵥ (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := by - have h_zero : ρ.M.mat.mulVec (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := - congr(WithLp.ofLp $h) + have h_zero : ρ.M.mat.mulVec (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := by + exact congr(WithLp.ofLp $h) convert congr_arg ( fun v => star ( x.M.H.eigenvectorBasis i : d → ℂ ) ⬝ᵥ v ) h_zero using 1 simp [ Matrix.dotProduct_mulVec] ring_nf @@ -1966,8 +1966,8 @@ private lemma ker_le_iff_eigenWeight_zero (ρ x : MState d) : constructor · exact fun h i ↦ eigenWeight_zero_of_eigenvalue_zero h · intro h v hv - obtain ⟨w, hw⟩ : ∃ w : d → ℂ, v = ∑ i, w i • x.M.H.eigenvectorBasis i := - ⟨_, Eq.symm (x.M.H.eigenvectorBasis.sum_repr v)⟩ + obtain ⟨w, hw⟩ : ∃ w : d → ℂ, v = ∑ i, w i • x.M.H.eigenvectorBasis i := by + exact ⟨ _, Eq.symm ( x.M.H.eigenvectorBasis.sum_repr v ) ⟩; -- Since $v \in \ker(x.M)$, we have $x.M(v) = 0$. Using the eigenvector basis, this implies that for each $i$, if the eigenvalue is non-zero, then $w i = 0$. have h_w_zero : ∀ i, x.M.H.eigenvalues i ≠ 0 → w i = 0 := by intro i hi @@ -1996,8 +1996,8 @@ private lemma ker_le_iff_eigenWeight_zero (ρ x : MState d) : private lemma neg_ker_exists_eigenWeight_pos (ρ x : MState d) (hx : ¬(x.M.ker ≤ ρ.M.ker)) : ∃ i, x.M.H.eigenvalues i = 0 ∧ 0 < eigenWeight ρ x i := by -- By `ker_le_iff_eigenWeight_zero`, ¬(x.M.ker ≤ ρ.M.ker) iff ∃ i, eigenvalue_i = 0 ∧ eigenWeight ≠ 0. Use this fact. - have h_eigenWeight_ne_zero : ∃ i, x.M.H.eigenvalues i = 0 ∧ eigenWeight ρ x i ≠ 0 := - Classical.not_forall_not.1 fun h => hx <| by simpa using ker_le_iff_eigenWeight_zero ρ x |>.2 fun i hi => Classical.not_not.1 fun hi' => h i ⟨ hi, hi' ⟩ ; + have h_eigenWeight_ne_zero : ∃ i, x.M.H.eigenvalues i = 0 ∧ eigenWeight ρ x i ≠ 0 := by + exact Classical.not_forall_not.1 fun h => hx <| by simpa using ker_le_iff_eigenWeight_zero ρ x |>.2 fun i hi => Classical.not_not.1 fun hi' => h i ⟨ hi, hi' ⟩ ; exact h_eigenWeight_ne_zero.imp fun i hi => ⟨ hi.1, lt_of_le_of_ne ( eigenWeight_nonneg ρ x i ) hi.2.symm ⟩ private lemma approxLog_at_zero (N : ℕ) : approxLog N 0 = -(N : ℝ) := by @@ -2031,22 +2031,22 @@ theorem qRelativeEnt_lowerSemicontinuous_2 (ρ x : MState d) (hx : ¬(x.M.ker -- Since $y < \top$, we can choose a neighborhood around $x$ where the inner product is less than $y$. have h_inner_lt_y : ∀ᶠ x' in nhds x, x'.M.ker ≤ ρ.M.ker → ⟪ρ.M, ρ.M.log - x'.M.log⟫ > y.toReal := by have h_inner_lt_y : Filter.Tendsto (fun N : ℕ => ⟪ρ.M, ρ.M.log - x.M.cfc (approxLog N)⟫) Filter.atTop Filter.atTop := by - have h_inner_lt_y : Filter.Tendsto (fun N : ℕ => ⟪ρ.M, ρ.M.log⟫ - ⟪ρ.M, x.M.cfc (approxLog N)⟫) Filter.atTop Filter.atTop := - Filter.Tendsto.add_atTop tendsto_const_nhds ( Filter.tendsto_neg_atBot_atTop.comp ( inner_cfc_approxLog_tendsto_bot ρ x hx ) ) |> Filter.Tendsto.congr ( by aesop ) ; + have h_inner_lt_y : Filter.Tendsto (fun N : ℕ => ⟪ρ.M, ρ.M.log⟫ - ⟪ρ.M, x.M.cfc (approxLog N)⟫) Filter.atTop Filter.atTop := by + exact Filter.Tendsto.add_atTop tendsto_const_nhds ( Filter.tendsto_neg_atBot_atTop.comp ( inner_cfc_approxLog_tendsto_bot ρ x hx ) ) |> Filter.Tendsto.congr ( by aesop ) ; convert h_inner_lt_y using 1 ext1 N simp [inner_sub_right] - obtain ⟨N, hN⟩ : ∃ N : ℕ, ⟪ρ.M, ρ.M.log - x.M.cfc (approxLog N)⟫ > y.toReal := - (h_inner_lt_y.eventually_gt_atTop _ ).exists + obtain ⟨N, hN⟩ : ∃ N : ℕ, ⟪ρ.M, ρ.M.log - x.M.cfc (approxLog N)⟫ > y.toReal := by + exact (h_inner_lt_y.eventually_gt_atTop _ ).exists have h_cont : Continuous (fun σ : MState d => ⟪ρ.M, ρ.M.log - σ.M.cfc (approxLog N)⟫) := by simp only [inner_sub_right] exact continuous_const.sub (continuous_inner_cfc_approxLog ρ N) - have h_cont : ∀ᶠ x' in nhds x, ⟪ρ.M, ρ.M.log - x'.M.cfc (approxLog N)⟫ > y.toReal := - h_cont.continuousAt.eventually ( lt_mem_nhds hN ) |> fun h => h.mono fun x' hx' => hx' |> fun hx'' => by simpa using hx''; + have h_cont : ∀ᶠ x' in nhds x, ⟪ρ.M, ρ.M.log - x'.M.cfc (approxLog N)⟫ > y.toReal := by + exact h_cont.continuousAt.eventually ( lt_mem_nhds hN ) |> fun h => h.mono fun x' hx' => hx' |> fun hx'' => by simpa using hx''; filter_upwards [h_cont] with x' hx' hx'' apply lt_of_lt_of_le hx' - have h_inner_le : ⟪ρ.M, x'.M.log⟫ ≤ ⟪ρ.M, x'.M.cfc (approxLog N)⟫ := - inner_cfc_approxLog_ge ρ x' N hx'' + have h_inner_le : ⟪ρ.M, x'.M.log⟫ ≤ ⟪ρ.M, x'.M.cfc (approxLog N)⟫ := by + exact inner_cfc_approxLog_ge ρ x' N hx'' rw [inner_sub_right, inner_sub_right] exact sub_le_sub_left h_inner_le _ filter_upwards [ h_inner_lt_y ] with x' hx'; @@ -2324,8 +2324,8 @@ private lemma posDef_add_eps {A : HermitianMat d ℂ} (hA : 0 ≤ A) {ε : ℝ} private lemma log_add_eps_eq_cfc (A : HermitianMat d 𝕜) (ε : ℝ) : (A + ε • 1).log = A.cfc (Real.log <| · + ε) := by have h_cfc : A + ε • 1 = A.cfc (· + ε) := by - have h_add : A.cfc (fun u => u + ε) = A.cfc (fun u => u) + A.cfc (fun _ => ε) := - A.cfc_add_apply _ _ + have h_add : A.cfc (fun u => u + ε) = A.cfc (fun u => u) + A.cfc (fun _ => ε) := by + exact A.cfc_add_apply _ _ simp only [HermitianMat.cfc_id', HermitianMat.cfc_const, h_add] rw [h_cfc, HermitianMat.log, A.cfc_comp_apply] @@ -2382,9 +2382,9 @@ private lemma HermitianMat.inner_log_mono_of_psd_of_le {A B C : HermitianMat d ⟪C, A.log⟫ ≤ ⟪C, B.log⟫ := by open scoped Topology in have h_eventually : ∀ᶠ ε in 𝓝[>] (0 : ℝ), - ⟪C, (A + ε • 1).log⟫ ≤ ⟪C, (B + ε • 1).log⟫ := - eventually_nhdsWithin_of_forall fun ε hε => - inner_log_mono_of_posDef_of_le hC (posDef_add_eps hA hε) (add_le_add_left hAB _) + ⟪C, (A + ε • 1).log⟫ ≤ ⟪C, (B + ε • 1).log⟫ := by + refine eventually_nhdsWithin_of_forall fun ε hε ↦ ?_ + exact inner_log_mono_of_posDef_of_le hC (posDef_add_eps hA hε) (add_le_add_left hAB _) refine le_of_tendsto_of_tendsto ?_ ?_ h_eventually · exact inner_log_shift_tendsto hker · apply inner_log_shift_tendsto @@ -2395,8 +2395,8 @@ private lemma HermitianMat.inner_log_sub_le_log_alpha (ρ : MState d) {σ₁ σ (hker₁ : σ₁.M.ker ≤ ρ.M.ker) (hker₂ : σ₂.M.ker ≤ ρ.M.ker) : ⟪ρ.M, σ₂.M.log - σ₁.M.log⟫ ≤ Real.log α := by have h_log_mono : ⟪ρ.M, σ₂.M.log - (α • σ₁.M).log⟫ ≤ 0 := by - have h_log_mono : ⟪ρ.M, σ₂.M.log⟫ ≤ ⟪ρ.M, (α • σ₁.M).log⟫ := - inner_log_mono_of_psd_of_le σ₂.nonneg hσ ρ.nonneg hker₂ + have h_log_mono : ⟪ρ.M, σ₂.M.log⟫ ≤ ⟪ρ.M, (α • σ₁.M).log⟫ := by + exact inner_log_mono_of_psd_of_le σ₂.nonneg hσ ρ.nonneg hker₂ simpa [inner_sub_right] using sub_nonpos_of_le h_log_mono have h_log_smul : (α • σ₁.M).log = (Real.log α) • σ₁.M.supportProj + σ₁.M.log := by apply HermitianMat.log_smul_of_pos diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 0f154e701..4041dd933 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -395,8 +395,8 @@ private lemma W_mat_sq_eq_conj [Nonempty dA] [Nonempty dB] [Nonempty dC] · exact sqrt_sq (by positivity) · convert sqrt_sq ( show 0 ≤ ( σBC.traceLeft⁻¹ : HermitianMat dC ℂ ) from ?_ ) using 1; have h_inv_pos : (σBC.traceLeft⁻¹ : HermitianMat dC ℂ).mat.PosDef := by - have h_inv_pos : (σBC.traceLeft : Matrix dC dC ℂ).PosDef := - PosDef_traceLeft σBC hσ + have h_inv_pos : (σBC.traceLeft : Matrix dC dC ℂ).PosDef := by + exact PosDef_traceLeft σBC hσ; convert! h_inv_pos.inv using 1; convert! h_inv_pos.posSemidef using 1; exact zero_le_iff; @@ -415,8 +415,8 @@ private lemma S_mat_conj_rhs_eq_one [Nonempty dA] [Nonempty dB] [Nonempty dC] S_mat ρAB σBC * ((ρAB.traceRight ⊗ₖ σBC⁻¹).reindex (Equiv.prodAssoc dA dB dC).symm).mat * S_mat ρAB σBC = 1 := by have h_comm : Commute (σBC.sqrt.mat) (σBC⁻¹.mat) := by - have h_comm : Commute (σBC.sqrt.mat) (σBC.mat) := - commute_sqrt_left rfl + have h_comm : Commute (σBC.sqrt.mat) (σBC.mat) := by + exact commute_sqrt_left rfl; have h_comm_inv : Commute (σBC.sqrt.mat) (σBC.mat) → Commute (σBC.sqrt.mat) (σBC⁻¹.mat) := by intro h_comm have h_comm_inv : Commute (σBC.sqrt.mat) (σBC.mat) → Commute (σBC.sqrt.mat) (σBC.mat⁻¹) := by @@ -745,12 +745,12 @@ private lemma S_mat_isUnit [Nonempty dA] [Nonempty dB] [Nonempty dC] constructor; · have h_det_ne_zero : ∀ (A : HermitianMat (dA) ℂ), A.mat.PosDef → (A.sqrt).mat.det ≠ 0 := by intro A hA - have h_det_ne_zero : (A.sqrt).mat.PosDef := - sqrt_posDef hA + have h_det_ne_zero : (A.sqrt).mat.PosDef := by + exact sqrt_posDef hA; exact h_det_ne_zero.det_pos.ne'; exact isUnit_iff_ne_zero.mpr ( h_det_ne_zero _ <| by simpa using PosDef_traceRight _ hρ |> fun h => h.inv ); - · have h_inv_sqrt : σBC.sqrt.mat.PosDef := - sqrt_posDef hσ + · have h_inv_sqrt : σBC.sqrt.mat.PosDef := by + exact sqrt_posDef hσ; exact isUnit_iff_ne_zero.mpr h_inv_sqrt.det_pos.ne'; unfold S_mat; simp_all [ Matrix.det_kronecker] @@ -774,8 +774,8 @@ theorem intermediate_ineq [Nonempty dA] [Nonempty dB] [Nonempty dC] convert! S_mat_conj_rhs_eq_one ρAB σBC hρ hσ using 1; · have := S_mat_isUnit ρAB σBC hρ hσ; cases' this.nonempty_invertible with u hu; - have h_pos_semidef : Matrix.PosSemidef ((S_mat ρAB σBC)⁻¹ * (S_mat ρAB σBC * ((ρAB.traceRight ⊗ₖ σBC⁻¹).reindex (Equiv.prodAssoc dA dB dC).symm).mat * S_mat ρAB σBC - S_mat ρAB σBC * (ρAB ⊗ₖ (σBC.traceLeft)⁻¹).mat * S_mat ρAB σBC) * (S_mat ρAB σBC)⁻¹ᴴ) := - Matrix.PosSemidef.mul_mul_conjTranspose_same h (S_mat ρAB σBC)⁻¹; + have h_pos_semidef : Matrix.PosSemidef ((S_mat ρAB σBC)⁻¹ * (S_mat ρAB σBC * ((ρAB.traceRight ⊗ₖ σBC⁻¹).reindex (Equiv.prodAssoc dA dB dC).symm).mat * S_mat ρAB σBC - S_mat ρAB σBC * (ρAB ⊗ₖ (σBC.traceLeft)⁻¹).mat * S_mat ρAB σBC) * (S_mat ρAB σBC)⁻¹ᴴ) := by + exact Matrix.PosSemidef.mul_mul_conjTranspose_same h (S_mat ρAB σBC)⁻¹; simp_all [ Matrix.mul_assoc, Matrix.sub_mul, Matrix.mul_sub ]; simp_all [ Matrix.posSemidef_iff_dotProduct_mulVec, Matrix.IsHermitian ]; have h_conj : (S_mat ρAB σBC)ᴴ = S_mat ρAB σBC := by @@ -802,12 +802,12 @@ theorem operator_ineq_SSA [Nonempty dA] [Nonempty dB] [Nonempty dC] convert HermitianMat.inv_kronecker _ _ using 1; · infer_instance; · exact ⟨ ⟨ Classical.arbitrary dB, Classical.arbitrary dC ⟩ ⟩; - · have h_trace_right_pos_def : (ρAB.traceRight).mat.PosDef := - PosDef_traceRight ρAB hρ + · have h_trace_right_pos_def : (ρAB.traceRight).mat.PosDef := by + exact PosDef_traceRight ρAB hρ exact ⟨by exact PosDef_traceRight ρAB hρ |>.isUnit⟩ · have h_inv_symm : σBC⁻¹.NonSingular := by - have h_inv_symm : σBC.NonSingular := - nonSingular_of_posDef hσ + have h_inv_symm : σBC.NonSingular := by + exact nonSingular_of_posDef hσ exact nonSingular_iff_inv.mpr h_inv_symm; exact h_inv_symm; convert congr_arg ( fun x : HermitianMat _ _ => x.reindex ( Equiv.prodAssoc dA dB dC ).symm ) h_inv_symm using 1; @@ -820,8 +820,8 @@ theorem operator_ineq_SSA [Nonempty dA] [Nonempty dB] [Nonempty dC] have h_inv_symm : (ρAB ⊗ₖ σBC.traceLeft⁻¹)⁻¹ = ρAB⁻¹ ⊗ₖ (σBC.traceLeft⁻¹)⁻¹ := by convert HermitianMat.inv_kronecker ρAB ( σBC.traceLeft⁻¹ ) using 1; · exact nonSingular_of_posDef hρ; - · have h_inv_symm : σBC.traceLeft.mat.PosDef := - PosDef_traceLeft σBC hσ + · have h_inv_symm : σBC.traceLeft.mat.PosDef := by + exact PosDef_traceLeft σBC hσ; -- Since σBC.traceLeft is positive definite, its inverse is also positive definite, and hence non-singular. have h_inv_pos_def : (σBC.traceLeft⁻¹).mat.PosDef := by convert! h_inv_symm.inv using 1; @@ -830,8 +830,8 @@ theorem operator_ineq_SSA [Nonempty dA] [Nonempty dB] [Nonempty dC] have h_inv_symm : (σBC.traceLeft⁻¹)⁻¹ = σBC.traceLeft := by have h_inv_symm : (σBC.traceLeft⁻¹).mat * σBC.traceLeft.mat = 1 := by have h_inv_symm : (σBC.traceLeft⁻¹).mat * σBC.traceLeft.mat = 1 := by - have h_inv_symm : σBC.traceLeft.mat.PosDef := - PosDef_traceLeft σBC hσ + have h_inv_symm : σBC.traceLeft.mat.PosDef := by + exact PosDef_traceLeft σBC hσ convert! Matrix.nonsing_inv_mul _ _; exact isUnit_iff_ne_zero.mpr h_inv_symm.det_pos.ne'; exact h_inv_symm @@ -881,8 +881,8 @@ private lemma hermitianMat_log_inv_eq_neg (A : HermitianMat d₁ ℂ) [A.NonSingular] : A⁻¹.log = -A.log := by -- By the property of continuous functional calculus, the logarithm of the inverse of a matrix is the negative of the logarithm of the matrix. have h_log_inv : A⁻¹.log = A.cfc (Real.log ∘ (·⁻¹)) := by - have h_log_inv : A⁻¹ = A.cfc (·⁻¹) := - Eq.symm HermitianMat.cfc_inv + have h_log_inv : A⁻¹ = A.cfc (·⁻¹) := by + exact Eq.symm HermitianMat.cfc_inv; rw [ h_log_inv, HermitianMat.log ]; exact Eq.symm (HermitianMat.cfc_comp A (fun x => x⁻¹) Real.log); simp [ HermitianMat.log ]; @@ -979,8 +979,8 @@ private lemma MState.approx_by_pd constructor <;> simp_all · simp_all [ Matrix.IsHermitian, Matrix.conjTranspose_add, Matrix.conjTranspose_smul ]; · intro x hx_ne_zero - have h_pos : 0 < (1 - ε) * (star x ⬝ᵥ A *ᵥ x) + ε * (star x ⬝ᵥ B *ᵥ x) := - add_pos_of_nonneg_of_pos ( mul_nonneg ( sub_nonneg.2 <| mod_cast hε.2.le ) <| mod_cast hA.2 x ) <| mul_pos ( mod_cast hε.1 ) <| mod_cast hB.2 hx_ne_zero; + have h_pos : 0 < (1 - ε) * (star x ⬝ᵥ A *ᵥ x) + ε * (star x ⬝ᵥ B *ᵥ x) := by + exact add_pos_of_nonneg_of_pos ( mul_nonneg ( sub_nonneg.2 <| mod_cast hε.2.le ) <| mod_cast hA.2 x ) <| mul_pos ( mod_cast hε.1 ) <| mod_cast hB.2 hx_ne_zero; convert h_pos using 1 ; simp [ Matrix.add_mulVec ] ; ring_nf! simp [ Matrix.mulVec, dotProduct, Finset.mul_sum _ _ _, mul_assoc, mul_left_comm, sub_mul, mul_sub ] ; ring!; convert! h_pos_def _ _ _ _ _ ⟨ _, _ ⟩ <;> norm_num [ * ]; @@ -990,8 +990,8 @@ private lemma MState.approx_by_pd · exact one_div_pos.mpr ( by linarith ); · exact div_lt_one ( by positivity ) |>.2 ( by linarith ) · -- Show that the sequence ρn converges to ρ. - have h_conv : Filter.Tendsto (fun n => εn n • (MState.uniform : MState d₁).M + (1 - εn n) • ρ.M) Filter.atTop (nhds ρ.M) := - le_trans ( Filter.Tendsto.add ( Filter.Tendsto.smul ( tendsto_const_nhds.div_atTop <| Filter.tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop ) tendsto_const_nhds ) ( Filter.Tendsto.smul ( tendsto_const_nhds.sub <| tendsto_const_nhds.div_atTop <| Filter.tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop ) tendsto_const_nhds ) ) ( by simp ); + have h_conv : Filter.Tendsto (fun n => εn n • (MState.uniform : MState d₁).M + (1 - εn n) • ρ.M) Filter.atTop (nhds ρ.M) := by + exact le_trans ( Filter.Tendsto.add ( Filter.Tendsto.smul ( tendsto_const_nhds.div_atTop <| Filter.tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop ) tendsto_const_nhds ) ( Filter.Tendsto.smul ( tendsto_const_nhds.sub <| tendsto_const_nhds.div_atTop <| Filter.tendsto_atTop_add_const_right _ _ tendsto_natCast_atTop_atTop ) tendsto_const_nhds ) ) ( by simp ); rw [ tendsto_iff_dist_tendsto_zero ] at *; convert h_conv using 1; ext n; simp [ρn, Mixable.mix]; @@ -1003,8 +1003,8 @@ private lemma MState.traceLeft_continuous : Continuous (MState.traceLeft : MState (d₁ × d₂) → MState d₂) := by -- Since the matrix traceLeft is continuous, the function that maps a state to its partial trace is also continuous. have h_traceLeft_cont : Continuous (fun ρ : HermitianMat (d₁ × d₂) ℂ => ρ.traceLeft) := by - have h_cont : Continuous (fun ρ : Matrix (d₁ × d₂) (d₁ × d₂) ℂ => ρ.traceLeft) := - continuous_pi fun _ => continuous_pi fun _ => continuous_finsetSum _ fun _ _ => continuous_apply _ |> Continuous.comp <| continuous_apply _ |> Continuous.comp <| continuous_id'; + have h_cont : Continuous (fun ρ : Matrix (d₁ × d₂) (d₁ × d₂) ℂ => ρ.traceLeft) := by + exact continuous_pi fun _ => continuous_pi fun _ => continuous_finsetSum _ fun _ _ => continuous_apply _ |> Continuous.comp <| continuous_apply _ |> Continuous.comp <| continuous_id'; convert h_cont.comp ( show Continuous fun ρ : HermitianMat ( d₁ × d₂ ) ℂ => ρ.1 from ?_ ) using 1; · constructor <;> intro h <;> rw [ continuous_induced_rng ] at * <;> aesop; · fun_prop; @@ -1124,8 +1124,8 @@ private lemma purify_AB_traceRight_eq (ρ : MState (dA × dB × dC)) : Sᵥₙ ((MState.pure ρ.purify).relabel (perm_AB_CR' dA dB dC).symm).traceRight = Sᵥₙ ρ.assoc'.traceRight := by have h_traceRight : ((MState.pure ρ.purify).relabel (perm_AB_CR' dA dB dC).symm).traceRight = ρ.assoc'.traceRight := by - have h_traceRight : (MState.pure ρ.purify).traceRight = ρ := - MState.purify_spec ρ + have h_traceRight : (MState.pure ρ.purify).traceRight = ρ := by + exact MState.purify_spec ρ; convert congr_arg ( fun m => m.assoc'.traceRight ) h_traceRight using 1; ext i j; simp [ MState.traceRight, MState.assoc' ] ; simp [ HermitianMat.traceRight, MState.SWAP, MState.assoc ]; diff --git a/QuantumInfo/Entropy/VonNeumann.lean b/QuantumInfo/Entropy/VonNeumann.lean index e7853c852..c5d38f473 100644 --- a/QuantumInfo/Entropy/VonNeumann.lean +++ b/QuantumInfo/Entropy/VonNeumann.lean @@ -284,8 +284,8 @@ private lemma charpoly_roots_filter_ne_zero_eq_eigenvalues_filter_ne_zero {d : T Mapping `RCLike.ofReal` over a multiset is injective. -/ private lemma multiset_map_ofReal_injective {R : Type*} [RCLike R] {M N : Multiset ℝ} : - M.map (RCLike.ofReal : ℝ → R) = N.map RCLike.ofReal ↔ M = N := - ⟨fun h ↦ by simpa using congr(($h).map RCLike.re), fun h ↦ by rw [h]⟩ + M.map (RCLike.ofReal : ℝ → R) = N.map RCLike.ofReal ↔ M = N := by + exact ⟨fun h ↦ by simpa using congr(($h).map RCLike.re), fun h ↦ by rw [h]⟩ /-- If the non-zero roots of the characteristic polynomials of two states are equal, diff --git a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean index 1b88c009b..f8ff8353a 100644 --- a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean +++ b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean @@ -49,8 +49,8 @@ private theorem norm_complexLaplaceIntegrand_le_envelope set e : ℝ := (E x).untop h have hdist : ‖w - z‖ ≤ δ := by simpa [Metric.mem_closedBall, dist_eq_norm, norm_sub_rev] using hw - have hre_abs : |w.re - z.re| ≤ δ := - (Complex.abs_re_le_norm (w - z)).trans (by simpa [Complex.sub_re] using hdist) + have hre_abs : |w.re - z.re| ≤ δ := by + exact (Complex.abs_re_le_norm (w - z)).trans (by simpa [Complex.sub_re] using hdist) rw [Complex.norm_exp, Complex.norm_exp, Complex.norm_exp] rcases le_total 0 e with he | he · refine le_add_of_le_of_nonneg ?_ (Real.exp_pos _).le diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean index 71c5191a9..a09d09d18 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean @@ -212,8 +212,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) simpa [Atilde] using blockDiagonal_selfAdjoint_wrap (ℋ := ℋ) hA hB have hAtilde0 : (0 : L (HSum ℋ)) ≤ Atilde := by simpa [Atilde] using blockDiagonal_nonneg (ℋ := ℋ) hA0 hB0 - have hAtilde_spec : spectrum ℝ Atilde ⊆ Set.Ici (0 : ℝ) := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) Atilde (ha := hAtilde_sa)).1 hAtilde0 + have hAtilde_spec : spectrum ℝ Atilde ⊆ Set.Ici (0 : ℝ) := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) Atilde (ha := hAtilde_sa)).1 hAtilde0 have hXtilde_star_mul : star Xtilde * Xtilde = blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 := by @@ -238,8 +238,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) · intro z simp [sub_eq_add_neg] have hblock : - blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := - sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) + blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by + exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp @@ -294,8 +294,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) /-- Uniform consequence of Theorem 2.5.2: `(i) → (v)` via `(iv)`. -/ theorem theorem_2_5_2_i_all_imp_v {f : ℝ → ℝ} (hf : CondIAll.{u} f) : CondV (ℋ := ℋ) f := by - have hconv : OperatorConvex (ℋ := ℋ) f := - hf.1 + have hconv : OperatorConvex (ℋ := ℋ) f := by + exact hf.1 have hcont : ContinuousOn f Set.univ := operatorConvex_continuousOn_univ (ℋ := ℋ) hconv refine theorem_2_5_2_iv_imp_v (ℋ := ℋ) ?_ hcont @@ -353,8 +353,8 @@ theorem theorem_2_5_2_i_ici_all_imp_v {f : ℝ → ℝ} · intro z simp [sub_eq_add_neg] have hblock : - blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := - sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) + blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by + exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean index 2acc5cdac..7b570d249 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean @@ -288,8 +288,8 @@ private theorem nontrivial_hsumL [Nontrivial ℋ] : Nontrivial (L (HSum ℋ)) := have hdiag_ne_zero : (blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 : L (HSum ℋ)) ≠ 0 := by intro h0 have hz : - blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 (hsumIncl ℋ 0 w) = 0 := - congrArg (fun T : L (HSum ℋ) => T (hsumIncl ℋ 0 w)) h0 + blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 (hsumIncl ℋ 0 w) = 0 := by + exact congrArg (fun T : L (HSum ℋ) => T (hsumIncl ℋ 0 w)) h0 have hw0 : w = 0 := by have hz0 := congrArg (fun z : HSum ℋ => hsumProj ℋ 0 z) hz simpa [blockDiagonal] using hz0 @@ -498,8 +498,8 @@ private lemma blockSwap_norm_le_one [Nontrivial ℋ] (X : L ℋ) (hX : ‖X‖ have hSstarSle : star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X ≤ (1 : L (HSum ℋ)) := by simpa [hSstarS] using hDiagLe - have hSstarSnonneg : 0 ≤ star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X := - star_mul_self_nonneg (blockSwap (ℋ := ℋ) X) + have hSstarSnonneg : 0 ≤ star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X := by + exact star_mul_self_nonneg (blockSwap (ℋ := ℋ) X) have hnormSq : ‖star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X‖ ≤ 1 := (CStarAlgebra.norm_le_one_iff_of_nonneg _ hSstarSnonneg).2 hSstarSle have hnormSq' : ‖blockSwap (ℋ := ℋ) X‖ * ‖blockSwap (ℋ := ℋ) X‖ ≤ 1 := by @@ -556,8 +556,8 @@ theorem theorem_2_5_2_i_ici_all_imp_iv {f : ℝ → ℝ} (hf : CondIciAll.{u} f) simpa [S] using blockSwap_norm_le_one (ℋ := ℋ) X hX letI : Algebra ℝ (L (HSum ℋ)) := by infer_instance - have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := - IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary S hSsa hSnorm + have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := by + exact IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary S hSsa hSnorm let U : unitary (L (HSum ℋ)) := ⟨S + Complex.I • CFC.sqrt (1 - S ^ 2), hU_mem⟩ let V : unitary (L (HSum ℋ)) := star U @@ -783,12 +783,12 @@ theorem theorem_2_5_2_i_ici_all_imp_iv {f : ℝ → ℝ} (hf : CondIciAll.{u} f) have hterm_nonpos : (f 0) • (R0 * R0) ≤ (0 : L ℋ) := by have hR0sq_nonneg : (0 : L ℋ) ≤ R0 * R0 := by simpa [hR0self.star_eq] using star_mul_self_nonneg R0 - have hneg : (0 : L ℋ) ≤ (- (f 0)) • (R0 * R0) := - smul_nonneg (by linarith [hf0]) hR0sq_nonneg + have hneg : (0 : L ℋ) ≤ (- (f 0)) • (R0 * R0) := by + exact smul_nonneg (by linarith [hf0]) hR0sq_nonneg exact (neg_nonneg.mp (by simpa [neg_smul] using hneg)) have htop : - cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := - blockDiagonal_le_left (ℋ := ℋ) hcore + cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := by + exact blockDiagonal_le_left (ℋ := ℋ) hcore have hdrop : star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) ≤ star X * cfcR (ℋ := ℋ) f A * X := by simpa [add_comm, add_left_comm, add_assoc] using @@ -810,8 +810,8 @@ theorem theorem_2_5_2_i_all_imp_iv {f : ℝ → ℝ} (hf : CondIAll.{u} f) : simpa [S] using blockSwap_norm_le_one (ℋ := ℋ) X hX letI : Algebra ℝ (L (HSum ℋ)) := by infer_instance - have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := - IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary S hSsa hSnorm + have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := by + exact IsSelfAdjoint.self_add_I_smul_cfcSqrt_sub_sq_mem_unitary S hSsa hSnorm let U : unitary (L (HSum ℋ)) := ⟨S + Complex.I • CFC.sqrt (1 - S ^ 2), hU_mem⟩ let V : unitary (L (HSum ℋ)) := star U @@ -1012,12 +1012,12 @@ theorem theorem_2_5_2_i_all_imp_iv {f : ℝ → ℝ} (hf : CondIAll.{u} f) : have hterm_nonpos : (f 0) • (R0 * R0) ≤ (0 : L ℋ) := by have hR0sq_nonneg : (0 : L ℋ) ≤ R0 * R0 := by simpa [hR0self.star_eq] using star_mul_self_nonneg R0 - have hneg : (0 : L ℋ) ≤ (- (f 0)) • (R0 * R0) := - smul_nonneg (by linarith [hf0]) hR0sq_nonneg + have hneg : (0 : L ℋ) ≤ (- (f 0)) • (R0 * R0) := by + exact smul_nonneg (by linarith [hf0]) hR0sq_nonneg exact (neg_nonneg.mp (by simpa [neg_smul] using hneg)) have htop : - cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := - blockDiagonal_le_left (ℋ := ℋ) hcore + cfcR (ℋ := ℋ) f (star X * A * X) ≤ star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) := by + exact blockDiagonal_le_left (ℋ := ℋ) hcore have hdrop : star X * cfcR (ℋ := ℋ) f A * X + (f 0) • (R0 * R0) ≤ star X * cfcR (ℋ := ℋ) f A * X := by simpa [add_comm, add_left_comm, add_assoc] using diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean index 467e3df2f..02e3168cf 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean @@ -205,8 +205,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) simpa [Atilde] using blockDiagonal_selfAdjoint (ℋ := ℋ) hA hB have hAtilde0 : (0 : L (HSum ℋ)) ≤ Atilde := by simpa [Atilde] using blockDiagonal_nonneg (ℋ := ℋ) hA0 hB0 - have hAtilde_spec : spectrum ℝ Atilde ⊆ Set.Ici (0 : ℝ) := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) Atilde (ha := hAtilde_sa)).1 hAtilde0 + have hAtilde_spec : spectrum ℝ Atilde ⊆ Set.Ici (0 : ℝ) := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) Atilde (ha := hAtilde_sa)).1 hAtilde0 have hXtilde_star_mul : star Xtilde * Xtilde = blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 := by @@ -231,8 +231,8 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) · intro z simp [sub_eq_add_neg] have hblock : - blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := - sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) + blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by + exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean index 46f6301fb..9caae93ae 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean @@ -147,8 +147,8 @@ private lemma phiK_nonneg (K : L ℋ) {T : L (HSOp ℋ)} (hT : 0 ≤ T) : 0 ≤ phiK (ℋ := ℋ) K T := by dsimp [phiK] have hpos : T.IsPositive := (ContinuousLinearMap.nonneg_iff_isPositive T).1 hT - have hnonneg : 0 ≤ Complex.re (inner ℂ (T (ofOp (star K))) (ofOp (star K))) := - ((ContinuousLinearMap.isPositive_iff_complex T).1 hpos (ofOp (star K))).2 + have hnonneg : 0 ≤ Complex.re (inner ℂ (T (ofOp (star K))) (ofOp (star K))) := by + exact ((ContinuousLinearMap.isPositive_iff_complex T).1 hpos (ofOp (star K))).2 have hre : Complex.re (inner ℂ (ofOp (star K)) (T (ofOp (star K)))) = Complex.re (inner ℂ (T (ofOp (star K))) (ofOp (star K))) := by @@ -309,11 +309,11 @@ private lemma hmiddle_leftMul_rightMul leftMulHS (ℋ := ℋ) (A ^ s) * rightMulHS (ℋ := ℋ) (B ^ (-s)) := by rcases hA with ⟨hA_sa, hA_spec⟩ rcases hB with ⟨hB_sa, hB_spec⟩ - have hA0 : 0 ≤ A := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) - have hB0 : 0 ≤ B := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 + have hB0 : 0 ≤ B := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 (by intro x hx; exact (hB_spec hx).le) have hright_negHalf : cfcR (ℋ := HSOp ℋ) (fun x : ℝ ↦ x ^ ((-1 : ℝ) / 2)) (rightMulHS (ℋ := ℋ) B) = @@ -441,12 +441,12 @@ private lemma hmiddle_leftMul_rightMul · simp [D, hxzero] have hxv0 : Module.End.HasEigenvector T0 α x := ⟨hx0, hxzero⟩ have hxv1 : Module.End.HasEigenvector T1 β x := ⟨hx1, hxzero⟩ - have hαeq : α = (α.re : ℂ) := - (RCLike.conj_eq_iff_re.mp + have hαeq : α = (α.re : ℂ) := by + exact (RCLike.conj_eq_iff_re.mp (hT0_symm.conj_eigenvalue_eq_self (Module.End.hasEigenvalue_of_hasEigenvector hxv0)) ).symm - have hβeq : β = (β.re : ℂ) := - (RCLike.conj_eq_iff_re.mp + have hβeq : β = (β.re : ℂ) := by + exact (RCLike.conj_eq_iff_re.mp (hT1_symm.conj_eigenvalue_eq_self (Module.End.hasEigenvalue_of_hasEigenvector hxv1)) ).symm have hx0r : x ∈ eigenspace T0 (α.re : ℂ) := by @@ -467,12 +467,12 @@ private lemma hmiddle_leftMul_rightMul re_inner_nonneg_of_nonneg (T := rightMulHS (ℋ := ℋ) (B ^ (-1 : ℝ))) (rightMulHS_nonneg (ℋ := ℋ) hBinv0) y - have hαnonneg : 0 ≤ α.re := - eigenvalue_nonneg_of_nonneg + have hαnonneg : 0 ≤ α.re := by + exact eigenvalue_nonneg_of_nonneg (Module.End.hasEigenvalue_of_hasEigenvector ⟨hx0r, hxzero⟩) hT0_nonneg_re - have hβnonneg : 0 ≤ β.re := - eigenvalue_nonneg_of_nonneg + have hβnonneg : 0 ≤ β.re := by + exact eigenvalue_nonneg_of_nonneg (Module.End.hasEigenvalue_of_hasEigenvector ⟨hx1r, hxzero⟩) hT1_nonneg_re have hxprod : @@ -555,11 +555,11 @@ private lemma phiK_operatorPowerMean_eq_liebTraceMap liebTraceMap (ℋ := ℋ) s K A B := by rcases hA with ⟨hA_sa, hA_spec⟩ rcases hB with ⟨hB_sa, hB_spec⟩ - have hA0 : 0 ≤ A := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) - have hB0 : 0 ≤ B := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 + have hB0 : 0 ≤ B := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 (by intro x hx; exact (hB_spec hx).le) have hright_half : cfcR (ℋ := HSOp ℋ) (fun x : ℝ ↦ x ^ ((1 : ℝ) / 2)) (rightMulHS (ℋ := ℋ) B) = @@ -831,8 +831,8 @@ private lemma pdSet_rpow_of_mem_Icc_zero_one {p : ℝ} (hp : p ∈ Set.Icc (0 : ℝ) 1) {A : L ℋ} (hA : A ∈ pdSet (ℋ := ℋ)) : A ^ p ∈ pdSet (ℋ := ℋ) := by rcases hA with ⟨hA_sa, hA_spec⟩ - have hA0 : 0 ≤ A := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) have hApow0 : 0 ≤ A ^ p := by simp @@ -863,7 +863,7 @@ private lemma pdSet_rpow_of_mem_Icc_zero_one rw [CFC.rpow_eq_cfc_real (A := L ℋ) (a := algebraMap ℝ (L ℋ) r) (y := p) (ha := hr0)] simp exact (CFC.exists_pos_algebraMap_le_iff (A := L ℋ) (a := A ^ p) (ha := hApow_sa)).1 - ⟨r ^ p, Real.rpow_pos_of_pos hr p, by simpa [hscalar, hApow] using hmono⟩ + ⟨r ^ p, Real.rpow_pos_of_pos hr p, hbound⟩ omit [Nontrivial ℋ] in set_option maxHeartbeats 400000 in @@ -876,14 +876,14 @@ private lemma liebTraceMap_mono_right rcases hA with ⟨hA_sa, hA_spec⟩ rcases hB₁ with ⟨hB₁_sa, hB₁_spec⟩ rcases hB₂ with ⟨hB₂_sa, hB₂_spec⟩ - have hA0 : 0 ≤ A := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) - have hB₁0 : 0 ≤ B₁ := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 + have hB₁0 : 0 ≤ B₁ := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 (by intro x hx; exact (hB₁_spec hx).le) - have hB₂0 : 0 ≤ B₂ := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 + have hB₂0 : 0 ≤ B₂ := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 (by intro x hx; exact (hB₂_spec hx).le) have hcfc := power_Icc_zero_one_operatorMonotoneOn_Ici (ℋ := ℋ) (1 - s) hs @@ -946,8 +946,8 @@ private lemma liebTraceMap_antitone_right rcases hA with ⟨hA_sa, hA_spec⟩ rcases hB₁ with ⟨hB₁_sa, hB₁_spec⟩ rcases hB₂ with ⟨hB₂_sa, hB₂_spec⟩ - have hA0 : 0 ≤ A := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 + have hA0 : 0 ≤ A := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) A (ha := hA_sa)).2 (by intro x hx; exact (hA_spec hx).le) have hcfc := power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi (ℋ := ℋ) (1 - s) hs @@ -1200,14 +1200,14 @@ theorem liebExtensionTrace_jointlyConcaveOn_pdSet rcases hB₁ with ⟨hB₁_sa, hB₁_spec⟩ rcases hB₂ with ⟨hB₂_sa, hB₂_spec⟩ rcases hB_combo with ⟨hB_combo_sa, hB_combo_spec⟩ - have hB₁0 : 0 ≤ B₁ := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 + have hB₁0 : 0 ≤ B₁ := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 (by intro x hx; exact (hB₁_spec hx).le) - have hB₂0 : 0 ≤ B₂ := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 + have hB₂0 : 0 ≤ B₂ := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 (by intro x hx; exact (hB₂_spec hx).le) - have hBcombo0 : 0 ≤ ((1 - θ) • B₁ + θ • B₂) := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) ((1 - θ) • B₁ + θ • B₂) + have hBcombo0 : 0 ≤ ((1 - θ) • B₁ + θ • B₂) := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) ((1 - θ) • B₁ + θ • B₂) (ha := hB_combo_sa)).2 (by intro x hx; exact (hB_combo_spec hx).le) have hpow_conc := @@ -1260,8 +1260,8 @@ theorem liebExtensionTrace_jointlyConcaveOn_pdSet liebExtensionTraceMap (ℋ := ℋ) q p K A B := by intro A B hB rcases hB with ⟨hB_sa, hB_spec⟩ - have hB0 : 0 ≤ B := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 + have hB0 : 0 ≤ B := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 (by intro x hx; exact (hB_spec hx).le) have hpow : (B ^ β) ^ (1 - q) = B ^ p := by @@ -1322,14 +1322,14 @@ theorem andoTrace_jointlyConvexOn_pdSet rcases hB₁ with ⟨hB₁_sa, hB₁_spec⟩ rcases hB₂ with ⟨hB₂_sa, hB₂_spec⟩ rcases hB_combo with ⟨hB_combo_sa, hB_combo_spec⟩ - have hB₁0 : 0 ≤ B₁ := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 + have hB₁0 : 0 ≤ B₁ := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₁ (ha := hB₁_sa)).2 (by intro x hx; exact (hB₁_spec hx).le) - have hB₂0 : 0 ≤ B₂ := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 + have hB₂0 : 0 ≤ B₂ := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B₂ (ha := hB₂_sa)).2 (by intro x hx; exact (hB₂_spec hx).le) - have hBcombo0 : 0 ≤ ((1 - θ) • B₁ + θ • B₂) := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) ((1 - θ) • B₁ + θ • B₂) + have hBcombo0 : 0 ≤ ((1 - θ) • B₁ + θ • B₂) := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) ((1 - θ) • B₁ + θ • B₂) (ha := hB_combo_sa)).2 (by intro x hx; exact (hB_combo_spec hx).le) have hpow_conc := @@ -1382,8 +1382,8 @@ theorem andoTrace_jointlyConvexOn_pdSet andoTraceMap (ℋ := ℋ) q r K A B := by intro A B hB rcases hB with ⟨hB_sa, hB_spec⟩ - have hB0 : 0 ≤ B := - (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 + have hB0 : 0 ≤ B := by + exact (StarOrderedRing.nonneg_iff_spectrum_nonneg (R := ℝ) B (ha := hB_sa)).2 (by intro x hx; exact (hB_spec hx).le) have hBunit : IsUnit B := by refine spectrum.isUnit_of_zero_notMem (R := ℝ) ?_ diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 24135d243..50ebc5a71 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -845,8 +845,8 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → C + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) AB ≤ C + ((t * (1 - u)) • cfcR (fun x : ℝ ↦ 1 / (x + t)) A - + (t * u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := - add_le_add_right hscale C + + (t * u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := by + exact add_le_add_right hscale C have hR : C + ((t * (1 - u)) • cfcR (fun x : ℝ ↦ 1 / (x + t)) A @@ -1341,8 +1341,8 @@ private lemma convexOn_G_rpowIntegrand₀₁_mul {q : NNReal} (hq_real : (q : Real.rpow_nonneg (le_of_lt htpos) _ have hs : Convex ℝ (Set.Ici (0 : 𝓐)) := convex_Ici (𝕜 := ℝ) (0 : 𝓐) have h_aff : ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun X : 𝓐 ↦ X - algebraMap ℝ (𝓐) t) := by - have hid : ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun X : 𝓐 ↦ X) := - convexOn_id (𝕜 := ℝ) (s := Set.Ici (0 : 𝓐)) hs + have hid : ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun X : 𝓐 ↦ X) := by + exact convexOn_id (𝕜 := ℝ) (s := Set.Ici (0 : 𝓐)) hs have hconst : ConvexOn ℝ (Set.Ici (0 : 𝓐)) (fun _ : 𝓐 ↦ -algebraMap ℝ (𝓐) t) := convexOn_const (-algebraMap ℝ (𝓐) t) hs simp_all [sub_eq_add_neg] @@ -1624,8 +1624,8 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : have hAA' : ((1 - u) • A) * ((1 - u) • A) = ((1 - u) * (1 - u)) • (A * A) := by calc - ((1 - u) • A) * ((1 - u) • A) = (1 - u) • (A * ((1 - u) • A)) := - Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A ((1 - u) • A) + ((1 - u) • A) * ((1 - u) • A) = (1 - u) • (A * ((1 - u) • A)) := by + exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A ((1 - u) • A) _ = (1 - u) • ((1 - u) • (A * A)) := by rw [Algebra.mul_smul_comm] _ = ((1 - u) * (1 - u)) • (A * A) := by @@ -1633,8 +1633,8 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : have hAB' : ((1 - u) • A) * (u • B) = ((1 - u) * u) • (A * B) := by calc - ((1 - u) • A) * (u • B) = (1 - u) • (A * (u • B)) := - Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A (u • B) + ((1 - u) • A) * (u • B) = (1 - u) • (A * (u • B)) := by + exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A (u • B) _ = (1 - u) • (u • (A * B)) := by rw [Algebra.mul_smul_comm] _ = ((1 - u) * u) • (A * B) := by @@ -1642,8 +1642,8 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : have hBA' : (u • B) * ((1 - u) • A) = (u * (1 - u)) • (B * A) := by calc - (u • B) * ((1 - u) • A) = u • (B * ((1 - u) • A)) := - Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B ((1 - u) • A) + (u • B) * ((1 - u) • A) = u • (B * ((1 - u) • A)) := by + exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B ((1 - u) • A) _ = u • ((1 - u) • (B * A)) := by simp [Algebra.mul_smul_comm] _ = (u * (1 - u)) • (B * A) := by @@ -1651,8 +1651,8 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : have hBB' : (u • B) * (u • B) = (u * u) • (B * B) := by calc - (u • B) * (u • B) = u • (B * (u • B)) := - Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B (u • B) + (u • B) * (u • B) = u • (B * (u • B)) := by + exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B (u • B) _ = u • (u • (B * B)) := by simp [Algebra.mul_smul_comm] _ = (u * u) • (B * B) := by diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean index ff6409706..fef28af12 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean @@ -220,12 +220,12 @@ theorem operatorConvex_continuousOn_spectrum_union {f : ℝ → ℝ} omit [Nontrivial ℋ] in theorem one_div_operatorAntitoneOn_Ioi : - OperatorAntitoneOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x : ℝ ↦ 1 / x) := - LownerHeinzCore.one_div_operatorAntitoneOn_Ioi (𝓐 := L ℋ) + OperatorAntitoneOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x : ℝ ↦ 1 / x) := by + exact (LownerHeinzCore.one_div_operatorAntitoneOn_Ioi (𝓐 := L ℋ)) theorem one_div_operatorConvexOn_Ioi : - OperatorConvexOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x : ℝ ↦ 1 / x) := - LownerHeinzCore.one_div_operatorConvexOn_Ioi (𝓐 := L ℋ) + OperatorConvexOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) (fun x : ℝ ↦ 1 / x) := by + exact (LownerHeinzCore.one_div_operatorConvexOn_Ioi (𝓐 := L ℋ)) omit [Nontrivial ℋ] in theorem one_div_add_t_operatorAntitoneOn_Ici : ∀ (t : ℝ), 0 < t → diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean index 8c598ee39..9fbfc2a0f 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/OperatorGeometricMean.lean @@ -31,9 +31,9 @@ private lemma rpow_continuousOn_Ici (p : ℝ) (hp : 0 ≤ p) : omit [Nontrivial ℋ] in private lemma operatorConcaveOn_Ioi_of_Ici {f : ℝ → ℝ} (h : OperatorConcaveOn (ℋ := ℋ) (Set.Ici (0 : ℝ)) f) : - OperatorConcaveOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) f := - fun _ _ _ hA hB ht0 ht1 hAs hBs => - h hA hB ht0 ht1 (Set.Subset.trans hAs Set.Ioi_subset_Ici_self) + OperatorConcaveOn (ℋ := ℋ) (Set.Ioi (0 : ℝ)) f := by + intro A B t hA hB ht0 ht1 hAs hBs + exact h hA hB ht0 ht1 (Set.Subset.trans hAs Set.Ioi_subset_Ici_self) (Set.Subset.trans hBs Set.Ioi_subset_Ici_self) omit [Nontrivial ℋ] in diff --git a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean index b26ef7faf..450aa8456 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean @@ -451,8 +451,8 @@ noncomputable def support : Submodule 𝕜 (EuclideanSpace 𝕜 n) := LinearMap.range A.lin.toLinearMap /-- The support of a Hermitian matrix is the sum of its nonzero eigenspaces. -/ -theorem support_eq_sup_eigenspace_nonzero : A.support = ⨆ μ ≠ 0, A.eigenspace μ := - A.lin.support_eq_sup_eigenspace_nonzero A.isSymmetric +theorem support_eq_sup_eigenspace_nonzero : A.support = ⨆ μ ≠ 0, A.eigenspace μ := by + exact A.lin.support_eq_sup_eigenspace_nonzero A.isSymmetric @[simp] theorem support_zero : (0 : HermitianMat n 𝕜).support = ⊥ := by simp [support] diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 8f70579d2..c3a67af64 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -33,8 +33,8 @@ variable (A : HermitianMat d 𝕜) (f : ℝ → ℝ) (g : ℝ → ℝ) (q r : /- Adding this to the `CStarAlgebra` aesop set allows `cfc_tac` to use it. -/ omit [Fintype d] [DecidableEq d] in @[aesop safe apply (rule_sets := [CStarAlgebra])] -theorem isSelfAdjoint : IsSelfAdjoint A.mat := - A.H +theorem isSelfAdjoint : IsSelfAdjoint A.mat := by + exact A.H /- Adding this to `fun_prop` allows `cfc_cont_tac` to use it. -/ @[fun_prop] @@ -43,8 +43,8 @@ theorem continuousOn_finite {α β : Type*} (f : α → β) (S : Set α) simpa [continuousOn_iff_continuous_restrict] using continuous_of_discreteTopology @[simp] -theorem conjTranspose_cfc : (cfc f A.mat).conjTranspose = cfc f A.mat := - cfc_predicate f A.mat +theorem conjTranspose_cfc : (cfc f A.mat).conjTranspose = cfc f A.mat := by + exact cfc_predicate f A.mat protected def cfc : HermitianMat d 𝕜 := ⟨cfc f A.mat, cfc_predicate _ _⟩ @@ -90,8 +90,8 @@ variable {A B : HermitianMat d 𝕜} @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.cfc_left (hAB : Commute A.mat B.mat) : - Commute (A.cfc f).mat B.mat := - hAB.cfc_real f + Commute (A.cfc f).mat B.mat := by + exact hAB.cfc_real f @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.cfc_right (hAB : Commute A.mat B.mat) : @@ -99,8 +99,8 @@ theorem _root_.Commute.cfc_right (hAB : Commute A.mat B.mat) : (hAB.symm.cfc_left f).symm theorem cfc_commute (f g : ℝ → ℝ) (hAB : Commute A.mat B.mat) : - Commute (A.cfc f).mat (B.cfc g).mat := - (hAB.cfc_right g).cfc_left f + Commute (A.cfc f).mat (B.cfc g).mat := by + exact (hAB.cfc_right g).cfc_left f @[aesop safe apply (rule_sets := [Commutes])] theorem cfc_self_commute (A : HermitianMat d 𝕜) (f g : ℝ → ℝ) : @@ -117,8 +117,8 @@ theorem cfc_reindex (e : d ≃ d₂) : (A.reindex e).cfc f = (A.cfc f).reindex e exact Matrix.cfc_reindex f e theorem spectrum_cfc_eq_image (A : HermitianMat d 𝕜) (f : ℝ → ℝ) : - spectrum ℝ (A.cfc f).mat = f '' (spectrum ℝ A.mat) := - cfc_map_spectrum f A.mat + spectrum ℝ (A.cfc f).mat = f '' (spectrum ℝ A.mat) := by + exact cfc_map_spectrum f A.mat set_option backward.isDefEq.respectTransparency false in /-- @@ -186,8 +186,8 @@ theorem mat_cfc_mul : (A.cfc (f * g)).mat = A.cfc f * A.cfc g := by simp only [mat_cfc] exact cfc_mul .. -theorem mat_cfc_mul_apply : (A.cfc (fun x ↦ f x * g x)).mat = A.cfc f * A.cfc g := - mat_cfc_mul .. +theorem mat_cfc_mul_apply : (A.cfc (fun x ↦ f x * g x)).mat = A.cfc f * A.cfc g := by + exact mat_cfc_mul .. nonrec theorem cfc_comp : A.cfc (g ∘ f) = (A.cfc f).cfc g := by ext1; exact cfc_comp .. @@ -383,10 +383,10 @@ theorem Matrix.PosDef.spectrum_subset_Ioi {d 𝕜 : Type*} [Fintype d] [Decidabl {A : Matrix d d 𝕜} (hA : A.PosDef) : spectrum ℝ A ⊆ Set.Ioi 0 := by intro x hx; -- Since $A$ is positive definite, all its eigenvalues are positive. - have h_eigenvalues_pos : ∀ i : d, 0 < hA.1.eigenvalues i := - hA.eigenvalues_pos - have h_spectrum_eq_range : spectrum ℝ A = Set.range (hA.1.eigenvalues) := - Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues hA.left + have h_eigenvalues_pos : ∀ i : d, 0 < hA.1.eigenvalues i := by + exact hA.eigenvalues_pos; + have h_spectrum_eq_range : spectrum ℝ A = Set.range (hA.1.eigenvalues) := by + exact Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues hA.left; aesop /-- @@ -455,8 +455,8 @@ lemma norm_cfc_sub_cfc_le_sqrt_card {A : HermitianMat d ℂ} {f g : ℝ → ℝ} · intro x hx apply le_csSup; · -- The supremum of a finite set of real numbers is finite. - have h_finite : Set.Finite (spectrum ℝ A.mat) := - Set.toFinite _ + have h_finite : Set.Finite (spectrum ℝ A.mat) := by + exact Set.toFinite _; obtain ⟨ M, hM ⟩ := h_finite.exists_finset_coe; refine' ⟨ ∑ x ∈ M, ‖f x - g x‖, Set.forall_mem_range.2 fun x => _ ⟩; rw [ ← hM ]; @@ -570,9 +570,9 @@ theorem continuous_cfc_joint_compact {X d : Type*} [TopologicalSpace X] [Fintype (hA₂ : ContinuousOn (fun x ↦ A x) S) : ContinuousOn (fun x ↦ (A x).cfc (f x)) S := by intro x x_in_S - have h_eps_delta : ContinuousWithinAt (fun y => (A y).cfc (f x)) S x := - ((continuousOn_cfc_of_compact hT (hf.uncurry_left x x_in_S)).comp hA₂ hA₁).continuousWithinAt - x_in_S + have h_eps_delta : ContinuousWithinAt (fun y => (A y).cfc (f x)) S x := by + refine ContinuousOn.continuousWithinAt ?_ x_in_S + exact (continuousOn_cfc_of_compact hT (hf.uncurry_left x x_in_S)).comp hA₂ hA₁ rw [ ContinuousWithinAt ] at *; rw [ Metric.tendsto_nhds ] at *; intro ε ε_pos @@ -737,11 +737,11 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} (hg : ContinuousOn g T) (hA₀ : spectrum ℝ A₀.mat ⊆ T) : ContinuousWithinAt (fun B ↦ B.cfc g) {B | spectrum ℝ B.mat ⊆ T} A₀ := by have h_ext : ∃ h : ℝ → ℝ, Continuous h ∧ ∀ x ∈ spectrum ℝ A₀.mat, h x = g x := by - have h_finite : Set.Finite (spectrum ℝ A₀.mat) := - Set.toFinite _ + have h_finite : Set.Finite (spectrum ℝ A₀.mat) := by + exact Set.toFinite _ generalize_proofs at *; ( - have h_cont : ContinuousOn g (spectrum ℝ A₀.val) := - hg.mono hA₀ + have h_cont : ContinuousOn g (spectrum ℝ A₀.val) := by + exact hg.mono hA₀ generalize_proofs at *; ( have := @ContinuousMap.exists_restrict_eq ℝ; specialize this ( show IsClosed ( spectrum ℝ A₀.val ) from h_finite.isClosed ) ( ContinuousMap.mk ( fun x => g x ) <| by exact continuousOn_iff_continuous_restrict.mp h_cont ) ; rcases this with ⟨ h, hh ⟩ ; exact ⟨ h, h.continuous, fun x hx => by simpa using congr_arg ( fun f => f ⟨ x, hx ⟩ ) hh ⟩ ;)); @@ -759,8 +759,8 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} simpa [ hh_eq y hy ] using h_diff_small.abs; have := Metric.tendsto_nhdsWithin_nhds.mp h_diff_small ( ε / ( Real.sqrt ( Fintype.card d ) + 1 ) ) ( div_pos ε_pos ( add_pos_of_nonneg_of_pos ( Real.sqrt_nonneg _ ) zero_lt_one ) ) ; aesop; choose! δ hδ_pos hδ using h_diff_small; - have h_finite : Set.Finite (spectrum ℝ A₀.mat) := - Set.toFinite _ + have h_finite : Set.Finite (spectrum ℝ A₀.mat) := by + exact Set.toFinite _; obtain ⟨δ_min, hδ_min_pos, hδ_min⟩ : ∃ δ_min > 0, ∀ y ∈ spectrum ℝ A₀.mat, δ_min ≤ δ y := by by_cases h_empty : spectrum ℝ A₀.mat = ∅; · exact ⟨ 1, zero_lt_one, by simp [ h_empty ] ⟩; @@ -770,15 +770,15 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} -- By the spectrum_subset_of_isOpen lemma, there exists a neighborhood U of A₀ such that the spectrum of B is within δ of the spectrum of A₀ for all B in U. obtain ⟨U, hU⟩ : ∃ U ∈ nhds A₀, ∀ B ∈ U, spectrum ℝ B.mat ⊆ {x | ∃ y ∈ spectrum ℝ A₀.mat, |x - y| < δ} := by have h_spectrum_subset : ∀ᶠ B in nhds A₀, spectrum ℝ B.mat ⊆ Metric.thickening δ (spectrum ℝ A₀.mat) := by - have h_open : IsOpen (Metric.thickening δ (spectrum ℝ A₀.mat)) := - Metric.isOpen_thickening + have h_open : IsOpen (Metric.thickening δ (spectrum ℝ A₀.mat)) := by + exact Metric.isOpen_thickening have := spectrum_subset_of_isOpen A₀ ( Metric.thickening δ ( spectrum ℝ A₀.mat ) ) h_open ( Metric.self_subset_thickening δ_pos _ ) ; aesop; generalize_proofs at *; ( exact ⟨ _, h_spectrum_subset, fun B hB => fun x hx => by simpa [ dist_eq_norm ] using Metric.mem_thickening_iff.mp ( hB hx ) ⟩) generalize_proofs at *; ( refine' ⟨ U, hU.1, fun B hB => _ ⟩ - have h_diff_small : ∀ x ∈ spectrum ℝ B.mat, |g x - h x| ≤ ε / (Real.sqrt (Fintype.card d) + 1) := - fun x hx => le_of_lt ( hδ x ( hB.2 hx ) _ ( hU.2 B hB.1 hx |> Classical.choose_spec |> And.left ) ( hU.2 B hB.1 hx |> Classical.choose_spec |> And.right ) ) |> le_trans <| by norm_num; + have h_diff_small : ∀ x ∈ spectrum ℝ B.mat, |g x - h x| ≤ ε / (Real.sqrt (Fintype.card d) + 1) := by + exact fun x hx => le_of_lt ( hδ x ( hB.2 hx ) _ ( hU.2 B hB.1 hx |> Classical.choose_spec |> And.left ) ( hU.2 B hB.1 hx |> Classical.choose_spec |> And.right ) ) |> le_trans <| by norm_num; generalize_proofs at *; ( have h_diff_small : ‖B.cfc g - B.cfc h‖ ≤ Real.sqrt (Fintype.card d) * (ε / (Real.sqrt (Fintype.card d) + 1)) := by apply_rules [ norm_cfc_sub_le_of_sup_le ]; @@ -798,8 +798,8 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} · intro x hx hx' hx'' have hd1 := hδ hx hx' have hd2 := hU x ⟨(Metric.mem_nhds_iff.mp hU_nhds).choose_spec.2 hx'', hx⟩ - have h_eq : A₀.cfc g = A₀.cfc h := - cfc_congr (show Set.EqOn g h (spectrum ℝ A₀.mat) from fun x hx => hh_eq x hx ▸ rfl) ▸ rfl + have h_eq : A₀.cfc g = A₀.cfc h := by + exact cfc_congr (show Set.EqOn g h (spectrum ℝ A₀.mat) from fun x hx => hh_eq x hx ▸ rfl) ▸ rfl rw [dist_eq_norm, h_eq] calc ‖x.cfc g - A₀.cfc h‖ = ‖(x.cfc g - x.cfc h) + (x.cfc h - A₀.cfc h)‖ := by congr 1; abel @@ -873,8 +873,8 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] choose U_i V_i hU_i hV_i hx₀_i hV_i_i h_cont_i using h_cont; exact ⟨ U_i, V_i, hU_i, hV_i, hx₀_i, hV_i_i, h_cont_i ⟩ ;); -- The open set W := ⋃ᵢ V_i contains spectrum(A x₀) (since each λᵢ ∈ V_i and spectrum = range of eigenvalues). W is open as a union of open sets. set W := ⋃ i, V_i i with hW_def - have hW_open : IsOpen W := - isOpen_iUnion hV_i + have hW_open : IsOpen W := by + exact isOpen_iUnion hV_i have hW_spectrum : spectrum ℝ (A x₀).mat ⊆ W := by intro t ht obtain ⟨i, hi⟩ : ∃ i, t = (A x₀).H.eigenvalues i := by @@ -891,10 +891,10 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] obtain ⟨U'', hU''⟩ : ∃ U'' ∈ nhds x₀, ∀ i, U'' ⊆ U_i i := by exact ⟨ ⋂ i, U_i i, Filter.mem_of_superset ( Filter.iInter_mem.mpr fun i => IsOpen.mem_nhds ( hU_i i ) ( h_cont.1 i ) ) fun x hx => by aesop, fun i => Set.iInter_subset _ i ⟩ set U := U' ∩ U'' with hU_def - have hU_mem : U ∈ nhds x₀ := - Filter.inter_mem hU'.1 hU''.1 - have hU_subset : ∀ y ∈ U ∩ S, spectrum ℝ (A y).mat ⊆ W := - fun y hy => hU'.2 y ⟨hy.1.1, hy.2⟩ |> Set.Subset.trans <| by simp [hW_def] + have hU_mem : U ∈ nhds x₀ := by + exact Filter.inter_mem hU'.1 hU''.1 + have hU_subset : ∀ y ∈ U ∩ S, spectrum ℝ (A y).mat ⊆ W := by + exact fun y hy => hU'.2 y ⟨ hy.1.1, hy.2 ⟩ |> Set.Subset.trans <| by simp [ hW_def ] ; have hU_cont : ∀ y ∈ U ∩ S, ∀ t ∈ spectrum ℝ (A y).mat, ‖f y t - f x₀ t‖ < ε := by intro y hy t ht obtain ⟨i, hi⟩ : ∃ i, t ∈ V_i i := by @@ -1058,8 +1058,8 @@ The integral of a Hermitian matrix function commutes with `toMat`. -/ lemma integral_toMat (A : ℝ → HermitianMat d 𝕜) (T₁ T₂ : ℝ) {μ : Measure ℝ} (hA : IntervalIntegrable A μ T₁ T₂) : - (∫ t in T₁..T₂, A t ∂μ).mat = ∫ t in T₁..T₂, (A t).mat ∂μ := - ((matₗ (R := ℝ)).intervalIntegral_comp_comm hA).symm + (∫ t in T₁..T₂, A t ∂μ).mat = ∫ t in T₁..T₂, (A t).mat ∂μ := by + exact ((matₗ (R := ℝ)).intervalIntegral_comp_comm hA).symm set_option backward.isDefEq.respectTransparency false in /-- @@ -1098,8 +1098,8 @@ lemma intervalIntegrable_toMat_iff (A : ℝ → HermitianMat d 𝕜) (T₁ T₂ exact IsSemisimpleModule.extension_property L h_toMat_linear LinearMap.id; exact ⟨ h_toMat_linear.choose, fun x ↦ by simpa using LinearMap.congr_fun h_toMat_linear.choose_spec x ⟩; obtain ⟨ L_inv, hL_inv ⟩ := h_toMat_linear; - have h_toMat_linear : IntegrableOn (fun t ↦ L_inv (L (A t))) (Set.uIoc T₁ T₂) μ := - ContinuousLinearMap.integrable_comp L_inv.toContinuousLinearMap h_toMat_integrable + have h_toMat_linear : IntegrableOn (fun t ↦ L_inv (L (A t))) (Set.uIoc T₁ T₂) μ := by + exact ContinuousLinearMap.integrable_comp ( L_inv.toContinuousLinearMap ) h_toMat_integrable; aesop; aesop; exact h_toMat_integrable h; @@ -1224,8 +1224,8 @@ theorem cfc_le_cfc_of_commute (hf : Monotone f) (hAB₁ : Commute A.mat B.mat) ( open ComplexOrder in theorem cfc_monoOn_pos_of_monoOn_posDef {d : Type*} [Fintype d] [DecidableEq d] {f : ℝ → ℝ} (hf_is_operator_convex : False) : - MonotoneOn (HermitianMat.cfc · f) { A : HermitianMat d ℂ | A.mat.PosDef } := - False.elim hf_is_operator_convex + MonotoneOn (HermitianMat.cfc · f) { A : HermitianMat d ℂ | A.mat.PosDef } := by + exact False.elim hf_is_operator_convex section uncategorized_cleanup @@ -1236,18 +1236,18 @@ theorem inv_ge_one_of_le_one (hA : A.mat.PosDef) (h : A ≤ 1) : 1 ≤ A⁻¹ := have h_cfc_nonneg : ∀ i, 0 ≤ (A.H.eigenvalues i)⁻¹ - 1 := by have h_pos : ∀ i, 0 < A.H.eigenvalues i ∧ A.H.eigenvalues i ≤ 1 := by -- Since $A$ is positive definite, all its eigenvalues are positive. - have h_pos : ∀ i, 0 < A.H.eigenvalues i := - fun i => Matrix.PosDef.eigenvalues_pos hA i + have h_pos : ∀ i, 0 < A.H.eigenvalues i := by + exact fun i => Matrix.PosDef.eigenvalues_pos hA i; -- Since $A \leq 1$, for any eigenvalue $\lambda_i$ of $A$, we have $\lambda_i \leq 1$. have h_le_one : ∀ i, A.H.eigenvalues i ≤ 1 := by have h_le_one : ∀ i, A.H.eigenvalues i ≤ 1 := by intro i - have h_eigenvalue : A.mat.PosSemidef := - hA.posSemidef + have h_eigenvalue : A.mat.PosSemidef := by + exact hA.posSemidef have h_eigenvalue_le_one : ∀ x : d → 𝕜, x ≠ 0 → (star x ⬝ᵥ A.mat.mulVec x) / (star x ⬝ᵥ x) ≤ 1 := by intro x hx_ne_zero - have h_eigenvalue_le_one : (star x ⬝ᵥ (1 - A.mat).mulVec x) ≥ 0 := - Matrix.PosSemidef.dotProduct_mulVec_nonneg h x + have h_eigenvalue_le_one : (star x ⬝ᵥ (1 - A.mat).mulVec x) ≥ 0 := by + exact Matrix.PosSemidef.dotProduct_mulVec_nonneg h x generalize_proofs at *; ( rw [ div_le_iff₀ ] <;> simp_all [ Matrix.sub_mulVec, dotProduct_sub ]) generalize_proofs at *; ( @@ -1361,8 +1361,8 @@ lemma ker_cfc_le_ker_on_set (A.cfc f).ker ≤ A.ker := by intro x hx have h_inner : ∀ i, A.H.eigenvalues i ≠ 0 → inner ℂ (A.H.eigenvectorBasis i) x = 0 := by - have h_inner_zero : (A.cfc f).mat.mulVec x = 0 := - (mem_ker_iff_mulVec_zero (A.cfc f) x).mp hx + have h_inner_zero : (A.cfc f).mat.mulVec x = 0 := by + exact (mem_ker_iff_mulVec_zero (A.cfc f) x).mp hx have h_inner_zero_expansion : ∑ i, (f (A.H.eigenvalues i) : ℂ) • inner ℂ (A.H.eigenvectorBasis i) x • A.H.eigenvectorBasis i = 0 := by convert h_inner_zero using 1; rw [ cfc_mulVec_expansion ]; @@ -1397,8 +1397,8 @@ lemma ker_le_ker_cfc_on_set (hs : spectrum ℝ A.mat ⊆ s) (h : ∀ i ∈ s, i intro x hx have h_inner_zero : ∀ i, A.H.eigenvalues i ≠ 0 → inner ℂ (A.H.eigenvectorBasis i) x = 0 := by intro i hi - have h_inner_zero : A.mat.mulVec x = 0 := - (mem_ker_iff_mulVec_zero A x).mp hx + have h_inner_zero : A.mat.mulVec x = 0 := by + exact (mem_ker_iff_mulVec_zero A x).mp hx; have := mulVec_eq_zero_iff_inner_eigenvector_zero A x; aesop; have h_mulVec_zero : (A.cfc f).mat.mulVec x = ∑ i, (f (A.H.eigenvalues i) : ℂ) • inner ℂ (A.H.eigenvectorBasis i) x • A.H.eigenvectorBasis i := by convert cfc_mulVec_expansion A f x using 1; diff --git a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean index 3979ceac8..12bf21d28 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean @@ -98,8 +98,8 @@ lemma Φ_mem_pdSet [Nonempty d] (A : HermitianMat d ℂ) (hA : A.mat.PosDef) : set_option synthInstance.maxHeartbeats 80000 in /-- `Φ` commutes with CFC for Hermitian matrices. -/ lemma Φ_cfc (A : HermitianMat d ℂ) (f : ℝ → ℝ) : - Φ (cfc f A.mat) = cfc f (Φ A.mat) := - StarAlgHomClass.map_cfc Φ f A.mat (hφ := Φ_continuous) + Φ (cfc f A.mat) = cfc f (Φ A.mat) := by + exact StarAlgHomClass.map_cfc Φ f A.mat (hφ := Φ_continuous) (ha := A.H.isSelfAdjoint) set_option synthInstance.maxHeartbeats 80000 in @@ -183,8 +183,8 @@ omit [Fintype d] in /-- σ + εI → σ as ε → 0+. -/ private lemma tendsto_add_eps (σ : HermitianMat d ℂ) : Filter.Tendsto (fun ε : ℝ ↦ σ + ε • (1 : HermitianMat d ℂ)) - (nhdsWithin 0 (Set.Ioi 0)) (nhds σ) := - tendsto_nhdsWithin_of_tendsto_nhds + (nhdsWithin 0 (Set.Ioi 0)) (nhds σ) := by + exact tendsto_nhdsWithin_of_tendsto_nhds (Continuous.tendsto' (by continuity) _ _ (by simp)) /-! ### Helper lemmas for the core concavity proof -/ @@ -255,8 +255,8 @@ private lemma variational_eq_optimizer have h_exp : (X ^ p) ^ ((p - 1) / p) = X ^ (p - 1) := by rw [← rpow_mul hX, mul_div_cancel₀ _ (by positivity)] have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X ^ p).trace := by - have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X * (X ^ (p - 1)).mat).trace.re := - Real.ext_cauchy rfl + have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X * (X ^ (p - 1)).mat).trace.re := by + exact Real.ext_cauchy rfl convert h_inner using 1 have h_exp : (X ^ p).mat = X.mat * (X ^ (p - 1)).mat := by convert mat_rpow_add hX _ @@ -294,8 +294,8 @@ private lemma liebExtension_bridge [Nonempty d] rw [← traceRe_Φ_general] simp [liebExtensionTraceMap, Φ_rpow, hσ, hZ] rw [show star (Φ K.mat) = Φ K.mat from ?_] - have h_rewrite : IsSelfAdjoint (Φ K.mat) := - Φ_isSelfAdjoint K + have h_rewrite : IsSelfAdjoint (Φ K.mat) := by + exact Φ_isSelfAdjoint K exact h_rewrite convert! h_joint_concave (Φ_mem_pdSet σ₁ hσ₁) (Φ_mem_pdSet σ₂ hσ₂) (Φ_mem_pdSet Z₁ hZ₁) (Φ_mem_pdSet Z₂ hZ₂) hθ₀ hθ₁ using 1 diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 9ca4a97a6..7dfea8744 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -27,8 +27,8 @@ noncomputable section theorem Matrix.IsHermitian.log_smul_of_ne_zero {A : Matrix d d 𝕜} (hA : A.IsHermitian) (hx : x ≠ 0) : cfc Real.log (x • A) = (Real.log x) • cfc (if · = 0 then (0 : ℝ) else 1) A + cfc Real.log A := by - have hCFC : cfc (Real.log ∘ (x * ·)) A = cfc Real.log (x • A) := - cfc_comp_smul x Real.log _ (by fun_prop) hA + have hCFC : cfc (Real.log ∘ (x * ·)) A = cfc Real.log (x • A) := by + exact cfc_comp_smul x Real.log _ (by fun_prop) hA rw [← hCFC, ← cfc_smul, ← cfc_add] apply cfc_congr intro t ht @@ -62,8 +62,8 @@ theorem reindex_exp (e : d ≃ d₂) : (A.reindex e).exp = A.exp.reindex e := cfc_reindex A Real.exp e variable (A) in -instance nonSingular_exp : NonSingular A.exp := - cfc_nonSingular A Real.exp (fun _ => Real.exp_ne_zero _) +instance nonSingular_exp : NonSingular A.exp := by + exact cfc_nonSingular A Real.exp (fun i ↦ by positivity) /-- The matrix exponential of a Hermitian matrix is nonnegative. -/ theorem exp_nonneg (A : HermitianMat d 𝕜) : 0 ≤ A.exp := by @@ -145,8 +145,8 @@ theorem inv_antitone (hA : A.mat.PosDef) (h : A ≤ B) : B⁻¹ ≤ A⁻¹ := by simp_all only [sub_nonneg] exact h -- Using the fact that $B = A + C^*C$, we can write $B^{-1}$ as $(A + C^*C)^{-1}$. - have h_inv_posDef : (1 + C * A.mat⁻¹ * C.conjTranspose).PosDef := - Matrix.PosDef.one.add_posSemidef (hA.inv.posSemidef.mul_mul_conjTranspose_same C) + have h_inv_posDef : (1 + C * A.mat⁻¹ * C.conjTranspose).PosDef := by + exact Matrix.PosDef.one.add_posSemidef (hA.inv.posSemidef.mul_mul_conjTranspose_same C) have hB_inv : B.mat⁻¹ = A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹ := by have hB_inv : (A.mat + C.conjTranspose * C)⁻¹ = A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹ := by have hB_inv : (A.mat + C.conjTranspose * C) * (A.mat⁻¹ - A.mat⁻¹ * C.conjTranspose * (1 + C * A.mat⁻¹ * C.conjTranspose)⁻¹ * C * A.mat⁻¹) = 1 := by @@ -220,10 +220,10 @@ theorem logApprox_mono {x y : HermitianMat d 𝕜} (hx : x.mat.PosDef) (hy : y.m refine' ContinuousAt.continuousWithinAt _; have h_inv_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m⁻¹) m.mat := by have h_inv_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m⁻¹) m.mat := by - have h_det_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m.det) m.mat := - Continuous.continuousAt continuous_id.matrix_det - have h_adj_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m.adjugate) m.mat := - Continuous.continuousAt continuous_id.matrix_adjugate + have h_det_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m.det) m.mat := by + exact Continuous.continuousAt ( continuous_id.matrix_det ) + have h_adj_cont : ContinuousAt (fun m : Matrix d d 𝕜 => m.adjugate) m.mat := by + exact Continuous.continuousAt ( continuous_id.matrix_adjugate ) simp_all [ Matrix.inv_def ]; exact ContinuousAt.smul ( h_det_cont.inv₀ ( by simpa using hm.det_pos.ne' ) ) h_adj_cont; exact h_inv_cont; @@ -446,8 +446,8 @@ lemma inv_convex {x y : HermitianMat d 𝕜} (hx : x.mat.PosDef) (hy : y.mat.Pos have h_block_pos : ∀ A : Matrix d d 𝕜, A.PosDef → (Matrix.fromBlocks A 1 1 A⁻¹).PosSemidef := by intro A hA have h_block_pos : (Matrix.fromBlocks A (1 : Matrix d d 𝕜) (1 : Matrix d d 𝕜) (A⁻¹)).PosSemidef := by - have h_inv_pos : A⁻¹.PosSemidef := - hA.inv.posSemidef + have h_inv_pos : A⁻¹.PosSemidef := by + exact hA.inv.posSemidef have h_block_pos : (Matrix.fromBlocks A (1 : Matrix d d 𝕜) (1 : Matrix d d 𝕜) (A⁻¹)) = (Matrix.fromBlocks 1 0 A⁻¹ 1) * (Matrix.fromBlocks A 0 0 (A⁻¹ - A⁻¹ * A * A⁻¹)) * (Matrix.fromBlocks 1 A⁻¹ 0 1) := by simp [ Matrix.fromBlocks_multiply ]; have := hA.det_pos; @@ -563,13 +563,13 @@ lemma integrable_inv_shift {A : HermitianMat d 𝕜} (hA : A.mat.PosDef) (b : have h_inv_cont : ContinuousAt (fun t : ℝ => (A + t • 1).mat⁻¹) t := by have h_det_cont : ContinuousAt (fun t : ℝ => (A + t • 1).mat.det) t := by fun_prop (disch := solve_by_elim) - have h_adj_cont : ContinuousAt (fun t : ℝ => (A + t • 1).mat.adjugate) t := - Continuous.continuousAt (Continuous.matrix_adjugate <| by continuity) + have h_adj_cont : ContinuousAt (fun t : ℝ => (A + t • 1).mat.adjugate) t := by + exact Continuous.continuousAt ( by exact Continuous.matrix_adjugate <| by continuity ) simp_all [ Matrix.inv_def ]; exact ContinuousAt.smul ( h_det_cont.inv₀ <| by simpa [ Matrix.isUnit_iff_isUnit_det ] using h_inv t ht.1 ) h_adj_cont exact h_inv_cont.continuousWithinAt - have h_inv_cont : ContinuousOn (fun t : ℝ => (A + t • 1)⁻¹) (Set.Icc 0 b) := - (continuousOn_iff_coe fun t => (A + t • 1)⁻¹).mpr h_inv_cont + have h_inv_cont : ContinuousOn (fun t : ℝ => (A + t • 1)⁻¹) (Set.Icc 0 b) := by + exact (continuousOn_iff_coe fun t => (A + t • 1)⁻¹).mpr h_inv_cont exact h_inv_cont.intervalIntegrable_of_Icc hb open ComplexOrder in diff --git a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean index 840e36aff..92e135a22 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean @@ -24,15 +24,15 @@ theorem isUnit_smul {c : R} (hA : IsUnit c) {M : Matrix d d S} (hM : IsUnit M) : use d • M' rfl -theorem isUnit_natCast {n : ℕ} (hn : n ≠ 0) [CharZero F] : IsUnit (n : Matrix d d F) := - (IsUnit.mk0 (n : F) (mod_cast hn)).map (algebraMap F _) +theorem isUnit_natCast {n : ℕ} (hn : n ≠ 0) [CharZero F] : IsUnit (n : Matrix d d F) := by + exact (IsUnit.mk0 (n : F) (mod_cast hn)).map (algebraMap F _) theorem isUnit_real_smul {r : ℝ} (hr : r ≠ 0) {M : Matrix d d 𝕜} (hM : IsUnit M) : IsUnit (r • M : Matrix d d 𝕜) := isUnit_smul hr.isUnit hM -theorem isUnit_real_cast {r : ℝ} (hr : r ≠ 0) : IsUnit (r • 1 : Matrix d d 𝕜) := - isUnit_real_smul hr isUnit_one +theorem isUnit_real_cast {r : ℝ} (hr : r ≠ 0) : IsUnit (r • 1 : Matrix d d 𝕜) := by + exact isUnit_real_smul hr isUnit_one end Matrix @@ -49,8 +49,8 @@ class NonSingular (A : HermitianMat n R) : Prop where theorem isUnit_mat_of_nonSingular [NonSingular A] : IsUnit A.mat := NonSingular.isUnit -theorem nonsingular_iff_isUnit : NonSingular A ↔ IsUnit A.mat := - Iff.intro (fun h ↦ h.isUnit) NonSingular.mk +theorem nonsingular_iff_isUnit : NonSingular A ↔ IsUnit A.mat := by + exact Iff.intro (fun h ↦ h.isUnit) NonSingular.mk instance instHasInv_of_invertible [i : Invertible A.mat] : NonSingular A := ⟨isUnit_of_invertible _⟩ diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 52cba3901..749d84b9c 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -72,11 +72,11 @@ theorem posSemidef_iff_spectrum_Ici [DecidableEq n] (A : HermitianMat n 𝕜) : simp [A.H, Set.Ici.eq_1] theorem posSemidef_iff_spectrum_nonneg [DecidableEq n] (A : HermitianMat n 𝕜) : - 0 ≤ A ↔ ∀ x ∈ spectrum ℝ A.mat, 0 ≤ x := - A.posSemidef_iff_spectrum_Ici + 0 ≤ A ↔ ∀ x ∈ spectrum ℝ A.mat, 0 ≤ x := by + exact A.posSemidef_iff_spectrum_Ici -theorem trace_nonneg (hA : 0 ≤ A) : 0 ≤ A.trace := - (RCLike.nonneg_iff.mp (zero_le_iff.mp hA).trace_nonneg).1 +theorem trace_nonneg (hA : 0 ≤ A) : 0 ≤ A.trace := by + exact (RCLike.nonneg_iff.mp (zero_le_iff.mp hA).trace_nonneg).1 theorem trace_pos (hA : 0 < A) : 0 < A.trace := by open ComplexOrder in @@ -154,8 +154,8 @@ theorem kronecker_pos {A : HermitianMat m 𝕜} (hA : 0 < A) (hB : 0 < B) : 0 < omit [Fintype n] in open MatrixOrder in -theorem posSemidef_to_nonneg {A : Matrix n n 𝕜} (hA : A.PosSemidef) : 0 ≤ A := - hA.nonneg +theorem posSemidef_to_nonneg {A : Matrix n n 𝕜} (hA : A.PosSemidef) : 0 ≤ A := by + exact hA.nonneg open MatrixOrder in theorem posDef_to_pos {A : Matrix n n 𝕜} (hA : A.PosDef) [Nonempty n] : 0 < A := by @@ -234,8 +234,8 @@ omit [Fintype n] in theorem mat_posSemidef_to_nonneg (hA : A.mat.PosSemidef) : 0 ≤ A := zero_le_iff.mpr hA -theorem mat_posDef_to_pos [Nonempty n] (hA : A.mat.PosDef) : 0 < A := - posDef_to_pos hA +theorem mat_posDef_to_pos [Nonempty n] (hA : A.mat.PosDef) : 0 < A := by + exact posDef_to_pos hA open Lean Meta in /-- Given an expression `e` (a `HermitianMat`) and a proof expression `p` whose type may be diff --git a/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean b/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean index fe25d8a3e..5db4fab2e 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean @@ -62,8 +62,8 @@ theorem peierls_inequality (A : HermitianMat d ℂ) (g : ℝ → ℝ) (hg : Conv convert! hg.map_sum_le _ _ _ <;> simp_all [mul_comm] convert! Finset.sum_le_sum fun i _ => h_jensen i using 1 rw [Finset.sum_comm, Finset.sum_congr rfl]; intros; rw [Finset.mul_sum]; ac_rfl - have h_unitary : ∀ (j : d), ∑ i, ‖(A.H.eigenvectorUnitary.val i j)‖^2 = 1 := - fun j => Matrix.unitaryGroup_row_norm (H A).eigenvectorUnitary j + have h_unitary : ∀ (j : d), ∑ i, ‖(A.H.eigenvectorUnitary.val i j)‖^2 = 1 := by + exact fun j => Matrix.unitaryGroup_row_norm (H A).eigenvectorUnitary j simp_all [trace_cfc_eq] theorem peierls_inequality_ici (A : HermitianMat d ℂ) (g : ℝ → ℝ) (hg : ConvexOn ℝ (Set.Ici 0) g) @@ -101,8 +101,8 @@ theorem peierls_inequality_ici (A : HermitianMat d ℂ) (g : ℝ → ℝ) (hg : exact A.eigenvalues_nonneg hA i convert! Finset.sum_le_sum fun i _ => h_jensen i using 1 rw [Finset.sum_comm, Finset.sum_congr rfl]; intros; rw [Finset.mul_sum]; ac_rfl - have h_unitary : ∀ (j : d), ∑ i, ‖(A.H.eigenvectorUnitary.val i j)‖^2 = 1 := - fun j => Matrix.unitaryGroup_row_norm (H A).eigenvectorUnitary j + have h_unitary : ∀ (j : d), ∑ i, ‖(A.H.eigenvectorUnitary.val i j)‖^2 = 1 := by + exact fun j => Matrix.unitaryGroup_row_norm (H A).eigenvectorUnitary j simp_all [trace_cfc_eq] /-- @@ -116,8 +116,8 @@ theorem trace_function_convex_univ (g : ℝ → ℝ) (hg : ConvexOn ℝ Set.univ -- Let $C = aA + bB$. set C : HermitianMat d ℂ := a • A + b • B -- By the properties of the trace and the convexity of $g$, we have: - have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := - trace_cfc_eq C g + have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := by + exact trace_cfc_eq C g have h_sum : ∑ i, g (C.H.eigenvalues i) ≤ a * ∑ i, g ((A.conj (star C.H.eigenvectorUnitary.val)).mat i i).re + b * ∑ i, g ((B.conj (star C.H.eigenvectorUnitary.val)).mat i i |> Complex.re) := by @@ -174,8 +174,8 @@ theorem trace_function_convex_ici {g : ℝ → ℝ} (hg : ConvexOn ℝ (Set.Ici -- Let $C = aA + bB$. set C : HermitianMat d ℂ := a • A + b • B -- By the properties of the trace and the convexity of $g$, we have: - have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := - trace_cfc_eq C g + have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := by + exact trace_cfc_eq C g have h_sum : ∑ i, g (C.H.eigenvalues i) ≤ a * ∑ i, g ((A.conj (star C.H.eigenvectorUnitary.val)).mat i i).re + b * ∑ i, g ((B.conj (star C.H.eigenvectorUnitary.val)).mat i i).re := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean index 5cc340ff5..03a3d2388 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean @@ -162,8 +162,8 @@ lemma projector_support_eq_sum : A.supportProj.mat = convert h_orthogonal_complement ( A.H.eigenvectorBasis i ) _ using 1; exact (mem_ker_iff_mulVec_zero A ((H A).eigenvectorBasis i)).mpr h_eigenvector_zero; -- By definition of $A.ker$, we know that $x$ can be written as a linear combination of eigenvectors with non-zero eigenvalues. - have h_decomp : x = ∑ i, (inner (𝕜) (A.H.eigenvectorBasis i) x) • A.H.eigenvectorBasis i := - Eq.symm (OrthonormalBasis.sum_repr' (H A).eigenvectorBasis x) + have h_decomp : x = ∑ i, (inner (𝕜) (A.H.eigenvectorBasis i) x) • A.H.eigenvectorBasis i := by + exact Eq.symm (OrthonormalBasis.sum_repr' (H A).eigenvectorBasis x); rw [ h_decomp ]; exact Submodule.sum_mem _ fun i _ => if hi : A.H.eigenvalues i = 0 then by simp [h_orthogonal_zero_eigenvalues i hi ] else Submodule.smul_mem _ _ ( Submodule.subset_span ⟨ i, hi, rfl ⟩ ); · rw [ Submodule.span_le, Set.image_subset_iff ]; diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 3f77ab651..be5017991 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -49,8 +49,8 @@ instance instRPow : Pow (HermitianMat d 𝕜) ℝ := ⟨rpow⟩ theorem rpow_conj_unitary (A : HermitianMat d 𝕜) (U : Matrix.unitaryGroup d 𝕜) (r : ℝ) : - (HermitianMat.conj U.val A) ^ r = HermitianMat.conj U.val (A ^ r) := - A.cfc_conj_unitary (· ^ r) U + (HermitianMat.conj U.val A) ^ r = HermitianMat.conj U.val (A ^ r) := by + exact A.cfc_conj_unitary (· ^ r) U theorem pow_eq_rpow : A ^ r = A.rpow r := rfl @@ -64,8 +64,8 @@ theorem diagonal_pow (f : d → ℝ) : rfl @[fun_prop] -theorem rpow_const_continuous {r : ℝ} (hr : 0 ≤ r) : Continuous (fun A : HermitianMat d ℂ ↦ A ^ r) := - HermitianMat.cfc_continuous (Real.continuous_rpow_const hr) +theorem rpow_const_continuous {r : ℝ} (hr : 0 ≤ r) : Continuous (fun A : HermitianMat d ℂ ↦ A ^ r) := by + exact HermitianMat.cfc_continuous (Real.continuous_rpow_const hr) @[fun_prop] theorem const_rpow_continuous [NonSingular A] : Continuous (fun r : ℝ ↦ A ^ r) := by @@ -184,10 +184,10 @@ lemma rpow_inv_eq_neg_rpow (hA : A.mat.PosDef) (p : ℝ) : (A ^ p)⁻¹ = A ^ (- ext i j; have h_inv : (A ^ p).mat * (A ^ (-p)).mat = 1 := by have h_inv : (A ^ p).mat * (A ^ (-p)).mat = 1 := by - have h_pow : (A ^ p).mat = A.cfc (fun x => x ^ p) := - rfl - have h_pow_neg : (A ^ (-p)).mat = A.cfc (fun x => x ^ (-p)) := - rfl + have h_pow : (A ^ p).mat = A.cfc (fun x => x ^ p) := by + exact rfl + have h_pow_neg : (A ^ (-p)).mat = A.cfc (fun x => x ^ (-p)) := by + exact rfl have h_inv : (A ^ p).mat * (A ^ (-p)).mat = A.cfc (fun x => x ^ p * x ^ (-p)) := by rw [ h_pow, h_pow_neg, ← mat_cfc_mul ]; rfl; @@ -198,8 +198,8 @@ lemma rpow_inv_eq_neg_rpow (hA : A.mat.PosDef) (p : ℝ) : (A ^ p)⁻¹ = A ^ (- rw [ h_inv, cfc_const ] ; norm_num; exact h_inv; -- By definition of matrix inverse, if $(A^p) * (A^{-p}) = 1$, then $(A^{-p})$ is the inverse of $(A^p)$. - have h_inv_def : (A ^ p).mat⁻¹ = (A ^ (-p)).mat := - Matrix.inv_eq_right_inv h_inv + have h_inv_def : (A ^ p).mat⁻¹ = (A ^ (-p)).mat := by + exact Matrix.inv_eq_right_inv h_inv; convert! congr_fun ( congr_fun h_inv_def i ) j using 1 open ComplexOrder in @@ -229,13 +229,13 @@ lemma rpow_neg_mul_rpow_self (hA : A.mat.PosDef) (p : ℝ) : open ComplexOrder in lemma isUnit_rpow_toMat (hA : A.mat.PosDef) (p : ℝ) : IsUnit (A ^ p).mat := by have hA_inv : IsUnit (A ^ (-p)).mat := by - have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := - rpow_neg_mul_rpow_self hA p + have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := by + exact rpow_neg_mul_rpow_self hA p exact IsUnit.of_mul_eq_one _ hA_inv -- Since $(A^{-p}) (A^p) = 1$, we have that $(A^p)$ is the inverse of $(A^{-p})$. have hA_inv : (A ^ p).mat = (A ^ (-p)).mat⁻¹ := by - have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := - rpow_neg_mul_rpow_self hA p + have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := by + exact rpow_neg_mul_rpow_self hA p; exact Eq.symm (Matrix.inv_eq_right_inv hA_inv); aesop @@ -287,8 +287,8 @@ lemma rpow_kron rw [← rpow_conj_unitary, Matrix.unitary_kron, conj_kron] rw [h_kron_r_pow] subst A B - have h_kron_r_pow_diag : (diagonal ℂ a ⊗ₖ diagonal ℂ b) ^ r = ((diagonal ℂ a) ^ r) ⊗ₖ ((diagonal ℂ b) ^ r) := - rpow_kron_diagonal a b r ha hb + have h_kron_r_pow_diag : (diagonal ℂ a ⊗ₖ diagonal ℂ b) ^ r = ((diagonal ℂ a) ^ r) ⊗ₖ ((diagonal ℂ b) ^ r) := by + exact rpow_kron_diagonal a b r ha hb rw [h_kron_r_pow_diag, Matrix.unitary_kron] rw [rpow_conj_unitary, rpow_conj_unitary, ← conj_kron] @@ -348,8 +348,8 @@ theorem cfc_sq_rpow_eq_cfc_rpow convert rfl; exact cfc_pow A; rw [ h_sqrt ]; - have h_sqrt : ∀ (f g : ℝ → ℝ), Continuous f → Continuous g → ∀ (A : HermitianMat d 𝕜), (A.cfc f).cfc g = A.cfc (fun x => g (f x)) := - fun f g _ _ A => Eq.symm (cfc_comp_apply A f g); + have h_sqrt : ∀ (f g : ℝ → ℝ), Continuous f → Continuous g → ∀ (A : HermitianMat d 𝕜), (A.cfc f).cfc g = A.cfc (fun x => g (f x)) := by + exact fun f g a a A => Eq.symm (cfc_comp_apply A f g); rw [ h_sqrt ]; · have h_sqrt : ∀ x : ℝ, 0 ≤ x → (x ^ 2) ^ (p / 2) = x ^ p := by intro x hx @@ -395,11 +395,11 @@ theorem rpowApprox_mono {A B : HermitianMat d ℂ} (hA : A.mat.PosDef) (hB : B.m · exact hA.add_posSemidef ( Matrix.PosSemidef.smul ( Matrix.PosSemidef.one ) ht.1.le ) · exact add_le_add_left hAB _ exact smul_le_smul_of_nonneg_left (sub_le_sub_left h_inv_antitone _) (Real.rpow_nonneg ht.1.le q) - have h_cont_tq : ContinuousOn (fun t : ℝ => t ^ q) (Set.Icc 0 T) := - continuousOn_id.rpow_const fun _ _ => Or.inr hq + have h_cont_tq : ContinuousOn (fun t : ℝ => t ^ q) (Set.Icc 0 T) := by + exact continuousOn_id.rpow_const fun _ _ => Or.inr hq have h_cont_const : - ContinuousOn (fun t : ℝ => (1 + t)⁻¹ • (1 : HermitianMat d ℂ)) (Set.Icc 0 T) := - ((continuousOn_const.add continuousOn_id).inv₀ + ContinuousOn (fun t : ℝ => (1 + t)⁻¹ • (1 : HermitianMat d ℂ)) (Set.Icc 0 T) := by + exact ((continuousOn_const.add continuousOn_id).inv₀ (fun t ht => by change (1 : ℝ) + t ≠ 0 linarith [ht.1])).smul continuousOn_const @@ -439,12 +439,12 @@ theorem rpowApprox_eq_cfc_scalar (A : HermitianMat d ℂ) (hA : A.mat.PosDef) (q have h_inv_def : (A + t • 1)⁻¹ = (A.cfc (fun u => u + t))⁻¹ := by rw [ show ( fun u => u + t ) = ( fun u => u ) + fun u => t from rfl, cfc_add ] ; aesop; have h_inv_comp : (A.cfc (fun u => u + t))⁻¹ = A.cfc (fun u => (u + t)⁻¹) := by - have h_inv_smul : ∀ {f : ℝ → ℝ} (hf : ∀ i, f (A.H.eigenvalues i) ≠ 0), (A.cfc f)⁻¹ = A.cfc (fun u => (f u)⁻¹) := - fun {f} hf => inv_cfc_eq_cfc_inv f hf + have h_inv_smul : ∀ {f : ℝ → ℝ} (hf : ∀ i, f (A.H.eigenvalues i) ≠ 0), (A.cfc f)⁻¹ = A.cfc (fun u => (f u)⁻¹) := by + exact fun {f} hf => inv_cfc_eq_cfc_inv f hf apply h_inv_smul intro i - have h_eigenvalue_pos : 0 < A.H.eigenvalues i := - Matrix.PosDef.eigenvalues_pos hA i + have h_eigenvalue_pos : 0 < A.H.eigenvalues i := by + exact Matrix.PosDef.eigenvalues_pos hA i exact ne_of_gt (add_pos h_eigenvalue_pos ht.left); rw [h_inv_def, h_inv_comp]; exact h_inv @@ -457,8 +457,8 @@ theorem rpowApprox_eq_cfc_scalar (A : HermitianMat d ℂ) (hA : A.mat.PosDef) (q have h_integrable : ∀ u : d, IntervalIntegrable (fun t : ℝ => t ^ q * (1 / (1 + t) - 1 / (A.H.eigenvalues u + t))) volume 0 T := by intro u have h_integrable : IntervalIntegrable (fun t : ℝ => t ^ q * (1 / (1 + t) - 1 / (A.H.eigenvalues u + t))) volume 0 T := by - have h_pos : 0 < A.H.eigenvalues u := - Matrix.PosDef.eigenvalues_pos hA u + have h_pos : 0 < A.H.eigenvalues u := by + exact Matrix.PosDef.eigenvalues_pos hA u exact ContinuousOn.intervalIntegrable ( by exact ContinuousOn.mul ( continuousOn_id.rpow_const fun x hx => Or.inr <| by linarith ) <| ContinuousOn.sub ( continuousOn_const.div ( continuousOn_const.add continuousOn_id ) fun x hx => by linarith [ Set.mem_Icc.mp <| by simpa [ hT.le ] using hx ] ) ( continuousOn_const.div ( continuousOn_const.add continuousOn_id ) fun x hx => by linarith [ Set.mem_Icc.mp <| by simpa [ hT.le ] using hx ] ) ) ..; exact h_integrable exact integral_cfc_eq_cfc_integral _ _ _ h_integrable @@ -479,8 +479,8 @@ lemma rpowConst_integrableOn (hq : 0 < q) (hq1 : q < 1) : IntegrableOn (fun u : ℝ => u ^ (q - 1) / (1 + u)) (Set.Ioi 0) := by rw [← Set.Ioc_union_Ioi_eq_Ioi zero_le_one] apply IntegrableOn.union - · have h_integrable_0_1 : IntegrableOn (fun u : ℝ => u ^ (q - 1)) (Set.Ioc 0 1) := - ( intervalIntegral.intervalIntegrable_rpow' ( by linarith ) ).1; + · have h_integrable_0_1 : IntegrableOn (fun u : ℝ => u ^ (q - 1)) (Set.Ioc 0 1) := by + exact ( intervalIntegral.intervalIntegrable_rpow' ( by linarith ) ).1; apply h_integrable_0_1.mono' · apply Measurable.aestronglyMeasurable fun_prop @@ -511,8 +511,8 @@ open MeasureTheory in lemma rpowConst_pos (hq : 0 < q) (hq1 : q < 1) : 0 < rpowConst q := by unfold rpowConst; have h_nonzero : 0 < ∫ u in Set.Ioi (0 : ℝ), u ^ (q - 1) / (1 + u) := by - have h_integrable : IntegrableOn (fun u : ℝ => u ^ (q - 1) / (1 + u)) (Set.Ioi (0 : ℝ)) := - rpowConst_integrableOn hq hq1 + have h_integrable : IntegrableOn (fun u : ℝ => u ^ (q - 1) / (1 + u)) (Set.Ioi (0 : ℝ)) := by + exact rpowConst_integrableOn hq hq1 rw [ integral_pos_iff_support_of_nonneg_ae ]; · simp [Function.support] exact lt_of_lt_of_le ( by norm_num ) ( measure_mono <| show Set.Ioi ( 0 : ℝ ) ⊆ { x : ℝ | ¬x ^ ( q - 1 ) = 0 ∧ ¬1 + x = 0 } ∩ Set.Ioi 0 from fun x hx => ⟨ ⟨ ne_of_gt <| Real.rpow_pos_of_pos hx _, ne_of_gt <| add_pos zero_lt_one hx ⟩, hx ⟩ ); @@ -610,8 +610,8 @@ theorem rpow_le_rpow_of_posDef (hA : A.mat.PosDef) (hAB : A ≤ B) convert le_of_tendsto_of_tendsto ( tendsto_rpowApprox hA hq ( lt_of_le_of_ne hq1 hq_eq_one ) ) ( tendsto_rpowApprox ( posDef_of_posDef_le hA hAB ) hq ( lt_of_le_of_ne hq1 hq_eq_one ) ) _ using 1 generalize_proofs at *; ( filter_upwards [ Filter.eventually_gt_atTop 0 ] with T hT using rpowApprox_mono hA ( posDef_of_posDef_le hA hAB ) hAB hq.le T hT |> le_trans <| by aesop;); - have h_rpow_pos : 0 < rpowConst q := - rpowConst_pos hq ( lt_of_le_of_ne hq1 hq_eq_one ); + have h_rpow_pos : 0 < rpowConst q := by + exact rpowConst_pos hq ( lt_of_le_of_ne hq1 hq_eq_one ); simp_all open ComplexOrder Filter in @@ -635,16 +635,16 @@ theorem rpow_le_rpow_of_le (hA : 0 ≤ A) (hAB : A ≤ B) ring_nf simp [ Matrix.mulVec, dotProduct, Finset.mul_sum _ _ _, mul_assoc, mul_left_comm]; simp [ Matrix.one_apply] - have h_inner_nonneg : 0 ≤ star x ⬝ᵥ A.mat.mulVec x := - inner_mulVec_nonneg hA x + have h_inner_nonneg : 0 ≤ star x ⬝ᵥ A.mat.mulVec x := by + exact inner_mulVec_nonneg hA x have h_inner_pos : 0 < star x ⬝ᵥ x := by simp_all exact h_inner.symm ▸ add_pos_of_nonneg_of_pos h_inner_nonneg ( mul_pos ( mod_cast hε_pos ) ( mod_cast h_inner_pos ) ) |> lt_of_lt_of_le <| le_rfl; have h_pos_def_Bε : (Bε ε).mat.PosDef := by convert posDef_of_posDef_le h_pos_def_Aε _ using 1 exact add_le_add_left hAB _ |> le_trans ( by simp [ Aε ] ) ; - have h_le_Aε_Bε : Aε ε ≤ Bε ε := - add_le_add_left hAB _ |> le_trans <| by simp [ Bε ] ; + have h_le_Aε_Bε : Aε ε ≤ Bε ε := by + exact add_le_add_left hAB _ |> le_trans <| by simp [ Bε ] ; exact ⟨h_pos_def_Aε, h_pos_def_Bε, h_le_Aε_Bε⟩ -- By the continuity of the function $M \mapsto M^q$, we have $(Aε ε)^q \to A^q$ and $(Bε ε)^q \to B^q$ as $\epsilon \to 0^+$. have h_cont : Filter.Tendsto (fun ε => (Aε ε) ^ q) (nhdsWithin 0 (Set.Ioi 0)) (nhds (A ^ q)) ∧ Filter.Tendsto (fun ε => (Bε ε) ^ q) (nhdsWithin 0 (Set.Ioi 0)) (nhds (B ^ q)) := by @@ -653,8 +653,8 @@ theorem rpow_le_rpow_of_le (hA : 0 ≤ A) (hAB : A ≤ B) apply rpow_const_continuous hq.le |> Continuous.continuousOn refine' ⟨ h_cont.continuousAt ( by simp ) |> fun h => h.tendsto.comp ( tendsto_nhdsWithin_of_tendsto_nhds <| Continuous.tendsto' _ _ _ _ ), h_cont.continuousAt ( by simp ) |> fun h => h.tendsto.comp ( tendsto_nhdsWithin_of_tendsto_nhds <| Continuous.tendsto' _ _ _ _ ) ⟩ <;> continuity; -- By the continuity of the function $M \mapsto M^q$, we have $(Aε ε)^q \leq (Bε ε)^q$ for all $\epsilon > 0$. - have h_le : ∀ ε > 0, (Aε ε) ^ q ≤ (Bε ε) ^ q := - fun ε hε => rpow_le_rpow_of_posDef ( h_pos_def ε hε |>.1 ) ( h_pos_def ε hε |>.2.2 ) hq hq1 |> le_trans <| by simp [ * ] ; + have h_le : ∀ ε > 0, (Aε ε) ^ q ≤ (Bε ε) ^ q := by + exact fun ε hε => rpow_le_rpow_of_posDef ( h_pos_def ε hε |>.1 ) ( h_pos_def ε hε |>.2.2 ) hq hq1 |> le_trans <| by simp [ * ] ; exact le_of_tendsto_of_tendsto h_cont.1 h_cont.2 ( Filter.eventually_of_mem self_mem_nhdsWithin fun ε hε => h_le ε hε ) |> fun h => by simpa using h; end LoewnerHeinz @@ -961,8 +961,8 @@ private lemma lieb_thirring_le_one_posDef intro k hk calc ∏ i : Fin k, singularValuesSorted N ⟨i.val, by omega⟩ - = singularValuesSorted (compoundMatrix N k) (compoundZero k hk) := - prod_singularValuesSorted_eq_compoundSV N k hk + = singularValuesSorted (compoundMatrix N k) (compoundZero k hk) := by + exact prod_singularValuesSorted_eq_compoundSV N k hk _ ≤ singularValuesSorted (compoundMatrix M k) (compoundZero k hk) ^ r := by simpa [M, N] using compound_top_singular_le_posDef hA hB hr0 hr1 k hk _ = ∏ i : Fin k, (singularValuesSorted M ⟨i.val, by omega⟩) ^ r := by @@ -1217,8 +1217,8 @@ private lemma trace_mul_inv_shift_eq_sum_div {A : HermitianMat d ℂ} (hA : 0 _ = ∑ i, A.H.eigenvalues i / (A.H.eigenvalues i + t) := by refine Finset.sum_congr rfl ?_ intro i hi - have hpos : 0 < A.H.eigenvalues i + t := - add_pos_of_nonneg_of_pos (by simpa using (zero_le_iff.mp hA).eigenvalues_nonneg i) ht + have hpos : 0 < A.H.eigenvalues i + t := by + exact add_pos_of_nonneg_of_pos (by simpa using (zero_le_iff.mp hA).eigenvalues_nonneg i) ht rw [show ((↑(A.H.eigenvalues i) + ↑t : ℂ)) = ↑(A.H.eigenvalues i + t) by simp, Complex.normSq_ofReal] field_simp [hpos.ne', div_eq_mul_inv] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean index 8d47bc21c..5a7a5236f 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean @@ -62,8 +62,8 @@ lemma schattenNorm_pow_eq · rw [ mul_comm, ← HermitianMat.rpow_mul ]; exact hA; · -- Since $A$ is positive, $A^{k*p}$ is also positive, and the trace of a positive matrix is non-negative. - have h_pos : 0 ≤ A ^ (k * p) := - HermitianMat.rpow_nonneg hA + have h_pos : 0 ≤ A ^ (k * p) := by + exact HermitianMat.rpow_nonneg hA; exact HermitianMat.trace_nonneg h_pos; · exact HermitianMat.rpow_nonneg hA @@ -120,8 +120,8 @@ lemma schattenNorm_eq_sum_singularValues_rpow (A : Matrix d d ℂ) {p : ℝ} (hp lemma schattenNorm_rpow_eq_sum_sorted (A : Matrix d d ℂ) {p : ℝ} (hp : 0 < p) : schattenNorm A p ^ p = ∑ i : Fin (Fintype.card d), singularValuesSorted A i ^ p := by - simpa [schattenNorm_rpow_eq_sum_singularValues A hp] using - sum_singularValues_rpow_eq_sum_sorted A p + rw [schattenNorm_rpow_eq_sum_singularValues A hp] + exact sum_singularValues_rpow_eq_sum_sorted A p open InnerProductSpace in /-- diff --git a/QuantumInfo/ForMathlib/Isometry.lean b/QuantumInfo/ForMathlib/Isometry.lean index 7742b0127..133acee53 100644 --- a/QuantumInfo/ForMathlib/Isometry.lean +++ b/QuantumInfo/ForMathlib/Isometry.lean @@ -57,8 +57,8 @@ theorem Matrix.submatrix_one_isometry {e : d₂ → d} {f : d₃ → d} (he : e. obtain ⟨ x, hx ⟩ := h_unique i; rw [show ( Finset.univ.filter fun y => e y = f i ) = { x } from Finset.eq_singleton_iff_unique_mem.2 ⟨ by aesop, fun y hy => hx.2 y <| Eq.symm <| Finset.mem_filter.1 hy |>.2.symm ⟩] ; simp ; next h => -- Since $e$ is injective and $e i \neq e j$, there is no $x$ such that $e i = f x$ and $e j = f x$. - have h_no_x : ∀ x : d₂, ¬(e x = f i ∧ e x = f j) := - fun x hx => h ( hf ( hx.1.symm.trans hx.2 ) ); + have h_no_x : ∀ x : d₂, ¬(e x = f i ∧ e x = f j) := by + exact fun x hx => h ( hf ( hx.1.symm.trans hx.2 ) ); exact Finset.sum_eq_zero fun x hx => by specialize h_no_x x; aesop omit [DecidableEq d₂] in @@ -135,8 +135,8 @@ theorem Matrix.IsHermitian.eigenvalue_ext (hA : A.IsHermitian) have h_diag : ∀ v : EuclideanSpace 𝕜 d, ∃ c : d → 𝕜, v = ∑ i, c i • (hA.eigenvectorBasis i) := by intro v set c := fun i => innerₛₗ 𝕜 (hA.eigenvectorBasis i) v - have hv : v = ∑ i, c i • (hA.eigenvectorBasis i) := - Eq.symm (OrthonormalBasis.sum_repr' hA.eigenvectorBasis v) + have hv : v = ∑ i, c i • (hA.eigenvectorBasis i) := by + exact Eq.symm (OrthonormalBasis.sum_repr' hA.eigenvectorBasis v) use c; obtain ⟨c, hc⟩ := h_diag (WithLp.toLp 2 v) use c diff --git a/QuantumInfo/ForMathlib/LimSupInf.lean b/QuantumInfo/ForMathlib/LimSupInf.lean index bfeb2ec01..ba90146b3 100644 --- a/QuantumInfo/ForMathlib/LimSupInf.lean +++ b/QuantumInfo/ForMathlib/LimSupInf.lean @@ -105,8 +105,8 @@ lemma exists_liminf_zero_of_forall_liminf_le (y : ℝ≥0) (f : ℝ≥0 → ℕ exact le_trans ( hn _ ( le_of_lt ( h _ le_rfl ) ) ) ( le_of_lt ( hc₂ _ hx_pos _ hz _ ) )); -- Define $g(m) = 1/(k(m)+1)$ where $k(m)$ is the index such that $n_{k(m)} \leq m < n_{k(m)+1}$. set g : ℕ → ℝ≥0 := fun m => (Nat.findGreatest (fun k => m ≥ n k) m + 1 : ℝ≥0)⁻¹; - have hg_pos : ∀ m, g m > 0 := - fun _ => by positivity + have hg_pos : ∀ m, g m > 0 := by + exact fun m => by positivity;; have hg_tendsto_zero : Filter.Tendsto g Filter.atTop (𝓝 0) := by -- Since $n$ is strictly monotone, $Nat.findGreatest (fun k => m ≥ n k) m$ tends to infinity as $m$ tends to infinity. have h_find_greatest_inf : Filter.Tendsto (fun m => Nat.findGreatest (fun k => m ≥ n k) m) Filter.atTop Filter.atTop := by @@ -365,8 +365,8 @@ lemma limsup_le_of_block_sequence_bound {α : Type*} (y : ℝ≥0) (f : α → -- Let $k$ be such that $b \in [T_k, T_{k+1})$. obtain ⟨k, hk⟩ : ∃ k, T k ≤ b ∧ b < T (k + 1) := by -- Since $T$ is strictly increasing and unbounded, the set $\{n \mid T n \leq b\}$ is finite and non-empty. - have h_finite : Set.Finite {n | T n ≤ b} := - Set.finite_iff_bddAbove.2 ⟨b, fun n hn => le_trans (hT.id_le _) hn⟩ + have h_finite : Set.Finite {n | T n ≤ b} := by + exact Set.finite_iff_bddAbove.2 ⟨ b, fun n hn => le_trans ( hT.id_le _ ) hn ⟩; exact ⟨ Finset.max' ( h_finite.toFinset ) ⟨ K, h_finite.mem_toFinset.mpr a ⟩, h_finite.mem_toFinset.mp ( Finset.max'_mem _ _ ), not_le.mp fun h => not_lt_of_ge ( Finset.le_max' _ _ ( h_finite.mem_toFinset.mpr h ) ) ( Nat.lt_succ_self _ ) ⟩; rw [ hg k b hk.1 hk.2 ]; exact le_trans ( hbound k b hk.1 hk.2 ) ( add_le_add_right ( hK k ( le_of_not_gt fun hk' => by linarith [ hT.monotone hk'.nat_succ_le ] ) ) _ ) @@ -398,8 +398,8 @@ lemma exists_liminf_zero_of_forall_liminf_limsup_le_with_UB (y₁ y₂ : ℝ≥0 · aesop · aesop obtain ⟨N0, hN0⟩ : ∃ N0 : ℕ → ℕ, ∀ k, ∀ n ≥ N0 k, f₂ (x k) n ≤ y₂ + (k + 1 : ℝ≥0)⁻¹ := by - have h_limsup : ∀ k, Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := - fun k => hf₂ _ (hx.1 k) + have h_limsup : ∀ k, Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := by + exact fun k => hf₂ _ ( hx.1 k ); have h_limsup_le : ∀ k, ∀ ε > 0, ∃ N, ∀ n ≥ N, f₂ (x k) n ≤ y₂ + ε := by intro k ε hε_pos have h_limsup_le : Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := h_limsup k; diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index c33499d07..5c8324e32 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -59,8 +59,8 @@ noncomputable def singularValuesSorted (A : Matrix d d ℂ) : /-- Sorted singular values are nonneg. -/ lemma singularValuesSorted_nonneg (A : Matrix d d ℂ) (i : Fin (Fintype.card d)) : 0 ≤ singularValuesSorted A i := by - have h_nonneg : ∀ i, 0 ≤ (singularValues A i) := - singularValues_nonneg A + have h_nonneg : ∀ i, 0 ≤ (singularValues A i) := by + exact singularValues_nonneg A have h_sorted_nonneg : ∀ {l : List ℝ}, (∀ x ∈ l, 0 ≤ x) → ∀ i < l.length, 0 ≤ l[i]! := by aesop contrapose! h_sorted_nonneg @@ -94,16 +94,16 @@ lemma sum_singularValues_rpow_eq_sum_sorted (A : Matrix d d ℂ) (p : ℝ) : lemma singularValuesSorted_antitone (A : Matrix d d ℂ) : Antitone (singularValuesSorted A) := by intro i j hij - have h_sorted : List.Pairwise (· ≥ ·) (Finset.univ.val.map (singularValues A) |>.sort (· ≥ ·)) := - Multiset.pairwise_sort _ _ + have h_sorted : List.Pairwise (· ≥ ·) (Finset.univ.val.map (singularValues A) |>.sort (· ≥ ·)) := by + exact Multiset.pairwise_sort _ _ exact h_sorted.rel_get_of_le hij /-- The product of nonneg antitone sequences is antitone. -/ lemma antitone_mul_of_antitone_nonneg {n : ℕ} {f g : Fin n → ℝ} (hf : Antitone f) (hg : Antitone g) (hf_nn : ∀ i, 0 ≤ f i) (hg_nn : ∀ i, 0 ≤ g i) : - Antitone (fun i => f i * g i) := - fun _ _ hij => mul_le_mul (hf hij) (hg hij) (hg_nn _) (hf_nn _) + Antitone (fun i => f i * g i) := by + exact fun i j hij => mul_le_mul (hf hij) (hg hij) (hg_nn _) (hf_nn _) /-! ### Compound matrices and auxiliary lemmas for Horn's inequality @@ -201,15 +201,15 @@ lemma cauchyBinet {m : ℕ} {n : Type*} [Fintype n] [DecidableEq n] [LinearOrder obtain ⟨a, ha⟩ : ∃ a : Fin m → Fin m, ∀ i, σ i = S.val.orderEmbOfFin S.property (a i) := by have h_exists_a : ∀ i, ∃ a : Fin m, σ i = S.val.orderEmbOfFin S.property a := by intro i - have h_exists_a : σ i ∈ S.val := - hσ.2 ▸ Finset.mem_image_of_mem _ (Finset.mem_univ _) + have h_exists_a : σ i ∈ S.val := by + exact hσ.2 ▸ Finset.mem_image_of_mem _ (Finset.mem_univ _) have h_exists_a : Finset.image (fun a : Fin m => S.val.orderEmbOfFin S.property a) Finset.univ = S.val := by refine' Finset.eq_of_subset_of_card_le (Finset.image_subset_iff.mpr fun a _ => Finset.orderEmbOfFin_mem _ _ _) _ rw [Finset.card_image_of_injective _ fun a b h => by simpa [Fin.ext_iff] using h]; simp [S.2] grind exact ⟨fun i => Classical.choose (h_exists_a i), fun i => Classical.choose_spec (h_exists_a i)⟩ - have ha_inj : Function.Injective a := - fun i j hij => hσ.1 <| by simp [ha, hij] + have ha_inj : Function.Injective a := by + exact fun i j hij => hσ.1 <| by simp [ha, hij] exact ⟨Equiv.ofBijective a ⟨ha_inj, Finite.injective_iff_surjective.mp ha_inj⟩, funext fun i => ha i ▸ rfl⟩ · rintro ⟨a, rfl⟩ constructor @@ -352,8 +352,8 @@ lemma prod_le_prod_sorted {n : ℕ} {f : Fin n → ℝ} -- And the product is preserved under sorting (it's the same set of values) have h_exists_sorted : ∃ (g' : Fin k → Fin n), Function.Injective g' ∧ StrictMono g' ∧ - Finset.image g Finset.univ = Finset.image g' Finset.univ := - ⟨Finset.orderEmbOfFin (Finset.image g Finset.univ) (by simp [Finset.card_image_of_injective _ hg]), + Finset.image g Finset.univ = Finset.image g' Finset.univ := by + exact ⟨Finset.orderEmbOfFin (Finset.image g Finset.univ) (by simp [Finset.card_image_of_injective _ hg]), fun a b h => by simpa using h, fun a b h => by simpa using h, by ext x; simp⟩ @@ -389,8 +389,8 @@ lemma singularValuesSorted_zero_eq_sup {e : Type*} [Fintype e] [DecidableEq e] exact h_le_sup _ (by simp [singularValuesSorted]) · have h_max_le_ge : ∀ i, singularValues A i ≤ singularValuesSorted A ⟨0, h⟩ := by intro i - have h_max_le_ge : ∀ j, singularValuesSorted A j ≤ singularValuesSorted A ⟨0, h⟩ := - fun j => singularValuesSorted_antitone A (Nat.zero_le _) + have h_max_le_ge : ∀ j, singularValuesSorted A j ≤ singularValuesSorted A ⟨0, h⟩ := by + exact fun j => singularValuesSorted_antitone A (Nat.zero_le _) exact (by have h_max_le_ge : ∃ j, singularValues A i = singularValuesSorted A j := by have h_exists_j : singularValues A i ∈ Multiset.sort (Finset.univ.val.map (singularValues A)) (· ≥ ·) := by @@ -505,8 +505,8 @@ lemma exists_sorting_equiv (M : Matrix d d ℂ) : · norm_num [Function.Injective, Function.Surjective] exact fun i j hij => Fin.ext <| by simpa [Fin.ext_iff] using σ.injective <| Fin.ext hij · intro b - obtain ⟨a, ha⟩ : ∃ a : Fin (List.ofFn (singularValuesSorted M)).length, σ a = ⟨b, by simp⟩ := - σ.surjective _ + obtain ⟨a, ha⟩ : ∃ a : Fin (List.ofFn (singularValuesSorted M)).length, σ a = ⟨b, by simp⟩ := by + exact σ.surjective _ use ⟨a, lt_of_lt_of_le a.2 (by simp)⟩ exact Fin.ext (by simp [ha]) · intro i @@ -799,8 +799,8 @@ lemma horn_weak_log_majorization (A B : Matrix d d ℂ) (k : ℕ) lemma rpow_antitone_of_nonneg_antitone {n : ℕ} {f : Fin n → ℝ} (hf : Antitone f) (hf_nn : ∀ i, 0 ≤ f i) {r : ℝ} (hr : 0 < r) : - Antitone (fun i => f i ^ r) := - fun _ _ hij => Real.rpow_le_rpow (hf_nn _) (hf hij) hr.le + Antitone (fun i => f i ^ r) := by + exact fun i j hij => Real.rpow_le_rpow (hf_nn _) (hf hij) hr.le /-- Weak log-majorization is preserved under positive powers. -/ lemma rpow_preserves_weak_log_maj {n : ℕ} diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index 8ebf7cce8..f67bcdda8 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -59,8 +59,8 @@ variable (hA : A.IsHermitian) (hB : B.IsHermitian) include hA in omit [DecidableEq n] in -theorem smul_selfAdjoint {c : 𝕜} (hc : _root_.IsSelfAdjoint c) : (c • A).IsHermitian := - IsSelfAdjoint.smul hc hA +theorem smul_selfAdjoint {c : 𝕜} (hc : _root_.IsSelfAdjoint c) : (c • A).IsHermitian := by + exact IsSelfAdjoint.smul hc hA include hA in omit [DecidableEq n] in @@ -817,8 +817,8 @@ lemma IsHermitian.eigenvalues_eq_of_unitary_similarity_diagonal {d 𝕜 : Type*} exact Finset.sum_congr rfl fun _ _ => by congr; ext; aesop; rw [ h, h_char_poly ]; -- The roots of the characteristic polynomial of A are its eigenvalues (by `IsHermitian.charpoly_roots_eq_eigenvalues`). - have h_eigenvalues : (Matrix.charpoly A).roots = Multiset.map (RCLike.ofReal ∘ hA.eigenvalues) Finset.univ.val := - Matrix.IsHermitian.roots_charpoly_eq_eigenvalues hA; + have h_eigenvalues : (Matrix.charpoly A).roots = Multiset.map (RCLike.ofReal ∘ hA.eigenvalues) Finset.univ.val := by + exact Matrix.IsHermitian.roots_charpoly_eq_eigenvalues hA; -- The roots of the characteristic polynomial of D are the diagonal entries f. have h_diag_roots : (Matrix.charpoly (Matrix.diagonal fun i => (f i : 𝕜))).roots = Multiset.map (fun i => (f i : 𝕜)) Finset.univ.val := by simp [ Matrix.charpoly, Matrix.det_diagonal ]; @@ -1210,8 +1210,8 @@ lemma sub_iInf_eignevalues (hA : A.IsHermitian) : -- Since the eigenvalues are real and the sums involving Q and x are complex, the product of a complex number and its conjugate is non-negative. have h_nonneg : ∀ i, 0 ≤ (∑ x_2, Q x_2 i * star (x x_2)) * (∑ x_2, star (Q x_2 i) * x x_2) := by intro i - have h_nonneg : 0 ≤ (∑ x_2, Q x_2 i * star (x x_2)) * star (∑ x_2, Q x_2 i * star (x x_2)) := - mul_star_self_nonneg (∑ x_2, Q x_2 i * star (x x_2)) + have h_nonneg : 0 ≤ (∑ x_2, Q x_2 i * star (x x_2)) * star (∑ x_2, Q x_2 i * star (x x_2)) := by + exact mul_star_self_nonneg (∑ x_2, Q x_2 i * star (x x_2)) convert h_nonneg using 1; simp [ mul_comm, Finset.mul_sum _ _ _]; -- Since each term in the sum is a product of a non-negative number and a non-negative eigenvalue difference, the entire sum is non-negative. @@ -1433,8 +1433,8 @@ theorem IsHermitian.spectrum_subset_of_mem_Icc {d 𝕜 : Type*} [Fintype d] [Dec {A B x : Matrix d d 𝕜} (hA : A.IsHermitian) (hB : B.IsHermitian) (hl : (x - A).PosSemidef) (hr : (B - x).PosSemidef) : spectrum ℝ x ⊆ Set.Icc (⨅ i, hA.eigenvalues i) (⨆ i, hB.eigenvalues i) := by - simpa [Set.Ici_inter_Iic] using - Set.subset_inter (hA.spectrum_subset_Ici_of_sub hl) (hB.spectrum_subset_Iic_of_sub hr) + rw [← Set.Ici_inter_Iic] + exact Set.subset_inter (hA.spectrum_subset_Ici_of_sub hl) (hB.spectrum_subset_Iic_of_sub hr) /-- The right partial trace of a matrix is equal to the left partial trace of the matrix reindexed by swapping the tensor factors. diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index 044785b65..69c24bd29 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -368,12 +368,12 @@ omit [Fintype m] [RCLike R] [DecidableEq n] in theorem traceNorm_sandwich_le [DecidableEq n] {S M T : Matrix n n ℂ} (hS : ‖S‖ ≤ 1) (hT : ‖T‖ ≤ 1) : (S * M * T).traceNorm ≤ M.traceNorm := calc (S * M * T).traceNorm - ≤ (M * T).traceNorm := - le_trans + ≤ (M * T).traceNorm := by + exact le_trans (by simpa [Matrix.mul_assoc] using Matrix.traceNorm_mul_le_opNorm_traceNorm S (M * T)) (by simpa using mul_le_mul_of_nonneg_right hS (Matrix.traceNorm_nonneg (M * T))) - _ ≤ M.traceNorm := - le_trans (traceNorm_mul_le_traceNorm_opNorm M T) + _ ≤ M.traceNorm := by + exact le_trans (traceNorm_mul_le_traceNorm_opNorm M T) (by simpa using mul_le_mul_of_nonneg_left hT (Matrix.traceNorm_nonneg M)) end @@ -396,8 +396,8 @@ theorem abs_trace_le_traceNorm (A : Matrix n n ℂ) : simpa [Matrix.trace] using norm_sum_le (s := Finset.univ) (f := fun i => (C.val * D) i i) _ = ∑ i, ‖C.val i i‖ * Real.sqrt (hH.eigenvalues i) := by simp [D, Matrix.mul_apply, Matrix.diagonal, Real.norm_eq_abs, abs_of_nonneg] - _ ≤ ∑ i, Real.sqrt (hH.eigenvalues i) := - Finset.sum_le_sum (fun i _ => by + _ ≤ ∑ i, Real.sqrt (hH.eigenvalues i) := by + exact Finset.sum_le_sum (fun i _ => by simpa using mul_le_mul_of_nonneg_right (entry_norm_bound_of_unitary C.property i i) (Real.sqrt_nonneg _)) diff --git a/QuantumInfo/ForMathlib/Minimax.lean b/QuantumInfo/ForMathlib/Minimax.lean index 6663c2c13..9a7b2891c 100644 --- a/QuantumInfo/ForMathlib/Minimax.lean +++ b/QuantumInfo/ForMathlib/Minimax.lean @@ -48,8 +48,8 @@ theorem _root_.IsCompact.exists_isMinOn_lowerSemicontinuousOn {α β : Type*} -- Since $s$ is compact, the open cover $\{U_x \cap s \mid x \in s\}$ has a finite subcover. obtain ⟨t, ht⟩ : ∃ t : Finset β, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x ∩ s := by -- Since $s$ is compact, the open cover $\{U_x \mid x \in s\}$ has a finite subcover. - obtain ⟨t, ht⟩ : ∃ t : Finset β, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := - hs.elim_nhds_subcover U fun x hx => IsOpen.mem_nhds (hU x hx |>.1) (hU x hx |>.2.1) + obtain ⟨t, ht⟩ : ∃ t : Finset β, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := by + exact hs.elim_nhds_subcover U fun x hx => IsOpen.mem_nhds ( hU x hx |>.1 ) ( hU x hx |>.2.1 ); exact ⟨ t, ht.1, fun x hx => by rcases Set.mem_iUnion₂.1 ( ht.2 hx ) with ⟨ y, hy, hy' ⟩ ; exact Set.mem_iUnion₂.2 ⟨ y, hy, ⟨ hy', hx ⟩ ⟩ ⟩; -- Since $t$ is finite, there exists $x \in t$ such that $f(g(x))$ is minimal. obtain ⟨x, hx⟩ : ∃ x ∈ t, ∀ y ∈ t, f (g x) ≤ f (g y) := by diff --git a/QuantumInfo/ForMathlib/Misc.lean b/QuantumInfo/ForMathlib/Misc.lean index 6efee8a7a..0e6dd5b76 100644 --- a/QuantumInfo/ForMathlib/Misc.lean +++ b/QuantumInfo/ForMathlib/Misc.lean @@ -178,6 +178,6 @@ lemma exists_equiv_of_multiset_map_eq {α β γ : Type*} [Fintype α] [Fintype rw [ Multiset.map_map ] exact h.trans h_multiset_eq; -- By `Multiset.map_univ_eq_iff`, there exists `e' : α ≃ α` such that `f = (g ∘ σ) ∘ e'`. - obtain ⟨e', he'⟩ : ∃ e' : α ≃ α, f = (g ∘ σ) ∘ e' := - (Multiset.map_univ_eq_iff f (g ∘ ⇑σ)).mp hσ + obtain ⟨e', he'⟩ : ∃ e' : α ≃ α, f = (g ∘ σ) ∘ e' := by + exact (Multiset.map_univ_eq_iff f (g ∘ ⇑σ)).mp hσ; exact ⟨ e'.trans σ, by simp_all [ Function.comp ]; grind⟩ diff --git a/QuantumInfo/ForMathlib/SionMinimax.lean b/QuantumInfo/ForMathlib/SionMinimax.lean index 963334f48..bd404879e 100644 --- a/QuantumInfo/ForMathlib/SionMinimax.lean +++ b/QuantumInfo/ForMathlib/SionMinimax.lean @@ -268,8 +268,8 @@ theorem LeftOrdContinuous.comp_lowerSemicontinuousOn_strong_assumptions {α γ by_contra h_contra simp only [not_exists, not_and, not_lt] at h_contra have h_exists_z : ∃ z, z < f x ∧ g z > y := by - have h_lub : IsLUB (Set.Iio (f x)) (f x) := - isLUB_Iio + have h_lub : IsLUB (Set.Iio (f x)) (f x) := by + exact isLUB_Iio have := hg h_lub; have := this.exists_between hy simp_all only [Set.mem_image, Set.mem_Iio, exists_exists_and_eq_and, gt_iff_lt] diff --git a/QuantumInfo/ResourceTheory/SteinsLemma.lean b/QuantumInfo/ResourceTheory/SteinsLemma.lean index b39c2aa54..b5d4edadd 100644 --- a/QuantumInfo/ResourceTheory/SteinsLemma.lean +++ b/QuantumInfo/ResourceTheory/SteinsLemma.lean @@ -456,8 +456,8 @@ private lemma rexp_mul_smul_proj_lt_mul_sub_le_mul_sub {n : ℕ} {x : ℝ} dsimp gcongr apply Matrix.PosSemidef.trace_mono - rw [one_div, smul_mul_assoc, mul_smul_comm] - rw [inv_smul_le_iff_of_pos (mod_cast hn)] + rw [one_div, HermitianMat.mat_smul, smul_mul_assoc, mul_smul_comm] + rw [inv_smul_le_iff_of_pos (mod_cast hn), HermitianMat.mat_smul] rw [mul_smul_comm] obtain ⟨C, ⟨f, hf⟩, ⟨g, hg⟩⟩ := hℰσ.exists_HermitianMat_cfc rw [hf, hg] at hE ⊢ @@ -577,8 +577,8 @@ private lemma f_image_bound (mineig : ℝ) (n : ℕ) (h : 0 < mineig) (hn : 0 < -- Since the interval [mineig^n / 3, 1] is closed and bounded, and the function Real.log x / (Real.log (1 / mineig) + Real.log 3 / (max n 1)) is continuous on this interval, it must attain a maximum and minimum value on this interval. have h_cont : ContinuousOn (fun x => Real.log x / (Real.log (1 / mineig) + Real.log 3 / (max n 1))) (Set.Icc (mineig^n / 3) 1) := by -- Since Real.log x is continuous on the interval (0, ∞) and the denominator is a non-zero constant, the function Real.log x / (Real.log (1 / mineig) + Real.log 3 / (max n 1)) is continuous on the interval [mineig^n / 3, 1]. - have h_cont : ContinuousOn Real.log (Set.Icc (mineig^n / 3) 1) := - continuousOn_of_forall_continuousAt fun x hx => Real.continuousAt_log ( by linarith [ hx.1, pow_pos h n ] ); + have h_cont : ContinuousOn Real.log (Set.Icc (mineig^n / 3) 1) := by + exact continuousOn_of_forall_continuousAt fun x hx => Real.continuousAt_log ( by linarith [ hx.1, pow_pos h n ] ); exact h_cont.div_const _; exact ⟨ ( InfSet.sInf <| ( fun x => Real.log x / ( Real.log ( 1 / mineig ) + Real.log 3 / ( max n 1 ) ) ) '' Set.Icc ( mineig ^ n / 3 ) 1 ), ( SupSet.sSup <| ( fun x => Real.log x / ( Real.log ( 1 / mineig ) + Real.log 3 / ( max n 1 ) ) ) '' Set.Icc ( mineig ^ n / 3 ) 1 ), fun x hx => ⟨ ( csInf_le <| IsCompact.bddBelow <| isCompact_Icc.image_of_continuousOn h_cont ) <| Set.mem_image_of_mem _ hx, ( le_csSup <| IsCompact.bddAbove <| isCompact_Icc.image_of_continuousOn h_cont ) <| Set.mem_image_of_mem _ hx ⟩ ⟩; obtain ⟨ m, M, hM ⟩ := h_bounded @@ -611,8 +611,8 @@ private lemma f_image_bound (mineig : ℝ) (n : ℕ) (h : 0 < mineig) (hn : 0 < · gcongr; · have := h_f_le n 1 ; norm_num at this ; linarith [ Real.log_le_sub_one_of_pos h ]; · -- Taking the logarithm of both sides of the inequality $mineig^n / 3 \leq w$, we get $n \log(mineig) - \log(3) \leq \log(w)$. - have h_log : Real.log (mineig^n / 3) ≤ Real.log w := - Real.log_le_log ( by positivity ) left; + have h_log : Real.log (mineig^n / 3) ≤ Real.log w := by + exact Real.log_le_log ( by positivity ) left; rwa [ Real.log_div ( by positivity ) ( by positivity ), Real.log_pow ] at h_log; · refine' Int.ceil_le.mpr _; rw [ div_le_iff₀ ] @@ -646,8 +646,8 @@ private lemma c'_bounded {mineig : ℝ} {ε2 : ℕ → ℝ≥0} (∀ (n : ℕ), 0 < c n) → ∃ (C : NNReal), ∀ᶠ (n : ℕ) in Filter.atTop, c' (↑(ε2 n)) n ≤ ↑C := by have h_bound : ∃ C : ℝ, ∀ᶠ n in Filter.atTop, Real.log (1 / mineig) + Real.log 3 / (Max.max n 1) + (Real.log (1 / mineig) + Real.log 3 / (Max.max n 1)) / n ≤ C := by - have h_bound : Filter.Tendsto (fun n => Real.log (1 / mineig) + Real.log 3 / (Max.max n 1) + (Real.log (1 / mineig) + Real.log 3 / (Max.max n 1)) / n) Filter.atTop (nhds (Real.log (1 / mineig) + Real.log 3 / 0 + (Real.log (1 / mineig) + Real.log 3 / 0) / 0)) := - le_trans ( Filter.Tendsto.add ( tendsto_const_nhds.add <| Filter.Tendsto.mul tendsto_const_nhds <| Filter.Tendsto.inv_tendsto_atTop <| Filter.tendsto_atTop_atTop.mpr fun x => ⟨ x + 1, fun y hy => le_max_of_le_left <| by linarith ⟩ ) <| Filter.Tendsto.mul ( tendsto_const_nhds.add <| Filter.Tendsto.mul tendsto_const_nhds <| Filter.Tendsto.inv_tendsto_atTop <| Filter.tendsto_atTop_atTop.mpr fun x => ⟨ x + 1, fun y hy => le_max_of_le_left <| by linarith ⟩ ) <| tendsto_inv_atTop_zero ) <| by norm_num; + have h_bound : Filter.Tendsto (fun n => Real.log (1 / mineig) + Real.log 3 / (Max.max n 1) + (Real.log (1 / mineig) + Real.log 3 / (Max.max n 1)) / n) Filter.atTop (nhds (Real.log (1 / mineig) + Real.log 3 / 0 + (Real.log (1 / mineig) + Real.log 3 / 0) / 0)) := by + exact le_trans ( Filter.Tendsto.add ( tendsto_const_nhds.add <| Filter.Tendsto.mul tendsto_const_nhds <| Filter.Tendsto.inv_tendsto_atTop <| Filter.tendsto_atTop_atTop.mpr fun x => ⟨ x + 1, fun y hy => le_max_of_le_left <| by linarith ⟩ ) <| Filter.Tendsto.mul ( tendsto_const_nhds.add <| Filter.Tendsto.mul tendsto_const_nhds <| Filter.Tendsto.inv_tendsto_atTop <| Filter.tendsto_atTop_atTop.mpr fun x => ⟨ x + 1, fun y hy => le_max_of_le_left <| by linarith ⟩ ) <| tendsto_inv_atTop_zero ) <| by norm_num; exact ⟨ _, h_bound.eventually ( ge_mem_nhds <| lt_add_one _ ) ⟩; intro c c' a simp_all only [one_div, Real.log_inv, Filter.eventually_atTop, Nat.cast_max, Nat.cast_one, @@ -1236,7 +1236,7 @@ private theorem EquationS62 dsimp [σ₁_mineig, iInf] rw [← Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues] rw [← Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues] - rw [sInf_spectrum_spacePow (σ₁ i) n, smul_smul] + rw [MState.mat_M, sInf_spectrum_spacePow (σ₁ i) n, MState.mat_M, smul_smul] _ = Real.exp (- n * (σ₁_c i n + (σ₁_c i n) / n)) • 1 := by rw [σ₁_c_identity i hn] _ ≥ Real.exp (-n * c' ε2 n) • 1 := by @@ -1834,8 +1834,8 @@ theorem Lemma7 (ρ : MState (H i)) {ε : Prob} (hε : 0 < ε ∧ ε < 1) (σ : ( rw [heq] simp only [Set.range_comp, MState.mat_M, EquivLike.range_eq_univ, Set.image_univ, ge_iff_le] let S : Set ℝ := (fun x => Real.exp (f_map i n x)) '' Set.Icc ((σ₁_mineig i ^ n) / 3) 1 - have h_card_subs : Set.ncard S ≤ n + 1 ∧ S.Finite := - f_image_bound (σ₁_mineig i) n (mineig_pos i) hn (log_le_f i) (f_le_log i) + have h_card_subs : Set.ncard S ≤ n + 1 ∧ S.Finite := by + exact f_image_bound (σ₁_mineig i) n (mineig_pos i) hn (log_le_f i) (f_le_log i) let S₂ : Set ℝ := (fun x => (σ''_unnormalized ρ ε m σ n).trace⁻¹ * Real.exp (f_map i n x)) '' Set.Icc ((σ₁_mineig i ^ n) / 3) 1 obtain ⟨h_card_subs₂, h_s₂_finite⟩ : Set.ncard S₂ ≤ n + 1 ∧ S₂.Finite := by have hS₂ : S₂ = ((σ''_unnormalized ρ ε m σ n).trace⁻¹ * ·) '' S := by @@ -1858,7 +1858,7 @@ theorem Lemma7 (ρ : MState (H i)) {ε : Prob} (hε : 0 < ε ∧ ε < 1) (σ : ( rw [HermitianMat.val_eq_coe, HermitianMat.mat_smul] rw [spectrum.smul_eq_smul _ _ (ContinuousFunctionalCalculus.spectrum_nonempty _ ((σ₁ i) ⊗ᵣ^[n]).M.H)] rw [Real.sInf_smul_of_nonneg (by norm_num)] - simp [div_eq_inv_mul, sInf_spectrum_spacePow] + simp [MState.mat_M, div_eq_inv_mul, sInf_spectrum_spacePow] have hdpos n : 0 < Fintype.card (spectrum ℝ (σ'' ρ ε m σ n).m) := by rw [Fintype.card_pos_iff, Set.nonempty_coe_sort] diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 5e61bddcb..10725db6c 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -270,11 +270,11 @@ theorem Sᵥₙ_eq_trace_cfc {d : Type*} [Fintype d] [DecidableEq d] (ρ : MStat have h_def : Sᵥₙ ρ = Finset.sum Finset.univ (fun x ↦ Real.negMulLog (ρ.M.H.eigenvalues x)) := rfl -- By definition of trace, the trace of `cfc ρ.M Real.negMulLog` is the sum of its eigenvalues. have h_trace : (ρ.M.cfc Real.negMulLog).trace = - ∑ x, (ρ.M.cfc Real.negMulLog).H.eigenvalues x := - (HermitianMat.sum_eigenvalues_eq_trace _).symm + ∑ x, (ρ.M.cfc Real.negMulLog).H.eigenvalues x := by + exact (HermitianMat.sum_eigenvalues_eq_trace _).symm obtain ⟨e, he⟩ : ∃ e : d ≃ d, (ρ.M.cfc Real.negMulLog).H.eigenvalues = - Real.negMulLog ∘ ρ.M.H.eigenvalues ∘ e := - Matrix.IsHermitian.cfc_eigenvalues _ _ + Real.negMulLog ∘ ρ.M.H.eigenvalues ∘ e := by + exact Matrix.IsHermitian.cfc_eigenvalues _ _ rw [h_def, h_trace, he] simp only [Function.comp_apply] conv_lhs => rw [ ← Equiv.sum_comp e ] @@ -285,12 +285,12 @@ The von Neumann entropy of a classical state (diagonal in the basis) is equal to theorem Sᵥₙ_ofClassical {d : Type*} [Fintype d] [DecidableEq d] (dist : ProbDistribution d) : Sᵥₙ (MState.ofClassical dist) = Hₛ dist := by -- Let's unfold the definition of `Sᵥₙ` using `Sᵥₙ_eq_trace_cfc`. - have h_def : Sᵥₙ (MState.ofClassical dist) = (HermitianMat.cfc (MState.ofClassical dist).M Real.negMulLog).trace := - Sᵥₙ_eq_trace_cfc (ofClassical dist); + have h_def : Sᵥₙ (MState.ofClassical dist) = (HermitianMat.cfc (MState.ofClassical dist).M Real.negMulLog).trace := by + exact Sᵥₙ_eq_trace_cfc (ofClassical dist); convert h_def using 1; -- By definition of $MState.ofClassical$, we know that $(MState.ofClassical dist).M$ is a diagonal matrix with entries $dist i$. - have h_diag : (MState.ofClassical dist).M = HermitianMat.diagonal ℂ (fun x => dist x) := - rfl; + have h_diag : (MState.ofClassical dist).M = HermitianMat.diagonal ℂ (fun x => dist x) := by + exact rfl; rw [ h_diag, HermitianMat.cfc_diagonal, HermitianMat.trace_diagonal ] ; aesop /-- The entanglement of formation of the maximally entangled state with on-site dimension 𝕕 is log(𝕕). -/ diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 89dd2da41..dc7658805 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -127,7 +127,7 @@ theorem ext_m {ρ₁ ρ₂ : MState d} (h : ρ₁.m = ρ₂.m) : ρ₁ = ρ₂ : /-- The map from mixed states to their matrices is injective -/ theorem m_inj : (MState.m (d := d)).Injective := - fun _ _ h => ext_m h + fun _ _ h ↦ by ext1; ext1; exact h theorem M_Injective : Function.Injective (MState.M (d := d)) := fun _ _ => MState.ext @@ -712,8 +712,8 @@ theorem eq_of_sum_eq_pure {d : Type*} [Fintype d] [DecidableEq d] exact MState.ext h_eq.symm theorem purity_prod {d₁ d₂ : Type*} [Fintype d₁] [Fintype d₂] [DecidableEq d₁] [DecidableEq d₂] - (ρ₁ : MState d₁) (ρ₂ : MState d₂) : (ρ₁ ⊗ᴹ ρ₂).purity = ρ₁.purity * ρ₂.purity := - prod_inner_prod ρ₁ ρ₁ ρ₂ ρ₂ + (ρ₁ : MState d₁) (ρ₂ : MState d₂) : (ρ₁ ⊗ᴹ ρ₂).purity = ρ₁.purity * ρ₂.purity := by + exact prod_inner_prod ρ₁ ρ₁ ρ₂ ρ₂ theorem pure_eq_pure_iff {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) : pure ψ = pure φ ↔ ∃ z : ℂ, ‖z‖ = 1 ∧ ψ.vec = z • φ.vec := by @@ -734,8 +734,8 @@ theorem pure_eq_pure_iff {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) specialize h_eq i k simp_all -- Since $\overline{z} \cdot \overline{\varphi_k} \neq 0$, we can divide both sides of the equation by $\overline{z} \cdot \overline{\varphi_k}$. - have h_div : ψ.vec i * starRingEnd ℂ z = φ.vec i := - mul_left_cancel₀ ( show starRingEnd ℂ ( φ.vec k ) ≠ 0 from by simpa [ Complex.ext_iff ] using hk ) ( by linear_combination' h_eq ); + have h_div : ψ.vec i * starRingEnd ℂ z = φ.vec i := by + exact mul_left_cancel₀ ( show starRingEnd ℂ ( φ.vec k ) ≠ 0 from by simpa [ Complex.ext_iff ] using hk ) ( by linear_combination' h_eq ); rw [ ← h_div, mul_left_comm, Complex.mul_conj, Complex.normSq_eq_norm_sq ] ; aesop; · cases h rename_i h @@ -749,8 +749,8 @@ theorem pure_eq_pure_iff {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) /-- Two kets are phase-equivalent if and only if their pure states are equal. -/ theorem PhaseEquiv_iff_pure_eq {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) : - Ket.PhaseEquiv.r ψ φ ↔ MState.pure ψ = MState.pure φ := - (pure_eq_pure_iff ψ φ).symm + Ket.PhaseEquiv.r ψ φ ↔ MState.pure ψ = MState.pure φ := by + exact (pure_eq_pure_iff ψ φ).symm /-- `MState.pure` descends to the quotient `KetUpToPhase`. -/ def pureQ {d : Type*} [Fintype d] [DecidableEq d] : KetUpToPhase d → MState d := @@ -799,15 +799,15 @@ theorem pure_separable_imp_IsProd {d₁ d₂ : Type*} [Fintype d₁] [Fintype d have h_purity : (pure ψ).purity = (k.val.1).purity * (k.val.2).purity := by convert MState.purity_prod _ _; exact MState.ext hk.2; - have h_purity_one : (pure ψ).purity = 1 := - ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; + have h_purity_one : (pure ψ).purity = 1 := by + exact ( pure_iff_purity_one _ ).mp ⟨ ψ, rfl ⟩; rw [ h_purity, Prob.mul_eq_one_iff ] at h_purity_one ; aesop obtain ⟨φ, hφ⟩ : ∃ φ : MState d₂, k.val.2 = φ ∧ φ.purity = 1 := by have h_purity_prod : (pure ψ).purity = (k.val.1).purity * (k.val.2).purity := by convert MState.purity_prod _ _; exact MState.ext hk.2; - have h_purity_one : (MState.pure ψ).purity = 1 := - pure_iff_purity_one _ |>.1 ⟨ ψ, rfl ⟩; + have h_purity_one : (MState.pure ψ).purity = 1 := by + exact pure_iff_purity_one _ |>.1 ⟨ ψ, rfl ⟩; aesop; -- Since `ξ` and `φ` are pure states, we have `ξ = pure ξ'` and `φ = pure φ'` for some `ξ', φ'`. obtain ⟨ξ', hξ'⟩ : ∃ ξ' : Ket d₁, ξ = MState.pure ξ' := by @@ -867,21 +867,21 @@ theorem pure_iff_rank_eq_one {d : Type*} [Fintype d] [DecidableEq d] (ρ : MStat -- Since ρ is Hermitian and has rank 1, it must be of the form |ψ⟩⟨ψ| for some ket ψ. Use this fact. have h_pure : ∃ ψ : d → ℂ, ρ.m = Matrix.of (fun i j => ψ i * star (ψ j)) := by have h_rank : ρ.m.rank = 1 := h - have h_herm : ρ.m.IsHermitian := - ρ.M.property + have h_herm : ρ.m.IsHermitian := by + exact ρ.M.property have := h_herm.spectral_theorem; -- Since the rank of ρ.m is 1, the diagonal matrix in the spectral theorem must have exactly one non-zero entry. obtain ⟨i, hi⟩ : ∃ i : d, h_herm.eigenvalues i ≠ 0 ∧ ∀ j : d, j ≠ i → h_herm.eigenvalues j = 0 := by have h_diag : ∑ i : d, (if h_herm.eigenvalues i = 0 then 0 else 1) = 1 := by have h_diag : Matrix.rank (Matrix.diagonal (h_herm.eigenvalues)) = 1 := by - have h_diag : Matrix.rank (Matrix.diagonal (h_herm.eigenvalues)) = Matrix.rank (ρ.m) := - Eq.symm (Matrix.IsHermitian.rank_eq_rank_diagonal h_herm); + have h_diag : Matrix.rank (Matrix.diagonal (h_herm.eigenvalues)) = Matrix.rank (ρ.m) := by + exact Eq.symm (Matrix.IsHermitian.rank_eq_rank_diagonal h_herm); exact h_diag.trans h_rank; rw [ Matrix.rank_diagonal ] at h_diag; simp [ Finset.sum_ite ]; rw [ Fintype.card_subtype ] at h_diag ; exact h_diag; - obtain ⟨i, hi⟩ : ∃ i : d, h_herm.eigenvalues i ≠ 0 := - not_forall.mp fun h => by simp [h] at h_diag + obtain ⟨i, hi⟩ : ∃ i : d, h_herm.eigenvalues i ≠ 0 := by + exact not_forall.mp fun h => by simp [ h ] at h_diag; rw [ Finset.sum_eq_add_sum_sdiff_singleton i _ (by simp) ] at h_diag; exact ⟨i, hi, fun j hj => Classical.not_not.1 fun hj' => absurd h_diag ( by rw [ if_neg hi ] ; exact ne_of_gt ( lt_add_of_pos_right _ ( lt_of_lt_of_le ( by simp [ hj' ] ) ( Finset.single_le_sum ( fun x _ => by positivity ) ( Finset.mem_sdiff.2 ⟨ Finset.mem_univ j, by simp [ hj ] ⟩ ) ) ) ) ) ⟩; @@ -1113,8 +1113,8 @@ The multiset of values in the spectrum of a relabeled state is the same as the m lemma multiset_spectrum_relabel_eq {d₁ d₂ : Type*} [Fintype d₁] [DecidableEq d₁] [Fintype d₂] [DecidableEq d₂] (ρ : MState d₁) (e : d₂ ≃ d₁) : Multiset.map (ρ.relabel e).spectrum Finset.univ.val = Multiset.map ρ.spectrum Finset.univ.val := by - have h_charpoly : Matrix.charpoly (ρ.relabel e).m = Matrix.charpoly ρ.m := - Matrix.charpoly_reindex e.symm ρ.m + have h_charpoly : Matrix.charpoly (ρ.relabel e).m = Matrix.charpoly ρ.m := by + exact Matrix.charpoly_reindex e.symm ρ.m have h_eigenvalues : Multiset.map (ρ.relabel e).M.H.eigenvalues Finset.univ.val = Multiset.map ρ.M.H.eigenvalues Finset.univ.val := by have h_eigenvalues : Polynomial.roots (Matrix.charpoly (ρ.relabel e).m) = Polynomial.roots (Matrix.charpoly ρ.m) := by rw [h_charpoly]; From 049e4970aa8be5a9809952536f9feafcd057f6da Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:42:50 -0700 Subject: [PATCH 292/498] refactor: golf convex roof and finite ensemble proofs Co-authored-by: Claude Opus 4.8 --- .../CanonicalEnsemble/Finite.lean | 6 ++---- QuantumInfo/States/Entanglement.lean | 12 ++++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index 3a0e4ec64..06fdbfe4b 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -166,8 +166,7 @@ lemma mathematicalPartitionFunction_of_fintype [IsFinite 𝓒] (T : Temperature) 𝓒.mathematicalPartitionFunction T = ∑ i, exp (- β T * 𝓒.energy i) := by rw [mathematicalPartitionFunction_eq_integral, MeasureTheory.integral_fintype] simp [IsFinite.μ_eq_count] - · rw [IsFinite.μ_eq_count] - exact Integrable.of_finite + · simp [IsFinite.μ_eq_count] lemma partitionFunction_of_fintype [IsFinite 𝓒] (T : Temperature) : 𝓒.partitionFunction T = ∑ i, exp (- T.β * 𝓒.energy i) := by @@ -184,8 +183,7 @@ lemma μBolt_of_fintype (T : Temperature) [IsFinite 𝓒] (i : ι) : exact Real.exp_nonneg _ instance {T} [IsFinite 𝓒] : IsFiniteMeasure (𝓒.μBolt T) := by - rw [μBolt] - exact isFiniteMeasure_withDensity_ofReal HasFiniteIntegral.of_finite + simpa [μBolt] using isFiniteMeasure_withDensity_ofReal HasFiniteIntegral.of_finite @[simp] lemma μProd_of_fintype (T : Temperature) [IsFinite 𝓒] (i : ι) : diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 10725db6c..cf730aa89 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -126,8 +126,7 @@ theorem le_mixed_convex_roof (ρ : MState d) : unfold mixed_convex_roof rw [WithTop.le_untop_iff] apply le_iInf; intro ⟨n, hnpos⟩; apply le_iInf; intro e; apply le_iInf; intro hmix - rw [some_eq_coe', ENNReal.coe_le_coe] - exact h n hnpos e hmix + exact ENNReal.coe_le_coe.mpr (h n hnpos e hmix) set_option backward.isDefEq.respectTransparency false in theorem le_convex_roof (ρ : MState d) : @@ -135,8 +134,7 @@ theorem le_convex_roof (ρ : MState d) : unfold convex_roof rw [WithTop.le_untop_iff] apply le_iInf; intro ⟨n, hnpos⟩; apply le_iInf; intro e; apply le_iInf; intro hmix - rw [some_eq_coe', ENNReal.coe_le_coe] - exact h n hnpos e hmix + exact ENNReal.coe_le_coe.mpr (h n hnpos e hmix) set_option backward.isDefEq.respectTransparency false in theorem convex_roof_le (ρ : MState d): @@ -145,8 +143,7 @@ theorem convex_roof_le (ρ : MState d): unfold convex_roof rw [WithTop.untop_le_iff] apply iInf_le_of_le ⟨n, hnpos⟩; apply iInf_le_of_le e; apply iInf_le_of_le hmix - rw [some_eq_coe', ENNReal.coe_le_coe] - exact h + exact ENNReal.coe_le_coe.mpr h set_option backward.isDefEq.respectTransparency false in omit [Nonempty d] in @@ -156,8 +153,7 @@ theorem mixed_convex_roof_le (ρ : MState d): unfold mixed_convex_roof rw [WithTop.untop_le_iff] apply iInf_le_of_le ⟨n, hnpos⟩; apply iInf_le_of_le e; apply iInf_le_of_le hmix - rw [some_eq_coe', ENNReal.coe_le_coe] - exact h + exact ENNReal.coe_le_coe.mpr h /-- The mixed convex roof extension of `f` is smaller than or equal to its convex roof extension, since the former minimizes over a larger set of ensembles. -/ From 7f36fd77725c26b34b19d91468e5b10a89c894ab Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:46:21 -0700 Subject: [PATCH 293/498] refactor: golf Wick time-condition proofs Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/WickContraction/IsFull.lean | 6 ++---- .../WickContraction/TimeCond.lean | 14 +++++--------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/IsFull.lean b/Physlib/QFT/PerturbationTheory/WickContraction/IsFull.lean index 0e76f2f02..f5b061883 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/IsFull.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/IsFull.lean @@ -42,10 +42,8 @@ lemma isFull_iff_equivInvolution_no_fixed_point : /-- The equivalence between full contractions and fixed-point free involutions. -/ def isFullInvolutionEquiv : {c : WickContraction n // IsFull c} ≃ {f : Fin n → Fin n // Function.Involutive f ∧ (∀ i, f i ≠ i)} where - toFun c := ⟨equivInvolution c.1, by - apply And.intro (equivInvolution c.1).2 - rw [← isFull_iff_equivInvolution_no_fixed_point] - exact c.2⟩ + toFun c := ⟨equivInvolution c.1, + ⟨(equivInvolution c.1).2, (isFull_iff_equivInvolution_no_fixed_point (c := c.1)).mp c.2⟩⟩ invFun f := ⟨equivInvolution.symm ⟨f.1, f.2.1⟩, by rw [isFull_iff_equivInvolution_no_fixed_point] simpa using f.2.2⟩ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean index 4ffbac4bb..56df380aa 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean @@ -48,8 +48,7 @@ lemma timeOrderRel_both_of_eqTimeOnly {i j : Fin φs.length} (h : {i, j} ∈ φs apply And.intro · exact timeOrderRel_of_eqTimeOnly_pair φsΛ h hc · apply timeOrderRel_of_eqTimeOnly_pair φsΛ _ hc - rw [@Finset.pair_comm] - exact h + simpa [@Finset.pair_comm] using h lemma eqTimeOnly_iff_forall_finset {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) : φsΛ.EqTimeOnly ↔ ∀ (a : φsΛ.1), @@ -109,9 +108,8 @@ lemma staticContract_eq_timeContract_of_eqTimeOnly (h : φsΛ.EqTimeOnly) : simp only [List.get_eq_getElem] rw [timeContract_of_timeOrderRel] apply timeOrderRel_of_eqTimeOnly_pair φsΛ - rw [← finset_eq_fstFieldOfContract_sndFieldOfContract] - exact a.2 - exact h + · simp [← finset_eq_fstFieldOfContract_sndFieldOfContract, a.2] + · exact h lemma eqTimeOnly_congr {φs φs' : List 𝓕.FieldOp} (h : φs = φs') (φsΛ : WickContraction φs.length) : (congr (by simp [h]) φsΛ).EqTimeOnly (φs := φs') ↔ φsΛ.EqTimeOnly := by @@ -305,8 +303,7 @@ lemma haveEqTime_iff_finset {φs : List 𝓕.FieldOp} (φsΛ : WickContraction use φsΛ.fstFieldOfContract ⟨a, h1⟩ use φsΛ.sndFieldOfContract ⟨a, h1⟩ simp_all only [and_true, true_and] - rw [← finset_eq_fstFieldOfContract_sndFieldOfContract] - exact h1 + simpa [← finset_eq_fstFieldOfContract_sndFieldOfContract] using h1 @[simp] lemma empty_not_haveEqTime {φs : List 𝓕.FieldOp} : @@ -491,8 +488,7 @@ lemma join_haveEqTime_of_eqTimeOnly_nonEmpty {φs : List 𝓕.FieldOp} (φsΛ : use i, j simp_all only [ne_eq, true_or, true_and] apply h1 j i - rw [Finset.pair_comm] - exact h + simpa [Finset.pair_comm] using h lemma hasEqTimeEquiv_ext_sigma {φs : List 𝓕.FieldOp} {x1 x2 : Σ (φsΛ : {φsΛ : WickContraction φs.length // φsΛ.EqTimeOnly ∧ φsΛ ≠ empty}), From c6412086ec56f83961963111b2f1db3e6fc601e6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:50:59 -0700 Subject: [PATCH 294/498] refactor: golf canonical ensemble wrappers Co-authored-by: Claude Opus 4.8 --- .../StatisticalMechanics/CanonicalEnsemble/Basic.lean | 9 +++------ .../StatisticalMechanics/CanonicalEnsemble/Finite.lean | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 62d794775..8d3dc1866 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -370,8 +370,7 @@ lemma μBolt_ne_zero_of_μ_ne_zero (T : Temperature) (h : 𝓒.μ ≠ 0) : simp only [Measure.coe_zero, Pi.zero_apply] have hs : {x | ENNReal.ofReal (rexp (-(↑T.β * 𝓒.energy x))) ≠ 0} = Set.univ := by ext i - simp only [ne_eq, ENNReal.ofReal_eq_zero, not_le, Set.mem_setOf_eq, Set.mem_univ, iff_true] - exact exp_pos _ + simp [ENNReal.ofReal_eq_zero, exp_pos] conv => enter [1, s] rw [MeasureTheory.withDensity_apply_eq_zero' (by fun_prop), hs] @@ -449,8 +448,7 @@ lemma mathematicalPartitionFunction_eq_zero_iff (T : Temperature) [IsFiniteMeasu let s : Set ι := {x | 0 < rexp (-(T.β * 𝓒.energy x))} have h : s = Set.univ := by ext i - simp [s] - exact exp_pos (-(T.β * 𝓒.energy i)) + simpa [s] using exp_pos (-(T.β * 𝓒.energy i)) change 𝓒.μ s = 0 ↔ 𝓒.μ = 0 rw [h] simp only [Measure.measure_univ_eq_zero] @@ -598,8 +596,7 @@ lemma integrable_energy_congr (T : Temperature) (e : ι1 ≃ᵐ ι) Integrable (𝓒.congr e).energy ((𝓒.congr e).μProd T) := by simp [μProd_congr] refine (integrable_map_equiv e.symm (𝓒.congr e).energy).mpr ?_ - simp only [congr_energy_comp_symmm] - exact h + simpa only [congr_energy_comp_symmm] using h @[fun_prop] lemma integrable_energy_nsmul (n : ℕ) (T : Temperature) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index 06fdbfe4b..c1223820b 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -179,8 +179,7 @@ lemma μBolt_of_fintype (T : Temperature) [IsFinite 𝓒] (i : ι) : rw [μBolt] simp only [neg_mul] rw [@measureReal_def] - simp [IsFinite.μ_eq_count] - exact Real.exp_nonneg _ + simpa [IsFinite.μ_eq_count] using Real.exp_nonneg _ instance {T} [IsFinite 𝓒] : IsFiniteMeasure (𝓒.μBolt T) := by simpa [μBolt] using isFiniteMeasure_withDensity_ofReal HasFiniteIntegral.of_finite @@ -265,8 +264,7 @@ lemma entropy_nonneg [MeasurableSingletonClass ι] [IsFinite 𝓒] [Nonempty ι] Fintype.sum_nonpos fun i => mul_nonpos_iff.2 <| Or.inl ⟨probability_nonneg_finite 𝓒 T i, Real.log_nonpos (probability_nonneg_finite 𝓒 T i) (probability_le_one 𝓒 T i)⟩ - rw [shannonEntropy, neg_mul, neg_nonneg] - exact mul_nonpos_iff.2 <| Or.inl ⟨kB_pos.le, hsum⟩ + simpa [shannonEntropy, neg_mul, neg_nonneg] using mul_nonpos_iff.2 <| Or.inl ⟨kB_pos.le, hsum⟩ lemma shannonEntropy_eq_differentialEntropy [MeasurableSingletonClass ι] [IsFinite 𝓒] (T : Temperature) : From 45a10c195159e3055fd951e23343666e63a2faa4 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 01:55:19 -0700 Subject: [PATCH 295/498] refactor: golf tensor and Wick wrappers Co-authored-by: Claude Opus 4.8 --- .../WickContraction/UncontractedList.lean | 6 ++---- Physlib/Relativity/LorentzGroup/Boosts/Basic.lean | 6 ++---- Physlib/Relativity/SL2C/Basic.lean | 3 +-- Physlib/Relativity/Tensors/MetricTensor.lean | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index ae51b46af..af27c1a35 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -235,8 +235,7 @@ lemma uncontractedList_eq_sort (c : WickContraction n) : lemma uncontractedList_length_eq_card (c : WickContraction n) : c.uncontractedList.length = c.uncontracted.card := by - rw [uncontractedList_eq_sort] - exact Finset.length_sort fun x1 x2 => x1 ≤ x2 + simp [uncontractedList_eq_sort] lemma filter_uncontractedList (c : WickContraction n) (p : Fin n → Prop) [DecidablePred p] : (c.uncontractedList.filter p) = (c.uncontracted.filter p).sort (· ≤ ·) := by @@ -286,8 +285,7 @@ lemma uncontractedIndexEquiv_symm_eq_filter_length (k : c.uncontracted) : rw [fin_list_sorted_indexOf_mem] · simp · exact uncontractedList_sorted c - · rw [uncontractedList_mem_iff] - exact k.2 + · simp [uncontractedList_mem_iff, k.2] lemma take_uncontractedIndexEquiv_symm (k : c.uncontracted) : c.uncontractedList.take (c.uncontractedIndexEquiv.symm k).val = diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean index bc226a563..58aae9217 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Basic.lean @@ -30,8 +30,7 @@ def γ (β : ℝ) : ℝ := 1 / Real.sqrt (1 - β^2) lemma γ_sq (β : ℝ) (hβ : |β| < 1) : (γ β)^2 = 1 / (1 - β^2) := by simp only [γ, one_div, inv_pow, _root_.inv_inj] refine Real.sq_sqrt ?_ - simp only [sub_nonneg, sq_le_one_iff_abs_le_one] - exact le_of_lt hβ + simpa only [sub_nonneg, sq_le_one_iff_abs_le_one] using le_of_lt hβ @[simp] lemma γ_zero : γ 0 = 1 := by simp [γ] @@ -241,8 +240,7 @@ lemma boost_inr_other_inr {i j k : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j lemma boost_inr_inr_other {i j k : Fin d} {β : ℝ} (hβ : |β| < 1) (hij : j ≠ i) : (boost i β hβ).1 (Sum.inr k) (Sum.inr j) = if j = k then 1 else 0:= by rw [← boost_transpose_eq_self] - simp only [transpose, transpose_apply] - exact boost_inr_other_inr hβ hij + simpa only [transpose, transpose_apply] using boost_inr_other_inr hβ hij /-! ## Properties of boosts in the zero-direction diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index e8f415116..fda7a6809 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -234,8 +234,7 @@ lemma toLorentzGroup_fst_col (M : SL(2, ℂ)) : refine sub_eq_zero.mp ?_ refine Fintype.linearIndependent_iff.mp PauliMatrix.pauliBasis'.linearIndependent (fun x => ((toLorentzGroup M).1 x (Sum.inl 0) - k x)) ?_ μ - simp only [sub_smul] - exact h1x + simpa only [sub_smul] using h1x /-- The first element of the image of `SL(2, ℂ)` in the Lorentz group. -/ lemma toLorentzGroup_inl_inl (M : SL(2, ℂ)) : diff --git a/Physlib/Relativity/Tensors/MetricTensor.lean b/Physlib/Relativity/Tensors/MetricTensor.lean index d2ca771d4..dcbfe32e7 100644 --- a/Physlib/Relativity/Tensors/MetricTensor.lean +++ b/Physlib/Relativity/Tensors/MetricTensor.lean @@ -68,8 +68,7 @@ lemma contrT_metricTensor_metricTensor {c : C} : rw [metricTensor, metricTensor, fromConstPair, fromConstPair] rw [fromPairT_contr_fromPairT_eq_fromPairTContr] erw [fromPairTContr_metric_metric_eq_permT_unit] - rw [permT_permT] - rfl + simp [permT_permT] lemma contrT_metricTensor_metricTensor_eq_dual_unit {c : C} : contrT 2 1 2 (by simp; rfl) (prodT (metricTensor c) (metricTensor (S.τ c))) = From 3ae8efdd16da81cef9eecb250cb6ea729ac3f530 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:03:58 -0700 Subject: [PATCH 296/498] refactor: golf oscillator and tensor wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean | 3 +-- Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean | 3 +-- Physlib/Relativity/LorentzGroup/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean | 3 +-- Physlib/SpaceAndTime/Time/TimeUnit.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 459c4035c..3dc7dc1b9 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -296,8 +296,7 @@ lemma isCriticallyDamped_decayRate (hS : S.IsCriticallyDamped) : S.ω = S.decayR nlinarith exact ne_of_gt hm_sq_pos have hsq : S.decayRate^2 = S.ω^2 := by - have hsub : S.decayRate^2 - S.ω^2 = 0 := by - exact (mul_eq_zero.mp hS).resolve_left hm_sq_ne_zero + have hsub : S.decayRate^2 - S.ω^2 = 0 := (mul_eq_zero.mp hS).resolve_left hm_sq_ne_zero linarith nlinarith [S.decayRate_nonneg, S.ω_pos] diff --git a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean index 1b14565bd..57ecc5cec 100644 --- a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean @@ -110,8 +110,7 @@ noncomputable def tangentInnerCore (g : RiemannianMetric I n M) (x : M) : InnerProductSpace.Core ℝ (TangentSpace I x) where inner := λ v w => g.inner x v w conj_inner_symm := λ v w => by - simp only [inner_apply, conj_trivial] - exact g.toPseudoRiemannianMetric.symm x w v + simpa only [inner_apply, conj_trivial] using g.toPseudoRiemannianMetric.symm x w v re_inner_nonneg := λ v => by simp only [inner_apply, RCLike.re_to_real] by_cases hv : v = 0 diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 6402fc26e..44886c726 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -62,8 +62,7 @@ variable {Λ Λ' : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ} lemma mem_iff_self_mul_dual : Λ ∈ LorentzGroup d ↔ Λ * dual Λ = 1 := Iff.rfl lemma mem_iff_dual_mul_self : Λ ∈ LorentzGroup d ↔ dual Λ * Λ = 1 := by - rw [mem_iff_self_mul_dual] - exact _root_.mul_eq_one_comm + simpa [mem_iff_self_mul_dual] using (_root_.mul_eq_one_comm (a := Λ) (b := dual Λ)) lemma mem_iff_transpose : Λ ∈ LorentzGroup d ↔ Λᵀ ∈ LorentzGroup d := by refine Iff.intro (fun h ↦ ?_) (fun h ↦ ?_) diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index ab8149a5d..f88c782e5 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -71,8 +71,7 @@ instance : TopologicalSpace (Contr d) := TopologicalSpace.induced ContrMod.toFin1dℝEquiv (Pi.topologicalSpace) lemma continuous_contr {T : Type} [TopologicalSpace T] (f : T → Contr d) - (h : Continuous (fun i => (f i).toFin1dℝ)) : Continuous f := by - exact continuous_induced_rng.mpr h + (h : Continuous (fun i => (f i).toFin1dℝ)) : Continuous f := continuous_induced_rng.mpr h set_option backward.isDefEq.respectTransparency false in lemma contr_continuous {T : Type} [TopologicalSpace T] (f : Contr d → T) diff --git a/Physlib/SpaceAndTime/Time/TimeUnit.lean b/Physlib/SpaceAndTime/Time/TimeUnit.lean index 2999c6db0..03a5a7d78 100644 --- a/Physlib/SpaceAndTime/Time/TimeUnit.lean +++ b/Physlib/SpaceAndTime/Time/TimeUnit.lean @@ -41,8 +41,7 @@ structure TimeUnit : Type where namespace TimeUnit @[simp] -lemma val_ne_zero (x : TimeUnit) : x.val ≠ 0 := by - exact Ne.symm (ne_of_lt x.property) +lemma val_ne_zero (x : TimeUnit) : x.val ≠ 0 := Ne.symm (ne_of_lt x.property) lemma val_pos (x : TimeUnit) : 0 < x.val := x.property From ad0684ad07374c5860ac48ec9ede688051ef9b5b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:06:04 -0700 Subject: [PATCH 297/498] refactor: golf Hermitian cfc wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index c3a67af64..4c114f526 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -33,8 +33,7 @@ variable (A : HermitianMat d 𝕜) (f : ℝ → ℝ) (g : ℝ → ℝ) (q r : /- Adding this to the `CStarAlgebra` aesop set allows `cfc_tac` to use it. -/ omit [Fintype d] [DecidableEq d] in @[aesop safe apply (rule_sets := [CStarAlgebra])] -theorem isSelfAdjoint : IsSelfAdjoint A.mat := by - exact A.H +theorem isSelfAdjoint : IsSelfAdjoint A.mat := A.H /- Adding this to `fun_prop` allows `cfc_cont_tac` to use it. -/ @[fun_prop] @@ -43,8 +42,7 @@ theorem continuousOn_finite {α β : Type*} (f : α → β) (S : Set α) simpa [continuousOn_iff_continuous_restrict] using continuous_of_discreteTopology @[simp] -theorem conjTranspose_cfc : (cfc f A.mat).conjTranspose = cfc f A.mat := by - exact cfc_predicate f A.mat +theorem conjTranspose_cfc : (cfc f A.mat).conjTranspose = cfc f A.mat := cfc_predicate f A.mat protected def cfc : HermitianMat d 𝕜 := ⟨cfc f A.mat, cfc_predicate _ _⟩ @@ -90,8 +88,7 @@ variable {A B : HermitianMat d 𝕜} @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.cfc_left (hAB : Commute A.mat B.mat) : - Commute (A.cfc f).mat B.mat := by - exact hAB.cfc_real f + Commute (A.cfc f).mat B.mat := hAB.cfc_real f @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.cfc_right (hAB : Commute A.mat B.mat) : @@ -99,8 +96,7 @@ theorem _root_.Commute.cfc_right (hAB : Commute A.mat B.mat) : (hAB.symm.cfc_left f).symm theorem cfc_commute (f g : ℝ → ℝ) (hAB : Commute A.mat B.mat) : - Commute (A.cfc f).mat (B.cfc g).mat := by - exact (hAB.cfc_right g).cfc_left f + Commute (A.cfc f).mat (B.cfc g).mat := (hAB.cfc_right g).cfc_left f @[aesop safe apply (rule_sets := [Commutes])] theorem cfc_self_commute (A : HermitianMat d 𝕜) (f g : ℝ → ℝ) : @@ -117,8 +113,7 @@ theorem cfc_reindex (e : d ≃ d₂) : (A.reindex e).cfc f = (A.cfc f).reindex e exact Matrix.cfc_reindex f e theorem spectrum_cfc_eq_image (A : HermitianMat d 𝕜) (f : ℝ → ℝ) : - spectrum ℝ (A.cfc f).mat = f '' (spectrum ℝ A.mat) := by - exact cfc_map_spectrum f A.mat + spectrum ℝ (A.cfc f).mat = f '' (spectrum ℝ A.mat) := cfc_map_spectrum f A.mat set_option backward.isDefEq.respectTransparency false in /-- From 32786f809d63de835724153d28abecd0a309aa4d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:07:37 -0700 Subject: [PATCH 298/498] refactor: golf Hermitian rpow witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index be5017991..4911fcbae 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -184,10 +184,8 @@ lemma rpow_inv_eq_neg_rpow (hA : A.mat.PosDef) (p : ℝ) : (A ^ p)⁻¹ = A ^ (- ext i j; have h_inv : (A ^ p).mat * (A ^ (-p)).mat = 1 := by have h_inv : (A ^ p).mat * (A ^ (-p)).mat = 1 := by - have h_pow : (A ^ p).mat = A.cfc (fun x => x ^ p) := by - exact rfl - have h_pow_neg : (A ^ (-p)).mat = A.cfc (fun x => x ^ (-p)) := by - exact rfl + have h_pow : (A ^ p).mat = A.cfc (fun x => x ^ p) := rfl + have h_pow_neg : (A ^ (-p)).mat = A.cfc (fun x => x ^ (-p)) := rfl have h_inv : (A ^ p).mat * (A ^ (-p)).mat = A.cfc (fun x => x ^ p * x ^ (-p)) := by rw [ h_pow, h_pow_neg, ← mat_cfc_mul ]; rfl; @@ -229,8 +227,7 @@ lemma rpow_neg_mul_rpow_self (hA : A.mat.PosDef) (p : ℝ) : open ComplexOrder in lemma isUnit_rpow_toMat (hA : A.mat.PosDef) (p : ℝ) : IsUnit (A ^ p).mat := by have hA_inv : IsUnit (A ^ (-p)).mat := by - have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := by - exact rpow_neg_mul_rpow_self hA p + have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := rpow_neg_mul_rpow_self hA p exact IsUnit.of_mul_eq_one _ hA_inv -- Since $(A^{-p}) (A^p) = 1$, we have that $(A^p)$ is the inverse of $(A^{-p})$. have hA_inv : (A ^ p).mat = (A ^ (-p)).mat⁻¹ := by @@ -443,8 +440,7 @@ theorem rpowApprox_eq_cfc_scalar (A : HermitianMat d ℂ) (hA : A.mat.PosDef) (q exact fun {f} hf => inv_cfc_eq_cfc_inv f hf apply h_inv_smul intro i - have h_eigenvalue_pos : 0 < A.H.eigenvalues i := by - exact Matrix.PosDef.eigenvalues_pos hA i + have h_eigenvalue_pos : 0 < A.H.eigenvalues i := Matrix.PosDef.eigenvalues_pos hA i exact ne_of_gt (add_pos h_eigenvalue_pos ht.left); rw [h_inv_def, h_inv_comp]; exact h_inv @@ -457,8 +453,7 @@ theorem rpowApprox_eq_cfc_scalar (A : HermitianMat d ℂ) (hA : A.mat.PosDef) (q have h_integrable : ∀ u : d, IntervalIntegrable (fun t : ℝ => t ^ q * (1 / (1 + t) - 1 / (A.H.eigenvalues u + t))) volume 0 T := by intro u have h_integrable : IntervalIntegrable (fun t : ℝ => t ^ q * (1 / (1 + t) - 1 / (A.H.eigenvalues u + t))) volume 0 T := by - have h_pos : 0 < A.H.eigenvalues u := by - exact Matrix.PosDef.eigenvalues_pos hA u + have h_pos : 0 < A.H.eigenvalues u := Matrix.PosDef.eigenvalues_pos hA u exact ContinuousOn.intervalIntegrable ( by exact ContinuousOn.mul ( continuousOn_id.rpow_const fun x hx => Or.inr <| by linarith ) <| ContinuousOn.sub ( continuousOn_const.div ( continuousOn_const.add continuousOn_id ) fun x hx => by linarith [ Set.mem_Icc.mp <| by simpa [ hT.le ] using hx ] ) ( continuousOn_const.div ( continuousOn_const.add continuousOn_id ) fun x hx => by linarith [ Set.mem_Icc.mp <| by simpa [ hT.le ] using hx ] ) ) ..; exact h_integrable exact integral_cfc_eq_cfc_integral _ _ _ h_integrable From fb69087ba6042d7d3b20fcc885783da1a0176fb1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:09:07 -0700 Subject: [PATCH 299/498] refactor: golf Hermitian cfc local witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 4c114f526..5dead216b 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -732,11 +732,9 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} (hg : ContinuousOn g T) (hA₀ : spectrum ℝ A₀.mat ⊆ T) : ContinuousWithinAt (fun B ↦ B.cfc g) {B | spectrum ℝ B.mat ⊆ T} A₀ := by have h_ext : ∃ h : ℝ → ℝ, Continuous h ∧ ∀ x ∈ spectrum ℝ A₀.mat, h x = g x := by - have h_finite : Set.Finite (spectrum ℝ A₀.mat) := by - exact Set.toFinite _ + have h_finite : Set.Finite (spectrum ℝ A₀.mat) := Set.toFinite _ generalize_proofs at *; ( - have h_cont : ContinuousOn g (spectrum ℝ A₀.val) := by - exact hg.mono hA₀ + have h_cont : ContinuousOn g (spectrum ℝ A₀.val) := hg.mono hA₀ generalize_proofs at *; ( have := @ContinuousMap.exists_restrict_eq ℝ; specialize this ( show IsClosed ( spectrum ℝ A₀.val ) from h_finite.isClosed ) ( ContinuousMap.mk ( fun x => g x ) <| by exact continuousOn_iff_continuous_restrict.mp h_cont ) ; rcases this with ⟨ h, hh ⟩ ; exact ⟨ h, h.continuous, fun x hx => by simpa using congr_arg ( fun f => f ⟨ x, hx ⟩ ) hh ⟩ ;)); @@ -754,8 +752,7 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} simpa [ hh_eq y hy ] using h_diff_small.abs; have := Metric.tendsto_nhdsWithin_nhds.mp h_diff_small ( ε / ( Real.sqrt ( Fintype.card d ) + 1 ) ) ( div_pos ε_pos ( add_pos_of_nonneg_of_pos ( Real.sqrt_nonneg _ ) zero_lt_one ) ) ; aesop; choose! δ hδ_pos hδ using h_diff_small; - have h_finite : Set.Finite (spectrum ℝ A₀.mat) := by - exact Set.toFinite _; + have h_finite : Set.Finite (spectrum ℝ A₀.mat) := Set.toFinite _; obtain ⟨δ_min, hδ_min_pos, hδ_min⟩ : ∃ δ_min > 0, ∀ y ∈ spectrum ℝ A₀.mat, δ_min ≤ δ y := by by_cases h_empty : spectrum ℝ A₀.mat = ∅; · exact ⟨ 1, zero_lt_one, by simp [ h_empty ] ⟩; @@ -765,8 +762,7 @@ lemma continuousWithinAt_cfc_of_continuousOn {T : Set ℝ} {g : ℝ → ℝ} -- By the spectrum_subset_of_isOpen lemma, there exists a neighborhood U of A₀ such that the spectrum of B is within δ of the spectrum of A₀ for all B in U. obtain ⟨U, hU⟩ : ∃ U ∈ nhds A₀, ∀ B ∈ U, spectrum ℝ B.mat ⊆ {x | ∃ y ∈ spectrum ℝ A₀.mat, |x - y| < δ} := by have h_spectrum_subset : ∀ᶠ B in nhds A₀, spectrum ℝ B.mat ⊆ Metric.thickening δ (spectrum ℝ A₀.mat) := by - have h_open : IsOpen (Metric.thickening δ (spectrum ℝ A₀.mat)) := by - exact Metric.isOpen_thickening + have h_open : IsOpen (Metric.thickening δ (spectrum ℝ A₀.mat)) := Metric.isOpen_thickening have := spectrum_subset_of_isOpen A₀ ( Metric.thickening δ ( spectrum ℝ A₀.mat ) ) h_open ( Metric.self_subset_thickening δ_pos _ ) ; aesop; generalize_proofs at *; ( exact ⟨ _, h_spectrum_subset, fun B hB => fun x hx => by simpa [ dist_eq_norm ] using Metric.mem_thickening_iff.mp ( hB hx ) ⟩) @@ -868,8 +864,7 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] choose U_i V_i hU_i hV_i hx₀_i hV_i_i h_cont_i using h_cont; exact ⟨ U_i, V_i, hU_i, hV_i, hx₀_i, hV_i_i, h_cont_i ⟩ ;); -- The open set W := ⋃ᵢ V_i contains spectrum(A x₀) (since each λᵢ ∈ V_i and spectrum = range of eigenvalues). W is open as a union of open sets. set W := ⋃ i, V_i i with hW_def - have hW_open : IsOpen W := by - exact isOpen_iUnion hV_i + have hW_open : IsOpen W := isOpen_iUnion hV_i have hW_spectrum : spectrum ℝ (A x₀).mat ⊆ W := by intro t ht obtain ⟨i, hi⟩ : ∃ i, t = (A x₀).H.eigenvalues i := by From 19fdd5f6494d828a2f8db08575292a5d6a6135cd Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:11:15 -0700 Subject: [PATCH 300/498] refactor: golf majorization witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/Majorization.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index 5c8324e32..36a3eff8d 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -59,8 +59,7 @@ noncomputable def singularValuesSorted (A : Matrix d d ℂ) : /-- Sorted singular values are nonneg. -/ lemma singularValuesSorted_nonneg (A : Matrix d d ℂ) (i : Fin (Fintype.card d)) : 0 ≤ singularValuesSorted A i := by - have h_nonneg : ∀ i, 0 ≤ (singularValues A i) := by - exact singularValues_nonneg A + have h_nonneg : ∀ i, 0 ≤ (singularValues A i) := singularValues_nonneg A have h_sorted_nonneg : ∀ {l : List ℝ}, (∀ x ∈ l, 0 ≤ x) → ∀ i < l.length, 0 ≤ l[i]! := by aesop contrapose! h_sorted_nonneg @@ -102,8 +101,7 @@ lemma singularValuesSorted_antitone (A : Matrix d d ℂ) : lemma antitone_mul_of_antitone_nonneg {n : ℕ} {f g : Fin n → ℝ} (hf : Antitone f) (hg : Antitone g) (hf_nn : ∀ i, 0 ≤ f i) (hg_nn : ∀ i, 0 ≤ g i) : - Antitone (fun i => f i * g i) := by - exact fun i j hij => mul_le_mul (hf hij) (hg hij) (hg_nn _) (hf_nn _) + Antitone (fun i => f i * g i) := fun _ _ hij => mul_le_mul (hf hij) (hg hij) (hg_nn _) (hf_nn _) /-! ### Compound matrices and auxiliary lemmas for Horn's inequality @@ -201,15 +199,13 @@ lemma cauchyBinet {m : ℕ} {n : Type*} [Fintype n] [DecidableEq n] [LinearOrder obtain ⟨a, ha⟩ : ∃ a : Fin m → Fin m, ∀ i, σ i = S.val.orderEmbOfFin S.property (a i) := by have h_exists_a : ∀ i, ∃ a : Fin m, σ i = S.val.orderEmbOfFin S.property a := by intro i - have h_exists_a : σ i ∈ S.val := by - exact hσ.2 ▸ Finset.mem_image_of_mem _ (Finset.mem_univ _) + have h_exists_a : σ i ∈ S.val := hσ.2 ▸ Finset.mem_image_of_mem _ (Finset.mem_univ _) have h_exists_a : Finset.image (fun a : Fin m => S.val.orderEmbOfFin S.property a) Finset.univ = S.val := by refine' Finset.eq_of_subset_of_card_le (Finset.image_subset_iff.mpr fun a _ => Finset.orderEmbOfFin_mem _ _ _) _ rw [Finset.card_image_of_injective _ fun a b h => by simpa [Fin.ext_iff] using h]; simp [S.2] grind exact ⟨fun i => Classical.choose (h_exists_a i), fun i => Classical.choose_spec (h_exists_a i)⟩ - have ha_inj : Function.Injective a := by - exact fun i j hij => hσ.1 <| by simp [ha, hij] + have ha_inj : Function.Injective a := fun i j hij => hσ.1 <| by simp [ha, hij] exact ⟨Equiv.ofBijective a ⟨ha_inj, Finite.injective_iff_surjective.mp ha_inj⟩, funext fun i => ha i ▸ rfl⟩ · rintro ⟨a, rfl⟩ constructor @@ -799,8 +795,7 @@ lemma horn_weak_log_majorization (A B : Matrix d d ℂ) (k : ℕ) lemma rpow_antitone_of_nonneg_antitone {n : ℕ} {f : Fin n → ℝ} (hf : Antitone f) (hf_nn : ∀ i, 0 ≤ f i) {r : ℝ} (hr : 0 < r) : - Antitone (fun i => f i ^ r) := by - exact fun i j hij => Real.rpow_le_rpow (hf_nn _) (hf hij) hr.le + Antitone (fun i => f i ^ r) := fun _ _ hij => Real.rpow_le_rpow (hf_nn _) (hf hij) hr.le /-- Weak log-majorization is preserved under positive powers. -/ lemma rpow_preserves_weak_log_maj {n : ℕ} From 5ac886c0ebf47c1261e41b7146257135224b55bf Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:12:50 -0700 Subject: [PATCH 301/498] refactor: golf relative entropy witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index d168bb412..ef14c9295 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -311,8 +311,7 @@ lemma HermitianMat.mul_supportProj_of_ker_le {A B : HermitianMat d ℂ} (h : LinearMap.ker B.lin.toLinearMap ≤ LinearMap.ker A.lin.toLinearMap) : A.mat * B.supportProj.mat = A.mat := by -- Since $B.supportProj$ is the projection onto $range B$, we have $B.supportProj * B.mat = B.mat$. - have h_supportProj_mul_B : B.supportProj.mat * B.mat = B.mat := by - exact supportProj_mul_self B + have h_supportProj_mul_B : B.supportProj.mat * B.mat = B.mat := supportProj_mul_self B have h_range_A_subset_range_B : LinearMap.range A.lin.toLinearMap ≤ LinearMap.range B.lin.toLinearMap := by have h_orthogonal_complement : LinearMap.range (B.lin : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d) = (LinearMap.ker (B.lin : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d))ᗮ := by have h_orthogonal_complement : ∀ (T : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d), T = T.adjoint → LinearMap.range T = (LinearMap.ker T)ᗮ := by @@ -505,10 +504,8 @@ private lemma trace_conj_eq_inner_rpow {ρ σ : MState d} {t : ℝ} (ht : t ≠ rw [ h_cyclic, two_mul ] ring_nf have h_exp : (σ.M ^ (t + t)).mat = (σ.M ^ t).mat * (σ.M ^ t).mat := by - have h_nonneg : 0 ≤ σ.M := by - exact σ.nonneg - have h_ne_zero : t + t ≠ 0 := by - exact fun h => ht ( by linarith ) + have h_nonneg : 0 ≤ σ.M := σ.nonneg + have h_ne_zero : t + t ≠ 0 := fun h => ht ( by linarith ) exact HermitianMat.mat_rpow_add h_nonneg h_ne_zero rw [ mul_two, h_exp ] have h_inner : ⟪ρ.M, σ.M ^ (2 * t)⟫ = ((ρ.M.mat * (σ.M ^ (2 * t)).mat).trace).re := rfl @@ -1933,8 +1930,7 @@ private lemma eigenWeight_eq_zero_iff (ρ x : MState d) (i : d) : intro v w have h_inner : star v ⬝ᵥ (ρ.M.mat.mulVec w) = star (star w ⬝ᵥ (ρ.M.mat.mulVec v)) := by have h_inner : star v ⬝ᵥ (ρ.M.mat.mulVec w) = star (star w ⬝ᵥ (ρ.M.mat.mulVec v)) := by - have h_inner : ρ.M.mat = star ρ.M.mat := by - exact ρ.M.2.symm ▸ rfl + have h_inner : ρ.M.mat = star ρ.M.mat := ρ.M.2.symm ▸ rfl conv_rhs => rw [ h_inner ] simp [ Matrix.mulVec, dotProduct ] ring_nf @@ -1952,8 +1948,7 @@ private lemma eigenWeight_eq_zero_iff (ρ x : MState d) (i : d) : refine ⟨h_forward, fun h ↦ ?_⟩ -- Since ρ e_i = 0, we have e_i^* ρ e_i = 0. have h_zero : (Matrix.vecMul (star (x.M.H.eigenvectorBasis i : d → ℂ)) ρ.M.mat) ⬝ᵥ (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := by - have h_zero : ρ.M.mat.mulVec (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := by - exact congr(WithLp.ofLp $h) + have h_zero : ρ.M.mat.mulVec (x.M.H.eigenvectorBasis i : d → ℂ) = 0 := congr(WithLp.ofLp $h) convert congr_arg ( fun v => star ( x.M.H.eigenvectorBasis i : d → ℂ ) ⬝ᵥ v ) h_zero using 1 simp [ Matrix.dotProduct_mulVec] ring_nf From 56564fca8551e56f4540ea60afd6a01da86cfbbe Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:14:23 -0700 Subject: [PATCH 302/498] refactor: golf entropy DPI witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/DPI.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index e4d41665c..625aca836 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -316,8 +316,7 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} simp [add_comm] simp [← Matrix.ext_iff] intro i j; exact (by - have h_support : A.kerProj + A.supportProj = 1 := by - exact kerProj_add_supportProj A + have h_support : A.kerProj + A.supportProj = 1 := kerProj_add_supportProj A convert! congr_arg (fun f => f i j) h_support using 1) rw [← Matrix.add_mulVec, h_support, Matrix.one_mulVec] have hsup : B.mat *ᵥ (A.kerProj.mat *ᵥ x.ofLp) = 0 := by @@ -325,8 +324,7 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} have h_support : A.mat * A.kerProj.mat = 0 := by have h_support : A.mat * A.kerProj.mat = A.mat * (1 - A.supportProj.mat) := by congr - have h_support : A.kerProj + A.supportProj = 1 := by - exact kerProj_add_supportProj A + have h_support : A.kerProj + A.supportProj = 1 := kerProj_add_supportProj A exact eq_sub_of_add_eq <| congr_arg Subtype.val h_support rw [h_support, mul_sub, mul_one, sub_eq_zero] exact Eq.symm (mul_supportProj_of_ker_le fun ⦃x⦄ a => a) @@ -341,8 +339,7 @@ lemma supportProj_mul_of_ker_le {A B : HermitianMat d ℂ} · simp [Matrix.mulVec, dotProduct] · simp [Matrix.mulVec, dotProduct] rfl - have h_support : B.mat = B.mat.conjTranspose := by - exact B.2.symm + have h_support : B.mat = B.mat.conjTranspose := B.2.symm have h_support : (B.mat * A.supportProj.mat).conjTranspose = A.supportProj.mat * B.mat := by simp [Matrix.conjTranspose_mul] lia @@ -847,8 +844,7 @@ theorem sandwichedTraceFunctional_self (hα : 0 < α) (ρ : MState d) : · exact div_ne_zero (sub_ne_zero_of_ne (Ne.symm h)) (mul_ne_zero two_ne_zero hα.ne') · nlinarith [mul_div_cancel₀ (1 - α) (by positivity : (2 * α) ≠ 0)] have h_simp : (ρ.M ^ (1 + 2 * ((1 - α) / (2 * α)))) ^ α = - ρ.M ^ ((1 + 2 * ((1 - α) / (2 * α))) * α) := by - exact (HermitianMat.rpow_mul (le_of_lt this)).symm + ρ.M ^ ((1 + 2 * ((1 - α) / (2 * α))) * α) := (HermitianMat.rpow_mul (le_of_lt this)).symm field_simp at * simp_all only [add_sub_cancel, one_div, rpow_one, MState.tr] @@ -1235,8 +1231,7 @@ theorem sandwichedRenyiEntropy_conj_unitary (hα : 0 < α) (ρ σ : MState d) · use (U.val.conjTranspose.toEuclideanLin x) simp_all [ker, Matrix.toEuclideanLin] simp_all [lin, Matrix.toLpLin] - have h_unitary : (U.val * U.val.conjTranspose) = 1 := by - exact U.2.2 + have h_unitary : (U.val * U.val.conjTranspose) = 1 := U.2.2 generalize_proofs at *; ( apply_fun (U.val.conjTranspose *ᵥ ·) at hx simp_all [Matrix.mul_assoc, Matrix.mulVec_mulVec] From d4d5ea10a501beee25eaac05003f186101243862 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:16:02 -0700 Subject: [PATCH 303/498] refactor: golf Hermitian order and log witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 6 ++---- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 7dfea8744..2b3cd9e10 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -62,8 +62,7 @@ theorem reindex_exp (e : d ≃ d₂) : (A.reindex e).exp = A.exp.reindex e := cfc_reindex A Real.exp e variable (A) in -instance nonSingular_exp : NonSingular A.exp := by - exact cfc_nonSingular A Real.exp (fun i ↦ by positivity) +instance nonSingular_exp : NonSingular A.exp := cfc_nonSingular A Real.exp (fun i ↦ by positivity) /-- The matrix exponential of a Hermitian matrix is nonnegative. -/ theorem exp_nonneg (A : HermitianMat d 𝕜) : 0 ≤ A.exp := by @@ -446,8 +445,7 @@ lemma inv_convex {x y : HermitianMat d 𝕜} (hx : x.mat.PosDef) (hy : y.mat.Pos have h_block_pos : ∀ A : Matrix d d 𝕜, A.PosDef → (Matrix.fromBlocks A 1 1 A⁻¹).PosSemidef := by intro A hA have h_block_pos : (Matrix.fromBlocks A (1 : Matrix d d 𝕜) (1 : Matrix d d 𝕜) (A⁻¹)).PosSemidef := by - have h_inv_pos : A⁻¹.PosSemidef := by - exact hA.inv.posSemidef + have h_inv_pos : A⁻¹.PosSemidef := hA.inv.posSemidef have h_block_pos : (Matrix.fromBlocks A (1 : Matrix d d 𝕜) (1 : Matrix d d 𝕜) (A⁻¹)) = (Matrix.fromBlocks 1 0 A⁻¹ 1) * (Matrix.fromBlocks A 0 0 (A⁻¹ - A⁻¹ * A * A⁻¹)) * (Matrix.fromBlocks 1 A⁻¹ 0 1) := by simp [ Matrix.fromBlocks_multiply ]; have := hA.det_pos; diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 749d84b9c..cacab4736 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -72,8 +72,7 @@ theorem posSemidef_iff_spectrum_Ici [DecidableEq n] (A : HermitianMat n 𝕜) : simp [A.H, Set.Ici.eq_1] theorem posSemidef_iff_spectrum_nonneg [DecidableEq n] (A : HermitianMat n 𝕜) : - 0 ≤ A ↔ ∀ x ∈ spectrum ℝ A.mat, 0 ≤ x := by - exact A.posSemidef_iff_spectrum_Ici + 0 ≤ A ↔ ∀ x ∈ spectrum ℝ A.mat, 0 ≤ x := A.posSemidef_iff_spectrum_Ici theorem trace_nonneg (hA : 0 ≤ A) : 0 ≤ A.trace := by exact (RCLike.nonneg_iff.mp (zero_le_iff.mp hA).trace_nonneg).1 @@ -154,8 +153,7 @@ theorem kronecker_pos {A : HermitianMat m 𝕜} (hA : 0 < A) (hB : 0 < B) : 0 < omit [Fintype n] in open MatrixOrder in -theorem posSemidef_to_nonneg {A : Matrix n n 𝕜} (hA : A.PosSemidef) : 0 ≤ A := by - exact hA.nonneg +theorem posSemidef_to_nonneg {A : Matrix n n 𝕜} (hA : A.PosSemidef) : 0 ≤ A := hA.nonneg open MatrixOrder in theorem posDef_to_pos {A : Matrix n n 𝕜} (hA : A.PosDef) [Nonempty n] : 0 < A := by @@ -234,8 +232,7 @@ omit [Fintype n] in theorem mat_posSemidef_to_nonneg (hA : A.mat.PosSemidef) : 0 ≤ A := zero_le_iff.mpr hA -theorem mat_posDef_to_pos [Nonempty n] (hA : A.mat.PosDef) : 0 < A := by - exact posDef_to_pos hA +theorem mat_posDef_to_pos [Nonempty n] (hA : A.mat.PosDef) : 0 < A := posDef_to_pos hA open Lean Meta in /-- Given an expression `e` (a `HermitianMat`) and a proof expression `p` whose type may be From 1ca20f2af77268558b736ae5ca5ebca2106ff7ff Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:18:54 -0700 Subject: [PATCH 304/498] refactor: golf Hermitian cfc and rpow witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 12 ++++-------- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 5dead216b..0b04673bc 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -181,8 +181,7 @@ theorem mat_cfc_mul : (A.cfc (f * g)).mat = A.cfc f * A.cfc g := by simp only [mat_cfc] exact cfc_mul .. -theorem mat_cfc_mul_apply : (A.cfc (fun x ↦ f x * g x)).mat = A.cfc f * A.cfc g := by - exact mat_cfc_mul .. +theorem mat_cfc_mul_apply : (A.cfc (fun x ↦ f x * g x)).mat = A.cfc f * A.cfc g := mat_cfc_mul .. nonrec theorem cfc_comp : A.cfc (g ∘ f) = (A.cfc f).cfc g := by ext1; exact cfc_comp .. @@ -881,8 +880,7 @@ lemma dist_lt_of_continuous_spectrum {X : Type*} [TopologicalSpace X] obtain ⟨U'', hU''⟩ : ∃ U'' ∈ nhds x₀, ∀ i, U'' ⊆ U_i i := by exact ⟨ ⋂ i, U_i i, Filter.mem_of_superset ( Filter.iInter_mem.mpr fun i => IsOpen.mem_nhds ( hU_i i ) ( h_cont.1 i ) ) fun x hx => by aesop, fun i => Set.iInter_subset _ i ⟩ set U := U' ∩ U'' with hU_def - have hU_mem : U ∈ nhds x₀ := by - exact Filter.inter_mem hU'.1 hU''.1 + have hU_mem : U ∈ nhds x₀ := Filter.inter_mem hU'.1 hU''.1 have hU_subset : ∀ y ∈ U ∩ S, spectrum ℝ (A y).mat ⊆ W := by exact fun y hy => hU'.2 y ⟨ hy.1.1, hy.2 ⟩ |> Set.Subset.trans <| by simp [ hW_def ] ; have hU_cont : ∀ y ∈ U ∩ S, ∀ t ∈ spectrum ℝ (A y).mat, ‖f y t - f x₀ t‖ < ε := by @@ -1232,8 +1230,7 @@ theorem inv_ge_one_of_le_one (hA : A.mat.PosDef) (h : A ≤ 1) : 1 ≤ A⁻¹ := have h_le_one : ∀ i, A.H.eigenvalues i ≤ 1 := by have h_le_one : ∀ i, A.H.eigenvalues i ≤ 1 := by intro i - have h_eigenvalue : A.mat.PosSemidef := by - exact hA.posSemidef + have h_eigenvalue : A.mat.PosSemidef := hA.posSemidef have h_eigenvalue_le_one : ∀ x : d → 𝕜, x ≠ 0 → (star x ⬝ᵥ A.mat.mulVec x) / (star x ⬝ᵥ x) ≤ 1 := by intro x hx_ne_zero have h_eigenvalue_le_one : (star x ⬝ᵥ (1 - A.mat).mulVec x) ≥ 0 := by @@ -1351,8 +1348,7 @@ lemma ker_cfc_le_ker_on_set (A.cfc f).ker ≤ A.ker := by intro x hx have h_inner : ∀ i, A.H.eigenvalues i ≠ 0 → inner ℂ (A.H.eigenvectorBasis i) x = 0 := by - have h_inner_zero : (A.cfc f).mat.mulVec x = 0 := by - exact (mem_ker_iff_mulVec_zero (A.cfc f) x).mp hx + have h_inner_zero : (A.cfc f).mat.mulVec x = 0 := (mem_ker_iff_mulVec_zero (A.cfc f) x).mp hx have h_inner_zero_expansion : ∑ i, (f (A.H.eigenvalues i) : ℂ) • inner ℂ (A.H.eigenvectorBasis i) x • A.H.eigenvectorBasis i = 0 := by convert h_inner_zero using 1; rw [ cfc_mulVec_expansion ]; diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 4911fcbae..2931944e4 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -630,8 +630,7 @@ theorem rpow_le_rpow_of_le (hA : 0 ≤ A) (hAB : A ≤ B) ring_nf simp [ Matrix.mulVec, dotProduct, Finset.mul_sum _ _ _, mul_assoc, mul_left_comm]; simp [ Matrix.one_apply] - have h_inner_nonneg : 0 ≤ star x ⬝ᵥ A.mat.mulVec x := by - exact inner_mulVec_nonneg hA x + have h_inner_nonneg : 0 ≤ star x ⬝ᵥ A.mat.mulVec x := inner_mulVec_nonneg hA x have h_inner_pos : 0 < star x ⬝ᵥ x := by simp_all exact h_inner.symm ▸ add_pos_of_nonneg_of_pos h_inner_nonneg ( mul_pos ( mod_cast hε_pos ) ( mod_cast h_inner_pos ) ) |> lt_of_lt_of_le <| le_rfl; From c66b5eadafcb166140555cfd8b82761033d93ab8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:21:08 -0700 Subject: [PATCH 305/498] refactor: golf Hermitian concavity witnesses Co-authored-by: Claude Opus 4.8 --- .../ForMathlib/HermitianMat/LiebConcavity.lean | 12 ++++-------- QuantumInfo/ForMathlib/HermitianMat/Peierls.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean index 12bf21d28..8e82a75ae 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean @@ -98,8 +98,7 @@ lemma Φ_mem_pdSet [Nonempty d] (A : HermitianMat d ℂ) (hA : A.mat.PosDef) : set_option synthInstance.maxHeartbeats 80000 in /-- `Φ` commutes with CFC for Hermitian matrices. -/ lemma Φ_cfc (A : HermitianMat d ℂ) (f : ℝ → ℝ) : - Φ (cfc f A.mat) = cfc f (Φ A.mat) := by - exact StarAlgHomClass.map_cfc Φ f A.mat (hφ := Φ_continuous) + Φ (cfc f A.mat) = cfc f (Φ A.mat) := StarAlgHomClass.map_cfc Φ f A.mat (hφ := Φ_continuous) (ha := A.H.isSelfAdjoint) set_option synthInstance.maxHeartbeats 80000 in @@ -183,8 +182,7 @@ omit [Fintype d] in /-- σ + εI → σ as ε → 0+. -/ private lemma tendsto_add_eps (σ : HermitianMat d ℂ) : Filter.Tendsto (fun ε : ℝ ↦ σ + ε • (1 : HermitianMat d ℂ)) - (nhdsWithin 0 (Set.Ioi 0)) (nhds σ) := by - exact tendsto_nhdsWithin_of_tendsto_nhds + (nhdsWithin 0 (Set.Ioi 0)) (nhds σ) := tendsto_nhdsWithin_of_tendsto_nhds (Continuous.tendsto' (by continuity) _ _ (by simp)) /-! ### Helper lemmas for the core concavity proof -/ @@ -255,8 +253,7 @@ private lemma variational_eq_optimizer have h_exp : (X ^ p) ^ ((p - 1) / p) = X ^ (p - 1) := by rw [← rpow_mul hX, mul_div_cancel₀ _ (by positivity)] have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X ^ p).trace := by - have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X * (X ^ (p - 1)).mat).trace.re := by - exact Real.ext_cauchy rfl + have h_inner : ⟪X, X ^ (p - 1)⟫_ℝ = (X * (X ^ (p - 1)).mat).trace.re := Real.ext_cauchy rfl convert h_inner using 1 have h_exp : (X ^ p).mat = X.mat * (X ^ (p - 1)).mat := by convert mat_rpow_add hX _ @@ -294,8 +291,7 @@ private lemma liebExtension_bridge [Nonempty d] rw [← traceRe_Φ_general] simp [liebExtensionTraceMap, Φ_rpow, hσ, hZ] rw [show star (Φ K.mat) = Φ K.mat from ?_] - have h_rewrite : IsSelfAdjoint (Φ K.mat) := by - exact Φ_isSelfAdjoint K + have h_rewrite : IsSelfAdjoint (Φ K.mat) := Φ_isSelfAdjoint K exact h_rewrite convert! h_joint_concave (Φ_mem_pdSet σ₁ hσ₁) (Φ_mem_pdSet σ₂ hσ₂) (Φ_mem_pdSet Z₁ hZ₁) (Φ_mem_pdSet Z₂ hZ₂) hθ₀ hθ₁ using 1 diff --git a/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean b/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean index 5db4fab2e..415346f0d 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean @@ -116,8 +116,7 @@ theorem trace_function_convex_univ (g : ℝ → ℝ) (hg : ConvexOn ℝ Set.univ -- Let $C = aA + bB$. set C : HermitianMat d ℂ := a • A + b • B -- By the properties of the trace and the convexity of $g$, we have: - have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := by - exact trace_cfc_eq C g + have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := trace_cfc_eq C g have h_sum : ∑ i, g (C.H.eigenvalues i) ≤ a * ∑ i, g ((A.conj (star C.H.eigenvectorUnitary.val)).mat i i).re + b * ∑ i, g ((B.conj (star C.H.eigenvectorUnitary.val)).mat i i |> Complex.re) := by From 82fbf02a7a2e541b9b154c77703a7010bbf7ad64 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:23:06 -0700 Subject: [PATCH 306/498] refactor: golf relativity timelike witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean | 9 +++------ .../Tensors/RealTensor/Vector/Causality/TimeLike.lean | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean index bcd0414a6..302fcf144 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean @@ -111,8 +111,7 @@ lemma genBoostAux₂_basis_minkowskiProduct (u v : Velocity d) (μ ν : Fin 1 rw [minkowskiProduct_symm] ring dsimp - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by - exact Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := Velocity.one_add_minkowskiProduct_ne_zero u v field_simp [h2] have h2 : (minkowskiProduct ↑v) u.1 = ⟪u.1, v.1⟫ₘ := by rw [minkowskiProduct_symm] simp only [map_add, _root_.smul_add, _root_.neg_smul, add_apply, _root_.neg_apply, smul_apply, @@ -130,8 +129,7 @@ lemma genBoostAux₁_basis_genBoostAux₂_minkowskiProduct (u v : Velocity d) ( ring simp only [smul_apply, map_add, Velocity.minkowskiProduct_self_eq_one, smul_eq_mul, neg_mul, neg_inj] - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by - exact Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := Velocity.one_add_minkowskiProduct_ne_zero u v field_simp [h2] rw [minkowskiProduct_symm] ring @@ -172,8 +170,7 @@ lemma basis_minkowskiProduct_genBoostAux₁_add_genBoostAux₂ (u v : Velocity d rw [genBoostAux₁_apply_basis, genBoostAux₂_apply_basis] rw [map_smul, map_smul] simp - have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := by - exact Velocity.one_add_minkowskiProduct_ne_zero u v + have h2 : (1 + ⟪u.1, v.1⟫ₘ) ≠ 0 := Velocity.one_add_minkowskiProduct_ne_zero u v field_simp ring diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean index 1febf830f..47be81f53 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean @@ -27,8 +27,7 @@ namespace Vector @[simp] lemma timelike_neg_time_component_product {d : ℕ} (v w : Vector d) (hv_neg : v (Sum.inl 0) < 0) (hw_neg : w (Sum.inl 0) < 0) : - v (Sum.inl 0) * w (Sum.inl 0) > 0 := by - exact mul_pos_of_neg_of_neg hv_neg hw_neg + v (Sum.inl 0) * w (Sum.inl 0) > 0 := mul_pos_of_neg_of_neg hv_neg hw_neg /-- For timelike vectors, the Minkowski inner product is positive -/ lemma timeLike_iff_norm_sq_pos {d : ℕ} (p : Vector d) : @@ -60,8 +59,7 @@ lemma timelike_time_dominates_space {d : ℕ} {v : Vector d} ∑ i, v (Sum.inr i) * v (Sum.inr i) := hv -- Rearrange the inequality have h : ∑ i, v (Sum.inr i) * v (Sum.inr i) < - v (Sum.inl 0) * v (Sum.inl 0) := by - exact lt_of_sub_pos h_norm_pos + v (Sum.inl 0) * v (Sum.inl 0) := lt_of_sub_pos h_norm_pos exact h /-- For nonzero timelike vectors, the time component is nonzero -/ @@ -102,8 +100,7 @@ lemma timeLike_iff_time_lt_space {d : ℕ} {v : Vector d} : @[simp] lemma timeComponent_squared_pos_of_timelike {d : ℕ} {v : Vector d} (hv : causalCharacter v = .timeLike) : - 0 < (timeComponent v)^2 := by - exact pow_two_pos_of_ne_zero (time_component_ne_zero_of_timelike hv) + 0 < (timeComponent v)^2 := pow_two_pos_of_ne_zero (time_component_ne_zero_of_timelike hv) /-- For timelike vectors, the spatial norm squared is strictly less than the time component squared -/ From d9efc56655682c8f0fa9299e46359d1ab1920bfa Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:25:25 -0700 Subject: [PATCH 307/498] refactor: golf space boundedness witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 9 +++------ Physlib/SpaceAndTime/Space/Norm/Basic.lean | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index 3973fcf04..ffb872a39 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -235,8 +235,7 @@ lemma integrable_space {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) @[fun_prop] lemma integrable_space_mul {d : ℕ} {f : Space d → ℝ} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) : - Integrable (fun x : Space d => η x * f x) volume := by - exact hf.integrable_space η + Integrable (fun x : Space d => η x * f x) volume := hf.integrable_space η @[fun_prop] lemma integrable_space_fderiv {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) @@ -634,8 +633,7 @@ lemma add {d : ℕ} {f g : Space d → F} @[fun_prop] lemma fun_add {d : ℕ} {f g : Space d → F} - (hf : IsDistBounded f) (hg : IsDistBounded g) : IsDistBounded (fun x => f x + g x) := by - exact hf.add hg + (hf : IsDistBounded f) (hg : IsDistBounded g) : IsDistBounded (fun x => f x + g x) := hf.add hg /-! @@ -915,8 +913,7 @@ lemma inv_shift {d : ℕ} (g : Space d) (hd : 2 ≤ d := by omega) : simp @[fun_prop] lemma nat_pow {d : ℕ} (n : ℕ) : - IsDistBounded (d := d) (fun x => ‖x‖ ^ n) := by - exact IsDistBounded.pow (d := d) (n : ℤ) (by omega) + IsDistBounded (d := d) (fun x => ‖x‖ ^ n) := IsDistBounded.pow (d := d) (n : ℤ) (by omega) @[fun_prop] lemma norm_add_nat_pow {d : ℕ} (n : ℕ) (a : ℝ) : diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index ed78e4b8e..035f9279b 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -1022,8 +1022,7 @@ private lemma radial_power_deriv_integral_by_parts ∂(.comap Subtype.val volume) = ∫ (x : ℝ) in Set.Ioi (0 : ℝ), - x ^ (p - 1) * η (x • n.1) := by - exact MeasureTheory.integral_subtype_comap (μ := volume) + x ^ (p - 1) * η (x • n.1) := MeasureTheory.integral_subtype_comap (μ := volume) (s := Set.Ioi (0 : ℝ)) measurableSet_Ioi (fun x : ℝ => x ^ (p - 1) * η (x • n.1)) rw [hleft_subtype, hright_subtype] @@ -1439,8 +1438,7 @@ lemma distLaplacian_fundamentalSolution_norm_zpow {d : ℕ} : ‖x‖ ^ (- (d : ℤ)) • basis.repr x) (IsDistBounded.zpow_smul_repr_self (- (d : ℤ)) (by omega))) = (d * (volume (α := Space d)).real - (Metric.ball 0 1)) • diracDelta ℝ 0 := by - exact distDiv_inv_pow_eq_dim (d := d) + (Metric.ball 0 1)) • diracDelta ℝ 0 := distDiv_inv_pow_eq_dim (d := d) rw [hdiv] rw [smul_smul] ring_nf From b501529aca88d9d165806c6494079286470835bb Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:27:37 -0700 Subject: [PATCH 308/498] refactor: golf entropy and mixed-state witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/SSA.lean | 9 +++------ QuantumInfo/States/Mixed/MState.lean | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 4041dd933..637693f31 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -802,12 +802,10 @@ theorem operator_ineq_SSA [Nonempty dA] [Nonempty dB] [Nonempty dC] convert HermitianMat.inv_kronecker _ _ using 1; · infer_instance; · exact ⟨ ⟨ Classical.arbitrary dB, Classical.arbitrary dC ⟩ ⟩; - · have h_trace_right_pos_def : (ρAB.traceRight).mat.PosDef := by - exact PosDef_traceRight ρAB hρ + · have h_trace_right_pos_def : (ρAB.traceRight).mat.PosDef := PosDef_traceRight ρAB hρ exact ⟨by exact PosDef_traceRight ρAB hρ |>.isUnit⟩ · have h_inv_symm : σBC⁻¹.NonSingular := by - have h_inv_symm : σBC.NonSingular := by - exact nonSingular_of_posDef hσ + have h_inv_symm : σBC.NonSingular := nonSingular_of_posDef hσ exact nonSingular_iff_inv.mpr h_inv_symm; exact h_inv_symm; convert congr_arg ( fun x : HermitianMat _ _ => x.reindex ( Equiv.prodAssoc dA dB dC ).symm ) h_inv_symm using 1; @@ -830,8 +828,7 @@ theorem operator_ineq_SSA [Nonempty dA] [Nonempty dB] [Nonempty dC] have h_inv_symm : (σBC.traceLeft⁻¹)⁻¹ = σBC.traceLeft := by have h_inv_symm : (σBC.traceLeft⁻¹).mat * σBC.traceLeft.mat = 1 := by have h_inv_symm : (σBC.traceLeft⁻¹).mat * σBC.traceLeft.mat = 1 := by - have h_inv_symm : σBC.traceLeft.mat.PosDef := by - exact PosDef_traceLeft σBC hσ + have h_inv_symm : σBC.traceLeft.mat.PosDef := PosDef_traceLeft σBC hσ convert! Matrix.nonsing_inv_mul _ _; exact isUnit_iff_ne_zero.mpr h_inv_symm.det_pos.ne'; exact h_inv_symm diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index dc7658805..9e2f90cef 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -749,8 +749,7 @@ theorem pure_eq_pure_iff {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) /-- Two kets are phase-equivalent if and only if their pure states are equal. -/ theorem PhaseEquiv_iff_pure_eq {d : Type*} [Fintype d] [DecidableEq d] (ψ φ : Ket d) : - Ket.PhaseEquiv.r ψ φ ↔ MState.pure ψ = MState.pure φ := by - exact (pure_eq_pure_iff ψ φ).symm + Ket.PhaseEquiv.r ψ φ ↔ MState.pure ψ = MState.pure φ := (pure_eq_pure_iff ψ φ).symm /-- `MState.pure` descends to the quotient `KetUpToPhase`. -/ def pureQ {d : Type*} [Fintype d] [DecidableEq d] : KetUpToPhase d → MState d := @@ -867,8 +866,7 @@ theorem pure_iff_rank_eq_one {d : Type*} [Fintype d] [DecidableEq d] (ρ : MStat -- Since ρ is Hermitian and has rank 1, it must be of the form |ψ⟩⟨ψ| for some ket ψ. Use this fact. have h_pure : ∃ ψ : d → ℂ, ρ.m = Matrix.of (fun i j => ψ i * star (ψ j)) := by have h_rank : ρ.m.rank = 1 := h - have h_herm : ρ.m.IsHermitian := by - exact ρ.M.property + have h_herm : ρ.m.IsHermitian := ρ.M.property have := h_herm.spectral_theorem; -- Since the rank of ρ.m is 1, the diagonal matrix in the spectral theorem must have exactly one non-zero entry. obtain ⟨i, hi⟩ : ∃ i : d, h_herm.eigenvalues i ≠ 0 ∧ ∀ j : d, j ≠ i → h_herm.eigenvalues j = 0 := by From 871b10792a5f9fc15a1711dd4201b4d4170ed735 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:30:26 -0700 Subject: [PATCH 309/498] refactor: golf math wrapper witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/AdjFDeriv.lean | 3 +-- Physlib/Mathematics/List.lean | 3 +-- Physlib/Mathematics/List/InsertionSort.lean | 6 ++---- Physlib/Mathematics/SpecialFunctions/PhysHermite.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Calculus/AdjFDeriv.lean b/Physlib/Mathematics/Calculus/AdjFDeriv.lean index bb4991bd1..cc035313e 100644 --- a/Physlib/Mathematics/Calculus/AdjFDeriv.lean +++ b/Physlib/Mathematics/Calculus/AdjFDeriv.lean @@ -144,8 +144,7 @@ lemma adjFDeriv_id : adjFDeriv 𝕜 (fun x : E => x) = fun _ dx => dx := by funext x rw[HasAdjFDerivAt.adjFDeriv (hasAdjFDerivAt_id x)] -lemma adjFDeriv_id' : adjFDeriv 𝕜 (id : E → E) = fun _ dx => dx := by - exact adjFDeriv_id +lemma adjFDeriv_id' : adjFDeriv 𝕜 (id : E → E) = fun _ dx => dx := adjFDeriv_id lemma hasAdjFDerivAt_const (x : E) (y : F) : HasAdjFDerivAt 𝕜 (fun _ : E => y) (fun _ => 0) x where diff --git a/Physlib/Mathematics/List.lean b/Physlib/Mathematics/List.lean index bb2ead5b4..c4ce3c460 100644 --- a/Physlib/Mathematics/List.lean +++ b/Physlib/Mathematics/List.lean @@ -186,8 +186,7 @@ lemma orderedInsertPos_drop_eq_orderedInsert {I : Type} (le1 : I → I → Prop) List.drop (orderedInsertPos le1 r r0).succ (List.orderedInsert le1 r0 r) := by conv_rhs => simp [orderedInsertPos, List.orderedInsert_eq_take_drop] have hr : r = List.takeWhile (fun b => !decide (le1 r0 b)) r ++ - List.dropWhile (fun b => !decide (le1 r0 b)) r := by - exact Eq.symm (List.takeWhile_append_dropWhile) + List.dropWhile (fun b => !decide (le1 r0 b)) r := Eq.symm (List.takeWhile_append_dropWhile) conv_lhs => rhs rw [hr] diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index 1dae13dd6..b2523a9d3 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -331,8 +331,7 @@ lemma insertionSortEquiv_insertionSort_append {α : Type} (r : α → α → Pro equivCons_succ] erw [ih] have hl : (List.insertionSort r (List.insertionSort r l1 ++ a :: l2)) = - (List.insertionSort r (l1 ++ a :: l2)) := by - exact insertionSort_insertionSort_append r l1 (a :: l2) + (List.insertionSort r (l1 ++ a :: l2)) := insertionSort_insertionSort_append r l1 (a :: l2) erw [orderedInsertEquiv_congr _ _ _ hl] simp only [List.foldr_cons, finCongr_apply] rfl @@ -379,8 +378,7 @@ lemma orderedInsert_filter_of_pos {α : Type} (r : α → α → Prop) [Decidabl simp only [List.pairwise_cons] at hl apply hl.1 have hlf : (List.filter (fun b => decide (p b)) l)[0] ∈ - (List.filter (fun b => decide (p b)) l) := by - exact List.getElem_mem c + (List.filter (fun b => decide (p b)) l) := List.getElem_mem c simp only [List.mem_filter, decide_eq_true_eq] at hlf exact hlf.1 rw [hl] diff --git a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean index 9692646e5..3dca87e95 100644 --- a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean +++ b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean @@ -481,8 +481,7 @@ lemma cos_mem_physHermite_span_topologicalClosure (c : ℝ) : simp only [HasSum] at h1 have h1 : Filter.Tendsto (fun s => fun y => ∑ x ∈ s, (-1) ^ x * (c * y) ^ (2 * x) / ((2 * x)! : ℝ)) - Filter.atTop (nhds (fun x => Real.cos (c * x))) := by - exact tendsto_pi_nhds.mpr fun x => h1 (c * x) + Filter.atTop (nhds (fun x => Real.cos (c * x))) := tendsto_pi_nhds.mpr fun x => h1 (c * x) have h2 (z : Finset ℕ) : (fun y => ∑ x ∈ z, (-1) ^ x * (c * y) ^ (2 * x) / ↑(2 * x)!) ∈ ↑(Submodule.span ℝ (Set.range (fun n => (physHermite n : ℝ → ℝ)))) := by have h0 : (fun y => ∑ x ∈ z, (-1) ^ x * (c * y) ^ (2 * x) / ↑(2 * x)!) = From 2de230db3e0909140b3c061c3bcabc5a26ae84e4 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:33:50 -0700 Subject: [PATCH 310/498] refactor: golf trace norm and uncertainty witnesses Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/Uncertainty.lean | 6 ++---- QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean index 372e833c1..dd96bb55d 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean @@ -115,11 +115,9 @@ lemma raw_commutator_eq_of_symmetric (h_raw : ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩ - B ⟨A ψ, hBA⟩⟫_ℂ = Complex.I * c) : ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = Complex.I * c := by have ha_pairing : - ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ := by - exact hA ψ ⟨B ⟨ψ, hψB⟩, hAB⟩ + ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ := hA ψ ⟨B ⟨ψ, hψB⟩, hAB⟩ have hb_pairing : - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), B ⟨A ψ, hBA⟩⟫_ℂ := by - exact hB ⟨ψ, hψB⟩ ⟨A ψ, hBA⟩ + ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), B ⟨A ψ, hBA⟩⟫_ℂ := hB ⟨ψ, hψB⟩ ⟨A ψ, hBA⟩ calc ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ - diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index 69c24bd29..516ae4399 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -368,12 +368,10 @@ omit [Fintype m] [RCLike R] [DecidableEq n] in theorem traceNorm_sandwich_le [DecidableEq n] {S M T : Matrix n n ℂ} (hS : ‖S‖ ≤ 1) (hT : ‖T‖ ≤ 1) : (S * M * T).traceNorm ≤ M.traceNorm := calc (S * M * T).traceNorm - ≤ (M * T).traceNorm := by - exact le_trans + ≤ (M * T).traceNorm := le_trans (by simpa [Matrix.mul_assoc] using Matrix.traceNorm_mul_le_opNorm_traceNorm S (M * T)) (by simpa using mul_le_mul_of_nonneg_right hS (Matrix.traceNorm_nonneg (M * T))) - _ ≤ M.traceNorm := by - exact le_trans (traceNorm_mul_le_traceNorm_opNorm M T) + _ ≤ M.traceNorm := le_trans (traceNorm_mul_le_traceNorm_opNorm M T) (by simpa using mul_le_mul_of_nonneg_left hT (Matrix.traceNorm_nonneg M)) end @@ -396,8 +394,7 @@ theorem abs_trace_le_traceNorm (A : Matrix n n ℂ) : simpa [Matrix.trace] using norm_sum_le (s := Finset.univ) (f := fun i => (C.val * D) i i) _ = ∑ i, ‖C.val i i‖ * Real.sqrt (hH.eigenvalues i) := by simp [D, Matrix.mul_apply, Matrix.diagonal, Real.norm_eq_abs, abs_of_nonneg] - _ ≤ ∑ i, Real.sqrt (hH.eigenvalues i) := by - exact Finset.sum_le_sum (fun i _ => by + _ ≤ ∑ i, Real.sqrt (hH.eigenvalues i) := Finset.sum_le_sum (fun i _ => by simpa using mul_le_mul_of_nonneg_right (entry_norm_bound_of_unitary C.property i i) (Real.sqrt_nonneg _)) From f4f98d63d24b3e427c58fa54794c8a3bcb135ebd Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:35:48 -0700 Subject: [PATCH 311/498] refactor: golf relativity and time wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean | 3 +-- Physlib/Relativity/LorentzGroup/Proper.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean | 3 +-- Physlib/SpaceAndTime/Time/Basic.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean index e23ddb96d..c1727222f 100644 --- a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean +++ b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean @@ -176,5 +176,4 @@ theorem exp_isOrthochronous (A : lorentzAlgebra) : restricted Lorentz group. -/ theorem exp_mem_restricted_lorentzGroup (A : lorentzAlgebra) : (⟨NormedSpace.exp A.1, exp_mem_lorentzGroup A⟩ : LorentzGroup 3) ∈ - LorentzGroup.restricted 3 := by - exact ⟨exp_isProper A, exp_isOrthochronous A⟩ + LorentzGroup.restricted 3 := ⟨exp_isProper A, exp_isOrthochronous A⟩ diff --git a/Physlib/Relativity/LorentzGroup/Proper.lean b/Physlib/Relativity/LorentzGroup/Proper.lean index 98bbc1201..46ae348c6 100644 --- a/Physlib/Relativity/LorentzGroup/Proper.lean +++ b/Physlib/Relativity/LorentzGroup/Proper.lean @@ -43,8 +43,7 @@ local notation "ℤ₂" => Multiplicative (ZMod 2) instance : TopologicalSpace ℤ₂ := instTopologicalSpaceFin /-- The topological space defined by `ℤ₂` is discrete. -/ -instance : DiscreteTopology ℤ₂ := by - exact discreteTopology_iff_forall_isOpen.mpr fun _ => trivial +instance : DiscreteTopology ℤ₂ := discreteTopology_iff_forall_isOpen.mpr fun _ => trivial /-- The instance of a topological group on `ℤ₂` defined via the discrete topology. -/ instance : IsTopologicalGroup ℤ₂ := IsTopologicalGroup.mk diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index f4a41789a..0852e4548 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -284,8 +284,7 @@ instance : TopologicalSpace (ContrMod d) := TopologicalSpace.induced open Topology -lemma toFin1dℝEquiv_isInducing : IsInducing (@ContrMod.toFin1dℝEquiv d) := by - exact { eq_induced := rfl } +lemma toFin1dℝEquiv_isInducing : IsInducing (@ContrMod.toFin1dℝEquiv d) := { eq_induced := rfl } lemma toFin1dℝEquiv_symm_isInducing : IsInducing ((@ContrMod.toFin1dℝEquiv d).symm) := by let x := Equiv.toHomeomorphOfIsInducing (@ContrMod.toFin1dℝEquiv d).toEquiv diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index 867df55c2..bb25451ab 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -35,8 +35,7 @@ variable {d : ℕ} noncomputable instance : TopologicalSpace (Velocity d) := instTopologicalSpaceSubtype @[ext] -lemma ext {v w : Velocity d} (h : v.1 = w.1) : v = w := by - exact SetCoe.ext h +lemma ext {v w : Velocity d} (h : v.1 = w.1) : v = w := SetCoe.ext h lemma mem_iff {v : Vector d} : v ∈ Velocity d ↔ ⟪v, v⟫ₘ = (1 : ℝ) ∧ 0 < v.timeComponent := Iff.rfl diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 5c8296f21..812e5784e 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -421,8 +421,7 @@ instance : FiniteDimensional ℝ Time := Module.finite_of_rank_eq_one rank_eq_one lemma volume_eq_basis_addHaar : - (volume (α := Time)) = basis.toBasis.addHaar := by - exact (OrthonormalBasis.addHaar_eq_volume _).symm + (volume (α := Time)) = basis.toBasis.addHaar := (OrthonormalBasis.addHaar_eq_volume _).symm /-! From 5e30c8d959f9b14a0172d89fff720e35e2016226 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:37:53 -0700 Subject: [PATCH 312/498] refactor: golf Physlib wrapper witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean | 3 +-- Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean | 3 +-- .../RHN/AnomalyCancellation/PlusU1/Basic.lean | 3 +-- Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean | 3 +-- .../QFT/PerturbationTheory/WickContraction/SubContraction.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean index 36271a94d..174357a41 100644 --- a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean +++ b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean @@ -241,8 +241,7 @@ lemma exp_map_algebraMap {n : Type*} [Fintype n] [DecidableEq n] letI : NormedAlgebra ℂ (Matrix n n ℂ) := Matrix.linftyOpNormedAlgebra letI : CompleteSpace (Matrix n n ℂ) := inferInstance simp only [exp_eq_tsum ℝ] - have hs : Summable (fun k => (k.factorial : ℝ)⁻¹ • A ^ k) := by - exact NormedSpace.expSeries_summable' A + have hs : Summable (fun k => (k.factorial : ℝ)⁻¹ • A ^ k) := NormedSpace.expSeries_summable' A erw [Matrix.map_tsum (algebraMap ℝ ℂ).toAddMonoidHom RCLike.continuous_ofReal hs] apply tsum_congr intro k diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index cb28adaf7..7f4d2e80d 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -66,8 +66,7 @@ lemma apply_smooth_of_smooth {F : (X → U) → (X → V)} {F' : (X → V) → ( fun_prop lemma apply_smooth_self {F : (X → U) → (X → V)} {F' : (X → V) → (X → U)} {u : X → U} - (h : HasVarAdjDerivAt F F' u) : ContDiff ℝ ∞ (F u) := by - exact h.apply_smooth_of_smooth (h.smooth_at) + (h : HasVarAdjDerivAt F F' u) : ContDiff ℝ ∞ (F u) := h.apply_smooth_of_smooth (h.smooth_at) lemma smooth_R {F : (X → U) → (X → V)} {F' : (X → V) → (X → U)} {u : X → U} (h : HasVarAdjDerivAt F F' u) {φ : ℝ → X → U} (hφ : ContDiff ℝ ∞ ↿φ) (x : X) : diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean index 8fb0b8bcd..e55585d60 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/Basic.lean @@ -66,8 +66,7 @@ lemma quadSol (S : (PlusU1 n).QuadSols) : accQuad S.val = 0 := by simp only [PlusU1_quadraticACCs] at hS exact hS ⟨0, by simp⟩ -lemma cubeSol (S : (PlusU1 n).Sols) : accCube S.val = 0 := by - exact S.cubicSol +lemma cubeSol (S : (PlusU1 n).Sols) : accCube S.val = 0 := S.cubicSol /-- An element of `charges` which satisfies the linear ACCs gives us a element of `LinSols`. -/ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean index fa3f2a33c..d181b242c 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean @@ -129,8 +129,7 @@ lemma congrLift_surjective {n m : ℕ} {c : WickContraction n} (h : n = m) : simp [Function.surjective_id] lemma congrLift_bijective {n m : ℕ} {c : WickContraction n} (h : n = m) : - Function.Bijective (c.congrLift h) := by - exact ⟨c.congrLift_injective h, c.congrLift_surjective h⟩ + Function.Bijective (c.congrLift h) := ⟨c.congrLift_injective h, c.congrLift_surjective h⟩ /-- Given a contracted pair in `c : WickContraction n` the contracted pair in `congr h c`. -/ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean index e0b2db5cd..f8b8b0570 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean @@ -33,8 +33,7 @@ def subContraction (S : Finset (Finset (Fin φs.length))) (ha : S ⊆ φsΛ.1) : exact φsΛ.2.2 i (ha hi) j (ha hj)⟩ lemma mem_of_mem_subContraction {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} - {a : Finset (Fin φs.length)} (ha : a ∈ (φsΛ.subContraction S hs).1) : a ∈ φsΛ.1 := by - exact hs ha + {a : Finset (Fin φs.length)} (ha : a ∈ (φsΛ.subContraction S hs).1) : a ∈ φsΛ.1 := hs ha /-- Given a Wick contraction `φsΛ`, and a subset `S` of `φsΛ.1`, the Wick contraction on the uncontracted list `[φsΛ.subContraction S ha]ᵘᶜ` From 30c714c852cebe9e554e3aa3939537d1a0520895 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:40:50 -0700 Subject: [PATCH 313/498] refactor: golf QED and Hilbert wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean | 3 +-- Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index 28e56c01a..9c9a0e17a 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -908,8 +908,7 @@ def Pa' (f : (Fin n.succ) ⊕ (Fin n) → ℚ) : (PureU1 (2 * n.succ)).LinSols : ∑ i, f i • basisa i lemma Pa'_P'_P!' (f : (Fin n.succ) ⊕ (Fin n) → ℚ) : - Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := by - exact Fintype.sum_sum_type _ + Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := Fintype.sum_sum_type _ /-! diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean index 5c469ac08..fe88aa1ca 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean @@ -108,8 +108,7 @@ lemma generic_or_special (S : (PureU1 (2 * n.succ)).Sols) : GenericCase S ∨ SpecialCase S := by obtain ⟨g, f, h⟩ := span_basis S.1.1 have h1 : accCubeTriLinSymm (P g) (P g) (P! f) ≠ 0 ∨ - accCubeTriLinSymm (P g) (P g) (P! f) = 0 := by - exact ne_or_eq _ _ + accCubeTriLinSymm (P g) (P g) (P! f) = 0 := ne_or_eq _ _ rcases h1 with h1 | h1 · exact Or.inl (genericCase_exists S ⟨g, f, h, h1⟩) · exact Or.inr (specialCase_exists S ⟨g, f, h, h1⟩) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 8e3b9cb56..7213bf7fa 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -863,8 +863,7 @@ def Pa' (f : (Fin n) ⊕ (Fin n) → ℚ) : (PureU1 (2 * n + 1)).LinSols := ∑ i, f i • basisa i lemma Pa'_P'_P!' (f : (Fin n) ⊕ (Fin n) → ℚ) : - Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := by - exact Fintype.sum_sum_type _ + Pa' f = P' (f ∘ Sum.inl) + P!' (f ∘ Sum.inr) := Fintype.sum_sum_type _ /-! diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean index 567fbb4a6..9741bbcba 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean @@ -110,8 +110,7 @@ lemma generic_or_special (S : (PureU1 (2 * n.succ + 1)).Sols) : GenericCase S ∨ SpecialCase S := by obtain ⟨g, f, h⟩ := span_basis S.1.1 have h1 : accCubeTriLinSymm (P g) (P g) (P! f) ≠ 0 ∨ - accCubeTriLinSymm (P g) (P g) (P! f) = 0 := by - exact ne_or_eq _ _ + accCubeTriLinSymm (P g) (P g) (P! f) = 0 := ne_or_eq _ _ cases h1 <;> rename_i h1 · exact Or.inl (genericCase_exists S ⟨g, f, h, h1⟩) · exact Or.inr (specialCase_exists S ⟨g, f, h, h1⟩) diff --git a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean index 67623e9d4..733fb04c1 100644 --- a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean @@ -156,8 +156,7 @@ lemma mk_eq_iff {f g : ℝ → ℂ} {hf : MemHS f} {hg : MemHS g} : simp [mk] lemma ext_iff {f g : HilbertSpace} : - f = g ↔ (f : ℝ → ℂ) =ᶠ[ae volume] (g : ℝ → ℂ) := by - exact Lp.ext_iff + f = g ↔ (f : ℝ → ℂ) =ᶠ[ae volume] (g : ℝ → ℂ) := Lp.ext_iff end HilbertSpace end From 9b53d6a59b6a3656dd09daa67c65c33af0814b2b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:43:17 -0700 Subject: [PATCH 314/498] refactor: golf quantum information witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Capacity/Capacity.lean | 3 +-- .../HayataGroup/TraceInequality/JensenOperatorInequality.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Peierls.lean | 3 +-- QuantumInfo/ForMathlib/SionMinimax.lean | 3 +-- QuantumInfo/States/Entanglement.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Capacity/Capacity.lean b/QuantumInfo/Capacity/Capacity.lean index 0cf72a267..5a9a9f509 100644 --- a/QuantumInfo/Capacity/Capacity.lean +++ b/QuantumInfo/Capacity/Capacity.lean @@ -166,8 +166,7 @@ end AristotleLemmas theorem not_achievesRate_gt_log_dim_out (Λ : CPTPMap d₁ d₂) {R : ℝ} (hR : Real.logb 2 (Fintype.card d₂) < R): ¬Λ.AchievesRate R := by intro h; -- We show that the identity channel on the output space `d₂` emulates `Λ`. Since capacity is monotonic under emulation, `Q(Λ) ≤ Q(id_{d₂})`. - have h_emulate : (CPTPMap.id (dIn := d₂)).Emulates Λ := by - exact ⟨Λ, CPTPMap.id, by simp⟩ + have h_emulate : (CPTPMap.id (dIn := d₂)).Emulates Λ := ⟨Λ, CPTPMap.id, by simp⟩ -- If `Λ` achieves rate `R`, then `id_{d₂}` achieves rate `R`. This follows because if `Λ^{\otimes n}` emulates `B`, and `id^{\otimes n}` emulates `Λ^{\otimes n}` (by functoriality of tensor product), then `id^{\otimes n}` emulates `B`. have h_id_achieves : (CPTPMap.id (dIn := d₂)).AchievesRate R := by intro ε hε_pos diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean index a09d09d18..bf1d77e3d 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean @@ -294,8 +294,7 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) /-- Uniform consequence of Theorem 2.5.2: `(i) → (v)` via `(iv)`. -/ theorem theorem_2_5_2_i_all_imp_v {f : ℝ → ℝ} (hf : CondIAll.{u} f) : CondV (ℋ := ℋ) f := by - have hconv : OperatorConvex (ℋ := ℋ) f := by - exact hf.1 + have hconv : OperatorConvex (ℋ := ℋ) f := hf.1 have hcont : ContinuousOn f Set.univ := operatorConvex_continuousOn_univ (ℋ := ℋ) hconv refine theorem_2_5_2_iv_imp_v (ℋ := ℋ) ?_ hcont diff --git a/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean b/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean index 415346f0d..6ad270653 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Peierls.lean @@ -173,8 +173,7 @@ theorem trace_function_convex_ici {g : ℝ → ℝ} (hg : ConvexOn ℝ (Set.Ici -- Let $C = aA + bB$. set C : HermitianMat d ℂ := a • A + b • B -- By the properties of the trace and the convexity of $g$, we have: - have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := by - exact trace_cfc_eq C g + have h_trace : (C.cfc g).trace = ∑ i, g (C.H.eigenvalues i) := trace_cfc_eq C g have h_sum : ∑ i, g (C.H.eigenvalues i) ≤ a * ∑ i, g ((A.conj (star C.H.eigenvectorUnitary.val)).mat i i).re + b * ∑ i, g ((B.conj (star C.H.eigenvectorUnitary.val)).mat i i).re := by diff --git a/QuantumInfo/ForMathlib/SionMinimax.lean b/QuantumInfo/ForMathlib/SionMinimax.lean index bd404879e..792d4e1c2 100644 --- a/QuantumInfo/ForMathlib/SionMinimax.lean +++ b/QuantumInfo/ForMathlib/SionMinimax.lean @@ -268,8 +268,7 @@ theorem LeftOrdContinuous.comp_lowerSemicontinuousOn_strong_assumptions {α γ by_contra h_contra simp only [not_exists, not_and, not_lt] at h_contra have h_exists_z : ∃ z, z < f x ∧ g z > y := by - have h_lub : IsLUB (Set.Iio (f x)) (f x) := by - exact isLUB_Iio + have h_lub : IsLUB (Set.Iio (f x)) (f x) := isLUB_Iio have := hg h_lub; have := this.exists_between hy simp_all only [Set.mem_image, Set.mem_Iio, exists_exists_and_eq_and, gt_iff_lt] diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index cf730aa89..3723eb546 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -269,8 +269,7 @@ theorem Sᵥₙ_eq_trace_cfc {d : Type*} [Fintype d] [DecidableEq d] (ρ : MStat ∑ x, (ρ.M.cfc Real.negMulLog).H.eigenvalues x := by exact (HermitianMat.sum_eigenvalues_eq_trace _).symm obtain ⟨e, he⟩ : ∃ e : d ≃ d, (ρ.M.cfc Real.negMulLog).H.eigenvalues = - Real.negMulLog ∘ ρ.M.H.eigenvalues ∘ e := by - exact Matrix.IsHermitian.cfc_eigenvalues _ _ + Real.negMulLog ∘ ρ.M.H.eigenvalues ∘ e := Matrix.IsHermitian.cfc_eigenvalues _ _ rw [h_def, h_trace, he] simp only [Function.comp_apply] conv_lhs => rw [ ← Equiv.sum_comp e ] From ddd88bc576bdf5bca22dede054b9681fc8577a0b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:46:16 -0700 Subject: [PATCH 315/498] refactor: golf relativity and rational wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/RatComplexNum.lean | 3 +-- Physlib/Relativity/CliffordAlgebra.lean | 3 +-- Physlib/Relativity/MinkowskiMatrix.lean | 9 +++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/RatComplexNum.lean b/Physlib/Mathematics/RatComplexNum.lean index 042249e26..35016b9d2 100644 --- a/Physlib/Mathematics/RatComplexNum.lean +++ b/Physlib/Mathematics/RatComplexNum.lean @@ -258,8 +258,7 @@ lemma I_mul_toComplexNum (a : RatComplexNum) : I * toComplexNum a = toComplexNum ring lemma ofNat_mul_toComplexNum (n : ℕ) (a : RatComplexNum) : - n * toComplexNum a = toComplexNum (n * a) := by - simp only [map_mul, map_natCast] + n * toComplexNum a = toComplexNum (n * a) := by simp only [map_mul, map_natCast] lemma toComplexNum_injective : Function.Injective toComplexNum := by intro a b ha diff --git a/Physlib/Relativity/CliffordAlgebra.lean b/Physlib/Relativity/CliffordAlgebra.lean index f1029532c..75dda546a 100644 --- a/Physlib/Relativity/CliffordAlgebra.lean +++ b/Physlib/Relativity/CliffordAlgebra.lean @@ -91,8 +91,7 @@ representation. -/ @[simp] def γSet : Set (Matrix (Fin 4) (Fin 4) ℂ) := {γ i | i : Fin 4} -lemma γ_in_γSet (μ : Fin 4) : γ μ ∈ γSet := by - simp [γSet] +lemma γ_in_γSet (μ : Fin 4) : γ μ ∈ γSet := by simp [γSet] /-- The algebra generated by the gamma matrices in the Dirac representation. -/ def diracAlgebra : Subalgebra ℝ (Matrix (Fin 4) (Fin 4) ℂ) := diff --git a/Physlib/Relativity/MinkowskiMatrix.lean b/Physlib/Relativity/MinkowskiMatrix.lean index 75b2e3766..b7b893369 100644 --- a/Physlib/Relativity/MinkowskiMatrix.lean +++ b/Physlib/Relativity/MinkowskiMatrix.lean @@ -113,8 +113,7 @@ We prove some simple properties related to the components of the Minkowski matri /-- The `time-time` component of the Minkowski matrix is `1`. -/ @[simp] -lemma inl_0_inl_0 : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := by - rfl +lemma inl_0_inl_0 : @minkowskiMatrix d (Sum.inl 0) (Sum.inl 0) = 1 := by rfl /-- The space diagonal components of the Minkowski matrix are `-1`. -/ @[simp] @@ -202,14 +201,12 @@ We show properties of the action of the Minkowski matrix on vectors. /-- The time components of a vector acted on by the Minkowski matrix remains unchanged. -/ @[simp] lemma mulVec_inl_0 (v : (Fin 1 ⊕ Fin d) → ℝ) : - (η *ᵥ v) (Sum.inl 0) = v (Sum.inl 0) := by - simp [as_diagonal, mulVec_diagonal] + (η *ᵥ v) (Sum.inl 0) = v (Sum.inl 0) := by simp [as_diagonal, mulVec_diagonal] /-- The space components of a vector acted on by the Minkowski matrix swaps sign. -/ @[simp] lemma mulVec_inr_i (v : (Fin 1 ⊕ Fin d) → ℝ) (i : Fin d) : - (η *ᵥ v) (Sum.inr i) = - v (Sum.inr i) := by - simp [as_diagonal, mulVec_diagonal] + (η *ᵥ v) (Sum.inr i) = - v (Sum.inr i) := by simp [as_diagonal, mulVec_diagonal] /-! From e4be166b73144768465e1a6930eeb0bccc624290 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:50:25 -0700 Subject: [PATCH 316/498] refactor: golf unit scale wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Units/Basic.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Units/Basic.lean b/Physlib/Units/Basic.lean index 12c6bdd3b..73c05a67c 100644 --- a/Physlib/Units/Basic.lean +++ b/Physlib/Units/Basic.lean @@ -125,13 +125,11 @@ lemma dimScale_apply (u1 u2 : UnitChoices) (d : Dimension) : @[simp] lemma dimScale_self (u : UnitChoices) (d : Dimension) : - dimScale u u d = 1 := by - simp [dimScale] + dimScale u u d = 1 := by simp [dimScale] @[simp] lemma dimScale_one (u1 u2 : UnitChoices) : - dimScale u1 u2 1 = 1 := by - simp [dimScale] + dimScale u1 u2 1 = 1 := by simp [dimScale] lemma dimScale_transitive (u1 u2 u3 : UnitChoices) (d : Dimension) : dimScale u1 u2 d * dimScale u2 u3 d = dimScale u1 u3 d := by @@ -152,8 +150,7 @@ lemma dimScale_transitive (u1 u2 u3 : UnitChoices) (d : Dimension) : @[simp] lemma dimScale_mul_symm (u1 u2 : UnitChoices) (d : Dimension) : - dimScale u1 u2 d * dimScale u2 u1 d = 1 := by - rw [dimScale_transitive, dimScale_self] + dimScale u1 u2 d * dimScale u2 u1 d = 1 := by rw [dimScale_transitive, dimScale_self] @[simp] lemma dimScale_coe_mul_symm (u1 u2 : UnitChoices) (d : Dimension) : @@ -164,8 +161,7 @@ lemma dimScale_coe_mul_symm (u1 u2 : UnitChoices) (d : Dimension) : @[simp] lemma dimScale_ne_zero (u1 u2 : UnitChoices) (d : Dimension) : - dimScale u1 u2 d ≠ 0 := by - simp [dimScale] + dimScale u1 u2 d ≠ 0 := by simp [dimScale] lemma dimScale_symm (u1 u2 : UnitChoices) (d : Dimension) : dimScale u1 u2 d = (dimScale u2 u1 d)⁻¹ := by @@ -179,8 +175,7 @@ lemma dimScale_symm (u1 u2 : UnitChoices) (d : Dimension) : lemma dimScale_of_inv_eq_swap (u1 u2 : UnitChoices) (d : Dimension) : dimScale u1 u2 d⁻¹ = dimScale u2 u1 d := by - simp only [map_inv] - conv_rhs => rw[dimScale_symm] + simpa only [map_inv] using (dimScale_symm u2 u1 d).symm @[simp] lemma smul_dimScale_injective {M : Type} [MulAction ℝ≥0 M] (u1 u2 : UnitChoices) (d : Dimension) From 93cb80f7dd4d126456638b0cecf7d14a7531f4b9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:52:41 -0700 Subject: [PATCH 317/498] refactor: golf Fin extraction wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Fin.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index 4211e20c0..568430c6c 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -58,8 +58,7 @@ lemma predAboveI_eq_iff {i x : Fin n.succ.succ} (h : i ≠ x) (y : Fin n.succ) : · simp [← h] lemma predAboveI_lt {i x : Fin n.succ.succ} (h : x.val < i.val) : - predAboveI i x = ⟨x.val, by omega⟩ := by - simp [predAboveI, h] + predAboveI i x = ⟨x.val, by omega⟩ := by simp [predAboveI, h] lemma predAboveI_ge {i x : Fin n.succ.succ} (h : i.val < x.val) : predAboveI i x = ⟨x.val - 1, by omega⟩ := by @@ -198,8 +197,7 @@ def finExtractTwo {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : @[simp] lemma finExtractTwo_apply_fst {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : - finExtractTwo i j i = Sum.inl (Sum.inl 0) := by - simp [finExtractTwo] + finExtractTwo i j i = Sum.inl (Sum.inl 0) := by simp [finExtractTwo] lemma finExtractTwo_symm_inr {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : (finExtractTwo i j).symm ∘ Sum.inr = i.succAbove ∘ j.succAbove := by @@ -208,13 +206,11 @@ lemma finExtractTwo_symm_inr {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : @[simp] lemma finExtractTwo_symm_inr_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) (x : Fin n) : - (finExtractTwo i j).symm (Sum.inr x) = i.succAbove (j.succAbove x) := by - simp [finExtractTwo] + (finExtractTwo i j).symm (Sum.inr x) = i.succAbove (j.succAbove x) := by simp [finExtractTwo] @[simp] lemma finExtractTwo_symm_inl_inr_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : - (finExtractTwo i j).symm (Sum.inl (Sum.inr 0)) = i.succAbove j := by - simp [finExtractTwo] + (finExtractTwo i j).symm (Sum.inl (Sum.inr 0)) = i.succAbove j := by simp [finExtractTwo] @[simp] lemma finExtractTwo_symm_inl_inl_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : @@ -222,8 +218,7 @@ lemma finExtractTwo_symm_inl_inl_apply {n : ℕ} (i : Fin n.succ.succ) (j : Fin @[simp] lemma finExtractTwo_apply_snd {n : ℕ} (i : Fin n.succ.succ) (j : Fin n.succ) : - finExtractTwo i j (i.succAbove j) = Sum.inl (Sum.inr 0) := by - simp [← Equiv.eq_symm_apply] + finExtractTwo i j (i.succAbove j) = Sum.inl (Sum.inr 0) := by simp [← Equiv.eq_symm_apply] /-- Takes two maps `Fin n → Fin n` and returns the equivalence they form. -/ def finMapToEquiv (f1 : Fin n → Fin m) (f2 : Fin m → Fin n) From 90095f6d7bdaea2342499d50d69f85ca8fdb9cd0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:53:59 -0700 Subject: [PATCH 318/498] refactor: golf field-op supercommute wrappers Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/SuperCommute.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 65f67b7ee..491b3753e 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -290,32 +290,27 @@ lemma ofFieldOpListF_mul_ofFieldOpF_eq_superCommuteF (φs : List 𝓕.FieldOp) ( lemma crPartF_mul_anPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : crPartF φ * anPartF φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • anPartF φ' * crPartF φ + - [crPartF φ, anPartF φ']ₛF := by - simp [superCommuteF_crPartF_anPartF] + [crPartF φ, anPartF φ']ₛF := by simp [superCommuteF_crPartF_anPartF] lemma anPartF_mul_crPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : anPartF φ * crPartF φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPartF φ' * anPartF φ + - [anPartF φ, crPartF φ']ₛF := by - simp [superCommuteF_anPartF_crPartF] + [anPartF φ, crPartF φ']ₛF := by simp [superCommuteF_anPartF_crPartF] lemma crPartF_mul_crPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : crPartF φ * crPartF φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPartF φ' * crPartF φ + - [crPartF φ, crPartF φ']ₛF := by - simp [superCommuteF_crPartF_crPartF] + [crPartF φ, crPartF φ']ₛF := by simp [superCommuteF_crPartF_crPartF] lemma anPartF_mul_anPartF_eq_superCommuteF (φ φ' : 𝓕.FieldOp) : anPartF φ * anPartF φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • anPartF φ' * anPartF φ + - [anPartF φ, anPartF φ']ₛF := by - simp [superCommuteF_anPartF_anPartF] + [anPartF φ, anPartF φ']ₛF := by simp [superCommuteF_anPartF_anPartF] lemma ofCrAnListF_mul_ofFieldOpListF_eq_superCommuteF (φs : List 𝓕.CrAnFieldOp) (φs' : List 𝓕.FieldOp) : ofCrAnListF φs * ofFieldOpListF φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofFieldOpListF φs' * ofCrAnListF φs - + [ofCrAnListF φs, ofFieldOpListF φs']ₛF := by - simp [superCommuteF_ofCrAnListF_ofFieldOpFsList] + + [ofCrAnListF φs, ofFieldOpListF φs']ₛF := by simp [superCommuteF_ofCrAnListF_ofFieldOpFsList] /-! From 723642245a41fc5e95bb42bff0a7dd95856d184c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:55:11 -0700 Subject: [PATCH 319/498] refactor: golf tensor vector module wrappers Co-authored-by: Claude Opus 4.8 --- .../Tensors/RealTensor/Vector/Pre/Modules.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean index 0852e4548..c95ee408e 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Modules.lean @@ -146,24 +146,20 @@ lemma mulVec_val (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v : Contr (M *ᵥ v).val = M *ᵥ v.val := rfl lemma mulVec_sub (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v w : ContrMod d) : - M *ᵥ (v - w) = M *ᵥ v - M *ᵥ w := by - simp only [mulVec, LinearMap.map_sub] + M *ᵥ (v - w) = M *ᵥ v - M *ᵥ w := by simp only [mulVec, LinearMap.map_sub] lemma sub_mulVec (M N : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v : ContrMod d) : - (M - N) *ᵥ v = M *ᵥ v - N *ᵥ v := by - simp only [mulVec, map_sub, LinearMap.sub_apply] + (M - N) *ᵥ v = M *ᵥ v - N *ᵥ v := by simp only [mulVec, map_sub, LinearMap.sub_apply] lemma mulVec_add (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v w : ContrMod d) : - M *ᵥ (v + w) = M *ᵥ v + M *ᵥ w := by - simp only [mulVec, LinearMap.map_add] + M *ᵥ (v + w) = M *ᵥ v + M *ᵥ w := by simp only [mulVec, LinearMap.map_add] @[simp] lemma one_mulVec (v : ContrMod d) : (1 : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) *ᵥ v = v := by simp [mulVec, _root_.map_one] lemma mulVec_mulVec (M N : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) ℝ) (v : ContrMod d) : - M *ᵥ (N *ᵥ v) = (M * N) *ᵥ v := by - simp [mulVec, _root_.map_mul] + M *ᵥ (N *ᵥ v) = (M * N) *ᵥ v := by simp [mulVec, _root_.map_mul] /-! @@ -197,8 +193,7 @@ def toSpace (v : ContrMod d) : EuclideanSpace ℝ (Fin d) := WithLp.toLp 2 (v.va def rep : Representation ℝ (LorentzGroup d) (ContrMod d) where toFun g := Matrix.toLinAlgEquiv stdBasis g map_one' := EmbeddingLike.map_eq_one_iff.mpr rfl - map_mul' x y := by - simp only [lorentzGroupIsGroup_mul_coe, _root_.map_mul] + map_mul' x y := by simp only [lorentzGroupIsGroup_mul_coe, _root_.map_mul] lemma rep_apply_toFin1dℝ (g : LorentzGroup d) (ψ : ContrMod d) : (rep g ψ).toFin1dℝ = g.1 *ᵥ ψ.toFin1dℝ := rfl From d7ae52dc06a3d5f14534c657ae67980d4f170050 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:56:16 -0700 Subject: [PATCH 320/498] refactor: golf Lorentz toVector wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/ToVector.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/ToVector.lean b/Physlib/Relativity/LorentzGroup/ToVector.lean index 08af8b687..42c01950b 100644 --- a/Physlib/Relativity/LorentzGroup/ToVector.lean +++ b/Physlib/Relativity/LorentzGroup/ToVector.lean @@ -25,17 +25,14 @@ open Vector def toVector {d : ℕ} (Λ : LorentzGroup d) : Lorentz.Vector d := Λ • basis (Sum.inl 0) lemma toVector_mul {d : ℕ} (Λ₁ Λ₂ : LorentzGroup d) : - toVector (Λ₁ * Λ₂) = Λ₁ • toVector Λ₂ := by - rw [toVector, toVector, smul_smul] + toVector (Λ₁ * Λ₂) = Λ₁ • toVector Λ₂ := by rw [toVector, toVector, smul_smul] lemma toVector_neg {d : ℕ} (Λ : LorentzGroup d) : - toVector (-Λ) = -toVector Λ := by - simp [toVector, neg_smul] + toVector (-Λ) = -toVector Λ := by simp [toVector, neg_smul] @[simp] lemma toVector_apply {d : ℕ} (Λ : LorentzGroup d) - (i : Fin 1 ⊕ Fin d) : (toVector Λ) i = Λ.1 i (Sum.inl 0) := by - simp [toVector, smul_eq_sum] + (i : Fin 1 ⊕ Fin d) : (toVector Λ) i = Λ.1 i (Sum.inl 0) := by simp [toVector, smul_eq_sum] lemma toVector_eq_fun {d : ℕ} (Λ : LorentzGroup d) : toVector Λ = (fun i => Λ.1 i (Sum.inl 0)) := by @@ -54,13 +51,11 @@ lemma toVector_continuous {d : ℕ} : Continuous (toVector (d := d)) := by fun_prop lemma toVector_timeComponent {d : ℕ} (Λ : LorentzGroup d) : - (toVector Λ).timeComponent = Λ.1 (Sum.inl 0) (Sum.inl 0) := by - simp + (toVector Λ).timeComponent = Λ.1 (Sum.inl 0) (Sum.inl 0) := by simp @[simp] lemma toVector_minkowskiProduct_self {d : ℕ} (Λ : LorentzGroup d) : - ⟪toVector Λ, toVector Λ⟫ₘ = 1 := by - simp [toVector, minkowskiMatrix.inl_0_inl_0] + ⟪toVector Λ, toVector Λ⟫ₘ = 1 := by simp [toVector, minkowskiMatrix.inl_0_inl_0] lemma one_le_abs_timeComponent {d : ℕ} (Λ : LorentzGroup d) : 1 ≤ |Λ.1 (Sum.inl 0) (Sum.inl 0)| := by From c6552a7424949eb02a9fa69de7b0101948c6b00f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:57:31 -0700 Subject: [PATCH 321/498] refactor: golf Wick contraction wrappers Co-authored-by: Claude Opus 4.8 --- .../WickContraction/Basic.lean | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean index d181b242c..c20a58d9c 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Basic.lean @@ -202,8 +202,7 @@ lemma getDual?_get_self_mem (i : Fin n) (h : (c.getDual? i).isSome) : @[simp] lemma self_getDual?_get_mem (i : Fin n) (h : (c.getDual? i).isSome) : - {i, (c.getDual? i).get h} ∈ c.1 := by - rw [← getDual?_eq_some_iff_mem, Option.some_get] + {i, (c.getDual? i).get h} ∈ c.1 := by rw [← getDual?_eq_some_iff_mem, Option.some_get] lemma getDual?_eq_some_neq (i j : Fin n) (h : c.getDual? i = some j) : ¬ i = j := by @@ -260,16 +259,13 @@ lemma getDual?_isSome_of_mem (a : c.1) (i : a.1) : (c.getDual? i).isSome := by @[simp] lemma getDual?_getDual?_get_get (i : Fin n) (h : (c.getDual? i).isSome) : - c.getDual? ((c.getDual? i).get h) = some i := by - simp [getDual?_eq_some_iff_mem] + c.getDual? ((c.getDual? i).get h) = some i := by simp [getDual?_eq_some_iff_mem] lemma getDual?_getDual?_get_isSome (i : Fin n) (h : (c.getDual? i).isSome) : - (c.getDual? ((c.getDual? i).get h)).isSome := by - simp + (c.getDual? ((c.getDual? i).get h)).isSome := by simp lemma getDual?_getDual?_get_not_none (i : Fin n) (h : (c.getDual? i).isSome) : - ¬ (c.getDual? ((c.getDual? i).get h)) = none := by - simp + ¬ (c.getDual? ((c.getDual? i).get h)) = none := by simp /-! @@ -366,8 +362,7 @@ lemma fstFieldOfContract_lt_sndFieldOfContract (c : WickContraction n) (a : c.1) @[simp] lemma fstFieldOfContract_mem (c : WickContraction n) (a : c.1) : - c.fstFieldOfContract a ∈ a.1 := by - simp [finset_eq_fstFieldOfContract_sndFieldOfContract] + c.fstFieldOfContract a ∈ a.1 := by simp [finset_eq_fstFieldOfContract_sndFieldOfContract] lemma fstFieldOfContract_getDual?_isSome (c : WickContraction n) (a : c.1) : (c.getDual? (c.fstFieldOfContract a)).isSome := by @@ -380,8 +375,7 @@ lemma fstFieldOfContract_getDual? (c : WickContraction n) (a : c.1) : @[simp] lemma sndFieldOfContract_mem (c : WickContraction n) (a : c.1) : - c.sndFieldOfContract a ∈ a.1 := by - simp [finset_eq_fstFieldOfContract_sndFieldOfContract] + c.sndFieldOfContract a ∈ a.1 := by simp [finset_eq_fstFieldOfContract_sndFieldOfContract] lemma sndFieldOfContract_getDual?_isSome (c : WickContraction n) (a : c.1) : (c.getDual? (c.sndFieldOfContract a)).isSome := by From 782b7192efb88341f1f8f34153142d146696ce6e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 02:59:07 -0700 Subject: [PATCH 322/498] refactor: golf symmetric linear map wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/LinearMaps.lean | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Physlib/Mathematics/LinearMaps.lean b/Physlib/Mathematics/LinearMaps.lean index fca70f242..879a5489d 100644 --- a/Physlib/Mathematics/LinearMaps.lean +++ b/Physlib/Mathematics/LinearMaps.lean @@ -99,8 +99,7 @@ lemma map_add₁ (f : BiLinearSymm V) (S1 S2 T : V) : f (S1 + S2) T = f S1 T + f (congrArg (fun g : V →ₗ[ℚ] ℚ => g T) (f.map_add S1 S2)).trans (by rfl) lemma map_add₂ (f : BiLinearSymm V) (S : V) (T1 T2 : V) : - f S (T1 + T2) = f S T1 + f S T2 := by - rw [f.swap, f.map_add₁, f.swap T1 S, f.swap T2 S] + f S (T1 + T2) = f S T1 + f S T2 := by rw [f.swap, f.map_add₁, f.swap T1 S, f.swap T2 S] /-- Fixing the second input vectors, the resulting linear map. -/ def toLinear₁ (f : BiLinearSymm V) (T : V) : V →ₗ[ℚ] ℚ where @@ -111,8 +110,7 @@ def toLinear₁ (f : BiLinearSymm V) (T : V) : V →ₗ[ℚ] ℚ where lemma toLinear₁_apply (f : BiLinearSymm V) (S T : V) : f S T = f.toLinear₁ T S := rfl lemma map_sum₁ {n : ℕ} (f : BiLinearSymm V) (S : Fin n → V) (T : V) : - f (∑ i, S i) T = ∑ i, f (S i) T := by - simp [f.toLinear₁_apply, map_sum] + f (∑ i, S i) T = ∑ i, f (S i) T := by simp [f.toLinear₁_apply, map_sum] lemma map_sum₂ {n : ℕ} (f : BiLinearSymm V) (S : Fin n → V) (T : V) : f T (∑ i, S i) = ∑ i, f T (S i) := map_sum (f T) S Finset.univ @@ -211,24 +209,20 @@ lemma map_smul₁ (f : TriLinearSymm V) (a : ℚ) (S T L : V) : (congrArg (fun g : V →ₗ[ℚ] V →ₗ[ℚ] ℚ => g T L) (f.map_smul a S)).trans rfl lemma map_smul₂ (f : TriLinearSymm V) (S : V) (a : ℚ) (T L : V) : - f S (a • T) L = a * f S T L := by - rw [f.swap₁, f.map_smul₁, f.swap₁] + f S (a • T) L = a * f S T L := by rw [f.swap₁, f.map_smul₁, f.swap₁] lemma map_smul₃ (f : TriLinearSymm V) (S T : V) (a : ℚ) (L : V) : - f S T (a • L) = a * f S T L := by - rw [f.swap₃, f.map_smul₁, f.swap₃] + f S T (a • L) = a * f S T L := by rw [f.swap₃, f.map_smul₁, f.swap₃] lemma map_add₁ (f : TriLinearSymm V) (S1 S2 T L : V) : f (S1 + S2) T L = f S1 T L + f S2 T L := (congrArg (fun g : V →ₗ[ℚ] V →ₗ[ℚ] ℚ => g T L) (f.map_add S1 S2)).trans rfl lemma map_add₂ (f : TriLinearSymm V) (S T1 T2 L : V) : - f S (T1 + T2) L = f S T1 L + f S T2 L := by - rw [f.swap₁, f.map_add₁, f.swap₁ S T1, f.swap₁ S T2] + f S (T1 + T2) L = f S T1 L + f S T2 L := by rw [f.swap₁, f.map_add₁, f.swap₁ S T1, f.swap₁ S T2] lemma map_add₃ (f : TriLinearSymm V) (S T L1 L2 : V) : - f S T (L1 + L2) = f S T L1 + f S T L2 := by - rw [f.swap₃, f.map_add₁, f.swap₃, f.swap₃ L2 T S] + f S T (L1 + L2) = f S T L1 + f S T L2 := by rw [f.swap₃, f.map_add₁, f.swap₃, f.swap₃ L2 T S] /-- Fixing the second and third input vectors, the resulting linear map. -/ def toLinear₁ (f : TriLinearSymm V) (T L : V) : V →ₗ[ℚ] ℚ where @@ -239,8 +233,7 @@ def toLinear₁ (f : TriLinearSymm V) (T L : V) : V →ₗ[ℚ] ℚ where lemma toLinear₁_apply (f : TriLinearSymm V) (S T L : V) : f S T L = f.toLinear₁ T L S := rfl lemma map_sum₁ {n : ℕ} (f : TriLinearSymm V) (S : Fin n → V) (T : V) (L : V) : - f (∑ i, S i) T L = ∑ i, f (S i) T L := by - simp [toLinear₁_apply, map_sum] + f (∑ i, S i) T L = ∑ i, f (S i) T L := by simp [toLinear₁_apply, map_sum] lemma map_sum₂ {n : ℕ} (f : TriLinearSymm V) (S : Fin n → V) (T : V) (L : V) : f T (∑ i, S i) L = ∑ i, f T (S i) L := by From e7287d927b661558e32c7c27cca806342cd2a414 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:01:22 -0700 Subject: [PATCH 323/498] refactor: golf relative entropy wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index ef14c9295..a0f817ed2 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -357,8 +357,7 @@ lemma HermitianMat.mul_supportProj_of_ker_le {A B : HermitianMat d ℂ} lemma HermitianMat.inner_supportProj_of_ker_le {A B : HermitianMat d ℂ} (h : LinearMap.ker B.lin.toLinearMap ≤ LinearMap.ker A.lin.toLinearMap) : - ⟪A, B.supportProj⟫ = A.trace := by - rw [inner_def, mul_supportProj_of_ker_le h, trace] + ⟪A, B.supportProj⟫ = A.trace := by rw [inner_def, mul_supportProj_of_ker_le h, trace] lemma supportProj_inner_density (h : σ.M.ker ≤ ρ.M.ker) : ⟪σ.M.supportProj, ρ.M⟫_ℝ = 1 := by @@ -435,8 +434,7 @@ private theorem sandwichedRelRentropy_nonneg_α_gt_1 (h : σ.M.ker ≤ ρ.M.ker) positivity private lemma sandwichedRelRentropy.trace_at_one (ρ σ : MState d) : - ((ρ.M.conj (σ.M ^ ((1 - (1:ℝ)) / (2 * (1:ℝ)))).mat) ^ (1:ℝ)).trace = 1 := by - simp + ((ρ.M.conj (σ.M ^ ((1 - (1:ℝ)) / (2 * (1:ℝ)))).mat) ^ (1:ℝ)).trace = 1 := by simp /- For fixed PSD B, the derivative of α ↦ Tr[B^α] at α = 1 is ⟪B, B.log⟫ = Tr[B log B]. @@ -655,14 +653,12 @@ private lemma B_of_nonneg (ρ σ : MState d) (α : ℝ) : 0 ≤ B_of ρ σ α := -- The function g(M) = Tr[M^s] - Tr[M] satisfies g(M) = 0 when s = 1. private lemma trace_rpow_sub_trace_at_one (M : HermitianMat d ℂ) : - (M ^ (1 : ℝ)).trace - M.trace = 0 := by - simp [HermitianMat.rpow_one] + (M ^ (1 : ℝ)).trace - M.trace = 0 := by simp [HermitianMat.rpow_one] -- The cross term function value at α = 1 is zero. private lemma cross_term_at_one (ρ σ : MState d) : ((B_of ρ σ 1) ^ (1 : ℝ)).trace - (B_of ρ σ 1).trace - - (ρ.M ^ (1 : ℝ)).trace + 1 = 0 := by - simp [B_of_one, HermitianMat.rpow_one, ρ.tr] + - (ρ.M ^ (1 : ℝ)).trace + 1 = 0 := by simp [B_of_one, HermitianMat.rpow_one, ρ.tr] /- Scalar rpow cross term with just continuity: for a continuous function b with @@ -1629,8 +1625,7 @@ lemma maps_to_Iio_of_Ioi_1 : Set.MapsTo (fun α : ℝ => (1 - α) / (2 * α)) (S --PR'ed: #35494 @[simp] theorem frontier_singleton {X : Type*} [TopologicalSpace X] [T1Space X] [PerfectSpace X] - (p : X) : frontier {p} = {p} := by - simp [frontier] + (p : X) : frontier {p} = {p} := by simp [frontier] private theorem sandwichedRelRentropy.continuousOn_Ioi_1_aux (ρ σ : MState d) : ContinuousOn (fun (α : ℝ) ↦ ((HermitianMat.conj (σ.M ^ ((1 - α) / (2 * α))).mat) ρ.M ^ α)) (Set.Ioi 1) := by @@ -1785,8 +1780,7 @@ theorem qRelativeEnt_eq_neg_Sᵥₙ_add (ρ σ : MState d) : /-- The quantum relative entropy is unchanged by `MState.relabel` -/ @[simp] theorem qRelativeEnt_relabel (ρ σ : MState d) (e : d₂ ≃ d) : - 𝐃(ρ.relabel e‖σ.relabel e) = 𝐃(ρ‖σ) := by - simp [qRelativeEnt] + 𝐃(ρ.relabel e‖σ.relabel e) = 𝐃(ρ‖σ) := by simp [qRelativeEnt] @[simp] theorem sandwichedRelRentropy_of_unique [Unique d] (ρ σ : MState d) : @@ -2107,8 +2101,7 @@ theorem qRelativeEnt_joint_convexity : sorry @[simp] -theorem qRelEntropy_self (ρ : MState d) : 𝐃(ρ‖ρ) = 0 := by - simp [qRelativeEnt] +theorem qRelEntropy_self (ρ : MState d) : 𝐃(ρ‖ρ) = 0 := by simp [qRelativeEnt] @[aesop (rule_sets := [finiteness]) unsafe apply] theorem qRelativeEnt_ne_top {ρ σ : MState d} [σ.M.NonSingular] : 𝐃(ρ‖σ) ≠ ⊤ := by @@ -2433,5 +2426,4 @@ theorem qRelEntropy_le_add_of_le_smul (ρ : MState d) {σ₁ σ₂ : MState d} ( · simp [hker, SandwichedRelRentropy, qRelativeEnt] theorem qRelativeEnt_op_le {ρ σ : MState d} (h : ρ.M ≤ α • σ.M) : - 𝐃(ρ‖σ) ≤ .ofReal (Real.log α) := by - simpa using qRelEntropy_le_add_of_le_smul ρ h + 𝐃(ρ‖σ) ≤ .ofReal (Real.log α) := by simpa using qRelEntropy_le_add_of_le_smul ρ h From 33d6a585410e50532947ce370243a7ae48bcb990 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:02:41 -0700 Subject: [PATCH 324/498] refactor: golf Lowner-Heinz core wrappers Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 50ebc5a71..7303559df 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -156,8 +156,7 @@ variable [NonnegSpectrumClass ℝ 𝓐] omit [Nontrivial (𝓐)] [NonnegSpectrumClass ℝ 𝓐] in lemma conjugate_isPositive {X T : 𝓐} (hX : 0 ≤ X) (hT : IsSelfAdjoint T) : - 0 ≤ T * X * T := by - simpa using hT.conjugate_nonneg hX + 0 ≤ T * X * T := by simpa using hT.conjugate_nonneg hX omit [Nontrivial 𝓐] [NonnegSpectrumClass ℝ 𝓐] in theorem one_div_operatorAntitoneOn_Ioi : @@ -720,8 +719,7 @@ theorem ratio_add_t_operatorMonotoneOn_Ici : ∀ (t : ℝ), 0 < t → = (1 : 𝓐) - t • cfcR invfun B := by simpa using hrepr B hB0 hspB _ ≤ (1 : 𝓐) - t • cfcR invfun A := hmono_core - _ = cfcR (fun x : ℝ ↦ x / (x + t)) A := by - simpa using (hrepr A hA0 hspA).symm + _ = cfcR (fun x : ℝ ↦ x / (x + t)) A := by simpa using (hrepr A hA0 hspA).symm theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → OperatorConcaveOn (𝓐 := 𝓐) (Set.Ici (0 : ℝ)) (fun x : ℝ ↦ x / (x + t)) := by @@ -1515,8 +1513,7 @@ private lemma cfcR_mul_self (T : 𝓐) (hT : IsSelfAdjoint T) : simpa using (cfc_mul (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x) (g := fun x : ℝ ↦ x) (a := T)) - _ = T * T := by - simp [cfc_id' (R := ℝ) (a := T) (ha := hT)] + _ = T * T := by simp [cfc_id' (R := ℝ) (a := T) (ha := hT)] omit [Nontrivial (𝓐)] in omit [PartialOrder 𝓐] [StarOrderedRing 𝓐] [NonnegSpectrumClass ℝ 𝓐] in @@ -1532,8 +1529,7 @@ omit [Nontrivial (𝓐)] in omit [PartialOrder 𝓐] [StarOrderedRing 𝓐] [NonnegSpectrumClass ℝ 𝓐] in private lemma smul_sub_mul_sub (α : ℝ) (A B : 𝓐) : α • (A * A - A * B - B * A + B * B) = - α • (A * A) - α • (A * B) - α • (B * A) + α • (B * B) := by - rw [smul_add, smul_sub, smul_sub] + α • (A * A) - α • (A * B) - α • (B * A) + α • (B * B) := by rw [smul_add, smul_sub, smul_sub] omit [Nontrivial (𝓐)] in omit [PartialOrder 𝓐] [StarOrderedRing 𝓐] [NonnegSpectrumClass ℝ 𝓐] in @@ -1556,8 +1552,7 @@ private lemma square_convexity_diff_rhs (A B : 𝓐) (u : ℝ) : _ = α • (A * A) - α • (A * B) - α • (B * A) + α • (B * B) := smul_sub_mul_sub (α := α) A B _ = (u * (1 - u)) • (A * A) - (u * (1 - u)) • (A * B) - (u * (1 - u)) • (B * A) - + (u * (1 - u)) • (B * B) := by - simp [hα] + + (u * (1 - u)) • (B * B) := by simp [hα] omit [Nontrivial (𝓐)] in omit [PartialOrder 𝓐] [StarOrderedRing 𝓐] [NonnegSpectrumClass ℝ 𝓐] in From 251b34c7916a1c047e3d82c35f4ef154ba717112 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:05:04 -0700 Subject: [PATCH 325/498] refactor: golf Pauli and Weyl wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/PauliMatrices/Basic.lean | 12 ++++-------- .../Tensors/ComplexTensor/Weyl/Contraction.lean | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/Relativity/PauliMatrices/Basic.lean b/Physlib/Relativity/PauliMatrices/Basic.lean index 471937671..7e4e7b5b9 100644 --- a/Physlib/Relativity/PauliMatrices/Basic.lean +++ b/Physlib/Relativity/PauliMatrices/Basic.lean @@ -143,28 +143,24 @@ lemma σ1_σ1_trace : Matrix.trace (σ1 * σ1) = 2 := by simp /-- The trace of `σ1` multiplied by `σ2` is equal to `0`. -/ @[simp] -lemma σ1_σ2_trace : Matrix.trace (σ1 * σ2) = 0 := by - simp [pauliMatrix] +lemma σ1_σ2_trace : Matrix.trace (σ1 * σ2) = 0 := by simp [pauliMatrix] /-- The trace of `σ1` multiplied by `σ3` is equal to `0`. -/ @[simp] -lemma σ1_σ3_trace : Matrix.trace (σ1 * σ3) = 0 := by - simp [pauliMatrix] +lemma σ1_σ3_trace : Matrix.trace (σ1 * σ3) = 0 := by simp [pauliMatrix] /-- The trace of `σ2` multiplied by `σ0` is equal to `0`. -/ lemma σ2_σ0_trace : Matrix.trace (σ2 * σ0) = 0 := by simp [pauliMatrix] /-- The trace of `σ2` multiplied by `σ1` is equal to `0`. -/ -lemma σ2_σ1_trace : Matrix.trace (σ2 * σ1) = 0 := by - simp [pauliMatrix] +lemma σ2_σ1_trace : Matrix.trace (σ2 * σ1) = 0 := by simp [pauliMatrix] /-- The trace of `σ2` multiplied by `σ2` is equal to `2`. -/ lemma σ2_σ2_trace : Matrix.trace (σ2 * σ2) = 2 := by simp /-- The trace of `σ2` multiplied by `σ3` is equal to `0`. -/ @[simp] -lemma σ2_σ3_trace : Matrix.trace (σ2 * σ3) = 0 := by - simp [pauliMatrix] +lemma σ2_σ3_trace : Matrix.trace (σ2 * σ3) = 0 := by simp [pauliMatrix] /-- The trace of `σ3` multiplied by `σ0` is equal to `0`. -/ lemma σ3_σ0_trace : Matrix.trace (σ3 * σ0) = 0 := by simp [pauliMatrix] diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean index 4748e2992..71ff7c07d 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean @@ -140,8 +140,7 @@ def leftDualContraction : (leftHandedRep.tprod dualLeftHandedRep).IntertwiningMa lemma leftDualContraction_hom_tmul (ψ : LeftHandedWeyl) (φ : DualLeftHandedWeyl) : - leftDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := by - rfl + leftDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := by rfl lemma leftDualContraction_basis (i j : Fin 2) : leftDualContraction (leftBasis i ⊗ₜ dualLeftBasis j) = if i.1 = j.1 then (1 : ℂ) else 0 := by @@ -166,8 +165,7 @@ def dualLeftContraction : (dualLeftHandedRep.tprod leftHandedRep).IntertwiningMa simp lemma dualLeftContraction_hom_tmul (φ : DualLeftHandedWeyl) (ψ : LeftHandedWeyl) : - dualLeftContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := by - rfl + dualLeftContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := by rfl lemma dualLeftContraction_basis (i j : Fin 2) : dualLeftContraction (dualLeftBasis i ⊗ₜ leftBasis j) = if i.1 = j.1 then (1 : ℂ) else 0 := by @@ -206,8 +204,7 @@ def rightDualContraction : (rightHandedRep.tprod dualRightHandedRep).Intertwinin lemma rightDualContraction_hom_tmul (ψ : RightHandedWeyl) (φ : DualRightHandedWeyl) : - rightDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := by - rfl + rightDualContraction (ψ ⊗ₜ φ) = ψ.toFin2ℂ ⬝ᵥ φ.toFin2ℂ := by rfl lemma rightDualContraction_basis (i j : Fin 2) : rightDualContraction (rightBasis i ⊗ₜ dualRightBasis j) = @@ -247,8 +244,7 @@ def dualRightContraction : (dualRightHandedRep.tprod rightHandedRep).Intertwinin lemma dualRightContraction_hom_tmul (φ : DualRightHandedWeyl) (ψ : RightHandedWeyl) : - dualRightContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := by - rfl + dualRightContraction (φ ⊗ₜ ψ) = φ.toFin2ℂ ⬝ᵥ ψ.toFin2ℂ := by rfl lemma dualRightContraction_basis (i j : Fin 2) : dualRightContraction (dualRightBasis i ⊗ₜ rightBasis j) = From 18edf42e42527ffda91d6d9e881b1e37bd339623 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:06:45 -0700 Subject: [PATCH 326/498] refactor: golf relativity complexification wrappers Co-authored-by: Claude Opus 4.8 --- .../Relativity/LorentzGroup/Orthochronous/Basic.lean | 12 ++++-------- Physlib/Relativity/Tensors/RealTensor/ToComplex.lean | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean index efc9f1b9d..84e1cf0cf 100644 --- a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean @@ -37,8 +37,7 @@ def IsOrthochronous : Prop := 0 ≤ Λ.1 (Sum.inl 0) (Sum.inl 0) /-- A Lorentz transformation is `orthochronous` if and only if its first column is future pointing. -/ lemma isOrthochronous_iff_toVector_timeComponet_nonneg : - IsOrthochronous Λ ↔ 0 ≤ (toVector Λ).timeComponent := by - simp [IsOrthochronous, timeComponent] + IsOrthochronous Λ ↔ 0 ≤ (toVector Λ).timeComponent := by simp [IsOrthochronous, timeComponent] /-- A Lorentz transformation is orthochronous if and only if its transpose is orthochronous. -/ lemma isOrthochronous_iff_transpose : @@ -94,12 +93,10 @@ lemma not_isOrthochronous_iff_le_zero : ¬ IsOrthochronous Λ ↔ Λ.1 (Sum.inl constructor <;> intro h <;> rcases h1 with h1 | h1 <;> linarith lemma not_isOrthochronous_iff_toVector_timeComponet_nonpos : - ¬ IsOrthochronous Λ ↔ (toVector Λ).timeComponent ≤ 0:= by - simp [not_isOrthochronous_iff_le_zero] + ¬ IsOrthochronous Λ ↔ (toVector Λ).timeComponent ≤ 0:= by simp [not_isOrthochronous_iff_le_zero] /-- The identity Lorentz transformation is orthochronous. -/ -lemma id_isOrthochronous : @IsOrthochronous d 1 := by - simp [IsOrthochronous] +lemma id_isOrthochronous : @IsOrthochronous d 1 := by simp [IsOrthochronous] /-- The continuous map taking a Lorentz transformation to its `0 0` element. -/ def timeCompCont : C(LorentzGroup d, ℝ) := ⟨fun Λ => Λ.1 (Sum.inl 0) (Sum.inl 0), @@ -158,8 +155,7 @@ def orthchroMap : C(LorentzGroup d, ℤ₂) := /-- A Lorentz transformation which is orthochronous maps under `orthchroMap` to `1` in `ℤ₂` (the identity element). -/ lemma orthchroMap_IsOrthochronous {Λ : LorentzGroup d} (h : IsOrthochronous Λ) : - orthchroMap Λ = 1 := by - simp [orthchroMap, orthchroMapReal_on_IsOrthochronous h] + orthchroMap Λ = 1 := by simp [orthchroMap, orthchroMapReal_on_IsOrthochronous h] /-- A Lorentz transformation which is not-orthochronous maps under `orthchroMap` to the non-identity element of `ℤ₂`. -/ diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index 3a1dfb51d..07c0b1a89 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -93,16 +93,14 @@ lemma colorToComplex_match_up {n} {c : Fin n → realLorentzTensor.Color} {j} (match c j with | .up => complexLorentzTensor.Color.up | .down => complexLorentzTensor.Color.down) - = complexLorentzTensor.Color.up := by - rw [hc] + = complexLorentzTensor.Color.up := by rw [hc] lemma colorToComplex_match_down {n} {c : Fin n → realLorentzTensor.Color} {j} (hc : c j = realLorentzTensor.Color.down) : (match c j with | .up => complexLorentzTensor.Color.up | .down => complexLorentzTensor.Color.down) - = complexLorentzTensor.Color.down := by - rw [hc] + = complexLorentzTensor.Color.down := by rw [hc] lemma colorToComplex_comp_eq_match {n} (c : Fin n → realLorentzTensor.Color) (j : Fin n) : (colorToComplex ∘ c) j = @@ -355,8 +353,7 @@ lemma toComplexVector_up_eq_inclCongrRealLorentz (v : Lorentz.ContrMod 3) : (∑ i, v.toFin1dℝ i • Lorentz.ContrMod.stdBasis i) := by rw [map_sum] simp only [LinearMap.map_smulₛₗ, Complex.ofRealHom_eq_coe, Complex.coe_smul] - _ = Lorentz.inclCongrRealLorentz v := by - rw [← Lorentz.ContrMod.stdBasis_decomp v] + _ = Lorentz.inclCongrRealLorentz v := by rw [← Lorentz.ContrMod.stdBasis_decomp v] lemma toComplexVector_down_eq_inclCoRealLorentz (v : Lorentz.CoMod 3) : toComplexVector Color.down v = Lorentz.inclCoRealLorentz v := by @@ -372,8 +369,7 @@ lemma toComplexVector_down_eq_inclCoRealLorentz (v : Lorentz.CoMod 3) : (∑ i, v.toFin1dℝ i • Lorentz.CoMod.stdBasis i) := by rw [map_sum] simp only [LinearMap.map_smulₛₗ, Complex.ofRealHom_eq_coe, Complex.coe_smul] - _ = Lorentz.inclCoRealLorentz v := by - rw [← Lorentz.CoMod.stdBasis_decomp v] + _ = Lorentz.inclCoRealLorentz v := by rw [← Lorentz.CoMod.stdBasis_decomp v] /-- The function which turns a real pure tensor into a complex one. -/ noncomputable def toComplexPure {c : Fin n → Color} (p : Pure realLorentzTensor c) : From dbeb2dbb42b6712de82db72abd3f4196eb922c72 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:08:24 -0700 Subject: [PATCH 327/498] refactor: golf QFT algebra wrappers Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/SuperCommute.lean | 6 ++---- .../QFT/PerturbationTheory/WickAlgebra/Basic.lean | 6 ++---- .../PerturbationTheory/WickAlgebra/SuperCommute.lean | 12 ++++-------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index 491b3753e..ebfd583f8 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -647,13 +647,11 @@ lemma bosonic_superCommuteF {a b : 𝓕.FieldOpFreeAlgebra} (ha : a ∈ statisti lemma superCommuteF_bonsonic_symm {a b : 𝓕.FieldOpFreeAlgebra} (hb : b ∈ statisticSubmodule bosonic) : - [a, b]ₛF = - [b, a]ₛF := by - simp [bosonic_superCommuteF hb, superCommuteF_bonsonic hb] + [a, b]ₛF = - [b, a]ₛF := by simp [bosonic_superCommuteF hb, superCommuteF_bonsonic hb] lemma bonsonic_superCommuteF_symm {a b : 𝓕.FieldOpFreeAlgebra} (ha : a ∈ statisticSubmodule bosonic) : - [a, b]ₛF = - [b, a]ₛF := by - simp [bosonic_superCommuteF ha, superCommuteF_bonsonic ha] + [a, b]ₛF = - [b, a]ₛF := by simp [bosonic_superCommuteF ha, superCommuteF_bonsonic ha] lemma superCommuteF_fermionic_fermionic {a b : 𝓕.FieldOpFreeAlgebra} (ha : a ∈ statisticSubmodule fermionic) (hb : b ∈ statisticSubmodule fermionic) : diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean index 1c4599fd0..35eec32e3 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Basic.lean @@ -444,8 +444,7 @@ lemma anPart_position (φ : (Σ f, 𝓕.PositionLabel f) × SpaceTime) : @[simp] lemma anPart_outAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : - anPart (FieldOp.outAsymp φ) = ofCrAnOp ⟨FieldOp.outAsymp φ, ()⟩ := by - simp [anPart, ofCrAnOp] + anPart (FieldOp.outAsymp φ) = ofCrAnOp ⟨FieldOp.outAsymp φ, ()⟩ := by simp [anPart, ofCrAnOp] /-- For a field specification `𝓕`, and an element `φ` of `𝓕.FieldOp`, the creation part of `𝓕.FieldOp` as an element of `𝓕.WickAlgebra`. @@ -459,8 +458,7 @@ lemma crPart_eq_ι_crPartF (φ : 𝓕.FieldOp) : crPart φ = ι (crPartF φ) := @[simp] lemma crPart_inAsymp (φ : (Σ f, 𝓕.AsymptoticLabel f) × Momentum) : - crPart (FieldOp.inAsymp φ) = ofCrAnOp ⟨FieldOp.inAsymp φ, ()⟩ := by - simp [crPart, ofCrAnOp] + crPart (FieldOp.inAsymp φ) = ofCrAnOp ⟨FieldOp.inAsymp φ, ()⟩ := by simp [crPart, ofCrAnOp] @[simp] lemma crPart_position (φ : (Σ f, 𝓕.PositionLabel f) × SpaceTime) : diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 5d8ea6e99..b10359eb5 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -355,8 +355,7 @@ lemma ofCrAnOp_mul_ofCrAnList_eq_superCommute (φ : 𝓕.CrAnFieldOp) lemma ofFieldOpList_mul_ofFieldOpList_eq_superCommute (φs φs' : List 𝓕.FieldOp) : ofFieldOpList φs * ofFieldOpList φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofFieldOpList φs' * ofFieldOpList φs - + [ofFieldOpList φs, ofFieldOpList φs']ₛ := by - simp [superCommute_ofFieldOpList_ofFieldOpList] + + [ofFieldOpList φs, ofFieldOpList φs']ₛ := by simp [superCommute_ofFieldOpList_ofFieldOpList] lemma ofFieldOp_mul_ofFieldOpList_eq_superCommute (φ : 𝓕.FieldOp) (φs' : List 𝓕.FieldOp) : ofFieldOp φ * ofFieldOpList φs' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs') • ofFieldOpList φs' * ofFieldOp φ @@ -376,18 +375,15 @@ lemma ofFieldOpList_mul_ofFieldOp_eq_superCommute (φs : List 𝓕.FieldOp) (φ lemma ofCrAnList_mul_ofFieldOpList_eq_superCommute (φs : List 𝓕.CrAnFieldOp) (φs' : List 𝓕.FieldOp) : ofCrAnList φs * ofFieldOpList φs' = 𝓢(𝓕 |>ₛ φs, 𝓕 |>ₛ φs') • ofFieldOpList φs' * ofCrAnList φs - + [ofCrAnList φs, ofFieldOpList φs']ₛ := by - simp [superCommute_ofCrAnList_ofFieldOpList] + + [ofCrAnList φs, ofFieldOpList φs']ₛ := by simp [superCommute_ofCrAnList_ofFieldOpList] lemma crPart_mul_anPart_eq_superCommute (φ φ' : 𝓕.FieldOp) : crPart φ * anPart φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • anPart φ' * crPart φ - + [crPart φ, anPart φ']ₛ := by - simp [superCommute_crPart_anPart] + + [crPart φ, anPart φ']ₛ := by simp [superCommute_crPart_anPart] lemma anPart_mul_crPart_eq_superCommute (φ φ' : 𝓕.FieldOp) : anPart φ * crPart φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPart φ' * anPart φ - + [anPart φ, crPart φ']ₛ := by - simp [superCommute_anPart_crPart] + + [anPart φ, crPart φ']ₛ := by simp [superCommute_anPart_crPart] lemma crPart_mul_crPart_swap (φ φ' : 𝓕.FieldOp) : crPart φ * crPart φ' = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPart φ' * crPart φ := by From 0769f00e70800cd2ed51a6f2b41be057f1e5cadb Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:11:22 -0700 Subject: [PATCH 328/498] refactor: golf space and time derivative wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/Slice.lean | 9 +++------ Physlib/SpaceAndTime/Time/Derivatives.lean | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Slice.lean b/Physlib/SpaceAndTime/Space/Slice.lean index 4487e19d3..c0f1e181f 100644 --- a/Physlib/SpaceAndTime/Space/Slice.lean +++ b/Physlib/SpaceAndTime/Space/Slice.lean @@ -105,13 +105,11 @@ lemma slice_symm_apply {d : ℕ} (i : Fin d.succ) (r : ℝ) (x : Space d) : @[simp] lemma slice_symm_apply_self {d : ℕ} (i : Fin d.succ) (r : ℝ) (x : Space d) : - (slice i).symm (r, x) i = r := by - simp [slice_symm_apply] + (slice i).symm (r, x) i = r := by simp [slice_symm_apply] @[simp] lemma slice_symm_apply_succAbove {d : ℕ} (i : Fin d.succ) (r : ℝ) (x : Space d) (j : Fin d) : - (slice i).symm (r, x) (Fin.succAbove i j) = x j := by - simp [slice_symm_apply] + (slice i).symm (r, x) (Fin.succAbove i j) = x j := by simp [slice_symm_apply] /-! @@ -172,8 +170,7 @@ lemma norm_left_le_norm_slice_symm {d : ℕ} (i : Fin d.succ) (r : ℝ) (x : Spa @[simp] lemma fderiv_slice_symm {d : ℕ} (i : Fin d.succ) (p1 : ℝ × Space d) : - fderiv ℝ (slice i).symm p1 = (slice i).symm := by - rw [ContinuousLinearEquiv.fderiv] + fderiv ℝ (slice i).symm p1 = (slice i).symm := by rw [ContinuousLinearEquiv.fderiv] lemma fderiv_slice_symm_left_apply {d : ℕ} (i : Fin d.succ) (x : Space d) (r1 r2 : ℝ) : (fderiv ℝ (fun r => (slice i).symm (r, x))) r1 r2 = (slice i).symm (r2, 0) := by diff --git a/Physlib/SpaceAndTime/Time/Derivatives.lean b/Physlib/SpaceAndTime/Time/Derivatives.lean index 6f292be43..ca89a95e2 100644 --- a/Physlib/SpaceAndTime/Time/Derivatives.lean +++ b/Physlib/SpaceAndTime/Time/Derivatives.lean @@ -100,16 +100,14 @@ lemma deriv_eq_mfderiv [NormedAddCommGroup M] [NormedSpace ℝ M] open Manifold in lemma deriv_eq_manifoldDeriv [NormedAddCommGroup M] [NormedSpace ℝ M] (f : Time → M) (t : Time) : - deriv f t = manifoldDeriv 𝓘(ℝ, M) f t := by - rw [deriv_eq_mfderiv, manifoldDeriv_eq] + deriv f t = manifoldDeriv 𝓘(ℝ, M) f t := by rw [deriv_eq_mfderiv, manifoldDeriv_eq] open Manifold in @[simp] lemma manifoldDeriv_const {E H N : Type} [NormedAddCommGroup E] [NormedSpace ℝ E] [TopologicalSpace H] (I : ModelWithCorners ℝ E H) [TopologicalSpace N] [ChartedSpace H N] (n : N) : - manifoldDeriv I (fun _ : Time => n) t = 0 := by - simp [manifoldDeriv] + manifoldDeriv I (fun _ : Time => n) t = 0 := by simp [manifoldDeriv] /-! @@ -125,8 +123,7 @@ lemma deriv_smul (f : Time → EuclideanSpace ℝ (Fin d)) (k : ℝ) fun_prop lemma deriv_neg [NormedAddCommGroup M] [NormedSpace ℝ M] (f : Time → M) : - ∂ₜ (-f) t = -∂ₜ f t := by - simp [deriv, fderiv_neg] + ∂ₜ (-f) t = -∂ₜ f t := by simp [deriv, fderiv_neg] /-- Quotient rule for `Time.deriv` on real-valued functions: if `c` and `g` are differentiable at `t` and `g t ≠ 0`, then From 801fc65bc0d4c771f5bf03149a21f28835258269 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:13:13 -0700 Subject: [PATCH 329/498] refactor: golf Hermitian matrix wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/Jordan.lean | 9 +++------ QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 12 ++++-------- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 6 ++---- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean b/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean index fef86356d..1f6dbf8ab 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Jordan.lean @@ -37,12 +37,10 @@ theorem symmMul_comm : A.symmMul B = B.symmMul A := by rw [symmMul, symmMul, Subtype.mk.injEq, add_comm] @[simp] -theorem symmMul_zero : A.symmMul 0 = 0:= by - simp [symmMul] +theorem symmMul_zero : A.symmMul 0 = 0:= by simp [symmMul] @[simp] -theorem zero_symmMul : symmMul 0 A = 0 := by - simp [symmMul] +theorem zero_symmMul : symmMul 0 A = 0 := by simp [symmMul] theorem symmMul_toMat : (A.symmMul B).mat = (2 : 𝕜)⁻¹ • (A.mat * B.mat + B.mat * A.mat) := rfl @@ -57,8 +55,7 @@ theorem symmMul_of_commute (hAB : Commute A.mat B.mat) : rw [smul_add, ← add_smul, inv_eq_one_div, ← add_div] rw [add_self_div_two, one_smul] -theorem symmMul_self : (symmMul A A).mat = A.mat * A.mat := by - simp +theorem symmMul_self : (symmMul A A).mat = A.mat * A.mat := by simp variable [DecidableEq d] diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 2b3cd9e10..832ed950f 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -115,12 +115,10 @@ theorem reindex_log (e : d ≃ d₂) : (A.reindex e).log = A.log.reindex e := cfc_reindex A Real.log e @[simp] -theorem log_zero : (0 : HermitianMat d 𝕜).log = 0 := by - simp [log] +theorem log_zero : (0 : HermitianMat d 𝕜).log = 0 := by simp [log] @[simp] -theorem log_one : (1 : HermitianMat d 𝕜).log = 0 := by - simp [log] +theorem log_one : (1 : HermitianMat d 𝕜).log = 0 := by simp [log] theorem log_smul_of_pos (A : HermitianMat d 𝕜) (hx : x ≠ 0) : (x • A).log = Real.log x • A.supportProj + A.log := by @@ -129,8 +127,7 @@ theorem log_smul_of_pos (A : HermitianMat d 𝕜) (hx : x ≠ 0) : simp [cfc, log, supportProj_eq_cfc] theorem log_smul {A : HermitianMat d 𝕜} {x : ℝ} (hx : x ≠ 0) [NonSingular A] : - (x • A).log = Real.log x • 1 + A.log := by - simp [log_smul_of_pos A hx] + (x • A).log = Real.log x • 1 + A.log := by simp [log_smul_of_pos A hx] /- The inverse function is operator antitone for positive definite matrices. @@ -660,8 +657,7 @@ lemma log_conj_unitary (A : HermitianMat d 𝕜) (U : Matrix.unitaryGroup d 𝕜 open RealInnerProductSpace in theorem inner_log_smul_of [NonSingular A] {x : ℝ} (hx : x ≠ 0) : - ⟪(x • A).log, B⟫ = Real.log x * B.trace + ⟪A.log, B⟫ := by - simp [log_smul hx, inner_add_left] + ⟪(x • A).log, B⟫ = Real.log x * B.trace + ⟪A.log, B⟫ := by simp [log_smul hx, inner_add_left] section kron diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 2931944e4..cd3000fe6 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -93,8 +93,7 @@ theorem continuousOn_rpow_neg (A : HermitianMat d ℂ) : ContinuousOn (fun x : exact (Real.continuousAt_const_rpow' hx.ne).continuousWithinAt @[simp] -theorem rpow_one : A ^ (1 : ℝ) = A := by - simp [rpow_eq_cfc] +theorem rpow_one : A ^ (1 : ℝ) = A := by simp [rpow_eq_cfc] /-- Functional calculus of Real.sqrt is equal to functional calculus of x^(1/2). @@ -114,8 +113,7 @@ theorem one_rpow : (1 : HermitianMat d 𝕜) ^ r = 1 := by simp @[simp] -lemma rpow_zero (A : HermitianMat d 𝕜) : A ^ (0 : ℝ) = 1 := by - simp [rpow_eq_cfc] +lemma rpow_zero (A : HermitianMat d 𝕜) : A ^ (0 : ℝ) = 1 := by simp [rpow_eq_cfc] lemma rpow_diagonal (a : d → ℝ) (r : ℝ) : (diagonal ℂ a) ^ r = diagonal ℂ (fun i => a i ^ r) := cfc_diagonal _ _ From 1c3ab160fb8b546cf7faba119fdf7aa6b6628f95 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:14:54 -0700 Subject: [PATCH 330/498] refactor: golf CKM and Higgs wrappers Co-authored-by: Claude Opus 4.8 --- .../StandardParameterization/StandardParameters.lean | 12 ++++-------- .../Particles/StandardModel/HiggsBoson/Basic.lean | 9 +++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Physlib/Particles/FlavorPhysics/CKMMatrix/StandardParameterization/StandardParameters.lean b/Physlib/Particles/FlavorPhysics/CKMMatrix/StandardParameterization/StandardParameters.lean index 63a9f9b0e..deda0b3cc 100644 --- a/Physlib/Particles/FlavorPhysics/CKMMatrix/StandardParameterization/StandardParameters.lean +++ b/Physlib/Particles/FlavorPhysics/CKMMatrix/StandardParameterization/StandardParameters.lean @@ -155,21 +155,17 @@ lemma S₂₃_of_Vub_eq_one {V : Quotient CKMMatrixSetoid} (ha : VubAbs V = 1) : rw [S₂₃, if_pos ha] lemma S₂₃_of_Vub_ne_one {V : Quotient CKMMatrixSetoid} (ha : VubAbs V ≠ 1) : - S₂₃ V = VcbAbs V / √ (VudAbs V ^ 2 + VusAbs V ^ 2) := by - rw [S₂₃, if_neg ha] + S₂₃ V = VcbAbs V / √ (VudAbs V ^ 2 + VusAbs V ^ 2) := by rw [S₂₃, if_neg ha] end sines section cosines -lemma C₁₂_eq_ℂcos_θ₁₂ (V : Quotient CKMMatrixSetoid) : Complex.cos (θ₁₂ V) = C₁₂ V := by - simp [C₁₂] +lemma C₁₂_eq_ℂcos_θ₁₂ (V : Quotient CKMMatrixSetoid) : Complex.cos (θ₁₂ V) = C₁₂ V := by simp [C₁₂] -lemma C₁₃_eq_ℂcos_θ₁₃ (V : Quotient CKMMatrixSetoid) : Complex.cos (θ₁₃ V) = C₁₃ V := by - simp [C₁₃] +lemma C₁₃_eq_ℂcos_θ₁₃ (V : Quotient CKMMatrixSetoid) : Complex.cos (θ₁₃ V) = C₁₃ V := by simp [C₁₃] -lemma C₂₃_eq_ℂcos_θ₂₃ (V : Quotient CKMMatrixSetoid) : Complex.cos (θ₂₃ V) = C₂₃ V := by - simp [C₂₃] +lemma C₂₃_eq_ℂcos_θ₂₃ (V : Quotient CKMMatrixSetoid) : Complex.cos (θ₂₃ V) = C₂₃ V := by simp [C₂₃] lemma complexAbs_cos_θ₁₂ (V : Quotient CKMMatrixSetoid) : norm (Complex.cos (θ₁₂ V)) = cos (θ₁₂ V) := by diff --git a/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean b/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean index a455bc03d..408aa4370 100644 --- a/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean +++ b/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean @@ -449,8 +449,7 @@ def toRealScalars : HiggsVec →ₗ[ℝ] (Fin 4 → ℝ) where fin_cases i <;> simp lemma toRealScalars_smul_real (a : ℝ) (φ : HiggsVec) : - toRealScalars (a • φ) = a • toRealScalars φ := by - simp [toRealScalars] + toRealScalars (a • φ) = a • toRealScalars φ := by simp [toRealScalars] lemma ofReal_toRealScalars (a : ℝ) : toRealScalars (ofReal a) = !₄[Real.sqrt a, 0, 0, 0] := by @@ -777,8 +776,7 @@ lemma normSq_expand (φ : HiggsField) : -/ -lemma normSq_nonneg (φ : HiggsField) (x : SpaceTime) : 0 ≤ ‖φ‖_H^2 x := by - simp [normSq] +lemma normSq_nonneg (φ : HiggsField) (x : SpaceTime) : 0 ≤ ‖φ‖_H^2 x := by simp [normSq] /-! @@ -816,8 +814,7 @@ lemma normSq_smooth (φ : HiggsField) : ContMDiff 𝓘(ℝ, SpaceTime) 𝓘(ℝ, @[simp] lemma const_normSq (φ : HiggsVec) (x : SpaceTime) : - ‖const φ‖_H^2 x = ‖φ‖ ^ 2 := by - simp [normSq, const_apply] + ‖const φ‖_H^2 x = ‖φ‖ ^ 2 := by simp [normSq, const_apply] /-! From 4aea2b75a7458a657efbbaa8cb5a196c2a950704 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:17:01 -0700 Subject: [PATCH 331/498] refactor: golf trace inequality block wrappers Co-authored-by: Claude Opus 4.8 --- .../HayataGroup/TraceInequality/BlockDiagonal.lean | 12 ++++-------- .../JensenOperatorInequalityIImpIV.lean | 6 ++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean index 6f0af1e74..826ef9bcd 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean @@ -170,13 +170,11 @@ omit [Nontrivial ℋ] in omit [CompleteSpace ℋ] [Nontrivial ℋ] in @[simp] theorem hsumProj_blockDiagonal_zero (A B : L ℋ) (z : HSum ℋ) : - hsumProj ℋ 0 (blockDiagonal A B z) = A (hsumProj ℋ 0 z) := by - simp [blockDiagonal] + hsumProj ℋ 0 (blockDiagonal A B z) = A (hsumProj ℋ 0 z) := by simp [blockDiagonal] omit [CompleteSpace ℋ] [Nontrivial ℋ] in @[simp] theorem hsumProj_blockDiagonal_one (A B : L ℋ) (z : HSum ℋ) : - hsumProj ℋ 1 (blockDiagonal A B z) = B (hsumProj ℋ 1 z) := by - simp [blockDiagonal] + hsumProj ℋ 1 (blockDiagonal A B z) = B (hsumProj ℋ 1 z) := by simp [blockDiagonal] omit [CompleteSpace ℋ] [Nontrivial ℋ] in @[simp] theorem blockDiagonal_one : @@ -228,14 +226,12 @@ theorem blockDiagonal_nonneg {A B : L ℋ} (hA : 0 ≤ A) (hB : 0 ≤ B) : omit [CompleteSpace ℋ] [Nontrivial ℋ] in @[simp] theorem hsumProj_blockOp_zero (A00 A01 A10 A11 : L ℋ) (z : HSum ℋ) : hsumProj ℋ 0 (blockOp (ℋ := ℋ) A00 A01 A10 A11 z) = - A00 (hsumProj ℋ 0 z) + A01 (hsumProj ℋ 1 z) := by - simp [blockOp] + A00 (hsumProj ℋ 0 z) + A01 (hsumProj ℋ 1 z) := by simp [blockOp] omit [CompleteSpace ℋ] [Nontrivial ℋ] in @[simp] theorem hsumProj_blockOp_one (A00 A01 A10 A11 : L ℋ) (z : HSum ℋ) : hsumProj ℋ 1 (blockOp (ℋ := ℋ) A00 A01 A10 A11 z) = - A10 (hsumProj ℋ 0 z) + A11 (hsumProj ℋ 1 z) := by - simp [blockOp] + A10 (hsumProj ℋ 0 z) + A11 (hsumProj ℋ 1 z) := by simp [blockOp] omit [Nontrivial ℋ] in @[simp] theorem blockOp_star (A00 A01 A10 A11 : L ℋ) : diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean index 7b570d249..fbfef0ee2 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean @@ -76,8 +76,7 @@ private noncomputable def blockSwap (X : L ℋ) : L (HSum ℋ) := blockOp (ℋ := ℋ) 0 (star X) X 0 private lemma blockSwap_star (X : L ℋ) : - star (blockSwap (ℋ := ℋ) X) = blockSwap (ℋ := ℋ) X := by - simp [blockSwap, blockOp_star] + star (blockSwap (ℋ := ℋ) X) = blockSwap (ℋ := ℋ) X := by simp [blockSwap, blockOp_star] private lemma blockSwap_sq (X : L ℋ) : blockSwap (ℋ := ℋ) X * blockSwap (ℋ := ℋ) X = @@ -338,8 +337,7 @@ private lemma complex_I_smul_real_I_smul_invTwo (r : ℝ) (T : L ℋ) : norm_num _ = (-1 : ℂ) • (((r * 2⁻¹ : ℝ)) • T x) := by rw [smul_smul] - _ = -((2⁻¹ : ℝ) * r) • T x := by - simp [neg_smul, mul_comm] + _ = -((2⁻¹ : ℝ) * r) • T x := by simp [neg_smul, mul_comm] omit [CompleteSpace ℋ] in private lemma real_smul_complex_I_real_smul_complex_I_comm (s r : ℝ) (T : L ℋ) : From 225c264246f6d1e0f22949b015efc71252a9b6ba Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:18:56 -0700 Subject: [PATCH 332/498] refactor: golf QFT field specification wrappers Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/FieldSpecification/Filters.lean | 9 +++------ .../PerturbationTheory/FieldSpecification/TimeOrder.lean | 6 ++---- .../PerturbationTheory/WickContraction/Singleton.lean | 9 +++------ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/Filters.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/Filters.lean index 4f8d7caa2..02bc26ec2 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/Filters.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/Filters.lean @@ -44,8 +44,7 @@ lemma createFilter_append (φs φs' : List 𝓕.CrAnFieldOp) : lemma createFilter_singleton_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) : - createFilter [φ] = [φ] := by - simp [createFilter, hφ] + createFilter [φ] = [φ] := by simp [createFilter, hφ] lemma createFilter_singleton_annihilate (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.annihilate) : createFilter [φ] = [] := by @@ -79,12 +78,10 @@ lemma annihilateFilter_append (φs φs' : List 𝓕.CrAnFieldOp) : lemma annihilateFilter_singleton_create (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.create) : - annihilateFilter [φ] = [] := by - simp [annihilateFilter, hφ] + annihilateFilter [φ] = [] := by simp [annihilateFilter, hφ] lemma annihilateFilter_singleton_annihilate (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.annihilate) : - annihilateFilter [φ] = [φ] := by - simp [annihilateFilter, hφ] + annihilateFilter [φ] = [φ] := by simp [annihilateFilter, hφ] end FieldSpecification diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean index 490fed244..f7279f161 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean @@ -178,8 +178,7 @@ lemma timeOrderList_pair_not_ordered {φ ψ : 𝓕.FieldOp} (h : ¬ timeOrderRel exact fun h' => False.elim (h h') @[simp] -lemma timeOrderList_nil : timeOrderList (𝓕 := 𝓕) [] = [] := by - simp [timeOrderList] +lemma timeOrderList_nil : timeOrderList (𝓕 := 𝓕) [] = [] := by simp [timeOrderList] lemma timeOrderList_eq_maxTimeField_timeOrderList (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) : timeOrderList (φ :: φs) = maxTimeField φ φs :: timeOrderList (eraseMaxTimeField φ φs) := by @@ -264,8 +263,7 @@ def crAnTimeOrderList (φs : List 𝓕.CrAnFieldOp) : List 𝓕.CrAnFieldOp := List.insertionSort 𝓕.crAnTimeOrderRel φs @[simp] -lemma crAnTimeOrderList_nil : crAnTimeOrderList (𝓕 := 𝓕) [] = [] := by - simp [crAnTimeOrderList] +lemma crAnTimeOrderList_nil : crAnTimeOrderList (𝓕 := 𝓕) [] = [] := by simp [crAnTimeOrderList] lemma crAnTimeOrderList_pair_ordered {φ ψ : 𝓕.CrAnFieldOp} (h : crAnTimeOrderRel φ ψ) : crAnTimeOrderList [φ, ψ] = [φ, ψ] := by diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Singleton.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Singleton.lean index 6a294112a..b3bdcd747 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Singleton.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Singleton.lean @@ -40,12 +40,10 @@ def singleton {i j : Fin n} (hij : i < j) : WickContraction n := simp_all⟩ lemma mem_singleton {i j : Fin n} (hij : i < j) : - {i, j} ∈ (singleton hij).1 := by - simp [singleton] + {i, j} ∈ (singleton hij).1 := by simp [singleton] lemma mem_singleton_iff {i j : Fin n} (hij : i < j) {a : Finset (Fin n)} : - a ∈ (singleton hij).1 ↔ a = {i, j} := by - simp [singleton] + a ∈ (singleton hij).1 ↔ a = {i, j} := by simp [singleton] lemma of_singleton_eq {i j : Fin n} (hij : i < j) (a : (singleton hij).1) : a = ⟨{i, j}, mem_singleton hij⟩ := by @@ -55,8 +53,7 @@ lemma of_singleton_eq {i j : Fin n} (hij : i < j) (a : (singleton hij).1) : lemma singleton_prod {φs : List 𝓕.FieldOp} {i j : Fin φs.length} (hij : i < j) (f : (singleton hij).1 → M) [CommMonoid M] : - ∏ a, f a = f ⟨{i,j}, mem_singleton hij⟩:= by - simp [singleton, of_singleton_eq] + ∏ a, f a = f ⟨{i,j}, mem_singleton hij⟩:= by simp [singleton, of_singleton_eq] @[simp] lemma singleton_fstFieldOfContract {i j : Fin n} (hij : i < j) : From 133488482826534027f5ca136280b4b5762d2e61 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:20:39 -0700 Subject: [PATCH 333/498] refactor: golf canonical ensemble wrappers Co-authored-by: Claude Opus 4.8 --- .../StatisticalMechanics/CanonicalEnsemble/Basic.lean | 9 +++------ .../StatisticalMechanics/CanonicalEnsemble/Lemmas.lean | 9 +++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 8d3dc1866..45ff73291 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -783,13 +783,11 @@ lemma partitionFunction_nsmul lemma partitionFunction_dof_zero (𝓒 : CanonicalEnsemble ι) (T : Temperature) (h : 𝓒.dof = 0) : - 𝓒.partitionFunction T = 𝓒.mathematicalPartitionFunction T := by - simp [partitionFunction, h] + 𝓒.partitionFunction T = 𝓒.mathematicalPartitionFunction T := by simp [partitionFunction, h] lemma partitionFunction_phase_space_unit_one (𝓒 : CanonicalEnsemble ι) (T : Temperature) (h : 𝓒.phaseSpaceunit = 1) : - 𝓒.partitionFunction T = 𝓒.mathematicalPartitionFunction T := by - simp [partitionFunction, h] + 𝓒.partitionFunction T = 𝓒.mathematicalPartitionFunction T := by simp [partitionFunction, h] lemma log_partitionFunction (𝓒 : CanonicalEnsemble ι) (T : Temperature) @@ -835,8 +833,7 @@ lemma helmholtzFreeEnergy_def lemma helmholtzFreeEnergy_congr (𝓒 : CanonicalEnsemble ι) (e : ι1 ≃ᵐ ι) (T : Temperature) : - (𝓒.congr e).helmholtzFreeEnergy T = 𝓒.helmholtzFreeEnergy T := by - simp [helmholtzFreeEnergy] + (𝓒.congr e).helmholtzFreeEnergy T = 𝓒.helmholtzFreeEnergy T := by simp [helmholtzFreeEnergy] lemma helmholtzFreeEnergy_dof_zero (𝓒 : CanonicalEnsemble ι) (T : Temperature) (h : 𝓒.dof = 0) : diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index f08cee5bf..6e61e9fb0 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -339,8 +339,7 @@ theorem differentialEntropy_eq_meanEnergy_sub_helmholtz_div_temp_add_correction + kB * (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by simp [hS_phys, add_comm, add_left_comm] _ = (E - 𝓒.helmholtzFreeEnergy T) / T.val - + kB * 𝓒.dof * Real.log 𝓒.phaseSpaceunit := by - rw [hEF] + + kB * 𝓒.dof * Real.log 𝓒.phaseSpaceunit := by rw [hEF] /-- Discrete / normalized specialization of the previous theorem. If either `dof = 0` (no semiclassical correction) or `phaseSpaceUnit = 1` @@ -442,8 +441,7 @@ lemma meanEnergy_eq_ratio_of_integrals (∫ x, 𝓒.energy x * Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) := by simp [h_inv_toReal] _ = (∫ x, 𝓒.energy x * Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) / - (∫ x, Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) := by - simp [h_den, div_eq_mul_inv, mul_comm] + (∫ x, Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) := by simp [h_den, div_eq_mul_inv, mul_comm] /-- The mean energy is the negative derivative of the logarithm of the (mathematical) partition function with respect to β = 1/(kB T). @@ -509,8 +507,7 @@ lemma meanEnergy_eq_neg_deriv_log_mathZ_of_beta (- ∫ i, 𝓒.energy i * Real.exp (-(T.β : ℝ) * 𝓒.energy i) ∂𝓒.μ)) := by ring _ = - (derivWithin (fun β : ℝ => Real.log (∫ i, Real.exp (-β * 𝓒.energy i) ∂𝓒.μ)) - (Set.Ioi 0) (T.β : ℝ)) := by - rw [h_deriv_log] + (Set.Ioi 0) (T.β : ℝ)) := by rw [h_deriv_log] section Ratios From 6a9e53b7a8d4b5783d95d5c742f1459f342bba0f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:24:07 -0700 Subject: [PATCH 334/498] refactor: golf relativity tensor wrappers Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Vector/Pre/Contraction.lean | 6 ++---- Physlib/Relativity/Tensors/Dual.lean | 6 ++---- Physlib/Relativity/Tensors/Evaluation.lean | 6 ++---- Physlib/Relativity/Tensors/Product.lean | 9 +++------ 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean index 24f54ab9d..03e42a64a 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean @@ -89,8 +89,7 @@ def contrCoContraction : (ContrℂModule.SL2CRep.tprod CoℂModule.SL2CRep).Inte simp lemma contrCoContraction_hom_tmul (ψ : ContrℂModule) (φ : CoℂModule) : - contrCoContraction (ψ ⊗ₜ φ) = ψ.toFin13ℂ ⬝ᵥ φ.toFin13ℂ := by - rfl + contrCoContraction (ψ ⊗ₜ φ) = ψ.toFin13ℂ ⬝ᵥ φ.toFin13ℂ := by rfl lemma contrCoContraction_basis (i j : Fin 4) : contrCoContraction (complexContrBasisFin4 i ⊗ₜ complexCoBasisFin4 j) = @@ -126,8 +125,7 @@ def coContrContraction : (CoℂModule.SL2CRep.tprod ContrℂModule.SL2CRep).Inte simp lemma coContrContraction_hom_tmul (φ : CoℂModule) (ψ : ContrℂModule) : - coContrContraction (φ ⊗ₜ ψ) = φ.toFin13ℂ ⬝ᵥ ψ.toFin13ℂ := by - rfl + coContrContraction (φ ⊗ₜ ψ) = φ.toFin13ℂ ⬝ᵥ ψ.toFin13ℂ := by rfl lemma coContrContraction_basis (i j : Fin 4) : coContrContraction (complexCoBasisFin4 i ⊗ₜ complexContrBasisFin4 j) = diff --git a/Physlib/Relativity/Tensors/Dual.lean b/Physlib/Relativity/Tensors/Dual.lean index a0bdb7de3..f1c9841d1 100644 --- a/Physlib/Relativity/Tensors/Dual.lean +++ b/Physlib/Relativity/Tensors/Dual.lean @@ -32,8 +32,7 @@ noncomputable def fromDualMap {c : C} : S.Tensor ![S.τ c] →ₗ[k] S.Tensor ![ (contrT 1 1 2 (by simp; rfl) (prodT (metricTensor c) t)) map_add' t1 t2 := by simp - map_smul' r t := by - simp + map_smul' r t := by simp lemma fromDualMap_apply {c : C} (t : S.Tensor ![S.τ c]) : fromDualMap t = permT id (by simp; rfl) @@ -48,8 +47,7 @@ noncomputable def toDualMap {c : C} : S.Tensor ![c] →ₗ[k] S.Tensor ![S.τ c] simp) (prodT (metricTensor (S.τ c)) t)) map_add' t1 t2 := by simp - map_smul' r t := by - simp + map_smul' r t := by simp lemma toDualMap_apply {c : C} (t : S.Tensor ![c]) : toDualMap t = permT id (by diff --git a/Physlib/Relativity/Tensors/Evaluation.lean b/Physlib/Relativity/Tensors/Evaluation.lean index 1a88daef0..27b9edcf9 100644 --- a/Physlib/Relativity/Tensors/Evaluation.lean +++ b/Physlib/Relativity/Tensors/Evaluation.lean @@ -43,16 +43,14 @@ noncomputable def evalPCoeff (i : Fin (n + 1)) (φ : basisIdx (c i)) (p : Pure S lemma evalPCoeff_update_self (i : Fin (n + 1)) [inst : DecidableEq (Fin (n + 1))] (φ : basisIdx (c i)) (p : Pure S c) (x : V (c i)) : - evalPCoeff i φ (p.update i x) = (b (c i)).repr x φ := by - simp [evalPCoeff] + evalPCoeff i φ (p.update i x) = (b (c i)).repr x φ := by simp [evalPCoeff] @[simp] lemma evalPCoeff_update_succAbove (i : Fin (n + 1)) [inst : DecidableEq (Fin (n + 1))] (j : Fin n) (φ : basisIdx (c i)) (p : Pure S c) (x : V (c (i.succAbove j))) : - evalPCoeff i φ (p.update (i.succAbove j) x) = evalPCoeff i φ p := by - simp [evalPCoeff] + evalPCoeff i φ (p.update (i.succAbove j) x) = evalPCoeff i φ p := by simp [evalPCoeff] lemma evalPCoeff_basisVector (i : Fin (n + 1)) (φ : basisIdx (c i)) (b' : ComponentIdx (S := S) c) : evalPCoeff i φ (Pure.basisVector c b') = if b' i = φ then (1 : k) else 0 := by diff --git a/Physlib/Relativity/Tensors/Product.lean b/Physlib/Relativity/Tensors/Product.lean index 16c405c4b..d6d14d281 100644 --- a/Physlib/Relativity/Tensors/Product.lean +++ b/Physlib/Relativity/Tensors/Product.lean @@ -121,15 +121,13 @@ def Pure.prodP {n1 n2} {c : Fin n1 → C} {c1 : Fin n2 → C} lemma Pure.prodP_apply_castAdd {n1 n2} {c : Fin n1 → C} {c1 : Fin n2 → C} (p1 : Pure S c) (p2 : Pure S c1) (i : Fin n1) : Pure.prodP p1 p2 (Fin.castAdd n2 i) = - LinearEquiv.cast (R := k) (by simp) (p1 i) := by - simp [Pure.prodP] + LinearEquiv.cast (R := k) (by simp) (p1 i) := by simp [Pure.prodP] @[simp] lemma Pure.prodP_apply_natAdd {n1 n2} {c : Fin n1 → C} {c1 : Fin n2 → C} (p1 : Pure S c) (p2 : Pure S c1) (i : Fin n2) : Pure.prodP p1 p2 (Fin.natAdd n1 i) = - LinearEquiv.cast (R := k) (by simp) (p2 i) := by - simp [Pure.prodP] + LinearEquiv.cast (R := k) (by simp) (p2 i) := by simp [Pure.prodP] lemma Pure.prodP_apply_finSumFinEquiv {n1 n2} {c : Fin n1 → C} {c1 : Fin n2 → C} (p1 : Pure S c) (p2 : Pure S c1) (i : Fin n1 ⊕ Fin n2) : @@ -445,8 +443,7 @@ noncomputable def prodT {n1 n2} {c : Fin n1 → C} {c1 : Fin n2 → C} : lemma prodT_pure {n1 n2} {c : Fin n1 → C} {c1 : Fin n2 → C} (t : Pure S c) (t1 : Pure S c1) : - (t.toTensor).prodT (t1.toTensor) = (Pure.prodP t t1).toTensor := by - simp [prodT, Pure.toTensor] + (t.toTensor).prodT (t1.toTensor) = (Pure.prodP t t1).toTensor := by simp [prodT, Pure.toTensor] /-! From d4168abf2d1c271d081fd21894330d0b82390f5f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:26:58 -0700 Subject: [PATCH 335/498] refactor: golf Lowner-Heinz core wrappers Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 183 ++++++------------ 1 file changed, 61 insertions(+), 122 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 7303559df..22055182b 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -174,14 +174,10 @@ theorem one_div_operatorAntitoneOn_Ioi : cfcUnits (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) f A hA_ne0 (ha := hA_sa) let uB : (𝓐)ˣ := cfcUnits (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) f B hB_ne0 (ha := hB_sa) - have huA_val : (uA : 𝓐) = A := by - simp [uA, cfcUnits, f, cfc_id' (R := ℝ) (a := A) (ha := hA_sa)] - have huB_val : (uB : 𝓐) = B := by - simp [uB, cfcUnits, f, cfc_id' (R := ℝ) (a := B) (ha := hB_sa)] - have huB_nonneg : 0 ≤ (uB : 𝓐) := by - simpa [huB_val] using B_nonneg - have hub_le_hua : (uB : 𝓐) ≤ (uA : 𝓐) := by - simpa [huA_val, huB_val] using BA + have huA_val : (uA : 𝓐) = A := by simp [uA, cfcUnits, f, cfc_id' (R := ℝ) (a := A) (ha := hA_sa)] + have huB_val : (uB : 𝓐) = B := by simp [uB, cfcUnits, f, cfc_id' (R := ℝ) (a := B) (ha := hB_sa)] + have huB_nonneg : 0 ≤ (uB : 𝓐) := by simpa [huB_val] using B_nonneg + have hub_le_hua : (uB : 𝓐) ≤ (uA : 𝓐) := by simpa [huA_val, huB_val] using BA have hinv : (↑uA⁻¹ : 𝓐) ≤ (↑uB⁻¹ : 𝓐) := by simpa using (CStarAlgebra.inv_le_inv (A := 𝓐) (a := uB) (b := uA) huB_nonneg hub_le_hua) @@ -217,8 +213,7 @@ private lemma spectrum_convexCombo_Ioi {A B : 𝓐} {t : ℝ} simpa [C] using add_le_add (smul_le_smul_of_nonneg_left hrA_le (sub_nonneg.mpr ht1)) (smul_le_smul_of_nonneg_left hrB_le ht0) have hLHS : (1 - t) • algebraMap ℝ (𝓐) rA + t • algebraMap ℝ (𝓐) rB = - algebraMap ℝ (𝓐) rC := by - simp [rC, Algebra.smul_def] + algebraMap ℝ (𝓐) rC := by simp [rC, Algebra.smul_def] simpa [hLHS] using hsum intro x hx simpa [C] using (CFC.exists_pos_algebraMap_le_iff (A := 𝓐) (a := C) (ha := hC)).1 ⟨rC, hrC, hrC_le⟩ x hx @@ -306,8 +301,7 @@ private lemma schur_conj_eq_diagonal {C D invC : 𝓐} (hInvC_sa : IsSelfAdjoint fin_cases i <;> fin_cases j <;> simp [hInvC_sa.star_eq] have hP : star U * (!![C, 1; 1, D] : Matrix (Fin 2) (Fin 2) (𝓐)) = - !![C, 1; -invC * C + 1, -invC + D] := by - simp [hstarU, U] + !![C, 1; -invC * C + 1, -invC + D] := by simp [hstarU, U] have hQ : star U * (!![C, 1; 1, D] : Matrix (Fin 2) (Fin 2) (𝓐)) * U = !![C, 0; 0, D - invC] := by @@ -543,13 +537,11 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → (f := shift) (ha := hA)) have hx' : x ∈ shift '' spectrum ℝ A := by have hx0 : x ∈ spectrum ℝ (cfc shift A) := by - have hval : cfc shift A = A1 := by - simpa [cfcR, shift, A1] using hA_shift + have hval : cfc shift A = A1 := by simpa [cfcR, shift, A1] using hA_shift simpa [hval] using hx simpa [hs] using hx0 rcases hx' with ⟨y, hy, rfl⟩ - have hy0 : 0 ≤ y := by - simpa [Set.Ici] using (As hy) + have hy0 : 0 ≤ y := by simpa [Set.Ici] using (As hy) simpa [Set.Ioi] using (add_pos_of_nonneg_of_pos hy0 ht) have specB1 : spectrum ℝ B1 ⊆ Set.Ioi (0 : ℝ) := by intro x hx @@ -559,13 +551,11 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → (f := shift) (ha := hB)) have hx' : x ∈ shift '' spectrum ℝ B := by have hx0 : x ∈ spectrum ℝ (cfc shift B) := by - have hval : cfc shift B = B1 := by - simpa [cfcR, shift, B1] using hB_shift + have hval : cfc shift B = B1 := by simpa [cfcR, shift, B1] using hB_shift simpa [hval] using hx simpa [hs] using hx0 rcases hx' with ⟨y, hy, rfl⟩ - have hy0 : 0 ≤ y := by - simpa [Set.Ici] using (Bs hy) + have hy0 : 0 ≤ y := by simpa [Set.Ici] using (Bs hy) simpa [Set.Ioi] using (add_pos_of_nonneg_of_pos hy0 ht) have hC1 : C1 = C + T := by subst A1 B1 C1 @@ -582,22 +572,19 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → have h' : cfc (fun x : ℝ ↦ (shift x)⁻¹) A = Ring.inverse (cfc shift A) := by simpa [shift] using (cfc_inv (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := shift) (a := A) hshift_ne0_A (ha := hA)) - have hval : cfc shift A = A1 := by - simpa [cfcR, shift, A1] using hA_shift + have hval : cfc shift A = A1 := by simpa [cfcR, shift, A1] using hA_shift simpa [cfcR, shift, hval] using h' have hB_inv : cfcR (fun x : ℝ ↦ (x + t)⁻¹) B = Ring.inverse B1 := by have h' : cfc (fun x : ℝ ↦ (shift x)⁻¹) B = Ring.inverse (cfc shift B) := by simpa [shift] using (cfc_inv (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := shift) (a := B) hshift_ne0_B (ha := hB)) - have hval : cfc shift B = B1 := by - simpa [cfcR, shift, B1] using hB_shift + have hval : cfc shift B = B1 := by simpa [cfcR, shift, B1] using hB_shift simpa [cfcR, shift, hval] using h' have hC_inv : cfcR (fun x : ℝ ↦ (x + t)⁻¹) C = Ring.inverse (C + T) := by have h' : cfc (fun x : ℝ ↦ (shift x)⁻¹) C = Ring.inverse (cfc shift C) := by simpa [shift] using (cfc_inv (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := shift) (a := C) hshift_ne0_C (ha := hC)) - have hval : cfc shift C = C + T := by - simpa [cfcR, shift] using hC_shift + have hval : cfc shift C = C + T := by simpa [cfcR, shift] using hC_shift simpa [cfcR, shift, hval] using h' have hA1_inv : cfcR (fun x : ℝ ↦ x⁻¹) A1 = Ring.inverse A1 := by dsimp [cfcR] @@ -621,10 +608,8 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → (f := shift) (ha := hC)) have hx' : x ∈ shift '' spectrum ℝ C := by have hx0 : x ∈ spectrum ℝ (cfc shift C) := by - have hval : cfc shift C = C + T := by - simpa [cfcR, shift] using hC_shift - have hval' : cfc shift C = C1 := by - simpa [hC1] using hval + have hval : cfc shift C = C + T := by simpa [cfcR, shift] using hC_shift + have hval' : cfc shift C = C1 := by simpa [hC1] using hval simpa [hval'] using hx simpa [hs] using hx0 rcases hx' with ⟨y, hy, rfl⟩ @@ -632,8 +617,7 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → have : 0 < y + t := add_pos_of_nonneg_of_pos hy0 ht simpa [Set.Ioi] using this have hC1_ne0 : ∀ x ∈ spectrum ℝ C1, (x : ℝ) ≠ 0 := fun x hx ↦ ne_of_gt (specC1 hx) - have hC1_sa : IsSelfAdjoint C1 := by - simpa [hC1] using (hC.add hT) + have hC1_sa : IsSelfAdjoint C1 := by simpa [hC1] using (hC.add hT) have hC1_inv : cfcR (fun x : ℝ ↦ x⁻¹) C1 = Ring.inverse C1 := by dsimp [cfcR] simpa [cfc_id' (R := ℝ) (a := C1) (ha := hC1_sa)] using @@ -674,8 +658,7 @@ theorem ratio_add_t_operatorMonotoneOn_Ici : ∀ (t : ℝ), 0 < t → have hEqT : (spectrum ℝ T).EqOn (fun x : ℝ ↦ x / (x + t)) (fun x : ℝ ↦ 1 - t * invfun x) := by intro x hx - have hx0 : (0 : ℝ) ≤ x := by - simpa [Set.Ici] using (hspT hx) + have hx0 : (0 : ℝ) ≤ x := by simpa [Set.Ici] using (hspT hx) simp [invfun] field_simp [ne_of_gt (add_pos_of_nonneg_of_pos hx0 ht)] ring @@ -716,8 +699,7 @@ theorem ratio_add_t_operatorMonotoneOn_Ici : ∀ (t : ℝ), 0 < t → rw [hone, hmul] calc cfcR (fun x : ℝ ↦ x / (x + t)) B - = (1 : 𝓐) - t • cfcR invfun B := by - simpa using hrepr B hB0 hspB + = (1 : 𝓐) - t • cfcR invfun B := by simpa using hrepr B hB0 hspB _ ≤ (1 : 𝓐) - t • cfcR invfun A := hmono_core _ = cfcR (fun x : ℝ ↦ x / (x + t)) A := by simpa using (hrepr A hA0 hspA).symm @@ -751,8 +733,7 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → (fun x : ℝ ↦ (-1 : ℝ) + t * invfun x) T := by apply cfc_congr intro x hx - have hx0 : (0 : ℝ) ≤ x := by - simpa [Set.Ici] using (Ts hx) + have hx0 : (0 : ℝ) ≤ x := by simpa [Set.Ici] using (Ts hx) have : - (x / (x + t)) = (-1 : ℝ) + t * (1 / (x + t)) := by field_simp [ne_of_gt (add_pos_of_nonneg_of_pos hx0 ht)] @@ -773,8 +754,7 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → simp [cfc_const_mul (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) t invfun T (hf := hcont)] _ = algebraMap ℝ (𝓐) (-1 : ℝ) - + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) T := by - simp [invfun] + + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) T := by simp [invfun] set AB : 𝓐 := (1 - u) • A + u • B have hAB : IsSelfAdjoint AB := by dsimp [AB] @@ -816,8 +796,7 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → have hconv_inv_AB : cfcR (fun x : ℝ ↦ 1 / (x + t)) AB ≤ (1 - u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) A - + u • cfcR (fun x : ℝ ↦ 1 / (x + t)) B := by - simpa [AB] using hconv_inv + + u • cfcR (fun x : ℝ ↦ 1 / (x + t)) B := by simpa [AB] using hconv_inv have hscale0 : t • cfcR (fun x : ℝ ↦ 1 / (x + t)) AB ≤ t • @@ -831,8 +810,7 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → + u • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := hscale0 _ = (t * (1 - u)) • cfcR (fun x : ℝ ↦ 1 / (x + t)) A - + (t * u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) B := by - simp [smul_add, smul_smul] + + (t * u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) B := by simp [smul_add, smul_smul] have hconst : (1 - u) • C + u • C = C := by simpa [add_smul, sub_add_cancel] using (add_smul (1 - u) u C).symm have hmain : @@ -884,12 +862,10 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → = ((1 - u) • C + u • C) + ((t * (1 - u)) • cfcR (fun x : ℝ ↦ 1 / (x + t)) A - + (t * u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := by - simp [hconst, add_comm] + + (t * u) • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := by simp [hconst, add_comm] _ = (1 - u) • (C + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) A) - + u • (C + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := by - simpa using hR'.symm + + u • (C + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) B) := by simpa using hR'.symm calc C + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) AB ≤ @@ -959,8 +935,7 @@ private lemma cfcₙ_rpowIntegrand₀₁_eq_smul_cfcR_ratio {q : NNReal} (hq : q cfcₙ (Real.rpowIntegrand₀₁ (q : ℝ) t) X = r • cfcR ratio X := by calc cfcₙ (Real.rpowIntegrand₀₁ (q : ℝ) t) X = - cfcR (Real.rpowIntegrand₀₁ (q : ℝ) t) X := by - simpa using hcfcₙ + cfcR (Real.rpowIntegrand₀₁ (q : ℝ) t) X := by simpa using hcfcₙ _ = cfcR (fun x : ℝ ↦ r * ratio x) X := hcfc_congr _ = r • cfcR ratio X := hcfc_mul _ = r • cfcR ratio X := by simp [cfcR] @@ -1058,8 +1033,7 @@ private lemma concaveOn_nnrpow_Ioo {q : NNReal} (hq : q ∈ Set.Ioo (0 : NNReal) refine hconc_int.congr ?_ intro A hA -- `A ^ q` is the set integral of the integrand on `Ioi 0` - have hEq : A ^ q = ∫ t, F t A ∂ν := by - simpa [F, ν] using (hμ A hA).2 + have hEq : A ^ q = ∫ t, F t A ∂ν := by simpa [F, ν] using (hμ A hA).2 simp [hEq] private lemma concaveOn_rpow_Ioo {p : ℝ} (hp : p ∈ Set.Ioo (0 : ℝ) 1) : @@ -1145,8 +1119,7 @@ theorem power_Icc_zero_one_operatorConcaveOn_Ici : ∀ p ∈ Set.Icc (0 : ℝ) 1 have hC0 : 0 ≤ (1 - u) • A + u • B := add_nonneg (smul_nonneg hu0' hA0) (smul_nonneg hu0 hB0) set C : 𝓐 := (1 - u) • A + u • B - have hC_mem : C ∈ Set.Ici (0 : 𝓐) := by - simpa [C, Set.Ici] using hC0 + have hC_mem : C ∈ Set.Ici (0 : 𝓐) := by simpa [C, Set.Ici] using hC0 have hA_mem : A ∈ Set.Ici (0 : 𝓐) := by simpa [Set.Ici] using hA0 have hB_mem : B ∈ Set.Ici (0 : 𝓐) := by simpa [Set.Ici] using hB0 have hconcC : (1 - u) • (A ^ p) + u • (B ^ p) ≤ C ^ p := by @@ -1446,8 +1419,7 @@ private lemma convexOn_nnrpow_Ioo_one_add {q : NNReal} (hq : q ∈ Set.Ioo (0 : simpa [add_comm, add_left_comm, add_assoc] using (CFC.nnrpow_add (A := 𝓐) (a := A) (x := (1 : NNReal)) (y := q) zero_lt_one hq0) simpa [CFC.nnrpow_one (A := 𝓐) A hA0] using h1 - have hEq_q : A ^ q = ∫ t, F0 t A ∂ν := by - simpa [F0, ν] using (hμ A hA).2 + have hEq_q : A ^ q = ∫ t, F0 t A ∂ν := by simpa [F0, ν] using (hμ A hA).2 have hEq_mul : A * (∫ t, F0 t A ∂ν) = ∫ t, A * F0 t A ∂ν := by have h : @@ -1520,8 +1492,7 @@ omit [PartialOrder 𝓐] [StarOrderedRing 𝓐] [NonnegSpectrumClass ℝ 𝓐] i private lemma sub_mul_sub (A B : 𝓐) : (A - B) * (A - B) = A * A - A * B - B * A + B * B := by calc - (A - B) * (A - B) = (A * A - B * A) - (A * B - B * B) := by - simp [mul_sub, sub_mul] + (A - B) * (A - B) = (A * A - B * A) - (A * B - B * B) := by simp [mul_sub, sub_mul] _ = A * A - A * B - B * A + B * B := by abel @@ -1544,8 +1515,7 @@ private lemma square_convexity_diff_rhs (A B : 𝓐) (u : ℝ) : α • (A * A) - α • (A * B) - α • (B * A) + α • (B * B) = (u * (1 - u)) • (A * A) - (u * (1 - u)) • (A * B) - (u * (1 - u)) • (B * A) - + (u * (1 - u)) • (B * B) := by - simp [α] + + (u * (1 - u)) • (B * B) := by simp [α] calc (u * (1 - u)) • ((A - B) * (A - B)) = α • ((A - B) * (A - B)) := by simp [α] _ = α • (A * A - A * B - B * A + B * B) := hsmul @@ -1623,8 +1593,7 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A ((1 - u) • A) _ = (1 - u) • ((1 - u) • (A * A)) := by rw [Algebra.mul_smul_comm] - _ = ((1 - u) * (1 - u)) • (A * A) := by - simp [smul_smul] + _ = ((1 - u) * (1 - u)) • (A * A) := by simp [smul_smul] have hAB' : ((1 - u) • A) * (u • B) = ((1 - u) * u) • (A * B) := by calc @@ -1632,26 +1601,21 @@ private lemma square_convexity_diff_hCC_sum (A B : 𝓐) (u : ℝ) : exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) (1 - u) A (u • B) _ = (1 - u) • (u • (A * B)) := by rw [Algebra.mul_smul_comm] - _ = ((1 - u) * u) • (A * B) := by - simp [smul_smul] + _ = ((1 - u) * u) • (A * B) := by simp [smul_smul] have hBA' : (u • B) * ((1 - u) • A) = (u * (1 - u)) • (B * A) := by calc (u • B) * ((1 - u) • A) = u • (B * ((1 - u) • A)) := by exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B ((1 - u) • A) - _ = u • ((1 - u) • (B * A)) := by - simp [Algebra.mul_smul_comm] - _ = (u * (1 - u)) • (B * A) := by - simpa using (smul_smul u (1 - u) (B * A)) + _ = u • ((1 - u) • (B * A)) := by simp [Algebra.mul_smul_comm] + _ = (u * (1 - u)) • (B * A) := by simpa using (smul_smul u (1 - u) (B * A)) have hBB' : (u • B) * (u • B) = (u * u) • (B * B) := by calc (u • B) * (u • B) = u • (B * (u • B)) := by exact Algebra.smul_mul_assoc (R := ℝ) (A := 𝓐) u B (u • B) - _ = u • (u • (B * B)) := by - simp [Algebra.mul_smul_comm] - _ = (u * u) • (B * B) := by - simp [smul_smul] + _ = u • (u • (B * B)) := by simp [Algebra.mul_smul_comm] + _ = (u * u) • (B * B) := by simp [smul_smul] rw [hAA', hAB', hBA', hBB'] omit [Nontrivial (𝓐)] in @@ -1670,19 +1634,15 @@ private lemma square_convexity_diff_hCC (A B : 𝓐) (u : ℝ) : set Y : 𝓐 := u • B have hXY : (1 - u) • A + u • B = X + Y := by simp [X, Y] calc - ((1 - u) • A + u • B) * ((1 - u) • A + u • B) = (X + Y) * (X + Y) := by - simp [hXY] - _ = X * (X + Y) + Y * (X + Y) := by - simp [add_mul] - _ = (X * X + X * Y) + (Y * X + Y * Y) := by - simp [mul_add, add_assoc] + ((1 - u) • A + u • B) * ((1 - u) • A + u • B) = (X + Y) * (X + Y) := by simp [hXY] + _ = X * (X + Y) + Y * (X + Y) := by simp [add_mul] + _ = (X * X + X * Y) + (Y * X + Y * Y) := by simp [mul_add, add_assoc] _ = X * X + X * Y + Y * X + Y * Y := by abel _ = ((1 - u) • A) * ((1 - u) • A) + ((1 - u) • A) * (u • B) + (u • B) * ((1 - u) • A) - + (u • B) * (u • B) := by - simp [X, Y] + + (u • B) * (u • B) := by simp [X, Y] exact hexpand.trans (square_convexity_diff_hCC_sum A B u) omit [PartialOrder 𝓐] [StarOrderedRing 𝓐] [NonnegSpectrumClass ℝ 𝓐] [Nontrivial (𝓐)] in @@ -1732,8 +1692,7 @@ private lemma operatorConvexOn_pow_two_Ici : have hub : 0 ≤ u * (1 - u) := mul_nonneg hu0 hu0' have hdiff : (1 - u) • (A * A) + u • (B * B) - C * C - = (u * (1 - u)) • ((A - B) * (A - B)) := by - simpa [C] using (square_convexity_diff A B u) + = (u * (1 - u)) • ((A - B) * (A - B)) := by simpa [C] using (square_convexity_diff A B u) have hnonneg : 0 ≤ (1 - u) • (A * A) + u • (B * B) - C * C := by have hscale : 0 ≤ (u * (1 - u)) • ((A - B) * (A - B)) := smul_nonneg hub hsq simpa [hdiff] using hscale @@ -1788,8 +1747,7 @@ theorem power_Icc_one_two_operatorConvexOn_Ici : ∀ p ∈ Set.Icc (1 : ℝ) 2, set C : 𝓐 := (1 - u) • A + u • B have hC0 : 0 ≤ C := add_nonneg (smul_nonneg hu0' hA0) (smul_nonneg hu0 hB0) - have hC_mem : C ∈ Set.Ici (0 : 𝓐) := by - simpa [C, Set.Ici] using hC0 + have hC_mem : C ∈ Set.Ici (0 : 𝓐) := by simpa [C, Set.Ici] using hC0 have hA_mem : A ∈ Set.Ici (0 : 𝓐) := by simpa [Set.Ici] using hA0 have hB_mem : B ∈ Set.Ici (0 : 𝓐) := by simpa [Set.Ici] using hB0 have hab : (1 - u) + u = (1 : ℝ) := by ring @@ -1905,13 +1863,11 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- (f := fun x : ℝ ↦ x ^ q) (a := A) (hg := hg) (hf := hcontA) (ha := hA_sa)).symm have hL : cfcR (fun x : ℝ ↦ 1 / x) Aq = - cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ q) A) := by - simp [Aq, one_div] + cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ q) A) := by simp [Aq, one_div] rw [hL] have hcomp' : cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ q) A) = - cfcR (fun x : ℝ ↦ (x ^ q)⁻¹) A := by - simpa [one_div] using hcomp + cfcR (fun x : ℝ ↦ (x ^ q)⁻¹) A := by simpa [one_div] using hcomp rw [hcomp'] dsimp [cfcR] apply cfc_congr @@ -1943,13 +1899,11 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- (f := fun x : ℝ ↦ x ^ q) (a := B) (hg := hg) (hf := hcontB) (ha := hB_sa)).symm have hL : cfcR (fun x : ℝ ↦ 1 / x) Bq = - cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ q) B) := by - simp [Bq, one_div] + cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ q) B) := by simp [Bq, one_div] rw [hL] have hcomp' : cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ q) B) = - cfcR (fun x : ℝ ↦ (x ^ q)⁻¹) B := by - simpa [one_div] using hcomp + cfcR (fun x : ℝ ↦ (x ^ q)⁻¹) B := by simpa [one_div] using hcomp rw [hcomp'] dsimp [cfcR] apply cfc_congr @@ -1961,19 +1915,15 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- have hanti : cfcR (fun x : ℝ ↦ x ^ p) A ≤ cfcR (fun x : ℝ ↦ x ^ p) B := by calc cfcR (fun x : ℝ ↦ x ^ p) A = - cfcR (fun x : ℝ ↦ 1 / x) Aq := by - simpa using hcompA.symm + cfcR (fun x : ℝ ↦ 1 / x) Aq := by simpa using hcompA.symm _ ≤ cfcR (fun x : ℝ ↦ 1 / x) Bq := h_inv - _ = cfcR (fun x : ℝ ↦ x ^ p) B := by - simpa using hcompB + _ = cfcR (fun x : ℝ ↦ x ^ p) B := by simpa using hcompB have hneg : -cfcR (fun x : ℝ ↦ x ^ p) B ≤ -cfcR (fun x : ℝ ↦ x ^ p) A := neg_le_neg hanti have hnegA : - cfcR (fun x : ℝ ↦ -(x ^ p)) A = -cfcR (fun x : ℝ ↦ x ^ p) A := by - simp [cfcR, cfc_neg] + cfcR (fun x : ℝ ↦ -(x ^ p)) A = -cfcR (fun x : ℝ ↦ x ^ p) A := by simp [cfcR, cfc_neg] have hnegB : - cfcR (fun x : ℝ ↦ -(x ^ p)) B = -cfcR (fun x : ℝ ↦ x ^ p) B := by - simp [cfcR, cfc_neg] + cfcR (fun x : ℝ ↦ -(x ^ p)) B = -cfcR (fun x : ℝ ↦ x ^ p) B := by simp [cfcR, cfc_neg] simpa [hnegA, hnegB] using hneg theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 : ℝ) 0, @@ -2017,8 +1967,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 (-Cr) ≤ (1 - t) • (-Ar) + t • (-Br) := by simpa [C, Ar, Br, Cr, cfcR, cfc_neg] using hconc (A := A) (B := B) (t := t) hA hB ht0 ht1 As0 Bs0 - have h2 : (1 - t) • (-Ar) + t • (-Br) = -Dr := by - simp [Dr, smul_neg, add_comm] + have h2 : (1 - t) • (-Ar) + t • (-Br) = -Dr := by simp [Dr, smul_neg, add_comm] have h3 : (-Cr) ≤ (-Dr) := by calc (-Cr) ≤ (1 - t) • (-Ar) + t • (-Br) := h1 @@ -2180,21 +2129,18 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 (f := fun x : ℝ ↦ x ^ r) (a := A) (hg := hg) (hf := hcontA) (ha := hA)).symm have hL : cfcR (fun x : ℝ ↦ 1 / x) Ar = - cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) A) := by - simp [Ar, one_div] + cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) A) := by simp [Ar, one_div] rw [hL] have hcomp' : cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) A) = - cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) A := by - simpa [one_div] using hcomp + cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) A := by simpa [one_div] using hcomp rw [hcomp'] dsimp [cfcR] apply cfc_congr intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using As hx calc - (x ^ r)⁻¹ = x ^ (-r) := by - simpa using (Real.rpow_neg (le_of_lt hx0) r).symm + (x ^ r)⁻¹ = x ^ (-r) := by simpa using (Real.rpow_neg (le_of_lt hx0) r).symm _ = x ^ p := by simp [r] have hcompB : cfcR (fun x : ℝ ↦ 1 / x) Br = cfcR (fun x : ℝ ↦ x ^ p) B := by @@ -2218,21 +2164,18 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 (f := fun x : ℝ ↦ x ^ r) (a := B) (hg := hg) (hf := hcontB) (ha := hB)).symm have hL : cfcR (fun x : ℝ ↦ 1 / x) Br = - cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) B) := by - simp [Br, one_div] + cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) B) := by simp [Br, one_div] rw [hL] have hcomp' : cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) B) = - cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) B := by - simpa [one_div] using hcomp + cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) B := by simpa [one_div] using hcomp rw [hcomp'] dsimp [cfcR] apply cfc_congr intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using Bs hx calc - (x ^ r)⁻¹ = x ^ (-r) := by - simpa using (Real.rpow_neg (le_of_lt hx0) r).symm + (x ^ r)⁻¹ = x ^ (-r) := by simpa using (Real.rpow_neg (le_of_lt hx0) r).symm _ = x ^ p := by simp [r] have hcompC : cfcR (fun x : ℝ ↦ 1 / x) Cr = cfcR (fun x : ℝ ↦ x ^ p) C := by @@ -2256,21 +2199,18 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 (f := fun x : ℝ ↦ x ^ r) (a := C) (hg := hg) (hf := hcontC) (ha := hC)).symm have hL : cfcR (fun x : ℝ ↦ 1 / x) Cr = - cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) C) := by - simp [Cr, one_div] + cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) C) := by simp [Cr, one_div] rw [hL] have hcomp' : cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) C) = - cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) C := by - simpa [one_div] using hcomp + cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) C := by simpa [one_div] using hcomp rw [hcomp'] dsimp [cfcR] apply cfc_congr intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using Cs hx calc - (x ^ r)⁻¹ = x ^ (-r) := by - simpa using (Real.rpow_neg (le_of_lt hx0) r).symm + (x ^ r)⁻¹ = x ^ (-r) := by simpa using (Real.rpow_neg (le_of_lt hx0) r).symm _ = x ^ p := by simp [r] -- finish have hmain : @@ -2292,8 +2232,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 have hchain' : cfcR (fun x : ℝ ↦ x⁻¹) Cr ≤ (1 - t) • cfcR (fun x : ℝ ↦ x⁻¹) Ar - + t • cfcR (fun x : ℝ ↦ x⁻¹) Br := by - simpa [one_div] using hchain + + t • cfcR (fun x : ℝ ↦ x⁻¹) Br := by simpa [one_div] using hchain simpa [hcompA', hcompB', hcompC'] using hchain' simpa [C] using hmain From 0ce08800c1af3aed77aabdbe888bf70f4e282ab6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:30:49 -0700 Subject: [PATCH 336/498] refactor: golf Jensen trace-inequality wrappers Co-authored-by: Claude Opus 4.8 --- .../GeneralizedPerspectiveFunction.lean | 12 ++--- .../JensenOperatorInequality.lean | 30 +++++-------- .../JensenOperatorInequalityIImpIV.lean | 45 +++++++------------ .../JensenOperatorInequalityIVtoV.lean | 18 +++----- .../TraceInequality/LownerHeinzTheorem.lean | 9 ++-- 5 files changed, 38 insertions(+), 76 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean index 2ffedfc62..65d99b379 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean @@ -126,8 +126,7 @@ private lemma spectrum_convexCombo_Ioi {A B : L ℋ} {t : ℝ} (smul_le_smul_of_nonneg_left hrB_le ht0) have hLHS : (1 - t) • algebraMap ℝ (L ℋ) rA + t • algebraMap ℝ (L ℋ) rB = - algebraMap ℝ (L ℋ) rC := by - simp [rC, Algebra.smul_def] + algebraMap ℝ (L ℋ) rC := by simp [rC, Algebra.smul_def] simpa [hLHS] using hsum intro x hx simpa [C] using @@ -249,8 +248,7 @@ omit [Nontrivial ℋ] in private lemma conj_le_conj {X Y T : L ℋ} (hXY : X ≤ Y) (hT : IsSelfAdjoint T) : T * X * T ≤ T * Y * T := by have hnonneg : 0 ≤ Y - X := sub_nonneg.mpr hXY - have hconj : 0 ≤ T * (Y - X) * T := by - simpa using hT.conjugate_nonneg hnonneg + have hconj : 0 ≤ T * (Y - X) * T := by simpa using hT.conjugate_nonneg hnonneg have hsub : T * (Y - X) * T = T * Y * T - T * X * T := by simp [sub_eq_add_neg, mul_add, add_mul, mul_assoc] exact sub_nonneg.mp (by simpa [hsub] using hconj) @@ -421,8 +419,7 @@ private theorem theorem_2_5_forward_jointlyConvexOn_psd_pd_of_condV simp [T₁, hS₁_sa.star_eq, hIR_sa.star_eq, mul_assoc, smul_smul] _ = (1 - θ) • (S * IR * (S₁ * cfcR (ℋ := ℋ) f M₁ * S₁) * IR * S) := by rw [Real.mul_self_sqrt (sub_nonneg.mpr hθ1)] - _ = (1 - θ) • (S₁ * cfcR (ℋ := ℋ) f M₁ * S₁) := by - simp [mul_assoc, hSIR, hIRS] + _ = (1 - θ) • (S₁ * cfcR (ℋ := ℋ) f M₁ * S₁) := by simp [mul_assoc, hSIR, hIRS] _ = (1 - θ) • ((f Δ h) A₁ B₁) := rfl have hright₂ : S * (star T₂ * cfcR (ℋ := ℋ) f M₂ * T₂) * S = @@ -434,8 +431,7 @@ private theorem theorem_2_5_forward_jointlyConvexOn_psd_pd_of_condV simp [T₂, hS₂_sa.star_eq, hIR_sa.star_eq, mul_assoc, smul_smul] _ = θ • (S * IR * (S₂ * cfcR (ℋ := ℋ) f M₂ * S₂) * IR * S) := by rw [Real.mul_self_sqrt hθ0] - _ = θ • (S₂ * cfcR (ℋ := ℋ) f M₂ * S₂) := by - simp [mul_assoc, hSIR, hIRS] + _ = θ • (S₂ * cfcR (ℋ := ℋ) f M₂ * S₂) := by simp [mul_assoc, hSIR, hIRS] _ = θ • ((f Δ h) A₂ B₂) := rfl have hright : S * (star T₁ * cfcR (ℋ := ℋ) f M₁ * T₁ + star T₂ * cfcR (ℋ := ℋ) f M₂ * T₂) * S = diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean index bf1d77e3d..1a843e17b 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequality.lean @@ -63,8 +63,7 @@ private theorem nontrivial_hsumL_wrap [Nontrivial ℋ] : Nontrivial (L (HSum ℋ have hdiag_ne_zero : (blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 : L (HSum ℋ)) ≠ 0 := by intro h0 have hz : - blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 (hsumIncl ℋ 0 w) = 0 := by - simp [h0] + blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 (hsumIncl ℋ 0 w) = 0 := by simp [h0] have hw0 : w = 0 := by have hz0 := congrArg (fun z : HSum ℋ => hsumProj ℋ 0 z) hz simpa [blockDiagonal] using hz0 @@ -130,10 +129,8 @@ private lemma cfcR_blockDiagonal_wrap (f : ℝ → ℝ) (hab := hpair) (ha := hA) (hb := hB)) calc cfcR (ℋ := HSum ℋ) f (blockDiagonal (ℋ := ℋ) A B) - = cfc (R := ℝ) (A := L (HSum ℋ)) (p := IsSelfAdjoint) f (φ (A, B)) := by - simp [cfcR, φ] - _ = φ (cfc (R := ℝ) (A := L ℋ × L ℋ) (p := IsSelfAdjoint) f (A, B)) := by - simpa using hmap.symm + = cfc (R := ℝ) (A := L (HSum ℋ)) (p := IsSelfAdjoint) f (φ (A, B)) := by simp [cfcR, φ] + _ = φ (cfc (R := ℝ) (A := L ℋ × L ℋ) (p := IsSelfAdjoint) f (A, B)) := by simpa using hmap.symm _ = φ (cfcR (ℋ := ℋ) f A, cfcR (ℋ := ℋ) f B) := by rw [hprod] _ = blockDiagonal (ℋ := ℋ) (cfcR (ℋ := ℋ) f A) (cfcR (ℋ := ℋ) f B) := by @@ -160,8 +157,7 @@ omit [CompleteSpace ℋ] in private lemma spectrum_zero_subset_Ici_wrap : spectrum ℝ (0 : L ℋ) ⊆ Set.Ici (0 : ℝ) := by intro x hx - have hx0 : x = 0 := by - simpa using hx + have hx0 : x = 0 := by simpa using hx simp [Set.Ici, hx0] omit [Nontrivial ℋ] in @@ -241,15 +237,12 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock - have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by - simp + have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp have hXtilde_norm : ‖Xtilde‖ ≤ 1 := by have hnormSq : ‖star Xtilde * Xtilde‖ ≤ 1 := (CStarAlgebra.norm_le_one_iff_of_nonneg _ hXtilde_star_mul_nonneg).2 hXtilde_star_mul_le - have hnormSq' : ‖Xtilde‖ * ‖Xtilde‖ ≤ 1 := by - simpa [CStarRing.norm_star_mul_self] using hnormSq - have hsq : ‖Xtilde‖ ^ 2 ≤ 1 := by - simpa [pow_two] using hnormSq' + have hnormSq' : ‖Xtilde‖ * ‖Xtilde‖ ≤ 1 := by simpa [CStarRing.norm_star_mul_self] using hnormSq + have hsq : ‖Xtilde‖ ^ 2 ≤ 1 := by simpa [pow_two] using hnormSq' nlinarith [norm_nonneg Xtilde] have hiv_hsum : CondIV (ℋ := HSum ℋ) f := @hiv (HSum ℋ) _ _ _ _ have hcore := hiv_hsum (A := Atilde) (X := Xtilde) hAtilde_sa hAtilde_spec hXtilde_norm @@ -355,15 +348,12 @@ theorem theorem_2_5_2_i_ici_all_imp_v {f : ℝ → ℝ} blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock - have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by - simp + have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp have hXtilde_norm : ‖Xtilde‖ ≤ 1 := by have hnormSq : ‖star Xtilde * Xtilde‖ ≤ 1 := (CStarAlgebra.norm_le_one_iff_of_nonneg _ hXtilde_star_mul_nonneg).2 hXtilde_star_mul_le - have hnormSq' : ‖Xtilde‖ * ‖Xtilde‖ ≤ 1 := by - simpa [CStarRing.norm_star_mul_self] using hnormSq - have hsq : ‖Xtilde‖ ^ 2 ≤ 1 := by - simpa [pow_two] using hnormSq' + have hnormSq' : ‖Xtilde‖ * ‖Xtilde‖ ≤ 1 := by simpa [CStarRing.norm_star_mul_self] using hnormSq + have hsq : ‖Xtilde‖ ^ 2 ≤ 1 := by simpa [pow_two] using hnormSq' nlinarith [norm_nonneg Xtilde] have hiv_hsum : CondIV (ℋ := HSum ℋ) f := theorem_2_5_2_i_ici_all_imp_iv (ℋ := HSum ℋ) (f := f) hfIci diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean index fbfef0ee2..8b5da62e6 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIImpIV.lean @@ -185,10 +185,8 @@ private lemma cfcR_blockDiagonal (f : ℝ → ℝ) (hab := hpair) (ha := hA) (hb := hB)) calc cfcR (ℋ := HSum ℋ) f (blockDiagonal (ℋ := ℋ) A B) - = cfc (R := ℝ) (A := L (HSum ℋ)) (p := IsSelfAdjoint) f (φ (A, B)) := by - simp [cfcR, φ] - _ = φ (cfc (R := ℝ) (A := L ℋ × L ℋ) (p := IsSelfAdjoint) f (A, B)) := by - simpa using hmap.symm + = cfc (R := ℝ) (A := L (HSum ℋ)) (p := IsSelfAdjoint) f (φ (A, B)) := by simp [cfcR, φ] + _ = φ (cfc (R := ℝ) (A := L ℋ × L ℋ) (p := IsSelfAdjoint) f (A, B)) := by simpa using hmap.symm _ = φ (cfcR (ℋ := ℋ) f A, cfcR (ℋ := ℋ) f B) := by rw [hprod] _ = blockDiagonal (ℋ := ℋ) (cfcR (ℋ := ℋ) f A) (cfcR (ℋ := ℋ) f B) := by @@ -333,8 +331,7 @@ private lemma complex_I_smul_real_I_smul_invTwo (r : ℝ) (T : L ℋ) : rw [hcomm] _ = ((Complex.I : ℂ) * Complex.I) • (r • ((2⁻¹ : ℝ) • T x)) := by rw [smul_smul] - _ = (-1 : ℂ) • (r • ((2⁻¹ : ℝ) • T x)) := by - norm_num + _ = (-1 : ℂ) • (r • ((2⁻¹ : ℝ) • T x)) := by norm_num _ = (-1 : ℂ) • (((r * 2⁻¹ : ℝ)) • T x) := by rw [smul_smul] _ = -((2⁻¹ : ℝ) * r) • T x := by simp [neg_smul, mul_comm] @@ -357,8 +354,7 @@ omit [CompleteSpace ℋ] in private lemma half_add_half_eq (T : L ℋ) : (2⁻¹ : ℝ) • T + (2⁻¹ : ℝ) • T = T := by calc - (2⁻¹ : ℝ) • T + (2⁻¹ : ℝ) • T = (2⁻¹ + 2⁻¹ : ℝ) • T := by - simp [add_smul] + (2⁻¹ : ℝ) • T + (2⁻¹ : ℝ) • T = (2⁻¹ + 2⁻¹ : ℝ) • T := by simp [add_smul] _ = (1 : ℝ) • T := by norm_num _ = T := by simp @@ -367,8 +363,7 @@ private lemma half_mul_real_add_half_mul_real_eq (r : ℝ) (T : L ℋ) : ((2⁻¹ : ℝ) * r) • T + ((2⁻¹ : ℝ) * r) • T = r • T := by calc ((2⁻¹ : ℝ) * r) • T + ((2⁻¹ : ℝ) * r) • T = - (((2⁻¹ : ℝ) * r) + ((2⁻¹ : ℝ) * r)) • T := by - simp [add_smul] + (((2⁻¹ : ℝ) * r) + ((2⁻¹ : ℝ) * r)) • T := by simp [add_smul] _ = r • T := by ring_nf private lemma rightEval_topLeft_scalar @@ -381,8 +376,7 @@ private lemma rightEval_topLeft_scalar have hP : (2⁻¹ : ℝ) • (star X * (T * X)) + (2⁻¹ : ℝ) • (star X * (T * X)) = - star X * (T * X) := by - simpa using half_add_half_eq (ℋ := ℋ) (star X * (T * X)) + star X * (T * X) := by simpa using half_add_half_eq (ℋ := ℋ) (star X * (T * X)) have hQhalf : -((2⁻¹ : ℝ) • Complex.I • r • Complex.I • (R0 * R0)) + -((2⁻¹ : ℝ) • Complex.I • r • Complex.I • (R0 * R0)) = @@ -401,8 +395,7 @@ private lemma rightEval_topLeft_scalar calc -((2⁻¹ : ℝ) • Complex.I • r • Complex.I • (R0 * R0)) + -((2⁻¹ : ℝ) • Complex.I • r • Complex.I • (R0 * R0)) = - ((2⁻¹ : ℝ) * r) • (R0 * R0) + ((2⁻¹ : ℝ) * r) • (R0 * R0) := by - simp [hterm] + ((2⁻¹ : ℝ) * r) • (R0 * R0) + ((2⁻¹ : ℝ) * r) • (R0 * R0) := by simp [hterm] _ = r • (R0 * R0) := half_mul_real_add_half_mul_real_eq (ℋ := ℋ) r (R0 * R0) calc (2⁻¹ : ℝ) • (star X * (T * X)) + @@ -429,8 +422,7 @@ private lemma rightEval_bottomRight_scalar simpa using half_mul_real_add_half_mul_real_eq (ℋ := ℋ) r (X * star X) have hT : (2⁻¹ : ℝ) • (R1 * (T * R1)) + (2⁻¹ : ℝ) • (R1 * (T * R1)) = - R1 * (T * R1) := by - simpa using half_add_half_eq (ℋ := ℋ) (R1 * (T * R1)) + R1 * (T * R1) := by simpa using half_add_half_eq (ℋ := ℋ) (R1 * (T * R1)) calc (2⁻¹ * r) • (X * star X) + ((2⁻¹ * r) • (X * star X) + @@ -490,8 +482,7 @@ private lemma blockSwap_norm_le_one [Nontrivial ℋ] (X : L ℋ) (hX : ‖X‖ simp [sub_eq_add_neg, add_left_comm, add_comm] have hle' : blockDiagonal (ℋ := ℋ) (star X * X) (X * star X) ≤ - blockDiagonal (ℋ := ℋ) (1 : L ℋ) (1 : L ℋ) := by - simpa [hsum] using hle + blockDiagonal (ℋ := ℋ) (1 : L ℋ) (1 : L ℋ) := by simpa [hsum] using hle simpa [blockDiagonal_one] using hle' have hSstarSle : star (blockSwap (ℋ := ℋ) X) * blockSwap (ℋ := ℋ) X ≤ (1 : L (HSum ℋ)) := by @@ -502,8 +493,7 @@ private lemma blockSwap_norm_le_one [Nontrivial ℋ] (X : L ℋ) (hX : ‖X‖ (CStarAlgebra.norm_le_one_iff_of_nonneg _ hSstarSnonneg).2 hSstarSle have hnormSq' : ‖blockSwap (ℋ := ℋ) X‖ * ‖blockSwap (ℋ := ℋ) X‖ ≤ 1 := by simpa [CStarRing.norm_star_mul_self] using hnormSq - have hsq : ‖blockSwap (ℋ := ℋ) X‖ ^ 2 ≤ 1 := by - simpa [pow_two] using hnormSq' + have hsq : ‖blockSwap (ℋ := ℋ) X‖ ^ 2 ≤ 1 := by simpa [pow_two] using hnormSq' have hnonneg : 0 ≤ ‖blockSwap (ℋ := ℋ) X‖ := norm_nonneg _ nlinarith @@ -528,8 +518,7 @@ omit [CompleteSpace ℋ] in private lemma spectrum_zero_subset_Ici : spectrum ℝ (0 : L ℋ) ⊆ Set.Ici (0 : ℝ) := by intro x hx - have hx0 : x = 0 := by - simpa using hx + have hx0 : x = 0 := by simpa using hx simp [Set.Ici, hx0] @@ -550,8 +539,7 @@ theorem theorem_2_5_2_i_ici_all_imp_iv {f : ℝ → ℝ} (hf : CondIciAll.{u} f) have hSsa : IsSelfAdjoint S := by change star S = S simpa [S] using blockSwap_star (ℋ := ℋ) X - have hSnorm : ‖S‖ ≤ 1 := by - simpa [S] using blockSwap_norm_le_one (ℋ := ℋ) X hX + have hSnorm : ‖S‖ ≤ 1 := by simpa [S] using blockSwap_norm_le_one (ℋ := ℋ) X hX letI : Algebra ℝ (L (HSum ℋ)) := by infer_instance have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := by @@ -648,8 +636,7 @@ theorem theorem_2_5_2_i_ici_all_imp_iv {f : ℝ → ℝ} (hf : CondIciAll.{u} f) · have hhalf : (2⁻¹ + 2⁻¹ : ℝ) = (1 : ℝ) := by norm_num calc (1 / 2 : ℝ) • (star X * A * X) + (1 / 2 : ℝ) • (star X * A * X) - = (2⁻¹ + 2⁻¹ : ℝ) • (star X * (A * X)) := by - simp [add_smul, mul_assoc] + = (2⁻¹ + 2⁻¹ : ℝ) • (star X * (A * X)) := by simp [add_smul, mul_assoc] _ = (1 : ℝ) • (star X * (A * X)) := by rw [hhalf] _ = star X * (A * X) := by simp _ = star X * A * X := by simp [mul_assoc] @@ -804,8 +791,7 @@ theorem theorem_2_5_2_i_all_imp_iv {f : ℝ → ℝ} (hf : CondIAll.{u} f) : have hSsa : IsSelfAdjoint S := by change star S = S simpa [S] using blockSwap_star (ℋ := ℋ) X - have hSnorm : ‖S‖ ≤ 1 := by - simpa [S] using blockSwap_norm_le_one (ℋ := ℋ) X hX + have hSnorm : ‖S‖ ≤ 1 := by simpa [S] using blockSwap_norm_le_one (ℋ := ℋ) X hX letI : Algebra ℝ (L (HSum ℋ)) := by infer_instance have hU_mem : S + Complex.I • CFC.sqrt (1 - S ^ 2) ∈ unitary (L (HSum ℋ)) := by @@ -903,8 +889,7 @@ theorem theorem_2_5_2_i_all_imp_iv {f : ℝ → ℝ} (hf : CondIAll.{u} f) : · have hhalf : (2⁻¹ + 2⁻¹ : ℝ) = (1 : ℝ) := by norm_num calc (1 / 2 : ℝ) • (star X * A * X) + (1 / 2 : ℝ) • (star X * A * X) - = (2⁻¹ + 2⁻¹ : ℝ) • (star X * (A * X)) := by - simp [add_smul, mul_assoc] + = (2⁻¹ + 2⁻¹ : ℝ) • (star X * (A * X)) := by simp [add_smul, mul_assoc] _ = (1 : ℝ) • (star X * (A * X)) := by rw [hhalf] _ = star X * (A * X) := by simp _ = star X * A * X := by simp [mul_assoc] diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean index 02e3168cf..efad0c931 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/JensenOperatorInequalityIVtoV.lean @@ -75,8 +75,7 @@ private theorem nontrivial_hsumL : Nontrivial (L (HSum ℋ)) := by have hdiag_ne_zero : (blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 : L (HSum ℋ)) ≠ 0 := by intro h0 have hz : - blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 (hsumIncl ℋ 0 w) = 0 := by - simp [h0] + blockDiagonal (ℋ := ℋ) (1 : L ℋ) 0 (hsumIncl ℋ 0 w) = 0 := by simp [h0] have hw0 : w = 0 := by have hz0 := congrArg (fun z : HSum ℋ => hsumProj ℋ 0 z) hz simpa [blockDiagonal] using hz0 @@ -146,10 +145,8 @@ private lemma cfcR_blockDiagonal (f : ℝ → ℝ) (hab := hpair) (ha := hA) (hb := hB)) calc cfcR (ℋ := HSum ℋ) f (blockDiagonal (ℋ := ℋ) A B) - = cfc (R := ℝ) (A := L (HSum ℋ)) (p := IsSelfAdjoint) f (φ (A, B)) := by - simp [cfcR, φ] - _ = φ (cfc (R := ℝ) (A := L ℋ × L ℋ) (p := IsSelfAdjoint) f (A, B)) := by - simpa using hmap.symm + = cfc (R := ℝ) (A := L (HSum ℋ)) (p := IsSelfAdjoint) f (φ (A, B)) := by simp [cfcR, φ] + _ = φ (cfc (R := ℝ) (A := L ℋ × L ℋ) (p := IsSelfAdjoint) f (A, B)) := by simpa using hmap.symm _ = φ (cfcR (ℋ := ℋ) f A, cfcR (ℋ := ℋ) f B) := by rw [hprod] _ = blockDiagonal (ℋ := ℋ) (cfcR (ℋ := ℋ) f A) (cfcR (ℋ := ℋ) f B) := by @@ -234,15 +231,12 @@ theorem theorem_2_5_2_iv_imp_v {f : ℝ → ℝ} (hiv : CondIVAll.{u} f) blockDiagonal (ℋ := ℋ) (star X * X + star Y * Y) 0 ≤ (1 : L (HSum ℋ)) := by exact sub_nonneg.mp (by simpa [hsub] using hblock_nonneg) simpa [hXtilde_star_mul] using hblock - have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by - simp + have hXtilde_star_mul_nonneg : (0 : L (HSum ℋ)) ≤ star Xtilde * Xtilde := by simp have hXtilde_norm : ‖Xtilde‖ ≤ 1 := by have hnormSq : ‖star Xtilde * Xtilde‖ ≤ 1 := (CStarAlgebra.norm_le_one_iff_of_nonneg _ hXtilde_star_mul_nonneg).2 hXtilde_star_mul_le - have hnormSq' : ‖Xtilde‖ * ‖Xtilde‖ ≤ 1 := by - simpa [CStarRing.norm_star_mul_self] using hnormSq - have hsq : ‖Xtilde‖ ^ 2 ≤ 1 := by - simpa [pow_two] using hnormSq' + have hnormSq' : ‖Xtilde‖ * ‖Xtilde‖ ≤ 1 := by simpa [CStarRing.norm_star_mul_self] using hnormSq + have hsq : ‖Xtilde‖ ^ 2 ≤ 1 := by simpa [pow_two] using hnormSq' nlinarith [norm_nonneg Xtilde] have hiv_hsum : CondIV (ℋ := HSum ℋ) f := @hiv (HSum ℋ) _ _ _ _ have hcore := hiv_hsum (A := Atilde) (X := Xtilde) hAtilde_sa hAtilde_spec hXtilde_norm diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean index fef28af12..f2f0c8e49 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzTheorem.lean @@ -158,10 +158,8 @@ theorem operatorConvex_convexOn_univ {f : ℝ → ℝ} (hf : OperatorConvex (ℋ (algebraMap ℝ (L ℋ) u) * (algebraMap ℝ (L ℋ) r) + (algebraMap ℝ (L ℋ) v) * (algebraMap ℝ (L ℋ) s) := by rw [Algebra.smul_def, Algebra.smul_def] - _ = algebraMap ℝ (L ℋ) (u * r) + algebraMap ℝ (L ℋ) (v * s) := by - simp - _ = algebraMap ℝ (L ℋ) (u * r + v * s) := by - simp + _ = algebraMap ℝ (L ℋ) (u * r) + algebraMap ℝ (L ℋ) (v * s) := by simp + _ = algebraMap ℝ (L ℋ) (u * r + v * s) := by simp have hop : cfcR (ℋ := ℋ) f ((1 - b) • (algebraMap ℝ (L ℋ) x) + b • (algebraMap ℝ (L ℋ) y)) ≤ @@ -183,8 +181,7 @@ theorem operatorConvex_convexOn_univ {f : ℝ → ℝ} (hf : OperatorConvex (ℋ halg_combo (u := 1 - b) (v := b) (r := f x) (s := f y)] at hop have hscalar : algebraMap ℝ (L ℋ) (f ((1 - b) * x + b * y)) ≤ - algebraMap ℝ (L ℋ) ((1 - b) * f x + b * f y) := by - simpa [Algebra.smul_def] using hop + algebraMap ℝ (L ℋ) ((1 - b) * f x + b * f y) := by simpa [Algebra.smul_def] using hop have hspec_le : ∀ z ∈ spectrum ℝ (algebraMap ℝ (L ℋ) (f ((1 - b) * x + b * y))), z ≤ (1 - b) * f x + b * f y := by From 1a79510a9531d33c667b4e3639d113f526ac21b8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:33:05 -0700 Subject: [PATCH 337/498] refactor: golf canonical ensemble witnesses Co-authored-by: Claude Opus 4.8 --- .../CanonicalEnsemble/Basic.lean | 9 ++--- .../CanonicalEnsemble/Finite.lean | 24 ++++-------- .../CanonicalEnsemble/Lemmas.lean | 39 +++++++------------ 3 files changed, 24 insertions(+), 48 deletions(-) diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 45ff73291..1c7529463 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -799,8 +799,7 @@ lemma log_partitionFunction have hden : 0 < 𝓒.phaseSpaceunit ^ 𝓒.dof := pow_pos 𝓒.hPos _ have hlogpow : Real.log (𝓒.phaseSpaceunit ^ 𝓒.dof) - = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by - simp + = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by simp simp [partitionFunction, Real.log_div hZ.ne' hden.ne', hlogpow, sub_eq_add_neg] @@ -866,8 +865,7 @@ lemma helmholtzFreeEnergy_add (Real.log (𝓒.partitionFunction T) + Real.log (𝓒1.partitionFunction T)) := by rw [Real.log_mul hpf₁.ne' hpf₂.ne'] _ = (-kB * T.val) * Real.log (𝓒.partitionFunction T) - + (-kB * T.val) * Real.log (𝓒1.partitionFunction T) := by - ring + + (-kB * T.val) * Real.log (𝓒1.partitionFunction T) := by ring _ = 𝓒.helmholtzFreeEnergy T + 𝓒1.helmholtzFreeEnergy T := by simp [helmholtzFreeEnergy, mul_comm, mul_assoc] @@ -886,8 +884,7 @@ lemma helmholtzFreeEnergy_nsmul = -kB * T.val * Real.log ((nsmul n 𝓒).partitionFunction T) := rfl _ = -kB * T.val * ((n : ℝ) * Real.log (𝓒.partitionFunction T)) := by rw [hlog] - _ = (n : ℝ) * (-kB * T.val * Real.log (𝓒.partitionFunction T)) := by - ring + _ = (n : ℝ) * (-kB * T.val * Real.log (𝓒.partitionFunction T)) := by ring _ = n * 𝓒.helmholtzFreeEnergy T := by simp [helmholtzFreeEnergy, mul_comm, mul_left_comm, mul_assoc] diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index c1223820b..a0388a8f4 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -81,8 +81,7 @@ instance [IsFinite 𝓒] [IsFinite 𝓒1] : IsFinite (𝓒 + 𝓒1) where · exact ht · exact hs · exact MeasurableSet.prod hs ht - dof_eq_zero := by - simp [IsFinite.dof_eq_zero (𝓒:=𝓒), IsFinite.dof_eq_zero (𝓒:=𝓒1)] + dof_eq_zero := by simp [IsFinite.dof_eq_zero (𝓒:=𝓒), IsFinite.dof_eq_zero (𝓒:=𝓒1)] phase_space_unit_eq_one := by simp [IsFinite.phase_space_unit_eq_one (𝓒:=𝓒)] instance [IsFinite 𝓒] (e : ι1 ≃ᵐ ι) : IsFinite (congr 𝓒 e) where @@ -103,8 +102,7 @@ instance [IsFinite 𝓒] (e : ι1 ≃ᵐ ι) : IsFinite (congr 𝓒 e) where · exact Set.toFinite (⇑e '' s) · exact hs · exact (MeasurableEquiv.measurableSet_preimage e.symm).mpr hs - dof_eq_zero := by - simp [IsFinite.dof_eq_zero (𝓒:=𝓒)] + dof_eq_zero := by simp [IsFinite.dof_eq_zero (𝓒:=𝓒)] phase_space_unit_eq_one := by simp [IsFinite.phase_space_unit_eq_one (𝓒:=𝓒)] instance [IsFinite 𝓒] (n : ℕ) : IsFinite (nsmul n 𝓒) where @@ -124,8 +122,7 @@ instance [IsFinite 𝓒] (n : ℕ) : IsFinite (nsmul n 𝓒) where | succ n ih => haveI : IsFinite (nsmul n 𝓒) := { μ_eq_count := ih - dof_eq_zero := by - simp [CanonicalEnsemble.dof_nsmul, IsFinite.dof_eq_zero (𝓒:=𝓒)] + dof_eq_zero := by simp [CanonicalEnsemble.dof_nsmul, IsFinite.dof_eq_zero (𝓒:=𝓒)] phase_space_unit_eq_one := by simp [CanonicalEnsemble.phase_space_unit_nsmul, IsFinite.phase_space_unit_eq_one (𝓒:=𝓒)] @@ -136,8 +133,7 @@ instance [IsFinite 𝓒] (n : ℕ) : IsFinite (nsmul n 𝓒) where (MeasurableEquiv.piFinSuccAbove (fun _ => ι) 0)).μ = Measure.count := by erw [IsFinite.μ_eq_count]; aesop rw [← h]; rw [← @nsmul_succ] - dof_eq_zero := by - simp [CanonicalEnsemble.dof_nsmul, IsFinite.dof_eq_zero (𝓒:=𝓒)] + dof_eq_zero := by simp [CanonicalEnsemble.dof_nsmul, IsFinite.dof_eq_zero (𝓒:=𝓒)] phase_space_unit_eq_one := by simp [CanonicalEnsemble.phase_space_unit_nsmul, IsFinite.phase_space_unit_eq_one (𝓒:=𝓒)] @@ -151,8 +147,7 @@ instance [IsFinite 𝓒] [Nonempty ι] : NeZero 𝓒.μ := by refine ⟨?_⟩ intro hμ obtain ⟨i₀⟩ := (inferInstance : Nonempty ι) - have hone : 𝓒.μ {i₀} = 1 := by - simp [IsFinite.μ_eq_count (𝓒:=𝓒)] + have hone : 𝓒.μ {i₀} = 1 := by simp [IsFinite.μ_eq_count (𝓒:=𝓒)] simp_all only [Measure.coe_zero, Pi.zero_apply, zero_ne_one] /-- The Shannon entropy of a finite canonical ensemble. @@ -346,8 +341,7 @@ noncomputable def meanEnergyBetaReal (b : ℝ) : ℝ := lemma meanEnergy_Beta_eq_finite [MeasurableSingletonClass ι] [IsFinite 𝓒] (b : ℝ) (hb : 0 < b) : 𝓒.meanEnergyBeta b = 𝓒.meanEnergyBetaReal b := by let T := Temperature.ofβ (Real.toNNReal b) - have hT_beta : (T.β : ℝ) = b := by - simp [T, Real.toNNReal_of_nonneg hb.le] + have hT_beta : (T.β : ℝ) = b := by simp [T, Real.toNNReal_of_nonneg hb.le] rw [meanEnergyBeta, meanEnergy_of_fintype 𝓒 T, meanEnergyBetaReal] refine Finset.sum_congr rfl fun i _ => ?_ simp [CanonicalEnsemble.probability, probabilityBetaReal, @@ -386,8 +380,7 @@ lemma deriv_mathematicalPartitionFunctionBetaReal (b : ℝ) : unfold mathematicalPartitionFunctionBetaReal meanEnergyNumerator have hd : ∀ c : ℝ, HasDerivAt (fun x => Real.exp (-x * c)) (-c * Real.exp (-b * c)) b := by intro c - have h : HasDerivAt (fun x => -x * c) (-c) b := by - simpa using (hasDerivAt_id b).neg.mul_const c + have h : HasDerivAt (fun x => -x * c) (-c) b := by simpa using (hasDerivAt_id b).neg.mul_const c simpa [mul_comm] using h.exp have h_sum : HasDerivAt (fun x => ∑ i, Real.exp (-x * 𝓒.energy i)) (∑ i, -𝓒.energy i * Real.exp (-b * 𝓒.energy i)) b := @@ -400,8 +393,7 @@ lemma deriv_meanEnergyNumerator (b : ℝ) : unfold meanEnergyNumerator have hd : ∀ c : ℝ, HasDerivAt (fun x => Real.exp (-x * c)) (-c * Real.exp (-b * c)) b := by intro c - have h : HasDerivAt (fun x => -x * c) (-c) b := by - simpa using (hasDerivAt_id b).neg.mul_const c + have h : HasDerivAt (fun x => -x * c) (-c) b := by simpa using (hasDerivAt_id b).neg.mul_const c simpa [mul_comm] using h.exp have h_sum : HasDerivAt (fun x => ∑ i, 𝓒.energy i * Real.exp (-x * 𝓒.energy i)) (∑ i, -(𝓒.energy i)^2 * Real.exp (-b * 𝓒.energy i)) b := by diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index 6e61e9fb0..9adbbc32d 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -80,8 +80,7 @@ lemma helmholtzFreeEnergy_eq_helmholtzMathematicalFreeEnergy_add_correction (T : simp_rw [helmholtzFreeEnergy, mathematicalHelmholtzFreeEnergy, partitionFunction, Real.log_div hZ_pos.ne' h_pow_pos.ne'] have h_log_pow : Real.log (𝓒.phaseSpaceunit ^ 𝓒.dof) - = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by - simp + = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by simp simp [sub_eq_add_neg, h_log_pow, mul_add, add_comm, mul_comm, mul_left_comm, mul_assoc] /-- General identity: S_diff = kB β ⟨E⟩ + kB log Z_math. @@ -190,8 +189,7 @@ lemma thermodynamicEntropy_eq_differentialEntropy_sub_correction simp_all only [neg_mul, physicalProbability_def] have h_int_const_eval : ∫ _i, (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit ∂ 𝓒.μProd T - = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by - simp [integral_const] + = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by simp [integral_const] unfold thermodynamicEntropy differentialEntropy rw [h_int_rewrite, integral_add h_int_log_prob h_int_const, @@ -201,8 +199,7 @@ lemma thermodynamicEntropy_eq_differentialEntropy_sub_correction (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit) = (-kB * ∫ i, Real.log (𝓒.probability T i) ∂ 𝓒.μProd T) - - kB * (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by - ring + - kB * (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by ring simp [this, sub_eq_add_neg, mul_assoc] /-- No semiclassical correction when `dof = 0`. -/ @@ -312,8 +309,7 @@ theorem differentialEntropy_eq_meanEnergy_sub_helmholtz_div_temp_add_correction have hy : 0 < 𝓒.phaseSpaceunit ^ 𝓒.dof := hpow_pos have hlog_pow : Real.log (𝓒.phaseSpaceunit ^ 𝓒.dof) - = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by - simp + = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by simp calc Real.log Zmath = Real.log (Zphys * 𝓒.phaseSpaceunit ^ 𝓒.dof) := by simp [hZdef] @@ -385,8 +381,7 @@ lemma integral_bolt_eq_integral_mul_exp set f : ι → ℝ≥0∞ := fun x => ENNReal.ofReal (Real.exp (-T.β * 𝓒.energy x)) have hf_meas : Measurable f := by fun_prop - have hf_lt_top : ∀ᵐ x ∂ 𝓒.μ, f x < ∞ := by - simp [f] + have hf_lt_top : ∀ᵐ x ∂ 𝓒.μ, f x < ∞ := by simp [f] have h := integral_withDensity_eq_integral_toReal_smul (μ := 𝓒.μ) hf_meas hf_lt_top φ @@ -419,8 +414,7 @@ lemma meanEnergy_eq_ratio_of_integrals unfold meanEnergy μProd have h_scale : ∫ x, 𝓒.energy x ∂ ((𝓒.μBolt T Set.univ)⁻¹ • 𝓒.μBolt T) - = ((𝓒.μBolt T Set.univ)⁻¹).toReal * ∫ x, 𝓒.energy x ∂ 𝓒.μBolt T := by - simp + = ((𝓒.μBolt T Set.univ)⁻¹).toReal * ∫ x, 𝓒.energy x ∂ 𝓒.μBolt T := by simp have h_energy_bolt_raw := integral_energy_bolt (𝓒:=𝓒) (T:=T) have h_den : @@ -429,17 +423,14 @@ lemma meanEnergy_eq_ratio_of_integrals exact (mathematicalPartitionFunction_eq_integral (𝓒:=𝓒) (T:=T)) have h_inv_toReal : ((𝓒.μBolt T Set.univ)⁻¹).toReal - = 1 / (𝓒.μBolt T Set.univ).toReal := by - simp [one_div, ENNReal.toReal_inv] + = 1 / (𝓒.μBolt T Set.univ).toReal := by simp [one_div, ENNReal.toReal_inv] calc ∫ x, 𝓒.energy x ∂ ((𝓒.μBolt T Set.univ)⁻¹ • 𝓒.μBolt T) = ((𝓒.μBolt T Set.univ)⁻¹).toReal * ∫ x, 𝓒.energy x ∂ 𝓒.μBolt T := h_scale _ = ((𝓒.μBolt T Set.univ)⁻¹).toReal * - (∫ x, 𝓒.energy x * Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) := by - simp [h_energy_bolt_raw] + (∫ x, 𝓒.energy x * Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) := by simp [h_energy_bolt_raw] _ = (1 / (𝓒.μBolt T Set.univ).toReal) * - (∫ x, 𝓒.energy x * Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) := by - simp [h_inv_toReal] + (∫ x, 𝓒.energy x * Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) := by simp [h_inv_toReal] _ = (∫ x, 𝓒.energy x * Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) / (∫ x, Real.exp (- T.β * 𝓒.energy x) ∂ 𝓒.μ) := by simp [h_den, div_eq_mul_inv, mul_comm] @@ -535,8 +526,7 @@ lemma log_phys_eq_log_math_sub_const_on_Ioi (Set.Ioi (0 : ℝ)) := by intro β hβ have hβpos : 0 < β := hβ - have hβnn : Real.toNNReal β = β := by - simp [Real.toNNReal, hβpos.le] + have hβnn : Real.toNNReal β = β := by simp [Real.toNNReal, hβpos.le] have _inst : IsFiniteMeasure (𝓒.μBolt (Temperature.ofβ (Real.toNNReal β))) := h_fin β hβpos have hZpos : @@ -547,16 +537,14 @@ lemma log_phys_eq_log_math_sub_const_on_Ioi have h_pow_pos : 0 < 𝓒.phaseSpaceunit ^ 𝓒.dof := pow_pos 𝓒.hPos _ have h_log_pow : Real.log (𝓒.phaseSpaceunit ^ 𝓒.dof) - = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by - simp + = (𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit := by simp have : Real.log (𝓒.partitionFunction (Temperature.ofβ (Real.toNNReal β))) = -((𝓒.dof : ℝ) * Real.log 𝓒.phaseSpaceunit) + Real.log (∫ i, Real.exp (-β * 𝓒.energy i) ∂ 𝓒.μ) := by have h_integral_pos : 0 < ∫ i, Real.exp (-β * 𝓒.energy i) ∂ 𝓒.μ := by have h_eq : ∫ i, Real.exp (-β * 𝓒.energy i) ∂ 𝓒.μ = - ∫ i, Real.exp (-(Real.toNNReal β).val * 𝓒.energy i) ∂ 𝓒.μ := by - simp [hβnn] + ∫ i, Real.exp (-(Real.toNNReal β).val * 𝓒.energy i) ∂ 𝓒.μ := by simp [hβnn] rw [h_eq] simp [mathematicalPartitionFunction_eq_integral (𝓒:=𝓒) (T:=Temperature.ofβ (Real.toNNReal β))] at hZpos @@ -671,8 +659,7 @@ theorem energyVariance_eq_meanSquareEnergy_sub_meanEnergy_sq rw [integral_const_mul] rw [integral_const] have hμProb : (𝓒.μProd T) Set.univ = 1 := by simp - have hμReal : (𝓒.μProd T).real Set.univ = 1 := by - simp [measureReal_def, hμProb] + have hμReal : (𝓒.μProd T).real Set.univ = 1 := by simp [measureReal_def, hμProb] calc ∫ i, (𝓒.energy i)^2 ∂𝓒.μProd T - 2 * U * ∫ i, 𝓒.energy i ∂𝓒.μProd T From ee4b3ae5f05a85c8b8591a33048c70ac97407841 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:35:01 -0700 Subject: [PATCH 338/498] refactor: golf Hermitian matrix witnesses Co-authored-by: Claude Opus 4.8 --- .../ForMathlib/HermitianMat/Order.lean | 24 +++++++------------ QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 15 ++++-------- QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean | 6 ++--- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index cacab4736..07148a042 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -341,27 +341,21 @@ meta def evalHermitianMatConj : PositivityExt where eval {_u _α} _zα _pα e := pure (.nonnegative (← mkAppM ``HermitianMat.conj_nonneg #[M, pfNonneg])) open MatrixOrder in -example {A : Matrix n n ℂ} (hA : A.PosSemidef) : 0 ≤ A := by - positivity +example {A : Matrix n n ℂ} (hA : A.PosSemidef) : 0 ≤ A := by positivity open MatrixOrder in -example {A : Matrix n n ℂ} [Nonempty n] (hA : A.PosDef) : 0 < A := by - positivity +example {A : Matrix n n ℂ} [Nonempty n] (hA : A.PosDef) : 0 < A := by positivity -example (hA : A.mat.PosSemidef) : 0 ≤ A := by - positivity +example (hA : A.mat.PosSemidef) : 0 ≤ A := by positivity -example [Nonempty n] (hA : A.mat.PosDef) : 0 < A := by - positivity +example [Nonempty n] (hA : A.mat.PosDef) : 0 < A := by positivity example [DecidableEq n] [DecidableEq m] [Nonempty n] [Nonempty m] (A B : HermitianMat n ℂ) (hA : 0 ≤ A) (hB : 0 ≤ B) (M : Matrix m n ℂ) : - 0 < (2 : HermitianMat (n × m) ℂ) + (3 • A) ⊗ₖ (Real.pi • B).conj M := by - positivity + 0 < (2 : HermitianMat (n × m) ℂ) + (3 • A) ⊗ₖ (Real.pi • B).conj M := by positivity example (A B : HermitianMat n ℂ) (hA : 0 < A) (hB : 0 < B) : - 0 < ((37 • A) ⊗ₖ ((38 : ℝ) • B)).trace := by - positivity + 0 < ((37 • A) ⊗ₖ ((38 : ℝ) • B)).trace := by positivity omit [Fintype n] in theorem convex_cone (hA : 0 ≤ A) (hB : 0 ≤ B) {c₁ c₂ : ℝ} (hc₁ : 0 ≤ c₁) (hc₂ : 0 ≤ c₂) : @@ -643,8 +637,7 @@ variable [DecidableEq n] [DecidableEq m] open MatrixOrder -- Test: eigenvalues nonneg from PSD HermitianMat -example (A : HermitianMat n ℂ) (hA : 0 < A) (i : n) : 0 ≤ A.H.eigenvalues i := by - positivity +example (A : HermitianMat n ℂ) (hA : 0 < A) (i : n) : 0 ≤ A.H.eigenvalues i := by positivity -- Test: A.mat nonneg from A nonneg example (A : HermitianMat n ℂ) (hA : 0 ≤ A) : 0 ≤ A.mat := by positivity @@ -669,8 +662,7 @@ example (M : Matrix n m ℝ) : positivity example (M : Matrix n n ℂ) (i : n) (A : HermitianMat n ℂ) (hA : 0 ≤ A) : - 0 ≤ (A + ⟨_, M.isHermitian_mul_conjTranspose_self⟩ + 0).H.eigenvalues i := by - positivity + 0 ≤ (A + ⟨_, M.isHermitian_mul_conjTranspose_self⟩ + 0).H.eigenvalues i := by positivity end tests end MatrixPositivity diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index cd3000fe6..256199809 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -629,8 +629,7 @@ theorem rpow_le_rpow_of_le (hA : 0 ≤ A) (hAB : A ≤ B) simp [ Matrix.mulVec, dotProduct, Finset.mul_sum _ _ _, mul_assoc, mul_left_comm]; simp [ Matrix.one_apply] have h_inner_nonneg : 0 ≤ star x ⬝ᵥ A.mat.mulVec x := inner_mulVec_nonneg hA x - have h_inner_pos : 0 < star x ⬝ᵥ x := by - simp_all + have h_inner_pos : 0 < star x ⬝ᵥ x := by simp_all exact h_inner.symm ▸ add_pos_of_nonneg_of_pos h_inner_nonneg ( mul_pos ( mod_cast hε_pos ) ( mod_cast h_inner_pos ) ) |> lt_of_lt_of_le <| le_rfl; have h_pos_def_Bε : (Bε ε).mat.PosDef := by convert posDef_of_posDef_le h_pos_def_Aε _ using 1 @@ -701,8 +700,7 @@ private lemma conj_rpow_le_one_of_conj_le_one_posDef have hconj := HermitianMat.conj_mono (M := (B ^ (-1 : ℝ)).mat) hAB have hleft : (A.conj B.mat).conj (B ^ (-1 : ℝ)).mat = A := by rw [HermitianMat.conj_conj] - have hmul : (B ^ (-1 : ℝ)).mat * B.mat = 1 := by - simpa using rpow_neg_mul_rpow_self hB 1 + have hmul : (B ^ (-1 : ℝ)).mat * B.mat = 1 := by simpa using rpow_neg_mul_rpow_self hB 1 exact (HermitianMat.conj_one (A := A)).symm ▸ by simp [hmul] have hright : (1 : HermitianMat d ℂ).conj (B ^ (-1 : ℝ)).mat = B ^ (-2 : ℝ) := by ext1 @@ -754,8 +752,7 @@ private lemma top_singular_le_of_self_mul_le_smul_one (hcard : 0 < Fintype.card e) : singularValuesSorted X ⟨0, hcard⟩ ≤ Real.sqrt α := by letI : Nonempty e := Fintype.card_pos_iff.mp hcard - let hne : (Finset.univ : Finset e).Nonempty := by - simp + let hne : (Finset.univ : Finset e).Nonempty := by simp rw [singularValuesSorted_zero_eq_sup X hcard] refine Finset.sup'_le _ _ ?_ intro i hi @@ -835,8 +832,7 @@ private lemma compound_top_singular_le_posDef have hconj := congrArg (fun H : HermitianMat _ ℂ => H.conj (Bk ^ (-1 : ℝ)).mat) hMk_eq_zero have hleft : (Ak.conj Bk.mat).conj (Bk ^ (-1 : ℝ)).mat = Ak := by rw [HermitianMat.conj_conj] - have : (Bk ^ (-1 : ℝ)).mat * Bk.mat = 1 := by - simpa using rpow_neg_mul_rpow_self hBk 1 + have : (Bk ^ (-1 : ℝ)).mat * Bk.mat = 1 := by simpa using rpow_neg_mul_rpow_self hBk 1 simp [this, HermitianMat.conj_one (A := Ak)] simpa [hleft] using hconj have hNk_zero : Nk.conjTranspose * Nk = 0 := by @@ -1236,8 +1232,7 @@ private lemma intervalIntegrable_weighted_trace_mul_inv_shift {A : HermitianMat hp hT).add hs refine hg.congr ?_ intro t ht - have htIoc : t ∈ Set.Ioc (0 : ℝ) T := by - simpa [Set.uIoc_of_le hT.le] using ht + have htIoc : t ∈ Set.Ioc (0 : ℝ) T := by simpa [Set.uIoc_of_le hT.le] using ht unfold g change ∑ i, t ^ (p - 1) * (A.H.eigenvalues i / (A.H.eigenvalues i + t)) = t ^ (p - 1) * (((A.mat * (A + t • 1).mat⁻¹).trace : ℂ)).re diff --git a/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean b/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean index 858d572df..f22658fef 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean @@ -85,8 +85,6 @@ meta def evalHermitianMatSqrt : PositivityExt where eval {_u _α} _zα _pα e := catch _ => pure (.nonnegative (← mkAppM ``HermitianMat.sqrt_nonneg #[A])) -example {A : HermitianMat d ℂ} : 0 ≤ A.sqrt := by - positivity +example {A : HermitianMat d ℂ} : 0 ≤ A.sqrt := by positivity -example [Nonempty d] {A : HermitianMat d ℂ} : 0 < (1 + A.sqrt).sqrt := by - positivity +example [Nonempty d] {A : HermitianMat d ℂ} : 0 < (1 + A.sqrt).sqrt := by positivity From 31e2a509214910b7eb9dedb323a3487657d0749f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:36:38 -0700 Subject: [PATCH 339/498] refactor: golf matrix witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/Matrix.lean | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/QuantumInfo/ForMathlib/Matrix.lean b/QuantumInfo/ForMathlib/Matrix.lean index f67bcdda8..5f8cdcfa2 100644 --- a/QuantumInfo/ForMathlib/Matrix.lean +++ b/QuantumInfo/ForMathlib/Matrix.lean @@ -421,8 +421,7 @@ theorem le_smul_one_of_eigenvalues_iff (hA : A.IsHermitian) (c : ℝ) : (∀ i, hA.eigenvalues i ≤ c) ↔ A ≤ c • (1 : Matrix n n 𝕜) := by let U : Matrix n n 𝕜 := ↑hA.eigenvectorUnitary have hU : U.conjTranspose = star U := by simp only [star] - have hU' : U * star U = 1 := by - simp only [SetLike.coe_mem, Unitary.mul_star_self_of_mem, U] + have hU' : U * star U = 1 := by simp only [SetLike.coe_mem, Unitary.mul_star_self_of_mem, U] have hc : c • (1 : Matrix n n 𝕜) = U * (c • 1) * U.conjTranspose := by simp only [Algebra.mul_smul_comm, mul_one, hU, Algebra.smul_mul_assoc, hU'] have hc' : c • (1 : Matrix n n 𝕜) = diagonal (RCLike.ofReal ∘ fun _ : n ↦ c) := by @@ -440,8 +439,7 @@ theorem le_smul_one_of_eigenvalues_iff (hA : A.IsHermitian) (c : ℝ) : simp only [Function.comp_apply, algebraMap_le_algebraMap, h i] intro hAc i replace hAc := conjTranspose_mul_mul_mono U hAc - have hU'CT : star U * U = 1 := by - simp only [SetLike.coe_mem, Unitary.star_mul_self_of_mem, U] + have hU'CT : star U * U = 1 := by simp only [SetLike.coe_mem, Unitary.star_mul_self_of_mem, U] have hcCT : U.conjTranspose * (c • 1) * U = c • (1 : Matrix n n 𝕜) := by simp only [Algebra.mul_smul_comm, mul_one, hU, Algebra.smul_mul_assoc, hU'CT] have hASTCT : U.conjTranspose * A * U = diagonal (RCLike.ofReal ∘ hA.eigenvalues) := by @@ -458,8 +456,7 @@ theorem smul_one_le_of_eigenvalues_iff (hA : A.IsHermitian) (c : ℝ) : -- I did the lazy thing and just copied the previous proof let U : Matrix n n 𝕜 := ↑hA.eigenvectorUnitary have hU : U.conjTranspose = star U := by simp only [star] - have hU' : U * star U = 1 := by - simp only [SetLike.coe_mem, Unitary.mul_star_self_of_mem, U] + have hU' : U * star U = 1 := by simp only [SetLike.coe_mem, Unitary.mul_star_self_of_mem, U] have hc : c • (1 : Matrix n n 𝕜) = U * (c • 1) * U.conjTranspose := by simp only [Algebra.mul_smul_comm, mul_one, hU, Algebra.smul_mul_assoc, hU'] have hc' : c • (1 : Matrix n n 𝕜) = diagonal (RCLike.ofReal ∘ fun _ : n ↦ c) := by @@ -477,8 +474,7 @@ theorem smul_one_le_of_eigenvalues_iff (hA : A.IsHermitian) (c : ℝ) : simp only [Function.comp_apply, algebraMap_le_algebraMap, h i] intro hAc i replace hAc := conjTranspose_mul_mul_mono U hAc - have hU'CT : star U * U = 1 := by - simp only [SetLike.coe_mem, Unitary.star_mul_self_of_mem, U] + have hU'CT : star U * U = 1 := by simp only [SetLike.coe_mem, Unitary.star_mul_self_of_mem, U] have hcCT : U.conjTranspose * (c • 1) * U = c • (1 : Matrix n n 𝕜) := by simp only [Algebra.mul_smul_comm, mul_one, hU, Algebra.smul_mul_assoc, hU'CT] have hASTCT : U.conjTranspose * A * U = diagonal (RCLike.ofReal ∘ hA.eigenvalues) := by @@ -914,8 +910,7 @@ variable {d₁ d₂ : Type*} [Fintype d₁] [Fintype d₂] @[simp] theorem trace_submatrix (A : Matrix d₁ d₁ α) (e : d₂ ≃ d₁) : - (A.submatrix e e).trace = A.trace := by - simpa [Matrix.trace] using e.sum_comp (fun x ↦ A x x) + (A.submatrix e e).trace = A.trace := by simpa [Matrix.trace] using e.sum_comp (fun x ↦ A x x) end subm @@ -1469,8 +1464,7 @@ theorem traceLeft_neg : (-A).traceLeft = -A.traceLeft := by ext : 2; simp [Matrix.traceLeft] @[simp] -theorem traceLeft_sub : (A - B).traceLeft = A.traceLeft - B.traceLeft := by - simp [sub_eq_add_neg] +theorem traceLeft_sub : (A - B).traceLeft = A.traceLeft - B.traceLeft := by simp [sub_eq_add_neg] variable {A B : Matrix (n × m) (n × m) α} From 8b12ab97a4862e438d014a9c8dde63ac4bef2ef1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:38:41 -0700 Subject: [PATCH 340/498] refactor: golf classical mechanics witnesses Co-authored-by: Claude Opus 4.8 --- .../DampedHarmonicOscillator/Basic.lean | 9 +++------ .../HarmonicOscillator/Basic.lean | 9 +++------ .../HarmonicOscillator/ConfigurationSpace.lean | 3 +-- .../HarmonicOscillator/Solution.lean | 3 +-- .../Lagrangian/TotalDerivativeEquivalence.lean | 15 +++++---------- 5 files changed, 13 insertions(+), 26 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 3dc7dc1b9..cfe399866 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -205,8 +205,7 @@ lemma equationOfMotion_iff_newtons_2nd_law (xₜ : Time → EuclideanSpace ℝ ( constructor · intro h t have h' : - S.m • ∂ₜ (∂ₜ xₜ) t + (S.γ • ∂ₜ xₜ t + S.k • xₜ t) = 0 := by - simpa [add_assoc] using h t + S.m • ∂ₜ (∂ₜ xₜ) t + (S.γ • ∂ₜ xₜ t + S.k • xₜ t) = 0 := by simpa [add_assoc] using h t have ha : S.m • ∂ₜ (∂ₜ xₜ) t = -(S.γ • ∂ₜ xₜ t + S.k • xₜ t) := eq_neg_of_add_eq_zero_left h' @@ -314,8 +313,7 @@ lemma k_eq_m_mul_ω_sq : S.k = S.m * S.ω^2 := by lemma k_eq_m_mul_decayRate_sq_of_criticallyDamped (hS : S.IsCriticallyDamped) : S.k = S.m * S.decayRate^2 := by have hωa : S.ω = S.decayRate := S.isCriticallyDamped_decayRate hS - have hωsq : S.decayRate ^ 2 = S.k / S.m := by - simpa [hωa] using S.ω_sq + have hωsq : S.decayRate ^ 2 = S.k / S.m := by simpa [hωa] using S.ω_sq field_simp [S.m_ne_zero] at hωsq nlinarith @@ -436,8 +434,7 @@ for the corresponding undamped harmonic oscillator. -/ lemma toUndamped_equationOfMotion (S : DampedHarmonicOscillator) (hS : S.IsUndamped) (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) : S.EquationOfMotion xₜ ↔ (S.toUndamped hS).EquationOfMotion xₜ := by - have hγ : S.γ = 0 := by - simpa [IsUndamped] using hS + have hγ : S.γ = 0 := by simpa [IsUndamped] using hS rw [S.equationOfMotion_iff_newtons_2nd_law xₜ, (S.toUndamped hS).equationOfMotion_iff_newtons_2nd_law xₜ hx] constructor diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index 9c43be37b..b692fc569 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -688,12 +688,9 @@ noncomputable def toCanonicalMomentum (t : Time) (x : EuclideanSpace ℝ (Fin 1) EuclideanSpace ℝ (Fin 1) ≃ₗ[ℝ] EuclideanSpace ℝ (Fin 1) where toFun v := gradient (S.lagrangian t x ·) v invFun p := (1 / S.m) • p - left_inv v := by - simp [gradient_lagrangian_velocity_eq] - right_inv p := by - simp [gradient_lagrangian_velocity_eq] - map_add' v1 v2 := by - simp [gradient_lagrangian_velocity_eq] + left_inv v := by simp [gradient_lagrangian_velocity_eq] + right_inv p := by simp [gradient_lagrangian_velocity_eq] + map_add' v1 v2 := by simp [gradient_lagrangian_velocity_eq] map_smul' c v := by simp [gradient_lagrangian_velocity_eq] module diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean index 18c3779d0..9f0ece940 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/ConfigurationSpace.lean @@ -142,8 +142,7 @@ chart's self-transition, which is analytic, so chart compatibility is immediate. instance : ChartedSpace (EuclideanSpace ℝ (Fin 1)) ConfigurationSpace where atlas := { valHomeomorphism.toOpenPartialHomeomorph } chartAt _ := valHomeomorphism.toOpenPartialHomeomorph - mem_chart_source := by - simp + mem_chart_source := by simp chart_mem_atlas := by intro x simp diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index 7e74046af..12bcd416e 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -1053,8 +1053,7 @@ lemma trajectory_velocity_eq_zero_iff_norm_eq_amplitude (IC : InitialConditions) · simp [hcos, abs_of_pos hA_pos] · simp [hcos, abs_of_pos hA_pos] · intro hnorm - have hnorm' : |A * cos θ| = A := by - simpa using hnorm + have hnorm' : |A * cos θ| = A := by simpa using hnorm have hcos_abs : |cos θ| = 1 := by calc |cos θ| = |A * cos θ| / A := by diff --git a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean index 9463f2147..e2d64f984 100644 --- a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean +++ b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean @@ -226,8 +226,7 @@ lemma isTotalTimeDerivativeVelocity [CompleteSpace X] simpa using (hEq (0 : Time) (0 : X) (0 : X)) have : dF ((1 : Time), (0 : X)) = - δL (0 : X) := by - simpa [dF] using h0.symm + δL (0 : X) := by simpa [dF] using h0.symm simpa [hδL0] using this -- Induced continuous linear functional on velocity: v ↦ dF (0,v). @@ -240,10 +239,8 @@ lemma isTotalTimeDerivativeVelocity [CompleteSpace X] have hv : δL v = fderiv ℝ ↿F ((0 : Time), (0 : X)) - ((1 : Time), v) := by - simpa using (hEq (0 : Time) (0 : X) v) - have hv' : δL v = dF ((1 : Time), v) := by - simpa [dF] using hv + ((1 : Time), v) := by simpa using (hEq (0 : Time) (0 : X) v) + have hv' : δL v = dF ((1 : Time), v) := by simpa [dF] using hv calc δL v = dF ((1 : Time), v) := hv' _ = dF (((0 : Time), v) + ((1 : Time), (0 : X))) := by simp only [Prod.mk_add_mk, zero_add, @@ -251,10 +248,8 @@ lemma isTotalTimeDerivativeVelocity [CompleteSpace X] _ = dF ((0 : Time), v) + dF ((1 : Time), (0 : X)) := by simpa using (dF.map_add ((0 : Time), v) ((1 : Time), (0 : X))) - _ = dF ((0 : Time), v) := by - simp [h_time] - _ = φ v := by - simp [φ] + _ = dF ((0 : Time), v) := by simp [h_time] + _ = φ v := by simp [φ] -- Frechet–Riesz: represent φ as inner product with some g. refine ⟨(InnerProductSpace.toDual ℝ (X)).symm φ, ?_⟩ From 414c4cbddb1af4a8a34bdc8245926872cc71756e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:41:08 -0700 Subject: [PATCH 341/498] refactor: golf particle physics witnesses Co-authored-by: Claude Opus 4.8 --- .../BeyondTheStandardModel/TwoHDM/GramMatrix.lean | 15 +++++---------- .../FlavorPhysics/CKMMatrix/Relations.lean | 6 ++---- .../Particles/FlavorPhysics/CKMMatrix/Rows.lean | 12 ++++-------- Physlib/Particles/StandardModel/Basic.lean | 9 +++------ .../StandardModel/HiggsBoson/Potential.lean | 3 +-- .../Particles/StandardModel/Representations.lean | 3 +-- 6 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean b/Physlib/Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean index e6e319dba..f6ac0b23a 100644 --- a/Physlib/Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean +++ b/Physlib/Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean @@ -99,18 +99,15 @@ lemma gaugeGroupI_exists_fst_eq {H : TwoHiggsDoublet} (h1 : H.Φ1 ≠ 0) : simp at h simp [h] have h_fst : (g • H.Φ2).ofLp 0 = ⟪H.Φ1, H.Φ2⟫_ℂ / ‖H.Φ1‖ := by - have h2 : ⟪H.Φ1, H.Φ2⟫_ℂ = ⟪g • H.Φ1, g • H.Φ2⟫_ℂ := by - simp + have h2 : ⟪H.Φ1, H.Φ2⟫_ℂ = ⟪g • H.Φ1, g • H.Φ2⟫_ℂ := by simp rw [h] at h2 conv_rhs at h2 => simp [PiLp.inner_apply] rw [h2] - have hx : (‖H.Φ1‖ : ℂ) ≠ 0 := by - simp_all + have hx : (‖H.Φ1‖ : ℂ) ≠ 0 := by simp_all field_simp apply And.intro h_fst - have hx : ‖g • H.Φ2‖ ^ 2 = ‖H.Φ2‖ ^ 2 := by - simp + have hx : ‖g • H.Φ2‖ ^ 2 = ‖H.Φ2‖ ^ 2 := by simp rw [PiLp.norm_sq_eq_of_L2] at hx simp at hx have hx0 : ‖(g • H.Φ2).ofLp 1‖ ^ 2 = ‖H.Φ2‖ ^ 2 - ‖(g • H.Φ2).ofLp 0‖ ^ 2 := by @@ -236,8 +233,7 @@ lemma gramMatrix_surjective_det_tr (K : Matrix (Fin 2) (Fin 2) ℂ) have det_eq_abc : K.det = a * b - ‖c‖ ^ 2 := by simp [hK_explicit2] rw [Complex.mul_conj'] - have tra_eq_abc : K.trace.re = a + b := by - simp [hK_explicit2] + have tra_eq_abc : K.trace.re = a + b := by simp [hK_explicit2] simp [det_eq_abc, ← Complex.ofReal_pow] at hKdet rw [tra_eq_abc] at hKtr rw [hK_explicit2] @@ -255,8 +251,7 @@ lemma gramMatrix_surjective_det_tr (K : Matrix (Fin 2) (Fin 2) ℂ) simp [PiLp.norm_eq_of_L2, ← Complex.ofReal_pow] exact Real.sq_sqrt hb_nonneg /- The case when a ≠ 0. -/ - have h1 : (√a : ℂ) ≠ 0 := by - simp_all + have h1 : (√a : ℂ) ≠ 0 := by simp_all use ⟨(!₂[√a, 0] : HiggsVec), !₂[conj c/ √a, √(a * b - ‖c‖ ^ 2) / √a]⟩ ext i j fin_cases i <;> fin_cases j <;> simp [gramMatrix, PiLp.norm_eq_of_L2, ← Complex.ofReal_pow] diff --git a/Physlib/Particles/FlavorPhysics/CKMMatrix/Relations.lean b/Physlib/Particles/FlavorPhysics/CKMMatrix/Relations.lean index 18358a9bc..f16cc2013 100644 --- a/Physlib/Particles/FlavorPhysics/CKMMatrix/Relations.lean +++ b/Physlib/Particles/FlavorPhysics/CKMMatrix/Relations.lean @@ -221,8 +221,7 @@ lemma conj_Vtb_mul_Vud {V : CKMMatrix} {τ : ℝ} simp only [neg_mul, exp_neg, Fin.isValue, ne_eq, exp_ne_zero, not_false_eq_true, mul_inv_cancel_left₀] have h2 : ([V]cs * [V]ud - [V]us * [V]cd) * conj [V]ud = [V]cs - * [V]ud * conj [V]ud - [V]us * ([V]cd * conj [V]ud) := by - ring + * [V]ud * conj [V]ud - [V]us * ([V]cd * conj [V]ud) := by ring rw [h2, V.Vcd_mul_conj_Vud] rw [normSq_eq_conj_mul_self, normSq_eq_conj_mul_self] simp only [Fin.isValue, neg_mul] @@ -236,8 +235,7 @@ lemma conj_Vtb_mul_Vus {V : CKMMatrix} {τ : ℝ} simp only [neg_mul, exp_neg, Fin.isValue, ne_eq, exp_ne_zero, not_false_eq_true, mul_inv_cancel_left₀, neg_add_rev] have h2 : ([V]cs * [V]ud - [V]us * [V]cd) * conj [V]us = ([V]cs - * conj [V]us) * [V]ud - [V]us * [V]cd * conj [V]us := by - ring + * conj [V]us) * [V]ud - [V]us * [V]cd * conj [V]us := by ring rw [h2, V.Vcs_mul_conj_Vus] rw [normSq_eq_conj_mul_self, normSq_eq_conj_mul_self] simp only [Fin.isValue, neg_mul] diff --git a/Physlib/Particles/FlavorPhysics/CKMMatrix/Rows.lean b/Physlib/Particles/FlavorPhysics/CKMMatrix/Rows.lean index 8c8998beb..db248587e 100644 --- a/Physlib/Particles/FlavorPhysics/CKMMatrix/Rows.lean +++ b/Physlib/Particles/FlavorPhysics/CKMMatrix/Rows.lean @@ -207,8 +207,7 @@ lemma cRow_cross_tRow_eq_uRow (V : CKMMatrix) : rw [← hg, smul_smul, inv_mul_cancel₀, one_smul] by_contra hn simp [hn] at h2 - have hg2 : norm (g 0)⁻¹ = 1 := by - simp [h2] + have hg2 : norm (g 0)⁻¹ = 1 := by simp [h2] have hg22 : ∃ (τ : ℝ), (g 0)⁻¹ = Complex.exp (τ * I) := by rw [← norm_mul_exp_arg_mul_I (g 0)⁻¹, hg2] use arg (g 0)⁻¹ @@ -216,8 +215,7 @@ lemma cRow_cross_tRow_eq_uRow (V : CKMMatrix) : obtain ⟨τ, hτ⟩ := hg22 use τ rw [hx, hτ] - · have hx : norm (g 0) = -1 := by - simp [← ofReal_inj, Fin.isValue, ofReal_neg, ofReal_one, h2] + · have hx : norm (g 0) = -1 := by simp [← ofReal_inj, Fin.isValue, ofReal_neg, ofReal_one, h2] have h3 := norm_nonneg (g 0) simp_all only [ofReal_neg, ofReal_one, Left.nonneg_neg_iff] have h4 : (0 : ℝ) < 1 := by norm_num @@ -247,8 +245,7 @@ lemma uRow_cross_cRow_eq_tRow (V : CKMMatrix) : ofReal_eq_one] at h2 cases' h2 with h2 h2 swap - · have hx : norm (g 2) = -1 := by - simp [h2, ← ofReal_inj, Fin.isValue, ofReal_neg, ofReal_one] + · have hx : norm (g 2) = -1 := by simp [h2, ← ofReal_inj, Fin.isValue, ofReal_neg, ofReal_one] have h3 := norm_nonneg (g 2) simp_all only [ofReal_neg, ofReal_one, Left.nonneg_neg_iff] have h4 : (0 : ℝ) < 1 := by norm_num @@ -257,8 +254,7 @@ lemma uRow_cross_cRow_eq_tRow (V : CKMMatrix) : rw [← hg, @smul_smul, inv_mul_cancel₀, one_smul] by_contra hn simp [hn] at h2 - have hg2 : norm (g 2)⁻¹ = 1 := by - simp [h2] + have hg2 : norm (g 2)⁻¹ = 1 := by simp [h2] have hg22 : ∃ (τ : ℝ), (g 2)⁻¹ = Complex.exp (τ * I) := by rw [← norm_mul_exp_arg_mul_I (g 2)⁻¹] use arg (g 2)⁻¹ diff --git a/Physlib/Particles/StandardModel/Basic.lean b/Physlib/Particles/StandardModel/Basic.lean index 18c72a2fe..42bbacfc6 100644 --- a/Physlib/Particles/StandardModel/Basic.lean +++ b/Physlib/Particles/StandardModel/Basic.lean @@ -141,8 +141,7 @@ noncomputable def gaugeGroupℤ₆SU3OfRoot (α : rootsOfUnity 6 ℂ) : let z : ℂ := ((α : ℂˣ) : ℂ) ⟨scalar (Fin 3) (z ^ 2), by rw [mem_specialUnitaryGroup_iff] - have hz : ‖z‖ = 1 := by - simpa [z] using Complex.norm_eq_one_of_mem_rootsOfUnity α.prop + have hz : ‖z‖ = 1 := by simpa [z] using Complex.norm_eq_one_of_mem_rootsOfUnity α.prop have hz2 : star (z ^ 2) * z ^ 2 = 1 := by rw [RCLike.star_def, Complex.conj_mul', Complex.norm_pow, hz] norm_num @@ -152,8 +151,7 @@ noncomputable def gaugeGroupℤ₆SU3OfRoot (α : rootsOfUnity 6 ℂ) : Matrix.diagonal_mul_diagonal, Matrix.diagonal_eq_one] funext i simpa [Pi.star_def] using hz2 - · have hα : z ^ 6 = 1 := by - simpa [z] using (mem_rootsOfUnity' 6 (α : ℂˣ)).mp α.prop + · have hα : z ^ 6 = 1 := by simpa [z] using (mem_rootsOfUnity' 6 (α : ℂˣ)).mp α.prop rw [Matrix.scalar_apply, Matrix.det_diagonal, Fin.prod_univ_three] calc z ^ 2 * z ^ 2 * z ^ 2 = z ^ 6 := by ring @@ -172,8 +170,7 @@ noncomputable def gaugeGroupℤ₆SU2OfRoot (α : rootsOfUnity 6 ℂ) : star ((u ^ 3 : unitary ℂ) : ℂ) = 1 rw [star_star] exact (u ^ 3 : unitary ℂ).prop.2 - have hα : z ^ 6 = 1 := by - simpa [z] using (mem_rootsOfUnity' 6 (α : ℂˣ)).mp α.prop + have hα : z ^ 6 = 1 := by simpa [z] using (mem_rootsOfUnity' 6 (α : ℂˣ)).mp α.prop have hw2 : w ^ 2 = 1 := by calc w ^ 2 = star (z ^ 6) := by diff --git a/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean b/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean index d0dc88789..8da1593e5 100644 --- a/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean +++ b/Physlib/Particles/StandardModel/HiggsBoson/Potential.lean @@ -89,8 +89,7 @@ lemma 𝓵_neg : P.neg.𝓵 = - P.𝓵 := by rfl -/ @[simp] -lemma toFun_zero (x : SpaceTime) : P.toFun 0 x = 0 := by - simp [toFun] +lemma toFun_zero (x : SpaceTime) : P.toFun 0 x = 0 := by simp [toFun] lemma complete_square (h : P.𝓵 ≠ 0) (φ : HiggsField) (x : SpaceTime) : P.toFun φ x = P.𝓵 * (‖φ‖_H^2 x - P.μ2 / (2 * P.𝓵)) ^ 2 - P.μ2 ^ 2 / (4 * P.𝓵) := by diff --git a/Physlib/Particles/StandardModel/Representations.lean b/Physlib/Particles/StandardModel/Representations.lean index d58482f5b..61027b5bd 100644 --- a/Physlib/Particles/StandardModel/Representations.lean +++ b/Physlib/Particles/StandardModel/Representations.lean @@ -40,8 +40,7 @@ noncomputable def repU1 : unitary ℂ →* unitaryGroup (Fin 2) ℂ where toFun g := repU1Map g map_mul' g h := by simp only [repU1Map, Submonoid.mk_mul_mk, mul_smul_one, smul_smul, mul_comm, ← mul_pow] - map_one' := by - simp only [repU1Map, one_pow, one_smul, Submonoid.mk_eq_one] + map_one' := by simp only [repU1Map, one_pow, one_smul, Submonoid.mk_eq_one] /-- The fundamental representation of SU(2) as a homomorphism to `unitaryGroup (Fin 2) ℂ`. -/ @[simps!] From 2c6583b551c602e01db7c9e02fc2798eeb403fe9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:44:14 -0700 Subject: [PATCH 342/498] refactor: golf QFT Wick witnesses Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/FieldStatistics/OfFinset.lean | 6 ++---- .../WickAlgebra/NormalOrder/Lemmas.lean | 6 ++---- .../PerturbationTheory/WickAlgebra/TimeOrder.lean | 12 ++++-------- .../QFT/PerturbationTheory/WickAlgebra/WickTerm.lean | 6 ++---- .../WickContraction/InsertAndContractNat.lean | 9 +++------ .../WickContraction/Sign/Join.lean | 9 +++------ Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean | 3 +-- .../QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 3 +-- .../QFT/QED/AnomalyCancellation/Permutations.lean | 6 ++---- 9 files changed, 20 insertions(+), 40 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean index 97f9ce2e2..62a10a098 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean @@ -32,8 +32,7 @@ lemma ofFinset_empty (q : 𝓕 → FieldStatistic) (f : Fin n → 𝓕) : rfl lemma ofFinset_singleton {n : ℕ} (q : 𝓕 → FieldStatistic) (f : Fin n → 𝓕) (i : Fin n) : - ofFinset q f {i} = q (f i) := by - simp [ofFinset] + ofFinset q f {i} = q (f i) := by simp [ofFinset] lemma ofFinset_finset_map {n m : ℕ} (q : 𝓕 → FieldStatistic) (i : Fin m → Fin n) (hi : Function.Injective i) @@ -59,8 +58,7 @@ lemma ofFinset_insert (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a : Finse simp only [ofFinset, Fin.getElem_fin] rw [← ofList_cons_eq_mul] have h1 : (φs[↑i] :: List.map φs.get (a.sort (fun x1 x2 => x1 ≤ x2))) - = List.map φs.get (i :: a.sort (fun x1 x2 => x1 ≤ x2)) := by - simp + = List.map φs.get (i :: a.sort (fun x1 x2 => x1 ≤ x2)) := by simp erw [h1] apply ofList_perm refine List.Perm.map φs.get ?_ diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index 7d23ed569..e672a1c55 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -68,12 +68,10 @@ lemma normalOrder_normalOrder_mid (a b c : 𝓕.WickAlgebra) : rfl lemma normalOrder_normalOrder_left (a b : 𝓕.WickAlgebra) : - 𝓝(a * b) = 𝓝(𝓝(a) * b) := by - simpa using normalOrder_normalOrder_mid (1 : 𝓕.WickAlgebra) a b + 𝓝(a * b) = 𝓝(𝓝(a) * b) := by simpa using normalOrder_normalOrder_mid (1 : 𝓕.WickAlgebra) a b lemma normalOrder_normalOrder_right (a b : 𝓕.WickAlgebra) : - 𝓝(a * b) = 𝓝(a * 𝓝(b)) := by - simpa using normalOrder_normalOrder_mid a b (1 : 𝓕.WickAlgebra) + 𝓝(a * b) = 𝓝(a * 𝓝(b)) := by simpa using normalOrder_normalOrder_mid a b (1 : 𝓕.WickAlgebra) lemma normalOrder_normalOrder (a : 𝓕.WickAlgebra) : 𝓝(𝓝(a)) = 𝓝(a) := by simpa using (normalOrder_normalOrder_left a (1 : 𝓕.WickAlgebra)).symm diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 6994c0651..db1fa564a 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -272,8 +272,7 @@ lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp} ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧ crAnTimeOrderRel c φ)) φs)) * ι (ofCrAnListF (List.filter (fun c => (crAnTimeOrderRel φ c ∧ ¬crAnTimeOrderRel c φ)) - (List.insertionSort crAnTimeOrderRel (φs' ++ φs))))) := by - simp [mul_sub, sub_mul] + (List.insertionSort crAnTimeOrderRel (φs' ++ φs))))) := by simp [mul_sub, sub_mul] _ = crAnTimeOrderSign (φs' ++ [φ, ψ] ++ φs) • (ι (ofCrAnListF (List.takeWhile (fun c => ¬crAnTimeOrderRel φ c) (List.insertionSort crAnTimeOrderRel (φs' ++ φs)))) * @@ -554,17 +553,14 @@ lemma timeOrder_timeOrder_mid (a b c : 𝓕.WickAlgebra) : ← map_mul, ← map_mul, timeOrder_eq_ι_timeOrderF, timeOrderF_timeOrderF_mid] lemma timeOrder_timeOrder_left (b c : 𝓕.WickAlgebra) : - 𝓣(b * c) = 𝓣(𝓣(b) * c) := by - simpa using timeOrder_timeOrder_mid (1 : 𝓕.WickAlgebra) b c + 𝓣(b * c) = 𝓣(𝓣(b) * c) := by simpa using timeOrder_timeOrder_mid (1 : 𝓕.WickAlgebra) b c lemma timeOrder_timeOrder_right (a b : 𝓕.WickAlgebra) : - 𝓣(a * b) = 𝓣(a * 𝓣(b)) := by - simpa using timeOrder_timeOrder_mid a b (1 : 𝓕.WickAlgebra) + 𝓣(a * b) = 𝓣(a * 𝓣(b)) := by simpa using timeOrder_timeOrder_mid a b (1 : 𝓕.WickAlgebra) /-- Time ordering is a projection. -/ lemma timeOrder_timeOrder (a : 𝓕.WickAlgebra) : - 𝓣(𝓣(a)) = 𝓣(a) := by - simpa using (timeOrder_timeOrder_left a (1 : 𝓕.WickAlgebra)).symm + 𝓣(𝓣(a)) = 𝓣(a) := by simpa using (timeOrder_timeOrder_left a (1 : 𝓕.WickAlgebra)).symm end WickAlgebra end FieldSpecification diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean index 137f7b358..f90ee7c7b 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/WickTerm.lean @@ -40,8 +40,7 @@ def wickTerm {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) : corresponding to the empty set `∅` (the only Wick contraction of `[]`) is `1`. -/ @[simp] lemma wickTerm_empty_nil : - wickTerm (empty (n := ([] : List 𝓕.FieldOp).length)) = 1 := by - simp [wickTerm, sign_empty] + wickTerm (empty (n := ([] : List 𝓕.FieldOp).length)) = 1 := by simp [wickTerm, sign_empty] /-- For a list `φs = φ₀…φₙ` of `𝓕.FieldOp`, a Wick contraction `φsΛ` of `φs`, an element `φ` of @@ -83,8 +82,7 @@ lemma wickTerm_insert_none (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) · intro ha simp only [uncontracted, Finset.mem_filter, Finset.mem_univ, true_and, ha, and_true, forall_const] - have hx : φsΛ.getDual? a = none ↔ ¬ (φsΛ.getDual? a).isSome := by - simp + have hx : φsΛ.getDual? a = none ↔ ¬ (φsΛ.getDual? a).isSome := by simp rw [hx] simp only [Bool.not_eq_true, Bool.eq_false_or_eq_true_self, true_and] intro h1 h2 diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean index 9cbcfdb06..e861b3cd6 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean @@ -342,8 +342,7 @@ lemma insertAndContractNat_some_uncontracted (c : WickContraction n) (i : Fin n. set_option backward.isDefEq.respectTransparency false in lemma insertAndContractNat_none_getDual?_isNone (c : WickContraction n) (i : Fin n.succ) : ((insertAndContractNat c i none).getDual? i).isNone := by - have hi : i ∈ (insertAndContractNat c i none).uncontracted := by - simp + have hi : i ∈ (insertAndContractNat c i none).uncontracted := by simp simp only [Nat.succ_eq_add_one, uncontracted, Finset.mem_filter, Finset.mem_univ, true_and] at hi rw [hi] simp @@ -352,8 +351,7 @@ set_option backward.isDefEq.respectTransparency false in @[simp] lemma insertAndContractNat_none_getDual?_eq_none (c : WickContraction n) (i : Fin n.succ) : (insertAndContractNat c i none).getDual? i = none := by - have hi : i ∈ (insertAndContractNat c i none).uncontracted := by - simp + have hi : i ∈ (insertAndContractNat c i none).uncontracted := by simp simp only [Nat.succ_eq_add_one, uncontracted, Finset.mem_filter, Finset.mem_univ, true_and] at hi rw [hi] @@ -769,8 +767,7 @@ lemma insertAndContractNat_surjective_on_nodual (i : Fin n.succ) obtain ⟨a', ha', rfl⟩ := h exact ha' · intro h - have hi : i ∈ c.uncontracted := by - simpa [uncontracted] using hc + have hi : i ∈ c.uncontracted := by simpa [uncontracted] using hc rw [mem_uncontracted_iff_not_contracted] at hi obtain ⟨j, hj⟩ := (@Fin.exists_succAbove_eq_iff _ i (c.fstFieldOfContract ⟨a, h⟩)).mpr (by diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean index 4ec1e24c5..8c2a39b06 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Join.lean @@ -243,8 +243,7 @@ lemma joinSignRightExtra_eq_i_j_finset_eq_if {φs : List 𝓕.FieldOp} not_forall, not_lt] intro hxij h1 h2 omega - · have hj1 : uncontractedListEmd (φsucΛ.fstFieldOfContract a) < j := by - omega + · have hj1 : uncontractedListEmd (φsucΛ.fstFieldOfContract a) < j := by omega by_cases hi1 : ¬ i < uncontractedListEmd (φsucΛ.sndFieldOfContract a) · simp only [hi1, and_false, ↓reduceIte, Finset.notMem_empty, or_false] have hj2 : ¬ j < uncontractedListEmd (φsucΛ.sndFieldOfContract a) := by omega @@ -252,8 +251,7 @@ lemma joinSignRightExtra_eq_i_j_finset_eq_if {φs : List 𝓕.FieldOp} not_or, not_forall, not_lt] intro hxij h1 h2 omega - · have hi1 : i < uncontractedListEmd (φsucΛ.sndFieldOfContract a) := by - omega + · have hi1 : i < uncontractedListEmd (φsucΛ.sndFieldOfContract a) := by omega simp only [hj1, true_and, hi1, and_true] by_cases hi2 : ¬ uncontractedListEmd (φsucΛ.fstFieldOfContract a) < i · simp only [hi2, and_false, ↓reduceIte, Finset.notMem_empty, or_self, iff_false, not_and, @@ -406,8 +404,7 @@ lemma join_sign_induction {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs obtain ⟨i, j, hij, φsucΛ', rfl, h1, h2, h3⟩ := exists_join_singleton_of_card_ge_zero φsΛ (by simp [hn]) hc rw [join_assoc, join_sign_singleton hij h1, join_sign_singleton hij h1] - have hn : φsucΛ'.1.card = n := by - omega + have hn : φsucΛ'.1.card = n := by omega rw [join_sign_induction φsucΛ' (congr (by simp [join_uncontractedListGet]) φsucΛ) h2 n hn] rw [mul_assoc] diff --git a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean index 6db77c551..4e33e354c 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean @@ -33,8 +33,7 @@ def asCharges (j : Fin n) : (PureU1 n.succ).Charges := else 0) lemma asCharges_eq_castSucc (j : Fin n) : - asCharges j (Fin.castSucc j) = 1 := by - simp [asCharges] + asCharges j (Fin.castSucc j) = 1 := by simp [asCharges] lemma asCharges_ne_castSucc {k j : Fin n} (h : k ≠ j) : asCharges k ⟨j, by simp⟩= 0 := by diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 7213bf7fa..1f661f2f0 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -291,8 +291,7 @@ def basisAsCharges (j : Fin n) : (PureU1 (2 * n + 1)).Charges := -/ -lemma basis_on_oddFst_self (j : Fin n) : basisAsCharges j (oddFst j) = 1 := by - simp [basisAsCharges] +lemma basis_on_oddFst_self (j : Fin n) : basisAsCharges j (oddFst j) = 1 := by simp [basisAsCharges] set_option backward.isDefEq.respectTransparency false in lemma basis_on_oddFst_other {k j : Fin n} (h : k ≠ j) : diff --git a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean index f5b278d4a..4041e08bc 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Permutations.lean @@ -99,8 +99,7 @@ def permTwoInj : Fin 2 ↪ Fin n where toFun s := match s with | 0 => i | 1 => j - inj' s1 s2 := by - aesop + inj' s1 s2 := by aesop lemma permTwoInj_fst : i ∈ Set.range ⇑(permTwoInj hij) := by simp only [Set.mem_range] @@ -156,8 +155,7 @@ def permThreeInj : Fin 3 ↪ Fin n where | 0 => i | 1 => j | 2 => k - inj' s1 s2 := by - aesop + inj' s1 s2 := by aesop lemma permThreeInj_fst : i ∈ Set.range ⇑(permThreeInj hij hjk hik) := by simp only [Set.mem_range] From 63a2fd70cbf677ab207df9c98c96394c66c9ec29 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:47:46 -0700 Subject: [PATCH 343/498] refactor: golf space and time witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 12 ++++-------- Physlib/SpaceAndTime/Space/Derivatives/Grad.lean | 6 ++---- Physlib/SpaceAndTime/Space/Integrals/Basic.lean | 6 ++---- Physlib/SpaceAndTime/Space/Module.lean | 6 ++---- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 9 +++------ Physlib/SpaceAndTime/SpaceTime/Basic.lean | 6 ++---- Physlib/SpaceAndTime/Time/TimeMan.lean | 6 ++---- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 9 +++------ Physlib/SpaceAndTime/TimeAndSpace/Basic.lean | 6 ++---- .../TimeAndSpace/EuclideanGroup/Action.lean | 6 ++---- 10 files changed, 24 insertions(+), 48 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index 3c82110c3..40edd79ec 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -488,14 +488,11 @@ noncomputable def distDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] toFun f := let ev : (Space d →L[ℝ] M) →L[ℝ] M := { toFun v := v (basis μ) - map_add' v1 v2 := by - simp only [_root_.add_apply] - map_smul' a v := by - simp + map_add' v1 v2 := by simp only [_root_.add_apply] + map_smul' a v := by simp } ev.comp (Distribution.fderivD ℝ f) - map_add' f1 f2 := by - simp + map_add' f1 f2 := by simp map_smul' a f := by simp @[inherit_doc distDeriv] @@ -509,8 +506,7 @@ macro "∂ᵈ[" i:term "]" : term => `(distDeriv $i) lemma distDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (μ : Fin d) (f : (Space d) →d[ℝ] M) (ε : 𝓢(Space d, ℝ)) : - (∂ᵈ[μ] f) ε = fderivD ℝ f ε (basis μ) := by - simp [distDeriv, Distribution.fderivD] + (∂ᵈ[μ] f) ε = fderivD ℝ f ε (basis μ) := by simp [distDeriv, Distribution.fderivD] /-! diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean index 74da1de5c..174330d76 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Grad.lean @@ -192,8 +192,7 @@ lemma grad_inner_eq {d} (f : Space d → ℝ) (x : Space d) (y : EuclideanSpace simp [inner_smul_right, grad_inner_single] lemma inner_grad_eq {d} (f : Space d → ℝ) (x : EuclideanSpace ℝ (Fin d)) (y : Space d) : - ⟪x, ∇ f y⟫_ℝ = ∑ i, x i * ∂[i] f y := by - simpa [← grad_inner_eq] using real_inner_comm (∇ f y) x + ⟪x, ∇ f y⟫_ℝ = ∑ i, x i * ∂[i] f y := by simpa [← grad_inner_eq] using real_inner_comm (∇ f y) x lemma grad_inner_repr_eq {d} (f : Space d → ℝ) (x y : Space d) : ⟪∇ f x, (Space.basis).repr y⟫_ℝ = fderiv ℝ f x y := by @@ -238,8 +237,7 @@ lemma gradient_apply_eq_grad {d} (f : Space d → ℝ) (x : Space d) : simp lemma gradient_eq_sum {d} (f : Space d → ℝ) (x : Space d) : - gradient f x = ∑ i, ∂[i] f x • basis i := by - simp [gradient_eq_grad, grad_eq_sum f x] + gradient f x = ∑ i, ∂[i] f x • basis i := by simp [gradient_eq_grad, grad_eq_sum f x] lemma euclid_gradient_eq_sum {d} (f : EuclideanSpace ℝ (Fin d) → ℝ) (x : EuclideanSpace ℝ (Fin d)) : gradient f x = ∑ i, fderiv ℝ f x (EuclideanSpace.single i 1) • EuclideanSpace.single i 1 := by diff --git a/Physlib/SpaceAndTime/Space/Integrals/Basic.lean b/Physlib/SpaceAndTime/Space/Integrals/Basic.lean index bdc863bfb..411404d21 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/Basic.lean @@ -113,8 +113,7 @@ lemma integral_volume_eq_spherical (d : ℕ) [NeZero d] (f : Space d → F) filter_upwards [Measure.ae_ne volume 0] with x hx congr simp [smul_smul] - have hx : ‖x‖ ≠ 0 := by - simpa using hx + have hx : ‖x‖ ≠ 0 := by simpa using hx field_simp simp @@ -234,8 +233,7 @@ lemma lintegral_volume_eq_spherical (d : ℕ) [NeZero d] filter_upwards [Measure.ae_ne volume 0] with x hx congr simp [smul_smul] - have hx : ‖x‖ ≠ 0 := by - simpa using hx + have hx : ‖x‖ ≠ 0 := by simpa using hx field_simp rw [one_smul] diff --git a/Physlib/SpaceAndTime/Space/Module.lean b/Physlib/SpaceAndTime/Space/Module.lean index a71e2e4f7..ee705c263 100644 --- a/Physlib/SpaceAndTime/Space/Module.lean +++ b/Physlib/SpaceAndTime/Space/Module.lean @@ -64,8 +64,7 @@ lemma add_val {d: ℕ} (x y : Space d) : @[simp] lemma add_apply {d : ℕ} (x y : Space d) (i : Fin d) : - (x + y) i = x i + y i := by - simp [add_val] + (x + y) i = x i + y i := by simp [add_val] instance {d} : AddCommMonoid (Space d) where add_assoc a b c := eq_of_apply fun i => by simp [add_assoc] @@ -154,8 +153,7 @@ lemma point_dim_zero_eq (p : Space 0) : p = 0 := @[simp] lemma norm_vadd_zero {d} (v : EuclideanSpace ℝ (Fin d)) : - ‖v +ᵥ (0 : Space d)‖ = ‖v‖ := by - simp [norm_eq, PiLp.norm_eq_of_L2] + ‖v +ᵥ (0 : Space d)‖ = ‖v‖ := by simp [norm_eq, PiLp.norm_eq_of_L2] instance : Neg (Space d) where neg p := ⟨fun i => - (p.val i)⟩ diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index 035f9279b..0bbc463e8 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -445,8 +445,7 @@ lemma deriv_normPowerSeries_zpow {d : ℕ} {n : ℕ} (m : ℤ) (x : Space d) (i simp only [basis_inner] field_simp ring_nf - have h1 : normPowerSeries n x ^ (-1 + m) = normPowerSeries n x ^ ((-2 + m) + 1) := by - ring_nf + have h1 : normPowerSeries n x ^ (-1 + m) = normPowerSeries n x ^ ((-2 + m) + 1) := by ring_nf rw [h1, zpow_add₀] simp only [Int.reduceNeg, zpow_one] ring @@ -990,8 +989,7 @@ private lemma radial_power_deriv_integral_by_parts simp [fderiv_smul_const] rw [iteratedFDeriv_succ_const] rfl) (by use 1, 1; simp [norm_smul]) η - have hη'_apply (x : ℝ) : η' x = η (x • n.1) := by - simp [η'] + have hη'_apply (x : ℝ) : η' x = η (x • n.1) := by simp [η'] have hmul_iter_apply : ∀ k x, ((Physlib.Distribution.powOneMul ℝ)^[k] η') x = x ^ k * η' x := by intro k @@ -1162,8 +1160,7 @@ lemma distDiv_norm_zpow_smul_repr_self_eq_smul dsimp [p] exact Int.toNat_of_nonneg (le_of_lt hq) have hp_pos : 0 < p := by - have : (0 : ℤ) < (p : ℤ) := by - simpa [hp_int] using hq + have : (0 : ℤ) < (p : ℤ) := by simpa [hp_int] using hq exact_mod_cast this have hcoef : (((q + d : ℤ) : ℝ)) = (p : ℝ) := by exact_mod_cast hp_int.symm diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index 5798908e5..ca4866a79 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -253,8 +253,7 @@ def time {d : ℕ} (c : SpeedOfLight := 1) : SpaceTime d →ₗ[ℝ] Time where @[simp] lemma time_val_toCoord_symm {d : ℕ} (c : SpeedOfLight) (f : Fin 1 ⊕ Fin d → ℝ) : - (time c f).val = f (Sum.inl 0) / c := by - simp [time, Lorentz.Vector.timeComponent] + (time c f).val = f (Sum.inl 0) / c := by simp [time, Lorentz.Vector.timeComponent] /-! @@ -290,8 +289,7 @@ def toTimeAndSpace {d : ℕ} (c : SpeedOfLight := 1) : SpaceTime d ≃L[ℝ] Tim simp ext i simp - map_smul' := by - simp + map_smul' := by simp } @[simp] diff --git a/Physlib/SpaceAndTime/Time/TimeMan.lean b/Physlib/SpaceAndTime/Time/TimeMan.lean index 0de96bad5..bf94d4044 100644 --- a/Physlib/SpaceAndTime/Time/TimeMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeMan.lean @@ -71,8 +71,7 @@ lemma val_injective : Function.Injective TimeMan.val := by lemma val_isOpenEmbedding : Topology.IsOpenEmbedding TimeMan.val where eq_induced := rfl - isOpen_range := by - simp + isOpen_range := by simp injective := val_injective lemma isOpen_iff {s : Set TimeMan} : @@ -107,8 +106,7 @@ def valHomeomorphism : TimeMan ≃ₜ ℝ where instance : ChartedSpace ℝ TimeMan where atlas := { valHomeomorphism.toOpenPartialHomeomorph } chartAt _ := valHomeomorphism.toOpenPartialHomeomorph - mem_chart_source := by - simp + mem_chart_source := by simp chart_mem_atlas := by intro x simp diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index 36ad4c971..72f6c8983 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -89,8 +89,7 @@ lemma val_injective : Function.Injective TimeTransMan.val := lemma val_isOpenEmbedding : Topology.IsOpenEmbedding TimeTransMan.val where eq_induced := rfl - isOpen_range := by - simp + isOpen_range := by simp injective := val_injective lemma isOpen_iff {s : Set TimeTransMan} : @@ -125,8 +124,7 @@ def valHomeomorphism : TimeTransMan ≃ₜ ℝ where instance : ChartedSpace ℝ TimeTransMan where atlas := { valHomeomorphism.toOpenPartialHomeomorph } chartAt _ := valHomeomorphism.toOpenPartialHomeomorph - mem_chart_source := by - simp + mem_chart_source := by simp chart_mem_atlas := by intro x simp @@ -218,8 +216,7 @@ lemma diff_eq_val (x : TimeUnit) (t1 t2 : TimeTransMan) : @[simp] lemma diff_self (x : TimeUnit) (t : TimeTransMan) : - diff x t t = 0 := by - simp [diff_eq_val] + diff x t t = 0 := by simp [diff_eq_val] lemma diff_fst_injective (x : TimeUnit) (t : TimeTransMan) : Function.Injective (diff x · t) := by intro t1 t2 h diff --git a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean index 4dfdca279..605a6910b 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean @@ -377,8 +377,7 @@ noncomputable def distTimeDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] map_smul' _ _ := rfl } ev.comp (Distribution.fderivD ℝ f) - map_add' f1 f2 := by - simp + map_add' f1 f2 := by simp map_smul' a f := by simp lemma distTimeDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] @@ -425,8 +424,7 @@ noncomputable def distSpaceDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M map_smul' _ _ := rfl } ev.comp (Distribution.fderivD ℝ f) - map_add' f1 f2 := by - simp + map_add' f1 f2 := by simp map_smul' a f := by simp lemma distSpaceDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] diff --git a/Physlib/SpaceAndTime/TimeAndSpace/EuclideanGroup/Action.lean b/Physlib/SpaceAndTime/TimeAndSpace/EuclideanGroup/Action.lean index a7e4575c9..e77aade77 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/EuclideanGroup/Action.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/EuclideanGroup/Action.lean @@ -82,13 +82,11 @@ lemma snd_smul (g : EuclideanGroup d) (tx : TimeAndSpace d) : /-- The Euclidean-group action fixes the time projection. -/ lemma time_smul (g : EuclideanGroup d) (tx : TimeAndSpace d) : - time (g • tx) = time tx := by - simp [time] + time (g • tx) = time tx := by simp [time] /-- The Euclidean-group action applies to the space projection. -/ lemma space_smul (g : EuclideanGroup d) (tx : TimeAndSpace d) : - space (g • tx) = g • space tx := by - simp [space] + space (g • tx) = g • space tx := by simp [space] /-- The Euclidean-group action on `TimeAndSpace d` preserves product distance. -/ lemma dist_smul (g : EuclideanGroup d) (tx ty : TimeAndSpace d) : From a82017cf2e82d536c87eb3fb9c56d9c4845b81dc Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:51:01 -0700 Subject: [PATCH 344/498] refactor: golf unit witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Units/Basic.lean | 6 ++---- Physlib/Units/Integral.lean | 9 +++------ Physlib/Units/UnitDependent.lean | 3 +-- Physlib/Units/WithDim/Basic.lean | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Physlib/Units/Basic.lean b/Physlib/Units/Basic.lean index 73c05a67c..8ecea386f 100644 --- a/Physlib/Units/Basic.lean +++ b/Physlib/Units/Basic.lean @@ -105,8 +105,7 @@ noncomputable def dimScale (u1 u2 : UnitChoices) :Dimension →* ℝ≥0 where (u1.mass / u2.mass) ^ (d.mass : ℝ) * (u1.charge / u2.charge) ^ (d.charge : ℝ) * (u1.temperature / u2.temperature) ^ (d.temperature : ℝ) - map_one' := by - simp + map_one' := by simp map_mul' d1 d2 := by simp only [Dimension.length_mul, Rat.cast_add, Dimension.time_mul, Dimension.mass_mul, Dimension.charge_mul, Dimension.temperature_mul] @@ -350,8 +349,7 @@ noncomputable def CarriesDimension.toDimensionful {M : Type} [CarriesDimension M simp [smul_smul] rw [mul_comm, UnitChoices.dimScale_transitive]} invFun f := f.1 u - left_inv m := by - simp + left_inv m := by simp right_inv f := by simp only ext u1 diff --git a/Physlib/Units/Integral.lean b/Physlib/Units/Integral.lean index ae28cffb6..970ea055c 100644 --- a/Physlib/Units/Integral.lean +++ b/Physlib/Units/Integral.lean @@ -44,10 +44,8 @@ noncomputable instance (M : Type) simp [HasDim.scaleUnit_apply] · exact measurable_const_smul (α := M) ↑(u1.dimScale u2 (dim M)).1 · exact measurable_const_smul (α := M) ↑(u2.dimScale u3 (dim M)).1 - scaleUnit_id u μ := by - simp [scaleUnit_id] - scaleUnit_mul u1 u2 r μ := by - simp + scaleUnit_id u μ := by simp [scaleUnit_id] + scaleUnit_mul u1 u2 r μ := by simp variable {M : Type} [NormedAddCommGroup M] [NormedSpace ℝ M] [HasDim M] [MeasurableSpace M] [MeasurableConstSMul ℝ M] @@ -83,8 +81,7 @@ lemma integral_isDimensionallyCorrect (d : Dimension) : then do the integral, and then we take the result back to `u2`. If the integral is dimensionally correct, this should be the same as just doing the original integral in `u2` units i.e. `∫ x, f x ∂μ`. -/ - _ = scaleUnit u1 u2 (∫ x, (scaleUnit u2 u1 f) x ∂(scaleUnit u2 u1 μ)) := by - simp + _ = scaleUnit u1 u2 (∫ x, (scaleUnit u2 u1 f) x ∂(scaleUnit u2 u1 μ)) := by simp /- Since we have assumed `μ` has dimension `d`, `(scaleUnit u2 μ u1)` is equal to `(u2.dimScale u1 d) • μ` -/ _ = scaleUnit u1 u2 (u2.dimScale u1 d • ∫ (x : M), scaleUnit u2 u1 f x ∂ μ) := by diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index cd1ef30fd..271c42a04 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -246,8 +246,7 @@ noncomputable instance {M1 : Type} [CarriesDimension M1] : MulUnitDependent M1 w rw [smul_smul, mul_comm, UnitChoices.dimScale_transitive] scaleUnit_trans' u1 u2 u3 m := by simp [toDimensionful, smul_smul, UnitChoices.dimScale_transitive] - scaleUnit_id u m := by - simp [toDimensionful, UnitChoices.dimScale_self] + scaleUnit_id u m := by simp [toDimensionful, UnitChoices.dimScale_self] scaleUnit_mul u1 u2 r m := by simp [toDimensionful] exact smul_comm (u1.dimScale u2 (dim M1)) r m diff --git a/Physlib/Units/WithDim/Basic.lean b/Physlib/Units/WithDim/Basic.lean index d24934bff..63d44b1bf 100644 --- a/Physlib/Units/WithDim/Basic.lean +++ b/Physlib/Units/WithDim/Basic.lean @@ -163,8 +163,7 @@ lemma val_mul_eq_mul {d1 d2 : Dimension} (m1 : WithDim d1 ℝ) (m2 : WithDim d2 @[simp] lemma val_pow_two_eq_mul {d1 : Dimension} (m1 : WithDim d1 ℝ) : - m1.val ^ 2 = (m1 * m1).val := by - simp [sq] + m1.val ^ 2 = (m1 * m1).val := by simp [sq] @[simp] lemma scaleUnit_val_eq_scaleUnit_val {d : Dimension} (M : Type) [MulAction ℝ≥0 M] From f3717052aa482a0e24fed1c179c485fd70a331e9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:56:26 -0700 Subject: [PATCH 345/498] refactor: golf quantum information witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ClassicalInfo/Distribution.lean | 6 ++---- QuantumInfo/Entropy/DPI.lean | 3 +-- QuantumInfo/Entropy/Relative.lean | 9 +++------ QuantumInfo/Entropy/SSA.lean | 3 +-- QuantumInfo/Entropy/VonNeumann.lean | 6 ++---- .../HayataGroup/TraceInequality/BlockDiagonal.lean | 6 ++---- QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean | 6 ++---- QuantumInfo/ForMathlib/SionMinimax.lean | 9 +++------ QuantumInfo/ResourceTheory/FreeState.lean | 9 +++------ QuantumInfo/ResourceTheory/HypothesisTesting.lean | 6 ++---- 10 files changed, 21 insertions(+), 42 deletions(-) diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index afb27e223..edd754ef8 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -254,10 +254,8 @@ theorem expect_val_eq_mixable_mix (d : ProbDistribution (Fin 2)) (x₁ x₂ : T) simp only [Mixable.mix, expect_val, DFunLike.coe, Mixable.to_U_of_mkT] calc ∑ i : Fin (Nat.succ 0).succ, (d i : ℝ) • Mixable.to_U (![x₁, x₂] i) = - ∑ i, (d i : ℝ) • Mixable.to_U (![x₁, x₂] i) := by - simp - _ = (d 0 : ℝ) • Mixable.to_U (![x₁, x₂] 0) + (d 1 : ℝ) • Mixable.to_U (![x₁, x₂] 1) := by - simp + ∑ i, (d i : ℝ) • Mixable.to_U (![x₁, x₂] i) := by simp + _ = (d 0 : ℝ) • Mixable.to_U (![x₁, x₂] 0) + (d 1 : ℝ) • Mixable.to_U (![x₁, x₂] 1) := by simp _ = (d 0 : ℝ) • Mixable.to_U x₁ + (1 - d 0).val • Mixable.to_U x₂ := by congr simpa only [Subtype.ext_iff, Prob.coe_one_minus, eq_sub_iff_add_eq, add_comm, diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 625aca836..5c0531dbf 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -1273,8 +1273,7 @@ The sandwiched Rényi divergence is invariant under tensoring with a fixed pure `D̃_α(ρ ⊗ |ψ⟩⟨ψ| ‖ σ ⊗ |ψ⟩⟨ψ|) = D̃_α(ρ ‖ σ)`. -/ theorem sandwichedRenyiEntropy_tensor_pure (hα : 0 < α) (ρ σ : MState d₁) (ψ : Ket d₂) : - D̃_ α(ρ ⊗ᴹ MState.pure ψ‖σ ⊗ᴹ MState.pure ψ) = D̃_ α(ρ‖σ) := by - simp [hα] + D̃_ α(ρ ⊗ᴹ MState.pure ψ‖σ ⊗ᴹ MState.pure ψ) = D̃_ α(ρ‖σ) := by simp [hα] /-- The sandwiched Rényi divergence is invariant under SWAP. -/ @[simp] diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index a0f817ed2..739081379 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -1536,8 +1536,7 @@ theorem sandwichedRelRentropy_additive_alpha_ne_one {α : ℝ} (hα : α ≠ 1) · norm_num [ add_div ]; exact rfl; · exact False.elim ( ‹¬ ( σ₁ ⊗ᴹ σ₂ |> MState.M |> HermitianMat.ker ) ≤ ( ρ₁ ⊗ᴹ ρ₂ |> MState.M |> HermitianMat.ker ) › ( by simpa [ HermitianMat.ker ] using ker_prod_le_iff _ _ _ _ |>.2 h_ker ) ); - · have h_ker_prod : ¬((σ₁ ⊗ᴹ σ₂).M.ker ≤ (ρ₁ ⊗ᴹ ρ₂).M.ker) := by - simp_all [ ker_prod_le_iff ] + · have h_ker_prod : ¬((σ₁ ⊗ᴹ σ₂).M.ker ≤ (ρ₁ ⊗ᴹ ρ₂).M.ker) := by simp_all [ ker_prod_le_iff ] rw [not_and_or] at h_ker rcases h_ker with h_ker | h_ker · simp [SandwichedRelRentropy, h_ker_prod, h_ker, hα0] @@ -2301,12 +2300,10 @@ private lemma posDef_add_eps {A : HermitianMat d ℂ} (hA : 0 ≤ A) {ε : ℝ} constructor · exact HermitianMat.H _ · intro x hx_ne_zero - have h_inner : star x ⬝ᵥ (A.val.mulVec x) ≥ 0 := by - simp [hA] + have h_inner : star x ⬝ᵥ (A.val.mulVec x) ≥ 0 := by simp [hA] have h_eps : star x ⬝ᵥ (ε • 1 : Matrix d d ℂ).mulVec x = ε * star x ⬝ᵥ x := by simp [Matrix.mulVec, dotProduct, Finset.mul_sum, mul_left_comm, Matrix.one_apply] - have h_pos : 0 < ε * star x ⬝ᵥ x := by - simp [*] + have h_pos : 0 < ε * star x ⬝ᵥ x := by simp [*] simpa [Matrix.add_mulVec, h_eps] using add_pos_of_nonneg_of_pos h_inner h_pos private lemma log_add_eps_eq_cfc (A : HermitianMat d 𝕜) (ε : ℝ) : diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 637693f31..1452ff06b 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -570,8 +570,7 @@ private lemma T₂_sq_le_one [Nonempty dB] · aesop · aesop -private lemma PERM_isometry : (PERM_mat dA dB dC)ᴴ * PERM_mat dA dB dC = 1 := by - simp [PERM_mat] +private lemma PERM_isometry : (PERM_mat dA dB dC)ᴴ * PERM_mat dA dB dC = 1 := by simp [PERM_mat] /-- Element-wise identity: W_mat = ∑_{b*} V_rho * V_sigma†. This is the key computation from Eq. (6) of Lin-Kim-Hsieh. -/ diff --git a/QuantumInfo/Entropy/VonNeumann.lean b/QuantumInfo/Entropy/VonNeumann.lean index c5d38f473..d415d33b9 100644 --- a/QuantumInfo/Entropy/VonNeumann.lean +++ b/QuantumInfo/Entropy/VonNeumann.lean @@ -141,8 +141,7 @@ theorem Sᵥₙ_unit_zero [Unique d] (ρ : MState d) : Sᵥₙ ρ = 0 := by /-- Von Neumann entropy is invariant under relabeling of the basis. -/ @[simp] theorem Sᵥₙ_relabel (ρ : MState d₁) (e : d₂ ≃ d₁) : - Sᵥₙ (ρ.relabel e) = Sᵥₙ ρ := by - simp [Sᵥₙ_eq_neg_trace_log] + Sᵥₙ (ρ.relabel e) = Sᵥₙ ρ := by simp [Sᵥₙ_eq_neg_trace_log] /-- Von Neumann entropy is unchanged under SWAP. TODO: All unitaries-/ @[simp] @@ -329,8 +328,7 @@ theorem qConditionalEnt_of_pure_symm (ψ : Ket (d₁ × d₂)) : /-- Quantum mutual information is symmetric. -/ @[simp] theorem qMutualInfo_symm (ρ : MState (d₁ × d₂)) : - qMutualInfo ρ.SWAP = qMutualInfo ρ := by - simp [qMutualInfo, add_comm] + qMutualInfo ρ.SWAP = qMutualInfo ρ := by simp [qMutualInfo, add_comm] /-- For a pure state, the entropy of one subsystem equals the entropy of its complement, even after relabeling. -/ diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean index 826ef9bcd..ce2f64444 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean @@ -208,16 +208,14 @@ theorem blockDiagonal_nonneg {A B : L ℋ} (hA : 0 ≤ A) (hB : 0 ≤ B) : (inner ℂ (A (hsumProj ℋ 0 z)) (hsumProj ℋ 0 z) + inner ℂ (B (hsumProj ℋ 1 z)) (hsumProj ℋ 1 z))) = ↑(RCLike.re (inner ℂ (A (hsumProj ℋ 0 z)) (hsumProj ℋ 0 z)) + - RCLike.re (inner ℂ (B (hsumProj ℋ 1 z)) (hsumProj ℋ 1 z))) := by - simp + RCLike.re (inner ℂ (B (hsumProj ℋ 1 z)) (hsumProj ℋ 1 z))) := by simp _ = inner ℂ (A (hsumProj ℋ 0 z)) (hsumProj ℋ 0 z) + inner ℂ (B (hsumProj ℋ 1 z)) (hsumProj ℋ 1 z) := by have hsumre : (↑(RCLike.re (inner ℂ (A (hsumProj ℋ 0 z)) (hsumProj ℋ 0 z)) + RCLike.re (inner ℂ (B (hsumProj ℋ 1 z)) (hsumProj ℋ 1 z))) : ℂ) = ((RCLike.re (inner ℂ (A (hsumProj ℋ 0 z)) (hsumProj ℋ 0 z)) : ℂ) + - (RCLike.re (inner ℂ (B (hsumProj ℋ 1 z)) (hsumProj ℋ 1 z)) : ℂ)) := by - simp + (RCLike.re (inner ℂ (B (hsumProj ℋ 1 z)) (hsumProj ℋ 1 z)) : ℂ)) := by simp rw [hsumre, hAz.1, hBz.1] · dsimp [blockDiagonal] erw [inner_add_left, hz0, hz1] diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index 516ae4399..ef1a4a7e9 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -30,8 +30,7 @@ def traceNorm (A : Matrix m n R) : ℝ := RCLike.re (CFC.sqrt (Aᴴ * A)).trace @[simp] -theorem traceNorm_zero : traceNorm (0 : Matrix m n R) = 0 := by - simp [traceNorm] +theorem traceNorm_zero : traceNorm (0 : Matrix m n R) = 0 := by simp [traceNorm] /-- The trace norm of the negative is equal to the trace norm. -/ @[simp] @@ -398,8 +397,7 @@ theorem abs_trace_le_traceNorm (A : Matrix n n ℂ) : simpa using mul_le_mul_of_nonneg_right (entry_norm_bound_of_unitary C.property i i) (Real.sqrt_nonneg _)) - _ = A.traceNorm := by - simpa [hH] using (traceNorm_eq_sum_sqrt_eigenvalues A).symm + _ = A.traceNorm := by simpa [hH] using (traceNorm_eq_sum_sqrt_eigenvalues A).symm end complexTraceNorm diff --git a/QuantumInfo/ForMathlib/SionMinimax.lean b/QuantumInfo/ForMathlib/SionMinimax.lean index 792d4e1c2..78c4fa68e 100644 --- a/QuantumInfo/ForMathlib/SionMinimax.lean +++ b/QuantumInfo/ForMathlib/SionMinimax.lean @@ -164,8 +164,7 @@ theorem lowerSemicontinuousOn_iff_isClosed_preimage {f : α → γ} [IsClosed s] exact ⟨ o, ho, h.1, Set.eq_empty_iff_forall_notMem.2 fun z hz => h.2 ⟨ hz.1, hz.2.1 ⟩ |> not_le_of_gt <| Set.mem_Iic.1 hz.2.2 ⟩; · exact ⟨ sᶜ, IsClosed.isOpen_compl, hx', by aesop ⟩; · intro a x hx y hy - have hx_not_in : x ∉ s ∩ f ⁻¹' Set.Iic y := by - simp [hy] + have hx_not_in : x ∉ s ∩ f ⁻¹' Set.Iic y := by simp [hy] rw [ eventually_nhdsWithin_iff ] filter_upwards [ IsOpen.mem_nhds ( isOpen_compl_iff.2 ( a y ) ) hx_not_in ] with z hz hzs exact lt_of_not_ge fun h => hz ⟨hzs, h⟩ @@ -469,8 +468,7 @@ private lemma sion_exists_min_2 (y₁ y₂ : N) (hy₁ : y₁ ∈ T) (hy₂ : y simp only [Set.mem_setOf_eq, I, C] at hzI replace ⟨hzI, hzI2⟩ := And.intro (hzI · |>.left) (hzI · |>.right) have hz_mem : z ∈ segment ℝ y₁ y₂ := - have cloL : IsClosed (segment ℝ y₁ y₂) := by - simp [← closure_openSegment] + have cloL : IsClosed (segment ℝ y₁ y₂) := by simp [← closure_openSegment] cloL.isSeqClosed hzI hzs let x := (hC_nonempty z hz_mem).some have hx : x ∈ C z := (hC_nonempty z hz_mem).some_mem @@ -506,8 +504,7 @@ private lemma sion_exists_min_2 (y₁ y₂ : N) (hy₁ : y₁ ∈ T) (hy₂ : y simp only [Set.mem_setOf_eq, J, C] at hzI replace ⟨hzI, hzI2⟩ := And.intro (hzI · |>.left) (hzI · |>.right) have hz_mem : z ∈ segment ℝ y₁ y₂ := - have cloL : IsClosed (segment ℝ y₁ y₂) := by - simp [← closure_openSegment] + have cloL : IsClosed (segment ℝ y₁ y₂) := by simp [← closure_openSegment] cloL.isSeqClosed hzI hzs let x := (hC_nonempty z hz_mem).some have hx : x ∈ C z := (hC_nonempty z hz_mem).some_mem diff --git a/QuantumInfo/ResourceTheory/FreeState.lean b/QuantumInfo/ResourceTheory/FreeState.lean index acd2db3a8..063939b33 100644 --- a/QuantumInfo/ResourceTheory/FreeState.lean +++ b/QuantumInfo/ResourceTheory/FreeState.lean @@ -153,13 +153,11 @@ theorem PosDef.prod {ρ : MState (H i)} {σ : MState (H j)} (hρ : ρ.m.PosDef) @[simp] theorem qRelEntropy_prodRelabel (ρ₁ ρ₂ : MState (H i)) (σ₁ σ₂ : MState (H j)): - 𝐃(ρ₁ ⊗ᵣ σ₁‖ρ₂ ⊗ᵣ σ₂) = 𝐃(ρ₁‖ρ₂) + 𝐃(σ₁‖σ₂) := by - simp [prodRelabel] + 𝐃(ρ₁ ⊗ᵣ σ₁‖ρ₂ ⊗ᵣ σ₂) = 𝐃(ρ₁‖ρ₂) + 𝐃(σ₁‖σ₂) := by simp [prodRelabel] @[simp] theorem sandwichedRelRentropy_prodRelabel {α : ℝ} (ρ₁ ρ₂ : MState (H i)) (σ₁ σ₂ : MState (H j)): - D̃_ α(ρ₁ ⊗ᵣ σ₁‖ρ₂ ⊗ᵣ σ₂) = D̃_ α(ρ₁‖ρ₂) + D̃_ α(σ₁‖σ₂) := by - simp [prodRelabel] + D̃_ α(ρ₁ ⊗ᵣ σ₁‖ρ₂ ⊗ᵣ σ₂) = D̃_ α(ρ₁‖ρ₂) + D̃_ α(σ₁‖σ₂) := by simp [prodRelabel] end ResourcePretheory @@ -196,8 +194,7 @@ scoped notation i "⊗^H[" n "]" => spacePow i n theorem spacePow_zero (i : ι) : i ^ 0 = 1 := rfl @[simp] -theorem spacePow_one (i : ι) : i ^ 1 = i := by - simp +theorem spacePow_one (i : ι) : i ^ 1 = i := by simp theorem spacePow_succ (i : ι) (n : ℕ) : i ^ (n + 1) = (i ^ n) * i := rfl diff --git a/QuantumInfo/ResourceTheory/HypothesisTesting.lean b/QuantumInfo/ResourceTheory/HypothesisTesting.lean index 9a9dbec0f..e6bec24a8 100644 --- a/QuantumInfo/ResourceTheory/HypothesisTesting.lean +++ b/QuantumInfo/ResourceTheory/HypothesisTesting.lean @@ -117,8 +117,7 @@ theorem le_of_subset (ρ : MState d) (ε : Prob) {S1 S2 : Set (MState d)} (h : S theorem of_singleton {ρ σ : MState d} {ε : Prob} : β_ ε(ρ‖{σ}) = ⨅ T : { m : HermitianMat d ℂ // ρ.exp_val (1 - m) ≤ ε ∧ 0 ≤ m ∧ m ≤ 1}, - ⟨_, σ.exp_val_prob T.2.right⟩ := by - simp only [OptimalHypothesisRate, iSup_singleton] + ⟨_, σ.exp_val_prob T.2.right⟩ := by simp only [OptimalHypothesisRate, iSup_singleton] open scoped Prob in theorem negLog_le_singleton (ρ : MState d) (ε : Prob) (S : Set (MState d)) @@ -209,8 +208,7 @@ theorem exists_min (ρ : MState d) (ε : Prob) (S : Set (MState d)): gcongr · exact T.2.2.1 · simp; positivity - have hρT' : ρ.exp_val (1 - T') = ε := by - simp [T', MState.exp_val_sub, δ, field] + have hρT' : ρ.exp_val (1 - T') = ε := by simp [T', MState.exp_val_sub, δ, field] have hT' : ρ.exp_val (1 - T') ≤ ε ∧ 0 ≤ T' ∧ T' ≤ 1 := by use hρT'.le From 2843ba85e595768742547d4638b72fa61676a6d5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 03:59:53 -0700 Subject: [PATCH 346/498] refactor: golf relativity tensor witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Basic.lean | 3 +-- Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean | 3 +-- Physlib/Relativity/LorentzGroup/Proper.lean | 3 +-- Physlib/Relativity/LorentzGroup/Rotations.lean | 3 +-- Physlib/Relativity/MinkowskiMatrix.lean | 3 +-- Physlib/Relativity/SL2C/Basic.lean | 3 +-- Physlib/Relativity/Tensors/Basic.lean | 6 ++---- Physlib/Relativity/Tensors/ComplexTensor/OfRat.lean | 3 +-- .../Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean | 3 +-- Physlib/Relativity/Tensors/Constructors.lean | 6 ++---- Physlib/Relativity/Tensors/Dual.lean | 6 ++---- Physlib/Relativity/Tensors/OfInt.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/ToComplex.lean | 6 ++---- Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean | 6 ++---- .../Tensors/RealTensor/Vector/Causality/LightLike.lean | 3 +-- .../Tensors/RealTensor/Vector/Causality/TimeLike.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean | 6 ++---- Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean | 6 ++---- Physlib/Relativity/Tensors/Reindexing.lean | 3 +-- 20 files changed, 27 insertions(+), 54 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 44886c726..2e87cc375 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -87,8 +87,7 @@ lemma mem_mul (hΛ : Λ ∈ LorentzGroup d) (hΛ' : Λ' ∈ LorentzGroup d) : Λ · rw [(mem_iff_dual_mul_self).mp hΛ] simp [(mem_iff_dual_mul_self).mp hΛ'] -lemma one_mem : 1 ∈ LorentzGroup d := by - simp [mem_iff_dual_mul_self] +lemma one_mem : 1 ∈ LorentzGroup d := by simp [mem_iff_dual_mul_self] lemma dual_mem (h : Λ ∈ LorentzGroup d) : dual Λ ∈ LorentzGroup d := by rw [mem_iff_dual_mul_self, dual_dual] diff --git a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean index 302fcf144..166e49a8f 100644 --- a/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean +++ b/Physlib/Relativity/LorentzGroup/Boosts/Generalized.lean @@ -45,8 +45,7 @@ variable {d : ℕ} /-- An auxiliary linear map used in the definition of a generalised boost. -/ def genBoostAux₁ (u v : Velocity d) : Vector d →ₗ[ℝ] Vector d where toFun x := (2 * ⟪x, u⟫ₘ) • v - map_add' x y := by - simp [map_add, mul_add, _root_.add_smul] + map_add' x y := by simp [map_add, mul_add, _root_.add_smul] map_smul' c x := by simp only [map_smul, RingHom.id_apply, smul_smul] simp only [FunLike.coe_smul, Pi.smul_apply, smul_eq_mul] diff --git a/Physlib/Relativity/LorentzGroup/Proper.lean b/Physlib/Relativity/LorentzGroup/Proper.lean index 46ae348c6..f013917e8 100644 --- a/Physlib/Relativity/LorentzGroup/Proper.lean +++ b/Physlib/Relativity/LorentzGroup/Proper.lean @@ -192,8 +192,7 @@ lemma isProper_iff (Λ : LorentzGroup d) : IsProper Λ ↔ detRep Λ = 1 := by simp only [IsProper, lorentzGroupIsGroup_one_coe, det_one] /-- The identity Lorentz transformation is proper. -/ -lemma isProper_id : @IsProper d 1 := by - simp [IsProper] +lemma isProper_id : @IsProper d 1 := by simp [IsProper] /-- If two Lorentz transformations are in the same connected component, and one is proper then the other is also proper. -/ diff --git a/Physlib/Relativity/LorentzGroup/Rotations.lean b/Physlib/Relativity/LorentzGroup/Rotations.lean index 301b454e9..4103c4fbe 100644 --- a/Physlib/Relativity/LorentzGroup/Rotations.lean +++ b/Physlib/Relativity/LorentzGroup/Rotations.lean @@ -121,8 +121,7 @@ def ofSpecialOrthogonal {d} : simp only [Submonoid.coe_mul, MulMemClass.mk_mul_mk] apply Subtype.ext simp [Matrix.fromBlocks_multiply] - left_inv Λ := by - simp + left_inv Λ := by simp right_inv Λ := by match Λ with | ⟨Λ, h⟩ => diff --git a/Physlib/Relativity/MinkowskiMatrix.lean b/Physlib/Relativity/MinkowskiMatrix.lean index b7b893369..a7c890f57 100644 --- a/Physlib/Relativity/MinkowskiMatrix.lean +++ b/Physlib/Relativity/MinkowskiMatrix.lean @@ -125,8 +125,7 @@ lemma inr_i_inr_i (i : Fin d) : @minkowskiMatrix d (Sum.inr i) (Sum.inr i) = -1 lemma off_diag_zero {μ ν : Fin 1 ⊕ Fin d} (h : μ ≠ ν) : η μ ν = 0 := by aesop (add safe forward as_diagonal) -lemma η_diag_ne_zero {μ : Fin 1 ⊕ Fin d} : η μ μ ≠ 0 := by - aesop (add safe forward as_diagonal) +lemma η_diag_ne_zero {μ : Fin 1 ⊕ Fin d} : η μ μ ≠ 0 := by aesop (add safe forward as_diagonal) /-! diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index fda7a6809..4d0d9f937 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -72,8 +72,7 @@ lemma toSelfAdjointMap_apply (A : selfAdjoint (Matrix (Fin 2) (Fin 2) ℂ)) : (star_eq_conjTranspose A.1).symm.trans $ selfAdjoint.mem_iff.mp A.2]⟩ := rfl lemma toSelfAdjointMap_apply_det (M : SL(2, ℂ)) (A : selfAdjoint (Matrix (Fin 2) (Fin 2) ℂ)) : - det ((toSelfAdjointMap M) A).1 = det A.1 := by - simp [toSelfAdjointMap] + det ((toSelfAdjointMap M) A).1 = det A.1 := by simp [toSelfAdjointMap] lemma toSelfAdjointMap_apply_pauliBasis'_inl (M : SL(2, ℂ)) : toSelfAdjointMap M (PauliMatrix.pauliBasis' (Sum.inl 0)) = diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index 3688860b1..cba125320 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -319,8 +319,7 @@ lemma componentMap_pure {n : ℕ} (c : Fin n → C) def ofComponents {n : ℕ} (c : Fin n → C) : (ComponentIdx (S := S) c → k) →ₗ[k] S.Tensor c where toFun f := ∑ b, f b • (Pure.basisVector c b).toTensor - map_add' fb gb := by - simp [add_smul, Finset.sum_add_distrib] + map_add' fb gb := by simp [add_smul, Finset.sum_add_distrib] map_smul' fb r := by simp [smul_smul, Finset.smul_sum] @[simp] @@ -497,8 +496,7 @@ lemma actionT_eq {g : G} {t : S.Tensor c} : g • t = PiTensorProduct.map (fun i => rep (c i) g) t := rfl noncomputable instance actionT : MulAction G (S.Tensor c) where - one_smul t := by - simp [actionT_eq] + one_smul t := by simp [actionT_eq] mul_smul g g' t := by simp [actionT_eq] change _ = (PiTensorProduct.map (fun i => rep (c i) g) ∘ₗ diff --git a/Physlib/Relativity/Tensors/ComplexTensor/OfRat.lean b/Physlib/Relativity/Tensors/ComplexTensor/OfRat.lean index 5490f8761..28942f482 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/OfRat.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/OfRat.lean @@ -50,8 +50,7 @@ noncomputable def ofRat {n : ℕ} {c : Fin n → complexLorentzTensor.Color} : lemma ofRat_basis_repr_apply {n : ℕ} {c : Fin n → complexLorentzTensor.Color} (f : (ComponentIdx c) → RatComplexNum) (b :(ComponentIdx c)) : - (Tensor.basis c).repr (ofRat f) b = toComplexNum (f b) := by - simp [ofRat] + (Tensor.basis c).repr (ofRat f) b = toComplexNum (f b) := by simp [ofRat] lemma basis_eq_ofRat {n : ℕ} {c : Fin n → complexLorentzTensor.Color} (b : (ComponentIdx c)) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index caddd4ebf..181fe0200 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -31,8 +31,7 @@ def complexContrBasis : Basis (Fin 1 ⊕ Fin 3) ℂ ContrℂModule := @[simp] lemma complexContrBasis_toFin13ℂ (i :Fin 1 ⊕ Fin 3) : - (complexContrBasis i).toFin13ℂ = Pi.single i 1 := by - simp [complexContrBasis] + (complexContrBasis i).toFin13ℂ = Pi.single i 1 := by simp [complexContrBasis] @[simp] lemma complexContrBasis_ρ_apply (M : SL(2,ℂ)) (i j : Fin 1 ⊕ Fin 3) : diff --git a/Physlib/Relativity/Tensors/Constructors.lean b/Physlib/Relativity/Tensors/Constructors.lean index 39f223f63..d5c23960b 100644 --- a/Physlib/Relativity/Tensors/Constructors.lean +++ b/Physlib/Relativity/Tensors/Constructors.lean @@ -475,10 +475,8 @@ noncomputable def fromTripleT {c1 c2 c3 : C} : let x2 := TensorProduct.lift prodT (TensorProduct.map LinearMap.id (TensorProduct.lift prodT) x1) permT id (And.intro Function.bijective_id (fun i => by fin_cases i <;> rfl)) x2 - map_add' x y := by - simp - map_smul' r x := by - simp + map_add' x y := by simp + map_smul' r x := by simp lemma fromTripleT_tmul {c1 c2 c3 : C} (x : V c1) (y : V c2) (z : V c3) : diff --git a/Physlib/Relativity/Tensors/Dual.lean b/Physlib/Relativity/Tensors/Dual.lean index f1c9841d1..3cf8f940c 100644 --- a/Physlib/Relativity/Tensors/Dual.lean +++ b/Physlib/Relativity/Tensors/Dual.lean @@ -30,8 +30,7 @@ namespace Tensor noncomputable def fromDualMap {c : C} : S.Tensor ![S.τ c] →ₗ[k] S.Tensor ![c] where toFun t := permT id (by simp; rfl) (contrT 1 1 2 (by simp; rfl) (prodT (metricTensor c) t)) - map_add' t1 t2 := by - simp + map_add' t1 t2 := by simp map_smul' r t := by simp lemma fromDualMap_apply {c : C} (t : S.Tensor ![S.τ c]) : @@ -45,8 +44,7 @@ noncomputable def toDualMap {c : C} : S.Tensor ![c] →ₗ[k] S.Tensor ![S.τ c] simp; rfl) (contrT 1 1 2 (by change _ ∧ S.τ (S.τ c) = c simp) (prodT (metricTensor (S.τ c)) t)) - map_add' t1 t2 := by - simp + map_add' t1 t2 := by simp map_smul' r t := by simp lemma toDualMap_apply {c : C} (t : S.Tensor ![c]) : diff --git a/Physlib/Relativity/Tensors/OfInt.lean b/Physlib/Relativity/Tensors/OfInt.lean index 4182cdede..c0a0b1e27 100644 --- a/Physlib/Relativity/Tensors/OfInt.lean +++ b/Physlib/Relativity/Tensors/OfInt.lean @@ -41,8 +41,7 @@ noncomputable def toTensor {n : ℕ} {c : Fin n → C} (f : TensorInt S c) : lemma basis_repr_apply {n : ℕ} {c : Fin n → C} (f : TensorInt S c) (b : ComponentIdx c) : - (Tensor.basis c).repr (toTensor f) b = Int.cast (f b) := by - simp [toTensor] + (Tensor.basis c).repr (toTensor f) b = Int.cast (f b) := by simp [toTensor] end TensorInt diff --git a/Physlib/Relativity/Tensors/RealTensor/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Basic.lean index 7626eac14..c726e8a62 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Basic.lean @@ -140,8 +140,7 @@ lemma basisIdxCongr_eq_refl {d : ℕ} {c1 c2 : realLorentzTensor.Color} (h : c1 lemma basisIdxCongr_apply {d : ℕ} {c1 c2 : realLorentzTensor.Color} (h : c1 = c2) (i : Fin 1 ⊕ Fin d) : - TensorSpecies.basisIdxCongr (basisIdx := fun _ => Fin 1 ⊕ Fin d) h i = i := by - simp + TensorSpecies.basisIdxCongr (basisIdx := fun _ => Fin 1 ⊕ Fin d) h i = i := by simp /-! diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index 07c0b1a89..3b8987abf 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -347,8 +347,7 @@ lemma toComplexVector_up_eq_inclCongrRealLorentz (v : Lorentz.ContrMod 3) : Lorentz.complexContrBasisFin4, Lorentz.ContrMod.toFin1dℝ_eq_val] rfl _ = ∑ i, v.toFin1dℝ i • Lorentz.inclCongrRealLorentz - (Lorentz.ContrMod.stdBasis i) := by - simp only [Lorentz.complexContrBasis_of_real] + (Lorentz.ContrMod.stdBasis i) := by simp only [Lorentz.complexContrBasis_of_real] _ = Lorentz.inclCongrRealLorentz (∑ i, v.toFin1dℝ i • Lorentz.ContrMod.stdBasis i) := by rw [map_sum] @@ -363,8 +362,7 @@ lemma toComplexVector_down_eq_inclCoRealLorentz (v : Lorentz.CoMod 3) : simp [toComplexVector, Lorentz.coBasis_repr_apply, Lorentz.complexCoBasisFin4] rfl _ = ∑ i, v.toFin1dℝ i • Lorentz.inclCoRealLorentz - (Lorentz.CoMod.stdBasis i) := by - simp only [Lorentz.complexCoBasis_of_real] + (Lorentz.CoMod.stdBasis i) := by simp only [Lorentz.complexCoBasis_of_real] _ = Lorentz.inclCoRealLorentz (∑ i, v.toFin1dℝ i • Lorentz.CoMod.stdBasis i) := by rw [map_sum] diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean index 529398ff4..2148ab349 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean @@ -409,10 +409,8 @@ def ofTemporalComponent {d : ℕ} : ℝ →L[ℝ] Vector d where Lorentz Vector with only non-zero spatial components. -/ def ofSpatialComponent {d : ℕ} : EuclideanSpace ℝ (Fin d) →L[ℝ] Vector d where toFun xs := ∑ i, xs i • basis (Sum.inr i) - map_add' xs ys := by - simp [add_smul, Finset.sum_add_distrib] - map_smul' c xs := by - simp [smul_smul, Finset.smul_sum] + map_add' xs ys := by simp [add_smul, Finset.sum_add_distrib] + map_smul' c xs := by simp [smul_smul, Finset.smul_sum] /-! diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/LightLike.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/LightLike.lean index c919ddf4f..3b39e714d 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/LightLike.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/LightLike.lean @@ -30,8 +30,7 @@ lemma lightLike_iff_norm_sq_zero {d : ℕ} (p : Vector d) : -- Zero vector has zero Minkowski norm squared @[simp] lemma causalCharacter_zero {d : ℕ} : causalCharacter (0 : Vector d) = - CausalCharacter.lightLike := by - simp [causalCharacter] + CausalCharacter.lightLike := by simp [causalCharacter] /-- Causally preceding is reflexive -/ @[simp] diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean index 47be81f53..f157866d1 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/TimeLike.lean @@ -51,8 +51,7 @@ lemma timelike_time_dominates_space {d : ℕ} {v : Vector d} rw [minkowskiProduct_toCoord] at hv simp only [PiLp.inner_apply, RCLike.inner_apply, conj_trivial] have h_spatial_sum : ∑ x, spatialPart v x * spatialPart v x = - ∑ i, v (Sum.inr i) * v (Sum.inr i) := by - simp only + ∑ i, v (Sum.inr i) * v (Sum.inr i) := by simp only have h_time : timeComponent v = v (Sum.inl 0) := rfl rw [h_spatial_sum, h_time] have h_norm_pos : 0 < v (Sum.inl 0) * v (Sum.inl 0) - diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index f88c782e5..d2bc01600 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -45,8 +45,7 @@ lemma contrBasis_ρ_apply {d : ℕ} (M : LorentzGroup d) (i j : Fin 1 ⊕ Fin d) @[simp] lemma contrBasis_toFin1dℝ {d : ℕ} (i : Fin 1 ⊕ Fin d) : - (contrBasis d i).toFin1dℝ = Pi.single i 1 := by - simp [ContrMod.toFin1dℝ, contrBasis] + (contrBasis d i).toFin1dℝ = Pi.single i 1 := by simp [ContrMod.toFin1dℝ, contrBasis] lemma contrBasis_repr_apply {d : ℕ} (p : Contr d) (i : Fin 1 ⊕ Fin d) : (contrBasis d).repr p i = p.val i := by @@ -105,8 +104,7 @@ lemma coBasis_repr_apply {d : ℕ} (p : Co d) (i : Fin 1 ⊕ Fin d) : @[simp] lemma coBasis_toFin1dℝ {d : ℕ} (i : Fin 1 ⊕ Fin d) : - (coBasis d i).toFin1dℝ = Pi.single i 1 := by - simp [coBasis] + (coBasis d i).toFin1dℝ = Pi.single i 1 := by simp [coBasis] /-- The standard basis of covariant Lorentz vectors indexed by `Fin (1 + d)`. -/ def coBasisFin (d : ℕ := 3) : Basis (Fin (1 + d)) ℝ (CoMod d) := diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index bb25451ab..9905eb2f8 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -51,8 +51,7 @@ lemma timeComponent_nonneg (v : Velocity d) : 0 ≤ v.1.timeComponent := by @[simp] lemma timeComponent_abs (v : Velocity d) : - |v.1.timeComponent| = v.1.timeComponent := by - simp + |v.1.timeComponent| = v.1.timeComponent := by simp lemma norm_spatialPart_le_timeComponent (v : Velocity d) : ‖v.1.spatialPart‖ ≤ ‖v.1.timeComponent‖ := by @@ -154,8 +153,7 @@ noncomputable def pathFromZero (u : Velocity d) : Path zero u where · exact sq_nonneg _⟩ continuous_toFun := by fun_prop - source' := by - simp + source' := by simp target' := by ext1 simp only [Set.Icc.coe_one, diff --git a/Physlib/Relativity/Tensors/Reindexing.lean b/Physlib/Relativity/Tensors/Reindexing.lean index 09b30038c..4f42a3e19 100644 --- a/Physlib/Relativity/Tensors/Reindexing.lean +++ b/Physlib/Relativity/Tensors/Reindexing.lean @@ -72,8 +72,7 @@ lemma auto {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} @[simp] lemma on_id {n : ℕ} {c c1 : Fin n → C} : - IsReindexing c c1 (id : Fin n → Fin n) ↔ ∀ i, c i = c1 i := by - simp [IsReindexing] + IsReindexing c c1 (id : Fin n → Fin n) ↔ ∀ i, c i = c1 i := by simp [IsReindexing] lemma on_id_symm {n : ℕ} {c c1 : Fin n → C} (h : IsReindexing c1 c id) : IsReindexing c c1 (id : Fin n → Fin n) := by From 61ce478b224c73a48c423276caa207594d08217c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 04:03:40 -0700 Subject: [PATCH 347/498] refactor: golf SU5 spectrum witnesses Co-authored-by: Claude Opus 4.8 --- .../AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean | 6 ++---- .../SuperSymmetry/SU5/ChargeSpectrum/Completions.lean | 3 +-- .../Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean | 6 ++---- .../SU5/ChargeSpectrum/MinimalSuperSet.lean | 3 +-- .../SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean | 9 +++------ .../SU5/ChargeSpectrum/PhenoConstrained.lean | 6 ++---- .../SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean | 3 +-- Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean | 6 ++---- Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean | 6 ++---- 9 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean index 0931185ae..fbd895a82 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean @@ -194,12 +194,10 @@ lemma α₁_proj (T : MSSMACC.Sols) : α₁ (proj T.1.1) = ring lemma α₁_proj_zero (T : MSSMACC.Sols) (h1 : α₃ (proj T.1.1) = 0) : - α₁ (proj T.1.1) = 0 := by - simp [α₁_proj, h1] + α₁ (proj T.1.1) = 0 := by simp [α₁_proj, h1] lemma α₂_proj_zero (T : MSSMACC.Sols) (h1 : α₃ (proj T.1.1) = 0) : - α₂ (proj T.1.1) = 0 := by - simp [α₂_proj, h1] + α₂ (proj T.1.1) = 0 := by simp [α₂_proj, h1] end proj diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean index 20a2b9332..45c94f84c 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean @@ -87,8 +87,7 @@ The empty charge spectrum is not complete, since it has no charges present. -/ @[simp] -lemma not_isComplete_empty : ¬ IsComplete (∅ : ChargeSpectrum 𝓩) := by - simp [IsComplete] +lemma not_isComplete_empty : ¬ IsComplete (∅ : ChargeSpectrum 𝓩) := by simp [IsComplete] /-! diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean index 526bbcec0..e6c6a8aff 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Map.lean @@ -113,8 +113,7 @@ lemma map_empty (f : 𝓩 →+ 𝓩1) : map f (∅ : ChargeSpectrum 𝓩) = ∅ -/ lemma map_map (f : 𝓩 →+ 𝓩1) (g : 𝓩1 →+ 𝓩2) (x : ChargeSpectrum 𝓩) : - map g (map f x) = map (g.comp f) x := by - simp [map, Option.map_map, Finset.image_image] + map g (map f x) = map (g.comp f) x := by simp [map, Option.map_map, Finset.image_image] /-! @@ -295,8 +294,7 @@ lemma not_isPhenoConstrained_of_map {f : 𝓩 →+ 𝓩1} {x : ChargeSpectrum omit [DecidableEq 𝓩] in lemma map_isComplete_iff {f : 𝓩 →+ 𝓩1} {x : ChargeSpectrum 𝓩} : - (map f x).IsComplete ↔ x.IsComplete := by - simp [IsComplete, map] + (map f x).IsComplete ↔ x.IsComplete := by simp [IsComplete, map] /-! diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimalSuperSet.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimalSuperSet.lean index 15604132a..7ecd6a333 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimalSuperSet.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimalSuperSet.lean @@ -126,8 +126,7 @@ two different forms of this result. @[simp] lemma self_not_mem_minimalSuperSet (S5 S10 : Finset 𝓩) (x : ChargeSpectrum 𝓩) : - x ∉ minimalSuperSet S5 S10 x := by - simp [minimalSuperSet] + x ∉ minimalSuperSet S5 S10 x := by simp [minimalSuperSet] lemma self_ne_mem_minimalSuperSet (S5 S10 : Finset 𝓩) (x y : ChargeSpectrum 𝓩) (hy : y ∈ minimalSuperSet S5 S10 x) : x ≠ y := by diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean index 6769f8402..49484a2a5 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/MinimallyAllowsTerm/Basic.lean @@ -177,8 +177,7 @@ lemma minimallyAllowsTerm_iff_powerset_countP_eq_one : exact Eq.symm (Multiset.countP_eq_card_filter (fun y => y.AllowsTerm T) x.powerset.val) rw [Multiset.card_eq_one] at h1 obtain ⟨a, ha⟩ := h1 - have haMem : a ∈ Multiset.filter (fun y => y.AllowsTerm T) x.powerset.val := by - simp [ha] + have haMem : a ∈ Multiset.filter (fun y => y.AllowsTerm T) x.powerset.val := by simp [ha] simp at haMem have hxMem : x ∈ Multiset.filter (fun y => y.AllowsTerm T) x.powerset.val := by simpa using allowsTerm_mono haMem.1 haMem.2 @@ -240,8 +239,7 @@ lemma card_le_degree_of_minimallyAllowsTerm (h : x.MinimallyAllowsTerm T) : x.card ≤ T.degree := by obtain ⟨y, y_mem_power, y_card,y_present⟩ := subset_card_le_degree_allowsTerm_of_allowsTerm (allowsTerm_of_minimallyAllowsTerm h) - have hy : y ∈ x.powerset.filter (fun y => y.AllowsTerm T) := by - simp_all + have hy : y ∈ x.powerset.filter (fun y => y.AllowsTerm T) := by simp_all rw [minimallyAllowsTerm_iff_powerset_filter_eq] at h rw [h] at hy simp at hy @@ -271,8 +269,7 @@ lemma eq_allowsTermForm_of_minimallyAllowsTerm (h1 : x.MinimallyAllowsTerm T) : obtain ⟨a, b, c, h2, h3⟩ := allowsTermForm_subset_allowsTerm_of_allowsTerm (allowsTerm_of_minimallyAllowsTerm h1) use a, b, c - have hy : allowsTermForm a b c T ∈ x.powerset.filter (fun y => y.AllowsTerm T) := by - simp_all + have hy : allowsTermForm a b c T ∈ x.powerset.filter (fun y => y.AllowsTerm T) := by simp_all rw [minimallyAllowsTerm_iff_powerset_filter_eq] at h1 rw [h1] at hy simp at hy diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoConstrained.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoConstrained.lean index bfd14fa6b..c8f96fb5e 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoConstrained.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/PhenoConstrained.lean @@ -138,8 +138,7 @@ def phenoConstrainingChargesSP (x : ChargeSpectrum 𝓩) : Multiset 𝓩 := @[simp] lemma phenoConstrainingChargesSP_empty : - phenoConstrainingChargesSP (∅ : ChargeSpectrum 𝓩) = ∅ := by - simp [phenoConstrainingChargesSP] + phenoConstrainingChargesSP (∅ : ChargeSpectrum 𝓩) = ∅ := by simp [phenoConstrainingChargesSP] /-! @@ -183,8 +182,7 @@ def IsPhenoConstrainedQ5 [DecidableEq 𝓩] (x : ChargeSpectrum 𝓩) (q5 : 𝓩 lemma isPhenoConstrainedQ5_iff [DecidableEq 𝓩] (x : ChargeSpectrum 𝓩) (q5 : 𝓩) : x.IsPhenoConstrainedQ5 q5 ↔ x.AllowsTermQ5 q5 β ∨ x.AllowsTermQ5 q5 Λ ∨ x.AllowsTermQ5 q5 W4 ∨ - x.AllowsTermQ5 q5 K1 ∨ x.AllowsTermQ5 q5 W1 := by - simp [IsPhenoConstrainedQ5, AllowsTermQ5] + x.AllowsTermQ5 q5 K1 ∨ x.AllowsTermQ5 q5 W1 := by simp [IsPhenoConstrainedQ5, AllowsTermQ5] /-! diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean index ecf0eeb8d..7c2b35b31 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Yukawa.lean @@ -188,8 +188,7 @@ lemma yukawaGeneratesDangerousAtLevel_iff_toFinset (x : ChargeSpectrum 𝓩) (n ext i simp only [Finset.mem_inter, Multiset.mem_toFinset, Finset.notMem_empty, iff_false, not_and] intro h1 h2 - have h3 : i ∈ (x.ofYukawaTermsNSum n) ∩ x.phenoConstrainingChargesSP := by - simpa using ⟨h1, h2⟩ + have h3 : i ∈ (x.ofYukawaTermsNSum n) ∩ x.phenoConstrainingChargesSP := by simpa using ⟨h1, h2⟩ simp_all /-! diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean index 7d3fb4490..551ae074a 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean @@ -290,8 +290,7 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : FiveQuanta 𝓩) (f · rw [Multiset.sum_eq_zero] refine Eq.symm (Multiset.count_eq_zero_of_notMem ?_) intro h - have h_mem : p.1 ∈ Multiset.map Prod.fst x := by - simp_all + have h_mem : p.1 ∈ Multiset.map Prod.fst x := by simp_all (expose_names; exact h_mem_1 h_mem) intro p' hp simp at hp @@ -564,8 +563,7 @@ def decompose (x : FiveQuanta 𝓩) : FiveQuanta 𝓩 := -/ lemma decompose_add (x y : FiveQuanta 𝓩) : - (x + y).decompose = x.decompose + y.decompose := by - simp [decompose] + (x + y).decompose = x.decompose + y.decompose := by simp [decompose] /-! diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean index 2d4a8347e..f2ebbb3b6 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean @@ -304,8 +304,7 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : TenQuanta 𝓩) (f · rw [Multiset.sum_eq_zero] refine Eq.symm (Multiset.count_eq_zero_of_notMem ?_) intro h - have h_mem : p.1 ∈ Multiset.map Prod.fst x := by - simp_all + have h_mem : p.1 ∈ Multiset.map Prod.fst x := by simp_all (expose_names; exact h_mem_1 h_mem) intro p' hp simp at hp @@ -639,8 +638,7 @@ def decompose (x : TenQuanta 𝓩) : TenQuanta 𝓩 := -/ lemma decompose_add (x y : TenQuanta 𝓩) : - (x + y).decompose = x.decompose + y.decompose := by - simp [decompose] + (x + y).decompose = x.decompose + y.decompose := by simp [decompose] /-! From 55a18d834446ceaf4a81a931144ae191001f19f1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 04:06:19 -0700 Subject: [PATCH 348/498] refactor: golf quantum mechanics witnesses Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Hydrogen/LaplaceRungeLenzVector.lean | 3 +-- .../DDimensions/Operators/Covariance.lean | 3 +-- .../Operators/StateObservables/ExpectedValue.lean | 3 +-- .../DDimensions/Operators/StateObservables/Variance.lean | 9 +++------ .../DDimensions/Operators/Uncertainty.lean | 9 +++------ .../OneDimension/GeneralPotential/Basic.lean | 3 +-- .../OneDimension/HarmonicOscillator/Basic.lean | 3 +-- .../OneDimension/HilbertSpace/Basic.lean | 3 +-- .../OneDimension/Operators/Momentum.lean | 6 ++---- 9 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Hydrogen/LaplaceRungeLenzVector.lean b/Physlib/QuantumMechanics/DDimensions/Hydrogen/LaplaceRungeLenzVector.lean index 44d43347b..546cfd16f 100644 --- a/Physlib/QuantumMechanics/DDimensions/Hydrogen/LaplaceRungeLenzVector.lean +++ b/Physlib/QuantumMechanics/DDimensions/Hydrogen/LaplaceRungeLenzVector.lean @@ -448,8 +448,7 @@ private lemma sum_Lprx (d : ℕ) (ε : ℝˣ) : calc _ = 𝐋 i j ∘L (𝐩 j ∘L 𝐱 i - 𝐩 i ∘L 𝐱 j) := by simp [angularMomentumOperator_antisymm j i, comp_assoc, sub_eq_add_neg] - _ = 𝐋 i j ∘L 𝐋 i j := by - simp [momentum_comp_position_eq, symm j i, angularMomentumOperator] + _ = 𝐋 i j ∘L 𝐋 i j := by simp [momentum_comp_position_eq, symm j i, angularMomentumOperator] rw [← angularMomentumSqr_comp_radiusRegPow_commute, angularMomentumOperatorSqr] private lemma sum_rxpL (d : ℕ) (ε : ℝˣ) : diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Covariance.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Covariance.lean index aa5fb91c5..95cc28043 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Covariance.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Covariance.lean @@ -84,8 +84,7 @@ lemma covariance_eq_re_symm_centered : ((⟪centered A ψ, centered B ⟨ψ, hψB⟩⟫_ℂ + ⟪centered B ⟨ψ, hψB⟩, centered A ψ⟫_ℂ).re) / 2 := by let z : ℂ := ⟪centered A ψ, centered B ⟨ψ, hψB⟩⟫_ℂ - have hz : ⟪centered B ⟨ψ, hψB⟩, centered A ψ⟫_ℂ = star z := by - simp [z, inner_conj_symm] + have hz : ⟪centered B ⟨ψ, hψB⟩, centered A ψ⟫_ℂ = star z := by simp [z, inner_conj_symm] rw [covariance_eq_re_inner_centered, hz] change z.re = ((z + star z).re) / 2 simp only [Complex.add_re, Complex.star_def, Complex.conj_re, add_self_div_two] diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean index e5dc6f9b0..e7e1346b0 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean @@ -40,8 +40,7 @@ variable {H : Type*} [NormedAddCommGroup H] [InnerProductSpace ℂ H] private lemma conj_inner_apply_self_eq_of_isSymmetric (T : H →ₗ.[ℂ] H) (hT : T.IsSymmetric) (ψ : T.domain) : - (starRingEnd ℂ) ⟪(ψ : H), T ψ⟫_ℂ = ⟪(ψ : H), T ψ⟫_ℂ := by - simpa [inner_conj_symm] using hT ψ ψ + (starRingEnd ℂ) ⟪(ψ : H), T ψ⟫_ℂ = ⟪(ψ : H), T ψ⟫_ℂ := by simpa [inner_conj_symm] using hT ψ ψ /-- Expectation value `re ⟪ψ, Tψ⟫_ℂ` for `ψ ∈ T.domain`. diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean index 28e7ffd8c..48d0dfc24 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean @@ -67,10 +67,8 @@ lemma variance_eq_norm_sq_sub_expectedValue_sq (T : H →ₗ.[ℂ] H) variance T ψ = ‖T ψ‖ ^ 2 - expectedValue T ψ ^ 2 := by let μ := expectedValue T ψ let a : H := T ψ - have hμ_right : ⟪(ψ : H), a⟫_ℂ = (μ : ℂ) := by - simpa [a, μ] using expectedValue_eq_inner T hT ψ - have hμ_left : ⟪a, (ψ : H)⟫_ℂ = (μ : ℂ) := by - simpa [inner_conj_symm] using congrArg star hμ_right + have hμ_right : ⟪(ψ : H), a⟫_ℂ = (μ : ℂ) := by simpa [a, μ] using expectedValue_eq_inner T hT ψ + have hμ_left : ⟪a, (ψ : H)⟫_ℂ = (μ : ℂ) := by simpa [inner_conj_symm] using congrArg star hμ_right have h_re_inner_centered : (⟪a, (μ : ℂ) • (ψ : H)⟫_ℂ).re = μ ^ 2 := by rw [inner_smul_right, hμ_left] simp [μ] @@ -92,8 +90,7 @@ lemma variance_nonneg (T : H →ₗ.[ℂ] H) (ψ : T.domain) : /-- Zero variance is the same as a zero centered vector. -/ lemma variance_eq_zero_iff_centered_eq_zero (T : H →ₗ.[ℂ] H) (ψ : T.domain) : - variance T ψ = 0 ↔ centered T ψ = 0 := by - simp [variance_eq_centered_norm_sq] + variance T ψ = 0 ↔ centered T ψ = 0 := by simp [variance_eq_centered_norm_sq] /-- Zero variance is the same as `Tψ = ⟨T⟩_ψ ψ`. -/ lemma variance_eq_zero_iff (T : H →ₗ.[ℂ] H) (ψ : T.domain) : diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean index dd96bb55d..090c4f3f3 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean @@ -243,17 +243,14 @@ lemma inner_centered_commutator_of_raw_commutator : let b : H := B ⟨ψ, hψB⟩ let μa : ℝ := expectedValue A ψ let μb : ℝ := expectedValue B ⟨ψ, hψB⟩ - have hμa_right : ⟪(ψ : H), a⟫_ℂ = (μa : ℂ) := by - simpa [a, μa] using expectedValue_eq_inner A hA ψ + have hμa_right : ⟪(ψ : H), a⟫_ℂ = (μa : ℂ) := by simpa [a, μa] using expectedValue_eq_inner A hA ψ have hμa_left : ⟪a, (ψ : H)⟫_ℂ = (μa : ℂ) := by - have h_symm : ⟪a, (ψ : H)⟫_ℂ = ⟪(ψ : H), a⟫_ℂ := by - simpa [a] using hA ψ ψ + have h_symm : ⟪a, (ψ : H)⟫_ℂ = ⟪(ψ : H), a⟫_ℂ := by simpa [a] using hA ψ ψ simpa [h_symm] using hμa_right have hμb_right : ⟪(ψ : H), b⟫_ℂ = (μb : ℂ) := by simpa [b, μb] using expectedValue_eq_inner B hB ⟨ψ, hψB⟩ have hμb_left : ⟪b, (ψ : H)⟫_ℂ = (μb : ℂ) := by - have h_symm : ⟪b, (ψ : H)⟫_ℂ = ⟪(ψ : H), b⟫_ℂ := by - simpa [b] using hB ⟨ψ, hψB⟩ ⟨ψ, hψB⟩ + have h_symm : ⟪b, (ψ : H)⟫_ℂ = ⟪(ψ : H), b⟫_ℂ := by simpa [b] using hB ⟨ψ, hψB⟩ ⟨ψ, hψB⟩ simpa [h_symm] using hμb_right calc centeredCommutatorExpectation A B ψ hψB = diff --git a/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean b/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean index 7c3a4b8fa..b690bb167 100644 --- a/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean @@ -24,8 +24,7 @@ open HilbertSpace Constants private lemma fun_add {α : Type*} (f g : α → ℂ) : (fun x ↦ f x) + (fun x ↦ g x) = fun x ↦ f x + g x := rfl -private lemma fun_smul (a1: ℂ) (f : ℝ → ℂ) : (a1 • fun x ↦ f x) = (fun x ↦ a1*(f x)) := by - rfl +private lemma fun_smul (a1: ℂ) (f : ℝ → ℂ) : (a1 • fun x ↦ f x) = (fun x ↦ a1*(f x)) := by rfl lemma momentumOperator_linear (a1 a2 : ℂ) (ψ1 ψ2 : ℝ → ℂ) (hψ1_x: Differentiable ℝ ψ1) (hψ2_x: Differentiable ℝ ψ2) : diff --git a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean index e9c20051a..2c9a82d7a 100644 --- a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean @@ -131,8 +131,7 @@ lemma one_over_ξ : 1/Q.ξ = √(Q.m * Q.ω / ℏ) := by rw [← Real.sqrt_inv] field_simp -lemma ξ_inverse : Q.ξ⁻¹ = √(Q.m * Q.ω / ℏ) := by - simpa only [inv_eq_one_div] using one_over_ξ Q +lemma ξ_inverse : Q.ξ⁻¹ = √(Q.m * Q.ω / ℏ) := by simpa only [inv_eq_one_div] using one_over_ξ Q lemma one_over_ξ_sq : (1/Q.ξ)^2 = Q.m * Q.ω / ℏ := by rw [one_over_ξ] diff --git a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean index 733fb04c1..b7aa49ef4 100644 --- a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/Basic.lean @@ -152,8 +152,7 @@ lemma mk_smul {f : ℝ → ℂ} {c : ℂ} {hf : MemHS f} : mk (memHS_smul (c := c) hf) = c • mk hf := rfl lemma mk_eq_iff {f g : ℝ → ℂ} {hf : MemHS f} {hg : MemHS g} : - mk hf = mk hg ↔ f =ᵐ[volume] g := by - simp [mk] + mk hf = mk hg ↔ f =ᵐ[volume] g := by simp [mk] lemma ext_iff {f g : HilbertSpace} : f = g ↔ (f : ℝ → ℂ) =ᶠ[ae volume] (g : ℝ → ℂ) := Lp.ext_iff diff --git a/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean b/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean index 19d847a86..9ee54dcb7 100644 --- a/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean +++ b/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean @@ -74,10 +74,8 @@ lemma momentumOperator_add {ψ1 ψ2 : ℝ → ℂ} `𝓢(ℝ, ℂ)` to itself, such that `ψ` is taken to `fun x => - I ℏ * ψ' x`. -/ def momentumOperatorSchwartz : 𝓢(ℝ, ℂ) →L[ℂ] 𝓢(ℝ, ℂ) where toFun ψ := (- Complex.I * ℏ) • SchwartzMap.derivCLM ℂ ℂ ψ - map_add' ψ1 ψ2 := by - simp only [neg_mul, map_add, smul_add, neg_smul] - map_smul' a ψ := by - simp only [map_smul, RingHom.id_apply, smul_comm (-Complex.I * ℏ) a] + map_add' ψ1 ψ2 := by simp only [neg_mul, map_add, smul_add, neg_smul] + map_smul' a ψ := by simp only [map_smul, RingHom.id_apply, smul_comm (-Complex.I * ℏ) a] cont := by fun_prop lemma momentumOperatorSchwartz_apply (ψ : 𝓢(ℝ, ℂ)) From 195b8006abded75439d8773322c232c564d148d7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 04:08:22 -0700 Subject: [PATCH 349/498] refactor: golf mathematics witnesses Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/Wirtinger/Basic.lean | 6 ++---- Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean | 3 +-- .../Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean | 6 ++---- Physlib/Mathematics/InnerProductSpace/Adjoint.lean | 3 +-- Physlib/Mathematics/InnerProductSpace/Basic.lean | 3 +-- Physlib/Mathematics/InnerProductSpace/Submodule.lean | 3 +-- Physlib/Mathematics/List.lean | 6 ++---- Physlib/Mathematics/List/InsertionSort.lean | 3 +-- Physlib/Mathematics/RatComplexNum.lean | 6 ++---- Physlib/Mathematics/SpecialFunctions/PhysHermite.lean | 3 +-- 10 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean b/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean index 62e780ebe..70ae62412 100644 --- a/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean +++ b/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean @@ -215,8 +215,7 @@ rule. /-- Constants have zero holomorphic directional Wirtinger derivative, `∂_v c = 0`. -/ @[simp] lemma dWirtingerDir_const (c : ℂ) (v u : V) : - dWirtingerDir (fun _ : V => c) v u = 0 := by - simp [dWirtingerDir_apply, fderiv_const_apply] + dWirtingerDir (fun _ : V => c) v u = 0 := by simp [dWirtingerDir_apply, fderiv_const_apply] /-- Constants have zero anti-holomorphic directional Wirtinger derivative, `∂̄_v c = 0`. -/ @[simp] lemma dWirtingerAntiDir_const (c : ℂ) (v u : V) : @@ -740,8 +739,7 @@ lemma differentiableAt_dWirtingerAntiDir (hf2 : ContDiffAt ℝ 2 f u) (w : V) : fields agreeing on a neighbourhood have equal derivative. -/ lemma dWirtingerDir_congr_of_eventuallyEq {f₁ f₂ : V → ℂ} {u : V} (h : f₁ =ᶠ[nhds u] f₂) (v : V) : - dWirtingerDir f₁ v u = dWirtingerDir f₂ v u := by - simp only [dWirtingerDir_apply, h.fderiv_eq] + dWirtingerDir f₁ v u = dWirtingerDir f₂ v u := by simp only [dWirtingerDir_apply, h.fderiv_eq] /-- The anti-holomorphic directional derivative depends only on the field near the point; dual of `dWirtingerDir_congr_of_eventuallyEq`. -/ diff --git a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean index 174357a41..f395ea3b9 100644 --- a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean +++ b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean @@ -38,8 +38,7 @@ instance [UniformSpace 𝕂] : UniformSpace (Matrix m n 𝕂) := by unfold Matri lemma tsum_eq_zero {β : Type*} [TopologicalSpace β] [AddCommMonoid β] {f : ℕ → β} (h : ∀ n, f n = 0) : - (∑' n, f n) = 0 := by - simp_all only [tsum_zero] + (∑' n, f n) = 0 := by simp_all only [tsum_zero] /-! ### The determinant of the matrix exponential diff --git a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean index ef6aeef83..d4b0c9673 100644 --- a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean @@ -193,8 +193,7 @@ def pseudoRiemannianMetricValToQuadraticForm (symm : ∀ (x : M) (v w : TangentSpace I x), (val x v) w = (val x w) v) (x : M) : QuadraticForm ℝ (TangentSpace I x) where toFun v := val x v v - toFun_smul a v := by - simp only [ContinuousLinearMap.map_smul, _root_.smul_apply, smul_smul] + toFun_smul a v := by simp only [ContinuousLinearMap.map_smul, _root_.smul_apply, smul_smul] exists_companion' := ⟨LinearMap.mk₂ ℝ (fun v y => val x v y + val x y v) (fun v₁ v₂ y => by simp only [map_add, add_apply]; ring) @@ -602,8 +601,7 @@ lemma cotangentMetricVal_nondegenerate (g : PseudoRiemannianMetric E H M n I) (x have h_forall : ∀ w : TangentSpace I x, ω w = 0 := by intro w let ω' : TangentSpace I x →L[ℝ] ℝ := g.flatL x w - have this : g.sharpL x ω' = w := by - simp only [ω', sharpL_apply_flatL] + have this : g.sharpL x ω' = w := by simp only [ω', sharpL_apply_flatL] have h_apply : cotangentMetricVal g x ω ω' = 0 := h ω' simp only [cotangentMetricVal_eq_apply_sharp] at h_apply rw [this] at h_apply diff --git a/Physlib/Mathematics/InnerProductSpace/Adjoint.lean b/Physlib/Mathematics/InnerProductSpace/Adjoint.lean index 28c70c14d..ddfdfd957 100644 --- a/Physlib/Mathematics/InnerProductSpace/Adjoint.lean +++ b/Physlib/Mathematics/InnerProductSpace/Adjoint.lean @@ -66,8 +66,7 @@ lemma adjoint_eq_clm_adjoint [CompleteSpace E] [CompleteSpace F] (f : E →L[ simp[_root_.adjoint,h,h.choose_spec.adjoint_inner_left] lemma HasAdjoint.adjoint_apply_zero {f : E → F} {f' : F → E} - (hf : HasAdjoint 𝕜 f f') : f' 0 = 0 := by - simpa using hf.adjoint_inner_left (f' 0) 0 + (hf : HasAdjoint 𝕜 f f') : f' 0 = 0 := by simpa using hf.adjoint_inner_left (f' 0) 0 lemma HasAdjoint.adjoint {f : E → F} {f' : F → E} diff --git a/Physlib/Mathematics/InnerProductSpace/Basic.lean b/Physlib/Mathematics/InnerProductSpace/Basic.lean index f71dcb65e..e05b555a8 100644 --- a/Physlib/Mathematics/InnerProductSpace/Basic.lean +++ b/Physlib/Mathematics/InnerProductSpace/Basic.lean @@ -512,8 +512,7 @@ instance {ι : Type*} [Fintype ι] : InnerProductSpace' 𝕜 (ι → E) where rw [hi] use i simp - have hj : ∀ j, ‖x j‖ ≤ ‖x i‖ := by - simpa [← hi] using fun j => norm_le_pi_norm x j + have hj : ∀ j, ‖x j‖ ≤ ‖x i‖ := by simpa [← hi] using fun j => norm_le_pi_norm x j rw [hi] constructor · apply le_trans (h (x i)).1 diff --git a/Physlib/Mathematics/InnerProductSpace/Submodule.lean b/Physlib/Mathematics/InnerProductSpace/Submodule.lean index 09f27f89c..ab9159c31 100644 --- a/Physlib/Mathematics/InnerProductSpace/Submodule.lean +++ b/Physlib/Mathematics/InnerProductSpace/Submodule.lean @@ -80,8 +80,7 @@ lemma mem_submodule_adjoint_iff_mem_submoduleToLp_orthogonal : · rw [mem_orthogonal] intro u hu rw [mem_adjoint_iff] at h - have h' : inner ℂ u.snd g.1 = inner ℂ u.fst g.2 := by - simpa [sub_eq_zero] using h u.fst u.snd hu + have h' : inner ℂ u.snd g.1 = inner ℂ u.fst g.2 := by simpa [sub_eq_zero] using h u.fst u.snd hu simp [h'] · rw [mem_adjoint_iff] intro a b hab diff --git a/Physlib/Mathematics/List.lean b/Physlib/Mathematics/List.lean index c4ce3c460..18a2036a0 100644 --- a/Physlib/Mathematics/List.lean +++ b/Physlib/Mathematics/List.lean @@ -604,8 +604,7 @@ lemma insertionSortEquiv_order {α : Type} {r : α → α → Prop} [DecidableRe | some i => List.eraseIdx l i lemma eraseIdx_length' {I : Type} (l : List I) (i : Fin l.length) : - (List.eraseIdx l i).length = l.length - 1 := by - simp [List.length_eraseIdx] + (List.eraseIdx l i).length = l.length - 1 := by simp [List.length_eraseIdx] lemma eraseIdx_length {I : Type} (l : List I) (i : Fin l.length) : (List.eraseIdx l i).length + 1 = l.length := by @@ -620,8 +619,7 @@ lemma eraseIdx_length_succ {I : Type} (l : List I) (i : Fin l.length) : omega lemma eraseIdx_cons_length {I : Type} (a : I) (l : List I) (i : Fin (a :: l).length) : - (List.eraseIdx (a :: l) i).length= l.length := by - simp [List.length_eraseIdx] + (List.eraseIdx (a :: l) i).length= l.length := by simp [List.length_eraseIdx] lemma eraseIdx_get {I : Type} (l : List I) (i : Fin l.length) : (List.eraseIdx l i).get = l.get ∘ (Fin.cast (eraseIdx_length l i)) ∘ diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index b2523a9d3..468dc7af2 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -285,8 +285,7 @@ lemma insertionSortEquiv_orderedInsert_append {α : Type} (r : α → α → Pro rw [insertionSortEquiv_congr _ _ h1] simp · have h1 : (List.orderedInsert r a (b :: l1) ++ a2 :: l2) = - (b :: List.orderedInsert r a (l1) ++ a2 :: l2) := by - simp [h] + (b :: List.orderedInsert r a (l1) ++ a2 :: l2) := by simp [h] rw [insertionSortEquiv_congr _ _ h1] simp only [List.cons_append, List.length_cons, Equiv.trans_apply, RelIso.coe_fn_toEquiv, Fin.castOrderIso_apply, Fin.cast_mk, diff --git a/Physlib/Mathematics/RatComplexNum.lean b/Physlib/Mathematics/RatComplexNum.lean index 35016b9d2..d1f489885 100644 --- a/Physlib/Mathematics/RatComplexNum.lean +++ b/Physlib/Mathematics/RatComplexNum.lean @@ -236,8 +236,7 @@ open Complex /-- The inclusion of `RatComplexNum` into the complex numbers. -/ noncomputable def toComplexNum : RatComplexNum →+* ℂ where toFun := fun x => x.fst + x.snd * I - map_one' := by - simp + map_one' := by simp map_add' a b := by simp only [add_fst, Rat.cast_add, add_snd] ring @@ -246,8 +245,7 @@ noncomputable def toComplexNum : RatComplexNum →+* ℂ where ring_nf simp only [I_sq, mul_neg, mul_one] ring - map_zero' := by - simp + map_zero' := by simp @[simp] lemma I_mul_toComplexNum (a : RatComplexNum) : I * toComplexNum a = toComplexNum (⟨0, 1⟩ * a) := by diff --git a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean index 3dca87e95..cc34efc22 100644 --- a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean +++ b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean @@ -400,8 +400,7 @@ theorem physHermite_norm (n : ℕ) : rw [aeval_C] simp rw [MeasureTheory.integral_const_mul] - have h1 : ∫ (x : ℝ), Real.exp (- x^2) = Real.sqrt (Real.pi) := by - simpa using integral_gaussian 1 + have h1 : ∫ (x : ℝ), Real.exp (- x^2) = Real.sqrt (Real.pi) := by simpa using integral_gaussian 1 rw [h1] lemma physHermite_norm_cons (n : ℕ) (c : ℝ) : From 3bb5353995e71e00b628bf24fa310a581b2a7a81 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 04:11:01 -0700 Subject: [PATCH 350/498] refactor: golf QFT contraction witnesses Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean | 3 +-- .../QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean | 3 +-- Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean | 3 +-- Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean | 3 +-- .../QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean | 3 +-- Physlib/QFT/PerturbationTheory/WickContraction/Erase.lean | 3 +-- .../QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean | 3 +-- .../PerturbationTheory/WickContraction/InsertAndContract.lean | 3 +-- Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean | 3 +-- Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean | 3 +-- .../QFT/PerturbationTheory/WickContraction/TimeContract.lean | 3 +-- .../QFT/PerturbationTheory/WickContraction/Uncontracted.lean | 3 +-- .../PerturbationTheory/WickContraction/UncontractedList.lean | 3 +-- 13 files changed, 13 insertions(+), 26 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean index df0cc243e..20d0111bc 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean @@ -290,8 +290,7 @@ Using the results from above. lemma normalOrderF_swap_anPartF_crPartF (φ φ' : 𝓕.FieldOp) (a b : FieldOpFreeAlgebra 𝓕) : 𝓝ᶠ(a * (anPartF φ) * (crPartF φ') * b) = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • 𝓝ᶠ(a * (crPartF φ') * - (anPartF φ) * b) := by - simp [normalOrderF_swap_crPartF_anPartF, smul_smul] + (anPartF φ) * b) := by simp [normalOrderF_swap_crPartF_anPartF, smul_smul] lemma normalOrderF_superCommuteF_crPartF_anPartF (φ φ' : 𝓕.FieldOp) (a b : FieldOpFreeAlgebra 𝓕) : 𝓝ᶠ(a * superCommuteF diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 8bc7c9536..309d5b919 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -109,8 +109,7 @@ def nilEquiv : CrAnSection (𝓕 := 𝓕) [] ≃ Unit where have h2 := ψs.2 simp only [List.map_eq_nil_iff] at h2 simp [h2] - right_inv _ := by - simp + right_inv _ := by simp /-- The creation and annihilation sections for a singleton list is given by a choice of `𝓕.fieldOpToCreateAnnihilateType φ`. If `φ` is a asymptotic state diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index 185c678a7..83bc26426 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -31,8 +31,7 @@ def koszulSign (q : 𝓕 → FieldStatistic) (le : 𝓕 → 𝓕 → Prop) [Deci @[simp] lemma koszulSign_singleton (q : 𝓕 → FieldStatistic) (le : 𝓕 → 𝓕 → Prop) [DecidableRel le] (φ : 𝓕) : - koszulSign q le [φ] = 1 := by - simp [koszulSign, koszulSignInsert] + koszulSign q le [φ] = 1 := by simp [koszulSign, koszulSignInsert] lemma koszulSign_mul_self (l : List 𝓕) : koszulSign q le l * koszulSign q le l = 1 := by induction l with diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean index 3d369bf8f..702c69dff 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean @@ -232,8 +232,7 @@ lemma koszulSignCons_eq_exchangeSign (φ0 φ1 : 𝓕) : koszulSignCons q le φ0 lemma koszulSignInsert_cons (r0 r1 : 𝓕) (r : List 𝓕) : koszulSignInsert q le r0 (r1 :: r) = (koszulSignCons q le r0 r1) * - koszulSignInsert q le r0 r := by - simp [koszulSignInsert, koszulSignCons] + koszulSignInsert q le r0 r := by simp [koszulSignInsert, koszulSignCons] lemma koszulSignInsert_of_le_mem (φ0 : 𝓕) : (φs : List 𝓕) → (h : ∀ b ∈ φs, le φ0 b) → koszulSignInsert q le φ0 φs = 1 diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean index 2447327aa..6e44c75ed 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean @@ -191,8 +191,7 @@ lemma timeOrder_timeContract_ne_time {φ ψ : 𝓕.FieldOp} This prevents Feynman diagrams where incoming vertices are connected to incoming vertices. -/ lemma timeContract_inAsymp_inAsymp (φ ψ : ((f : Field 𝓕) × AsymptoticLabel 𝓕 f) × Momentum) : - timeContract (.inAsymp φ) (.inAsymp ψ) = 0 := by - simp [timeContract_eq_superCommute] + timeContract (.inAsymp φ) (.inAsymp ψ) = 0 := by simp [timeContract_eq_superCommute] /-- The time contraction of an outgoing asymptotic field with another outgoing asymptotic field is zero. diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Erase.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Erase.lean index 97c576804..d61221e16 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Erase.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Erase.lean @@ -63,8 +63,7 @@ lemma mem_erase_uncontracted_iff (c : WickContraction n.succ) (i : Fin n.succ) ( simp only [Nat.succ_eq_add_one, Finset.disjoint_insert_right, Finset.mem_insert, Finset.mem_singleton, true_or, not_true_eq_false, Finset.disjoint_singleton_right, not_or, false_and, or_false] at hc - have hi : i ∈ ({i.succAbove j, i.succAbove k} : Finset (Fin n.succ)) := by - simp [← hc] + have hi : i ∈ ({i.succAbove j, i.succAbove k} : Finset (Fin n.succ)) := by simp [← hc] simp only [Nat.succ_eq_add_one, Finset.mem_insert, Finset.mem_singleton] at hi rcases hi with hi | hi · exact False.elim (Fin.succAbove_ne _ _ hi.symm) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean b/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean index b992630d7..d01363ef5 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/ExtractEquiv.lean @@ -47,8 +47,7 @@ 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 - simp + left_inv f := by simp right_inv f := by refine extractEquiv_equiv ?_ ?_ simp only [insertAndContractNat_erase] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean index 400ec8459..5405654e6 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean @@ -147,8 +147,7 @@ lemma insertAndContract_some_getDual?_some_eq (φ : 𝓕.FieldOp) (φs : List lemma insertAndContract_none_succAbove_getDual?_eq_none_iff (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) (i : Fin φs.length.succ) (j : Fin φs.length) : (φsΛ ↩Λ φ i none).getDual? (Fin.cast (insertIdx_length_fin φ φs i).symm - (i.succAbove j)) = none ↔ φsΛ.getDual? j = none := by - simp [insertAndContract, getDual?_congr] + (i.succAbove j)) = none ↔ φsΛ.getDual? j = none := by simp [insertAndContract, getDual?_congr] @[simp] lemma insertAndContract_some_succAbove_getDual?_eq_option (φ : 𝓕.FieldOp) (φs : List 𝓕.FieldOp) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean index b082ba49d..e343f09d3 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Sign/Basic.lean @@ -51,8 +51,7 @@ def sign (φs : List 𝓕.FieldOp) (φsΛ : WickContraction φs.length) : ℂ := 𝓕 |>ₛ ⟨φs.get, φsΛ.signFinset (φsΛ.fstFieldOfContract a) (φsΛ.sndFieldOfContract a)⟩) lemma sign_empty (φs : List 𝓕.FieldOp) : - sign φs empty = 1 := by - simp [sign, empty] + sign φs empty = 1 := by simp [sign, empty] lemma sign_congr {φs φs' : List 𝓕.FieldOp} (h : φs = φs') (φsΛ : WickContraction φs.length) : sign φs' (congr (by simp [h]) φsΛ) = sign φs φsΛ := by diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean index 56df380aa..ebbcaf446 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean @@ -307,8 +307,7 @@ lemma haveEqTime_iff_finset {φs : List 𝓕.FieldOp} (φsΛ : WickContraction @[simp] lemma empty_not_haveEqTime {φs : List 𝓕.FieldOp} : - ¬ HaveEqTime (empty : WickContraction φs.length) := by - simp [haveEqTime_iff_finset, empty] + ¬ HaveEqTime (empty : WickContraction φs.length) := by simp [haveEqTime_iff_finset, empty] /-- Given a Wick contraction the subset of contracted pairs between equal time fields. -/ def eqTimeContractSet {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) : diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean index 4dcc3a848..e36a584dc 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean @@ -77,8 +77,7 @@ lemma timeContract_insertAndContract_some @[simp] lemma timeContract_empty (φs : List 𝓕.FieldOp) : - (@empty φs.length).timeContract = 1 := by - simp [timeContract, empty] + (@empty φs.length).timeContract = 1 := by simp [timeContract, empty] open FieldStatistic diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean index b2500f021..b8ce1a2d8 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Uncontracted.lean @@ -100,8 +100,7 @@ lemma uncontracted_card_eq_iff (c : WickContraction n) : by_contra hn have hc' := exists_pair_of_not_eq_empty c hn obtain ⟨i, j, hij⟩ := hc' - have hci : c.getDual? i = some j := by - simpa [getDual?_eq_some_iff_mem] using hij + have hci : c.getDual? i = some j := by simpa [getDual?_eq_some_iff_mem] using hij simp_all · intro h subst h diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index af27c1a35..3ab88ab1b 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -234,8 +234,7 @@ lemma uncontractedList_eq_sort (c : WickContraction n) : · exact uncontractedList_sorted c lemma uncontractedList_length_eq_card (c : WickContraction n) : - c.uncontractedList.length = c.uncontracted.card := by - simp [uncontractedList_eq_sort] + c.uncontractedList.length = c.uncontracted.card := by simp [uncontractedList_eq_sort] lemma filter_uncontractedList (c : WickContraction n) (p : Fin n → Prop) [DecidablePred p] : (c.uncontractedList.filter p) = (c.uncontracted.filter p).sort (· ≤ ·) := by From 37f65eb9e8dcdc5316461a36eab219efa20a19ad Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 04:13:43 -0700 Subject: [PATCH 351/498] refactor: golf physics wrapper witnesses Co-authored-by: Claude Opus 4.8 --- .../Distributional/Dynamics/CurrentDensity.lean | 3 +-- .../Electromagnetism/Distributional/Dynamics/Lagrangian.lean | 3 +-- Physlib/Electromagnetism/Dynamics/IsExtrema.lean | 3 +-- Physlib/Electromagnetism/Dynamics/KineticTerm.lean | 3 +-- Physlib/Electromagnetism/Kinematics/MagneticField.lean | 3 +-- Physlib/Electromagnetism/PointParticle/OneDimension.lean | 3 +-- Physlib/Electromagnetism/Vacuum/HarmonicWave.lean | 3 +-- Physlib/FluidDynamics/NavierStokes/Momentum.lean | 3 +-- .../AnomalyCancellation/NoGrav/One/LinearParameterization.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean | 3 +-- Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean | 3 +-- Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean | 3 +-- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 3 +-- Physlib/SpaceAndTime/Space/Translations.lean | 3 +-- Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean | 3 +-- 17 files changed, 17 insertions(+), 34 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Distributional/Dynamics/CurrentDensity.lean index 66130cea2..182f1fd8b 100644 --- a/Physlib/Electromagnetism/Distributional/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Distributional/Dynamics/CurrentDensity.lean @@ -66,8 +66,7 @@ namespace DistLorentzCurrentDensity noncomputable def chargeDensity {d : ℕ} (c : SpeedOfLight) : (DistLorentzCurrentDensity d) →ₗ[ℝ] (Time × Space d) →d[ℝ] ℝ where toFun J := (1 / (c : ℝ)) • (Lorentz.Vector.temporalCLM d ∘L distTimeSlice c J) - map_add' J1 J2 := by - simp + map_add' J1 J2 := by simp map_smul' r J := by simp only [one_div, map_smul, ContinuousLinearMap.comp_smulₛₗ, RingHom.id_apply] rw [smul_comm] diff --git a/Physlib/Electromagnetism/Distributional/Dynamics/Lagrangian.lean b/Physlib/Electromagnetism/Distributional/Dynamics/Lagrangian.lean index e77b0b035..458cf24bd 100644 --- a/Physlib/Electromagnetism/Distributional/Dynamics/Lagrangian.lean +++ b/Physlib/Electromagnetism/Distributional/Dynamics/Lagrangian.lean @@ -78,8 +78,7 @@ noncomputable def gradFreeCurrentPotential {d} : DistLorentzCurrentDensity d →ₗ[ℝ] ((SpaceTime d) →d[ℝ] Lorentz.Vector d) where toFun J := { toFun ε := ∑ μ, (η μ μ • (J ε μ) • Lorentz.Vector.basis μ) - map_add' ε₁ ε₂ := by - simp [Finset.sum_add_distrib, add_smul] + map_add' ε₁ ε₂ := by simp [Finset.sum_add_distrib, add_smul] map_smul' r ε := by simp only [map_smul, apply_smul, smul_smul, Real.ringHom_apply, Finset.smul_sum] congr diff --git a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean index cd95454b3..dff99ce3f 100644 --- a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean @@ -468,8 +468,7 @@ lemma time_deriv_time_deriv_electricField_of_isExtrema {A : ElectromagneticPoten exact (hEd j j).differentiableAt _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (fun x => ∂[j] (A.electricField 𝓕.c t · i) x) x) - 1 / (𝓕.μ₀ * 𝓕.ε₀) * (∂[i] (fun x => (∇ ⬝ (A.electricField 𝓕.c t)) x) x) - - 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by - rfl + 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by rfl _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * ∑ j, (∂[j] (∂[j] (A.electricField 𝓕.c t · i)) x) - 1 / (𝓕.μ₀ * 𝓕.ε₀ ^ 2) * ∂[i] (J.chargeDensity 𝓕.c t ·) x - 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by diff --git a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean index 0f2f984ed..1aa213689 100644 --- a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean @@ -479,8 +479,7 @@ lemma kineticTerm_add_time_mul_const {d} {𝓕 : FreeSpace} (A : Electromagnetic _ = -1 / (2 * 𝓕.μ₀) * ∑ μ, ∑ ν, (η μ μ * η ν ν * (∂_ μ A x + if μ = Sum.inl 0 then c else 0) ν ^ 2 - (∂_ μ A x + if μ = Sum.inl 0 then c else 0) ν * - (∂_ ν A x + if ν = Sum.inl 0 then c else 0) μ) := by - simp only [hdiff] + (∂_ ν A x + if ν = Sum.inl 0 then c else 0) μ) := by simp only [hdiff] _ = -1 / (2 * 𝓕.μ₀) * ∑ μ, ∑ ν, (η μ μ * η ν ν * (∂_ μ A x ν + if μ = Sum.inl 0 then c ν else 0) ^ 2 - (∂_ μ A x ν + if μ = Sum.inl 0 then c ν else 0) * diff --git a/Physlib/Electromagnetism/Kinematics/MagneticField.lean b/Physlib/Electromagnetism/Kinematics/MagneticField.lean index 1d88db0dd..dfeeb0f5f 100644 --- a/Physlib/Electromagnetism/Kinematics/MagneticField.lean +++ b/Physlib/Electromagnetism/Kinematics/MagneticField.lean @@ -239,8 +239,7 @@ lemma fieldStrengthMatrix_inr_inr_eq_magneticFieldMatrix {c : SpeedOfLight} (A : ElectromagneticPotential d) (x : SpaceTime d) (i j : Fin d) : A.fieldStrengthMatrix x (Sum.inr i, Sum.inr j) = - A.magneticFieldMatrix c (x.time c) x.space (i, j) := by - simp [magneticFieldMatrix_eq] + A.magneticFieldMatrix c (x.time c) x.space (i, j) := by simp [magneticFieldMatrix_eq] /-! diff --git a/Physlib/Electromagnetism/PointParticle/OneDimension.lean b/Physlib/Electromagnetism/PointParticle/OneDimension.lean index 127faf8de..c03c213b7 100644 --- a/Physlib/Electromagnetism/PointParticle/OneDimension.lean +++ b/Physlib/Electromagnetism/PointParticle/OneDimension.lean @@ -201,8 +201,7 @@ lemma oneDimPointParticle_electricField_timeDeriv (𝓕 : FreeSpace) (q : ℝ) ( -/ lemma oneDimPointParticle_magneticFieldMatrix (q : ℝ) (r₀ : Space 1) : - (oneDimPointParticle 𝓕 q r₀).magneticFieldMatrix 𝓕.c = 0 := by - simp + (oneDimPointParticle 𝓕 q r₀).magneticFieldMatrix 𝓕.c = 0 := by simp /-! diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index 261749666..853e51de0 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -601,8 +601,7 @@ lemma harmonicWaveX_polarization_ellipse {d} (𝓕 : FreeSpace) (k : ℝ) (hk : symm calc _ _ = ∑ (i : Fin d), ∑ (j : Fin d), (cos (τ + φ i) ^ 2 + cos (τ + φ j) ^ 2 - - 2 * cos (τ + φ i) * cos (τ + φ j) * cos (φ j - φ i)) := by - simp [← hij] + - 2 * cos (τ + φ i) * cos (τ + φ j) * cos (φ j - φ i)) := by simp [← hij] _ = 2 * ∑ (i : Fin d), ∑ (j : Fin d), cos (τ + φ j) ^ 2 - 2 * ∑ (i : Fin d), ∑ (j : Fin d), cos (τ + φ i) * cos (τ + φ j) * cos (φ j - φ i) := by rw [two_mul] diff --git a/Physlib/FluidDynamics/NavierStokes/Momentum.lean b/Physlib/FluidDynamics/NavierStokes/Momentum.lean index 40928d4fd..1a99743b5 100644 --- a/Physlib/FluidDynamics/NavierStokes/Momentum.lean +++ b/Physlib/FluidDynamics/NavierStokes/Momentum.lean @@ -200,8 +200,7 @@ lemma matrixDiv_momentumFlux (d : ℕ) (fluid : FluidState d) hVelocity x] simp [momentumDensity, mul_comm, mul_assoc] _ = (∑ j, ∂[j] (fun x' => momentumDensity d fluid t x' j) x) * fluid.velocity t x i + - fluid.rho t x * (∑ j, fluid.velocity t x j * ∂[j] (fluid.velocity t) x i) := by - ring + fluid.rho t x * (∑ j, fluid.velocity t x j * ∂[j] (fluid.velocity t) x i) := by ring /-- The algebraic bridge between conservative and convective momentum. diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean index cc6ee4f0d..aad78b182 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/NoGrav/One/LinearParameterization.lean @@ -294,8 +294,7 @@ lemma cubic (S : linearParametersQENeqZero) : field_simp simp [hQ] ring_nf - have h1 : -216 - S.v ^ 3 * 216 - S.w ^ 3 * 216 = - 216 *(S.v ^3 + S.w ^3 +1) := by - ring + have h1 : -216 - S.v ^ 3 * 216 - S.w ^ 3 * 216 = - 216 *(S.v ^3 + S.w ^3 +1) := by ring rw [h1] simp_all exact add_eq_zero_iff_eq_neg diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean b/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean index a7bcc3db5..fba2c8715 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean @@ -119,8 +119,7 @@ lemma iteratedDeriv_const_smul (I : MultiIndex d) (c : ℝ) {f : Space d → ℝ /-- Iterated spatial derivatives preserve smoothness for scalar-valued functions. -/ lemma iteratedDeriv_contDiff (I : MultiIndex d) {f : Space d → ℝ} (hf : ContDiff ℝ ∞ f) : - ContDiff ℝ ∞ (∂^[I] f) := by - simpa [iteratedDeriv] using iteratedDerivList_contDiff I.toList hf + ContDiff ℝ ∞ (∂^[I] f) := by simpa [iteratedDeriv] using iteratedDerivList_contDiff I.toList hf /-- The topological support of a spatial derivative is contained in that of the original function. -/ diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean b/Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean index 361b7bdbe..a2a7abcb2 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Laplacian.lean @@ -98,7 +98,6 @@ scoped[Space] notation "Δᵈ" => distLaplacian @[simp] lemma distLaplacian_const {d : ℕ} (c : ℝ) : - Δᵈ (Distribution.const ℝ (Space d) c) = 0 := by - simp [distLaplacian, distGrad_const] + Δᵈ (Distribution.const ℝ (Space d) c) = 0 := by simp [distLaplacian, distGrad_const] end Space diff --git a/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean b/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean index e6d000336..9b8d358d4 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/MultiIndex.lean @@ -187,8 +187,7 @@ lemma toList_single (i : Fin d) : toList (increment 0 i : MultiIndex d) = [i] := have htail : tail (increment (0 : MultiIndex d.succ) j.succ) = increment (0 : MultiIndex d) j := by rw [tail_increment_succ, tail_zero] - have hzero : increment (0 : MultiIndex d.succ) j.succ 0 = 0 := by - simp [increment] + have hzero : increment (0 : MultiIndex d.succ) j.succ 0 = 0 := by simp [increment] simp [toList, hzero, htail, ih j] end MultiIndex diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean index 170ce4cf5..b5f108620 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean @@ -154,8 +154,7 @@ lemma translationVector.incl_range : /-- The translation by the zero vector is the identity of the Euclidean group. -/ lemma translation_zero : translationVector.incl n - (Multiplicative.ofAdd (0 : EuclideanSpace ℝ (Fin n))) = 1 := by - simp + (Multiplicative.ofAdd (0 : EuclideanSpace ℝ (Fin n))) = 1 := by simp /-- The subgroup of `EuclideanGroup n` whose elements fix the origin (translation = 0). This is the copy of `O(n)` sitting inside `E(n)`. -/ diff --git a/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean b/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean index b20ea1e63..3ed16ea71 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean @@ -73,8 +73,7 @@ lemma radialAngularMeasure_eq_volume_withDensity {d : ℕ} : radialAngularMeasur @[simp] lemma radialAngularMeasure_zero_eq_volume : - radialAngularMeasure (d := 0) = volume := by - simp [radialAngularMeasure] + radialAngularMeasure (d := 0) = volume := by simp [radialAngularMeasure] /-! diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index ffb872a39..2c986f325 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -1285,8 +1285,7 @@ lemma mul_inner_pow_neg_two {d : ℕ} (y : Space d) (hd : 2 ≤ d := by omega) : by_cases hx : x = 0 · subst hx simp - have hx' : ‖x‖ ≠ 0 := by - simpa using hx + have hx' : ‖x‖ ≠ 0 := by simpa using hx field_simp · apply AEMeasurable.aestronglyMeasurable fun_prop diff --git a/Physlib/SpaceAndTime/Space/Translations.lean b/Physlib/SpaceAndTime/Space/Translations.lean index d171b19e0..6864fc56e 100644 --- a/Physlib/SpaceAndTime/Space/Translations.lean +++ b/Physlib/SpaceAndTime/Space/Translations.lean @@ -98,8 +98,7 @@ noncomputable def distTranslate {d : ℕ} (a : EuclideanSpace ℝ (Fin d)) : map_add' T1 T2 := by ext η simp - map_smul' c T := by - simp + map_smul' c T := by simp lemma distTranslate_apply {d : ℕ} (a : EuclideanSpace ℝ (Fin d)) (T : (Space d) →d[ℝ] X) (η : 𝓢(Space d, ℝ)) : diff --git a/Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean b/Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean index a84380c9a..e7f5cb00a 100644 --- a/Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean +++ b/Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean @@ -93,8 +93,7 @@ def schwartzAction {d} : LorentzGroup d →* 𝓢(SpaceTime d, ℝ) →L[ℝ] lemma schwartzAction_mul_apply {d} (Λ₁ Λ₂ : LorentzGroup d) (η : 𝓢(SpaceTime d, ℝ)) : schwartzAction Λ₂ (schwartzAction (Λ₁) η) = - schwartzAction (Λ₂ * Λ₁) η := by - simp + schwartzAction (Λ₂ * Λ₁) η := by simp lemma schwartzAction_apply {d} (Λ : LorentzGroup d) (η : 𝓢(SpaceTime d, ℝ)) (x : SpaceTime d) : From d1b02a429eee79466febe1ddc4db345e1533f006 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 04:16:12 -0700 Subject: [PATCH 352/498] refactor: golf QuantumInfo wrapper witnesses Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean | 3 +-- QuantumInfo/ForMathlib/Isometry.lean | 3 +-- QuantumInfo/ForMathlib/Majorization.lean | 3 +-- QuantumInfo/Operators/Unitary.lean | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 0b04673bc..7b6572067 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -148,8 +148,7 @@ theorem cfc_eigenvalues (A : HermitianMat d 𝕜) : etc. We need these because (as above) `HermitianMat.cfc` is different from `_root_.cfc`. -/ @[simp] -nonrec theorem cfc_id : A.cfc id = A := by - simpa [HermitianMat.ext_iff] using cfc_id ℝ A.mat +nonrec theorem cfc_id : A.cfc id = A := by simpa [HermitianMat.ext_iff] using cfc_id ℝ A.mat @[simp] nonrec theorem cfc_id' : A.cfc (·) = A := diff --git a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean index 8e82a75ae..315bd700a 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean @@ -119,8 +119,7 @@ lemma trace_Φ_eq (M : Matrix d d ℂ) : /-- `traceRe(Φ(M)) = re(Tr[M])` for any matrix M. -/ lemma traceRe_Φ_general (M : Matrix d d ℂ) : - traceRe (Φ M) = Complex.re M.trace := by - simp [traceRe, trace_Φ_eq] + traceRe (Φ M) = Complex.re M.trace := by simp [traceRe, trace_Φ_eq] end HermitianMatBridge diff --git a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean index 92e135a22..d8213a60f 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean @@ -135,8 +135,7 @@ theorem nonSingular_iff_neg : NonSingular (-A) ↔ NonSingular A := by simp [nonSingular_iff_det_ne_zero, Matrix.det_neg] @[simp] -theorem nonSingular_iff_inv : NonSingular (A⁻¹) ↔ NonSingular A := by - simp [nonsingular_iff_isUnit] +theorem nonSingular_iff_inv : NonSingular (A⁻¹) ↔ NonSingular A := by simp [nonsingular_iff_isUnit] @[simp] theorem nonSingular_iff_kronecker [Nonempty n] [Nonempty m] : diff --git a/QuantumInfo/ForMathlib/Isometry.lean b/QuantumInfo/ForMathlib/Isometry.lean index 133acee53..162928573 100644 --- a/QuantumInfo/ForMathlib/Isometry.lean +++ b/QuantumInfo/ForMathlib/Isometry.lean @@ -370,8 +370,7 @@ theorem LinearMap.IsSymmetric.directSum_isInternal_of_commute' {𝕜 E : Type*} ext μ₁₂ simp only [DirectSum.zero_apply, ZeroMemClass.coe_zero] rw [← inner_self_eq_zero (𝕜 := 𝕜)] - have h_inner_zero : inner 𝕜 (x μ₁₂ : E) (x.coeAddMonoidHom _) = 0 := by - simp [hx] + have h_inner_zero : inner 𝕜 (x μ₁₂ : E) (x.coeAddMonoidHom _) = 0 := by simp [hx] rw [← h_inner_zero] simp only [DirectSum.coeAddMonoidHom_eq_dfinsuppSum, ZeroMemClass.coe_zero, implies_true, DFinsupp.sum_eq_sum_fintype, DFinsupp.equivFunOnFintype_apply] diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index 36a3eff8d..378b24d97 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -60,8 +60,7 @@ noncomputable def singularValuesSorted (A : Matrix d d ℂ) : lemma singularValuesSorted_nonneg (A : Matrix d d ℂ) (i : Fin (Fintype.card d)) : 0 ≤ singularValuesSorted A i := by have h_nonneg : ∀ i, 0 ≤ (singularValues A i) := singularValues_nonneg A - have h_sorted_nonneg : ∀ {l : List ℝ}, (∀ x ∈ l, 0 ≤ x) → ∀ i < l.length, 0 ≤ l[i]! := by - aesop + have h_sorted_nonneg : ∀ {l : List ℝ}, (∀ x ∈ l, 0 ≤ x) → ∀ i < l.length, 0 ≤ l[i]! := by aesop contrapose! h_sorted_nonneg use Multiset.sort (Finset.univ.val.map (singularValues A)) (· ≥ ·) refine' ⟨_, i, _, _⟩ diff --git a/QuantumInfo/Operators/Unitary.lean b/QuantumInfo/Operators/Unitary.lean index 3f308281d..fcae35670 100644 --- a/QuantumInfo/Operators/Unitary.lean +++ b/QuantumInfo/Operators/Unitary.lean @@ -47,8 +47,7 @@ of a matrix are always canonically sorted, this is actually an equality. -/ @[simp] theorem U_conj_spectrum_eq (ρ : MState d) (U : 𝐔[d]) : - (ρ.U_conj U).spectrum = ρ.spectrum := by - simp [spectrum, U_conj] + (ρ.U_conj U).spectrum = ρ.spectrum := by simp [spectrum, U_conj] @[simp] theorem inner_U_conj (ρ σ : MState d) (U : 𝐔[d]) : ⟪U ◃ ρ, U ◃ σ⟫_Prob = ⟪ρ, σ⟫_Prob := by From 1d78a2b58346d5f10305f08c95c9de02b7328615 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 04:59:28 -0700 Subject: [PATCH 353/498] refactor: golf QFT and relativity exact proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean | 3 +-- .../QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean | 3 +-- .../PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean | 3 +-- .../QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean | 3 +-- .../QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean | 3 +-- Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean | 3 +-- Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean | 3 +-- .../QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean | 3 +-- Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean | 3 +-- Physlib/QFT/PerturbationTheory/WickContraction/Card.lean | 3 +-- .../PerturbationTheory/WickContraction/InsertAndContract.lean | 3 +-- .../WickContraction/InsertAndContractNat.lean | 3 +-- Physlib/QFT/PerturbationTheory/WickContraction/Join.lean | 3 +-- Physlib/Relativity/CliffordAlgebra.lean | 3 +-- Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean | 3 +-- .../Relativity/LorentzGroup/Restricted/FromBoostRotation.lean | 3 +-- 16 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean index 3c80e41f0..230ba3ea6 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean @@ -279,8 +279,7 @@ instance fieldOpFreeAlgebraGrade : cases f1 <;> cases f2 <;> rfl · simp [p] · intro x y hx hy hx1 hx2 - simp only [add_mul, p] - exact Submodule.add_mem _ hx1 hx2 + simpa only [add_mul, p] using Submodule.add_mem _ hx1 hx2 · intro c a hx h1 simp only [Algebra.smul_mul_assoc, p] exact Submodule.smul_mem _ _ h1 diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean index 20d0111bc..f59af014a 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean @@ -167,8 +167,7 @@ lemma normalOrderF_crPartF_mul (φ : 𝓕.FieldOp) (a : FieldOpFreeAlgebra 𝓕) crPartF φ * 𝓝ᶠ(a) := by match φ with | .inAsymp φ => - rw [crPartF] - exact normalOrderF_create_mul ⟨FieldOp.inAsymp φ, ()⟩ rfl a + simpa [crPartF] using normalOrderF_create_mul ⟨FieldOp.inAsymp φ, ()⟩ rfl a | .position φ => rw [crPartF] exact normalOrderF_create_mul _ rfl _ diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean index ebfd583f8..4b2c3d9ae 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/SuperCommute.lean @@ -515,8 +515,7 @@ lemma superCommuteF_grade {a b : 𝓕.FieldOpFreeAlgebra} {f1 f2 : FieldStatisti rw [mul_comm] · simp [p] · intro x y hx hy hp1 hp2 - simp only [add_eq_mul, map_add, LinearMap.add_apply, p] - exact Submodule.add_mem _ hp1 hp2 + simpa only [add_eq_mul, map_add, LinearMap.add_apply, p] using Submodule.add_mem _ hp1 hp2 · intro c x hx hp1 simp only [add_eq_mul, map_smul, LinearMap.smul_apply, p] exact Submodule.smul_mem _ c hp1 diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 309d5b919..b8d24e787 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -388,8 +388,7 @@ lemma eraseIdxEquiv_symm_eq_take_cons_drop {n : ℕ} (φs : List 𝓕.FieldOp) ( simp only [congr_fst] have hn : (List.take n φs).length = n := by rw [@List.length_take] - simp only [inf_eq_left] - exact Nat.le_of_succ_le hn + simpa only [inf_eq_left] using Nat.le_of_succ_le hn rw [hn] @[simp] diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index e5bb82c66..9c09a429e 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -212,8 +212,7 @@ lemma normalOrderSign_swap_annihilate_annihilate (φa φa' : 𝓕.CrAnFieldOp) rw [normalOrderSign_swap_annihilate_annihilate φa φa' hφa hφa'] dsimp only [normalOrderSign, Wick.koszulSign] rw [← normalOrderSign] - simp only [mul_eq_mul_right_iff] - exact Or.inl (Wick.koszulSignInsert_eq_perm _ _ _ _ _ + simpa only [mul_eq_mul_right_iff] using Or.inl (Wick.koszulSignInsert_eq_perm _ _ _ _ _ (List.Perm.append_left φs (List.Perm.swap φa' φa φs'))) open FieldStatistic diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index 83bc26426..e9f0c716e 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -268,8 +268,7 @@ lemma koszulSign_swap_eq_rel_cons {ψ φ : 𝓕} lemma koszulSign_swap_eq_rel {ψ φ : 𝓕} (h1 : le φ ψ) (h2 : le ψ φ) : (φs φs' : List 𝓕) → koszulSign q le (φs ++ φ :: ψ :: φs') = koszulSign q le (φs ++ ψ :: φ :: φs') | [], φs' => by - simp only [List.nil_append] - exact koszulSign_swap_eq_rel_cons q le h1 h2 φs' + simpa only [List.nil_append] using koszulSign_swap_eq_rel_cons q le h1 h2 φs' | φ'' :: φs, φs' => by simp only [List.cons_append, koszulSign] rw [koszulSign_swap_eq_rel h1 h2] diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean index 702c69dff..30e54e66e 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean @@ -258,8 +258,7 @@ lemma koszulSignInsert_eq_rel_eq_stat {ψ φ : 𝓕} [IsTrans 𝓕 le] · simp only [hr, ↓reduceIte] have h1' : le ψ φ' := by apply IsTrans.trans ψ φ φ' h2 hr - simp only [h1', ↓reduceIte] - exact koszulSignInsert_eq_rel_eq_stat h1 h2 hq φs + simpa only [h1', ↓reduceIte] using koszulSignInsert_eq_rel_eq_stat h1 h2 hq φs · have hψφ' : ¬ le ψ φ' := by intro hψφ' apply hr diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean index a5c91ec80..eb79f0b45 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean @@ -83,8 +83,7 @@ lemma ι_normalOrderF_superCommuteF_ofCrAnOpF_eq_zero_mul (φa φa' : 𝓕.CrAnF simp only [mulLinearMap, FieldOpFreeAlgebra.ofListBasis_eq_ofList, LinearMap.coe_comp, Function.comp_apply, LinearMap.flip_apply, LinearMap.coe_mk, AddHom.coe_mk, AlgHom.toLinearMap_apply, LinearMap.zero_apply] - rw [← mul_assoc] - exact ι_normalOrderF_superCommuteF_ofCrAnListF_eq_zero φa φa' _ _ + simpa [← mul_assoc] using ι_normalOrderF_superCommuteF_ofCrAnListF_eq_zero φa φa' _ _ rw [hf] simp diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean index 85ef247f5..cc5bf44eb 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Universality.lean @@ -68,8 +68,7 @@ def universalLift {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp commutes' r := by rw [Algebra.algebraMap_eq_smul_one r] rw [show r • 1 = ι (𝓕 := 𝓕) (r • 1) from rfl, universalLiftMap_ι] - simp only [map_smul, map_one] - exact Eq.symm (Algebra.algebraMap_eq_smul_one r) + simpa only [map_smul, map_one] using Eq.symm (Algebra.algebraMap_eq_smul_one r) @[simp] lemma universalLift_ι {A : Type} [Semiring A] [Algebra ℂ A] (f : 𝓕.CrAnFieldOp → A) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean index a0707f20e..a2bce41e0 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean @@ -78,8 +78,7 @@ def consAddContract (i : Fin n.succ) (c : WickContraction n) : rcases h with h | h · obtain ⟨a, ha, rfl⟩ := h rw [Finset.mapEmbedding_apply, Finset.mapEmbedding_apply] - simp only [Finset.card_map] - exact c.2.1 a ha + simpa only [Finset.card_map] using c.2.1 a ha · subst h rw [@Finset.card_eq_two] use 0, i.succ diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean index 5405654e6..c724b3cb0 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContract.lean @@ -369,8 +369,7 @@ lemma stat_ofFinset_of_insertAndContractLiftFinset (φ : 𝓕.FieldOp) (φs : Li intro x hx refine Fin.ne_of_val_ne ?h.inl.h simp only [Fin.val_cast, ne_eq] - rw [Fin.val_eq_val] - exact Fin.succAbove_ne i x + exact fun h => Fin.succAbove_ne i x (Fin.ext h) · obtain ⟨k, hk⟩ := hk subst hk simp only [Nat.succ_eq_add_one] diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean index e861b3cd6..668a85b6e 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean @@ -44,8 +44,7 @@ def insertAndContractNat (c : WickContraction n) (i : Fin n.succ) (j : Option (c forall_exists_index, and_imp, forall_apply_eq_imp_iff₂, f] intro a ha rw [Finset.mapEmbedding_apply] - simp only [Finset.card_map] - exact c.2.1 a ha + simpa only [Finset.card_map] using c.2.1 a ha | some j => simp only [Finset.mem_insert, forall_eq_or_imp] apply And.intro diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean index 8762e045a..0d8942184 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Join.lean @@ -41,8 +41,7 @@ def join {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) · exact φsΛ.2.1 a ha · obtain ⟨a, ha, rfl⟩ := ha rw [Finset.mapEmbedding_apply] - simp only [Finset.card_map] - exact φsucΛ.2.1 a ha, by + simpa only [Finset.card_map] using φsucΛ.2.1 a ha, by intro a ha b hb simp only [Finset.le_eq_subset, Finset.mem_union, Finset.mem_map, RelEmbedding.coe_toEmbedding] at ha hb diff --git a/Physlib/Relativity/CliffordAlgebra.lean b/Physlib/Relativity/CliffordAlgebra.lean index 75dda546a..9627892c6 100644 --- a/Physlib/Relativity/CliffordAlgebra.lean +++ b/Physlib/Relativity/CliffordAlgebra.lean @@ -187,8 +187,7 @@ lemma ofCliffordAlgebra_range_eq_top : ofCliffordAlgebra.range = ⊤ := by /-- The homomorphism `ofCliffordAlgebra` is surjective. -/ theorem ofCliffordAlgebra_surjective : Function.Surjective ofCliffordAlgebra := by - rw [← AlgHom.range_eq_top] - exact ofCliffordAlgebra_range_eq_top + simpa [← AlgHom.range_eq_top] using ofCliffordAlgebra_range_eq_top end γ diff --git a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean index c1727222f..7b5f0e181 100644 --- a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean +++ b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean @@ -107,8 +107,7 @@ variable {n R ι : Type*} [Fintype n]-- [DecidableEq n] @[simp] lemma trace_reindex [Semiring R] [Fintype ι] (e : n ≃ ι) (A : Matrix n n R) : trace (A.submatrix e.symm e.symm) = trace A := by - simp only [trace, diag_apply, submatrix_apply] - exact e.symm.sum_comp (fun i : n => A i i) + simpa only [trace, diag_apply, submatrix_apply] using e.symm.sum_comp (fun i : n => A i i) variable {n R ι : Type*} [Fintype n] [DecidableEq n] diff --git a/Physlib/Relativity/LorentzGroup/Restricted/FromBoostRotation.lean b/Physlib/Relativity/LorentzGroup/Restricted/FromBoostRotation.lean index 83ca99d28..46ba4a485 100644 --- a/Physlib/Relativity/LorentzGroup/Restricted/FromBoostRotation.lean +++ b/Physlib/Relativity/LorentzGroup/Restricted/FromBoostRotation.lean @@ -52,8 +52,7 @@ def toRotation {d} (Λ : LorentzGroup.restricted d) : Rotations d := erw [generalizedBoost_apply_fst] simp · refine isProper_mul ?_ Λ.2.1 - rw [generalizedBoost_inv] - exact generalizedBoost_isProper _ _⟩ + simpa [generalizedBoost_inv] using generalizedBoost_isProper _ _⟩ @[fun_prop] lemma toRotation_continuous {d} : From feb2da3343c25f3a54bc5fbaeea92154c7b0159a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:07:29 -0700 Subject: [PATCH 354/498] refactor: golf QuantumInfo exact proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Unbundled.lean | 3 +-- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Basic.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Inner.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Schatten.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Trace.lean | 3 +-- QuantumInfo/ForMathlib/LimSupInf.lean | 3 +-- QuantumInfo/ForMathlib/Majorization.lean | 3 +-- QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean | 3 +-- QuantumInfo/ForMathlib/SionMinimax.lean | 3 +-- 14 files changed, 14 insertions(+), 28 deletions(-) diff --git a/QuantumInfo/Channels/Unbundled.lean b/QuantumInfo/Channels/Unbundled.lean index eec68ca52..8174091fe 100644 --- a/QuantumInfo/Channels/Unbundled.lean +++ b/QuantumInfo/Channels/Unbundled.lean @@ -306,8 +306,7 @@ theorem of_Fintype {M : MatrixMap A B R} (h : IsCompletelyPositive M) simp only [EmbeddingLike.apply_eq_iff_eq, Equiv.symm_apply_apply] constructor · intro h₂ - simp [MatrixMap.IsPositive] - exact h n + simpa [MatrixMap.IsPositive] using h n · intro h x hx specialize h (hx.submatrix (fun p : A × Fin n => (p.1, e.symm p.2))) rw [h_submatrix] diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 22055182b..77fa226b2 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -413,8 +413,7 @@ theorem one_div_operatorConvexOn_Ioi : Matrix.PosSemidef (star U * (!![C, 1; 1, D] : Matrix (Fin 2) (Fin 2) 𝓐) * U) := by -- rewrite the middle block matrix as `M` - rw [← hM] - exact posConj + simpa [← hM] using posConj -- rewrite the goal using the computed conjugation rw [← hconj] exact posConj' diff --git a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean index 450aa8456..9b1146256 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean @@ -659,8 +659,7 @@ theorem _root_.Matrix.range_mul_conjTranspose_of_ker_le_ker {A : Matrix d d 𝕜 rw [← inner_self_eq_zero (𝕜 := 𝕜)] have : ∀ y, @inner 𝕜 _ _ y (Matrix.toEuclideanLin M x) = 0 := by intro y - rw [← LinearMap.adjoint_inner_left] - exact h _ ⟨y, rfl⟩ + simpa [← LinearMap.adjoint_inner_left] using h _ ⟨y, rfl⟩ exact this _ · intro h y ⟨z, hz⟩ rw [← hz, LinearMap.adjoint_inner_left, h, inner_zero_right] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean index 7c22da3ed..0374563dc 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean @@ -192,8 +192,7 @@ theorem inner_mono (hA : 0 ≤ A) : B ≤ C → ⟪A, B⟫ ≤ ⟪A, C⟫ := by theorem inner_mono' (hA : 0 ≤ A) : B ≤ C → ⟪B, A⟫ ≤ ⟪C, A⟫ := by intro hBC - rw [inner_comm B A, inner_comm C A] - exact inner_mono hA hBC + simpa [inner_comm B A, inner_comm C A] using inner_mono hA hBC /-- The inner product for PSD matrices is at most the product of their traces. -/ theorem inner_le_mul_trace (hA : 0 ≤ A) (hB : 0 ≤ B) : ⟪A, B⟫ ≤ A.trace * B.trace := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean index 315bd700a..e649e19ff 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LiebConcavity.lean @@ -475,8 +475,7 @@ private lemma trace_conj_rpow_concave_pd [Nonempty d] {α : ℝ} (hα : 1 < α) rw [trace_lin] linarith [mul_le_mul_of_nonneg_left bridge hp_pos.le] _ ≤ (X_mix ^ p).trace := by - rw [hr_eq] - exact variational_lower_bound X_mix (a • Z₁ + b • Z₂) hX_mix hZ_mix hp_gt1 + simpa [hr_eq] using variational_lower_bound X_mix (a • Z₁ + b • Z₂) hX_mix hZ_mix hp_gt1 end VariationalAndBridge diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 07148a042..88799af92 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -51,8 +51,7 @@ theorem lt_iff_posdef : A < B ↔ (B - A).mat.PosSemidef ∧ A ≠ B := instance : IsStrictOrderedModule ℝ (HermitianMat n 𝕜) where smul_lt_smul_of_pos_left a ha b b₂ hb := by rw [HermitianMat.lt_iff_posdef] at hb ⊢ - simp only [← smul_sub, ne_eq, smul_right_inj ha.ne'] - exact ⟨hb.left.smul ha.le, hb.right⟩ + simpa only [← smul_sub, ne_eq, smul_right_inj ha.ne'] using ⟨hb.left.smul ha.le, hb.right⟩ smul_lt_smul_of_pos_right a ha b b2 hb := by rw [HermitianMat.lt_iff_posdef] at ha ⊢ rw [sub_zero] at ha diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 256199809..fe921ec68 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -165,8 +165,7 @@ theorem sandwich_self (hB : B.mat.PosDef) : (B.conj (B ^ (-1/2 : ℝ)).mat) = 1 := by have hB_inv_sqrt : (B ^ (-1 / 2 : ℝ)).mat * (B ^ (-1 / 2 : ℝ)).mat = (B ^ (-1 : ℝ)).mat := by rw [ ← mat_rpow_add ] <;> norm_num - rw [zero_le_iff] - exact hB.posSemidef + simpa [zero_le_iff] using hB.posSemidef have hB_inv : (B ^ (-1 : ℝ)).mat = B.mat⁻¹ := by rw [← inv_eq_rpow_neg_one hB, mat_inv] rw [ hB_inv ] at hB_inv_sqrt; diff --git a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean index 5a7a5236f..678d6198f 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean @@ -39,8 +39,7 @@ theorem schattenNorm_hermitian_pow {A : HermitianMat d ℂ} (hA : 0 ≤ A) {p : ext simp only [HermitianMat.conjTranspose_mat, HermitianMat.mat_pow] convert rfl using 2 - rw [sq] - exact Matrix.IsHermitian.cfc_eq _ _ + simpa [sq] using Matrix.IsHermitian.cfc_eq _ _ lemma schattenNorm_nonneg (A : Matrix d d ℂ) (p : ℝ) : 0 ≤ schattenNorm A p := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean b/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean index f22658fef..5200976b4 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean @@ -50,8 +50,7 @@ lemma sqrt_inv_mul_self_mul_sqrt_inv_eq_one {A : HermitianMat d 𝕜} (hA : A.ma A⁻¹.sqrt.mat * A.mat * A⁻¹.sqrt.mat = 1 := by have h_inv_def : A⁻¹.sqrt.mat * A⁻¹.sqrt.mat = A⁻¹ := by apply HermitianMat.sqrt_sq - rw [zero_le_iff] - exact hA.inv.posSemidef + simpa [zero_le_iff] using hA.inv.posSemidef have h_inv_comm : Commute A⁻¹.sqrt.mat A.mat := by commutes rw [h_inv_comm, mul_assoc, h_inv_def] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean index 7172e4a18..a647151f9 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean @@ -138,8 +138,7 @@ theorem sum_eigenvalues_eq_trace [DecidableEq n] (A : HermitianMat n 𝕜) : --Proving that traces are 0 or 1 is common enough that we have a convenience lemma here for turning --statements about HermitianMat traces into Matrix traces. theorem trace_eq_zero_iff (A : HermitianMat n 𝕜) : A.trace = 0 ↔ A.mat.trace = 0 := by - rw [← trace_eq_trace_rc] - exact ⟨mod_cast id, mod_cast id⟩ + simp [← trace_eq_trace_rc] theorem trace_eq_one_iff (A : HermitianMat n 𝕜) : A.trace = 1 ↔ A.mat.trace = 1 := by rw [← trace_eq_trace_rc] diff --git a/QuantumInfo/ForMathlib/LimSupInf.lean b/QuantumInfo/ForMathlib/LimSupInf.lean index ba90146b3..265e3555b 100644 --- a/QuantumInfo/ForMathlib/LimSupInf.lean +++ b/QuantumInfo/ForMathlib/LimSupInf.lean @@ -272,8 +272,7 @@ lemma tendsto_of_block_sequence {α : Type*} [TopologicalSpace α] {x : ℕ → · rw [← not_le] intro h exact not_lt_of_ge (Finset.le_max' _ _ (h_finite.mem_toFinset.mpr h)) (Nat.lt_succ_self _) - rw [hg k n hk] - exact ha k (le_of_not_gt fun hk' ↦ by linarith [hT.monotone hk']) + simpa [hg k n hk] using ha k (le_of_not_gt fun hk' ↦ by linarith [hT.monotone hk']) /- Given a lower bound sequence M and a property P that can always be satisfied eventually, there exists a strictly increasing sequence T bounded by M such that each interval [T_k, T_{k+1}) contains a witness for P. diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index 378b24d97..c97c42f30 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -634,8 +634,7 @@ lemma prod_singularValuesSorted_eq_compoundSV (M : Matrix d d ℂ) (k : ℕ) exact singularValuesSorted_antitone (compoundMatrix M k) (Fin.zero_le idx) · obtain ⟨j, hj⟩ := singularValuesSorted_mem_values (compoundMatrix M k) ⟨0, hcard⟩ obtain ⟨S, hS⟩ := singularValues_compoundMatrix_rev M k j - rw [hj, hS] - exact prod_singularValues_subset_le_sorted_prod M k hk S + simpa [hj, hS] using prod_singularValues_subset_le_sorted_prod M k hk S /-- The **Rayleigh quotient bound**: diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index ef1a4a7e9..18ffea7d0 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -37,8 +37,7 @@ theorem traceNorm_zero : traceNorm (0 : Matrix m n R) = 0 := by simp [traceNorm] theorem traceNorm_neg (A : Matrix m n R) : traceNorm (-A) = traceNorm A := by unfold traceNorm congr! 3 - rw [Matrix.conjTranspose_neg, Matrix.neg_mul, Matrix.mul_neg] - exact neg_neg _ + simp [Matrix.conjTranspose_neg, Matrix.neg_mul, Matrix.mul_neg] open MatrixOrder Isometry diff --git a/QuantumInfo/ForMathlib/SionMinimax.lean b/QuantumInfo/ForMathlib/SionMinimax.lean index 78c4fa68e..f1c801510 100644 --- a/QuantumInfo/ForMathlib/SionMinimax.lean +++ b/QuantumInfo/ForMathlib/SionMinimax.lean @@ -121,8 +121,7 @@ theorem LowerSemicontinuousOn.bddBelow {α : Type*} [TopologicalSpace α] {S : S intros x hx specialize hg x hx (g x - 1) (sub_one_lt (g x)) rw [eventually_nhdsWithin_iff] at hg - simp only [Set.mem_inter_iff, gt_iff_lt, and_imp] - exact ⟨_, hg, fun y hy hyS ↦ hy hyS⟩ + simpa only [Set.mem_inter_iff, gt_iff_lt, and_imp] using ⟨_, hg, fun y hy hyS ↦ hy hyS⟩ choose! U hU using h_neighborhood -- By the finite subcover property, there exists a finite subset t ⊆ S$ such that S ⊆ ⋃_{x ∈ t} U_x$. obtain ⟨t, ht⟩ : ∃ t, (∀ x ∈ t, x ∈ S) ∧ S ⊆ ⋃ x ∈ t, U x := From fe44e2a499d3990d25b25aad2949cc840d9d046f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:12:24 -0700 Subject: [PATCH 355/498] refactor: golf relativity and quantum mechanics exact proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Fin.lean | 3 +-- Physlib/Mathematics/Fin/Involutions.lean | 3 +-- Physlib/QuantumMechanics/DDimensions/Hydrogen/Basic.lean | 3 +-- .../DDimensions/Operators/SpectralTheory/Basic.lean | 3 +-- Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean | 3 +-- .../SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean | 3 +-- .../OneDimension/HarmonicOscillator/Basic.lean | 3 +-- .../OneDimension/HarmonicOscillator/Completeness.lean | 3 +-- .../Relativity/Tensors/ComplexTensor/Vector/Pre/Modules.lean | 3 +-- Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean | 3 +-- .../Relativity/Tensors/RealTensor/Vector/Causality/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean | 3 +-- 14 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index 568430c6c..b4a4171bc 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -144,8 +144,7 @@ lemma finExtractOne_apply_neq {n : ℕ} (i j : Fin (n + 1 + 1)) (hij : i ≠ j) finExtractOne i j = Sum.inr (predAboveI i j) := by symm apply (Equiv.symm_apply_eq _).mp ?_ - simp only [Nat.succ_eq_add_one, finExtractOne_symm_inr_apply] - exact succsAbove_predAboveI hij + simpa only [Nat.succ_eq_add_one, finExtractOne_symm_inr_apply] using succsAbove_predAboveI hij /-- Given an equivalence `Fin n.succ.succ ≃ Fin n.succ.succ`, and an `i : Fin n.succ.succ`, the map `Fin n.succ → Fin n.succ` obtained by dropping `i` and it's image. -/ diff --git a/Physlib/Mathematics/Fin/Involutions.lean b/Physlib/Mathematics/Fin/Involutions.lean index c65067e45..8a6af2743 100644 --- a/Physlib/Mathematics/Fin/Involutions.lean +++ b/Physlib/Mathematics/Fin/Involutions.lean @@ -341,8 +341,7 @@ def involutionNoFixedSetOne {n : ℕ} : simp [f.2.1 i.succ.succ] · intro i simp only [succ_eq_add_one, ne_eq, Function.comp_apply, f''', f'', f'] - rw [Fin.pred_eq_iff_eq_succ, Fin.pred_eq_iff_eq_succ] - exact f.2.2.1 i.succ.succ + simpa [Fin.pred_eq_iff_eq_succ, Fin.pred_eq_iff_eq_succ] using f.2.2.1 i.succ.succ invFun f := by let f' := fun (i : Fin n.succ.succ)=> match i with diff --git a/Physlib/QuantumMechanics/DDimensions/Hydrogen/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Hydrogen/Basic.lean index 9396e875d..d5d2fa985 100644 --- a/Physlib/QuantumMechanics/DDimensions/Hydrogen/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Hydrogen/Basic.lean @@ -51,8 +51,7 @@ lemma potential_eq : H.potential = fun x ↦ -H.k * ‖x‖⁻¹ := H.coulomb_po @[fun_prop] lemma potential_AESM : AEStronglyMeasurable H.potential := by - rw [potential_eq] - exact AEMeasurable.aestronglyMeasurable (by fun_prop) + simpa [potential_eq] using AEMeasurable.aestronglyMeasurable (by fun_prop) @[fun_prop] lemma potential_AEM : AEMeasurable H.potential := H.potential_AESM.aemeasurable diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean index 23c95332c..273c7ea5d 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean @@ -165,8 +165,7 @@ lemma regularityDomain_smul (T : H →ₗ.[ℂ] H) {w : ℂ} (hw : w ≠ 0) : · refine ⟨‖w‖⁻¹ * c, by positivity, fun x ↦ ?_⟩ rw [mul_assoc] apply (inv_mul_le_iff₀ <| norm_pos_iff.mpr hw).mpr - rw [← norm_smul, smul_sub, smul_smul, mul_inv_cancel_left₀ hw] - exact h_bound x + simpa [← norm_smul, smul_sub, smul_smul, mul_inv_cancel_left₀ hw] using h_bound x · simp [hw] · intro ⟨u, ⟨c, hc, h_bound⟩, huz⟩ refine ⟨‖w‖ * c, by positivity, fun x ↦ ?_⟩ diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean index 28413380c..9096d2c80 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Unbounded.lean @@ -366,8 +366,7 @@ lemma adjoint_add_le_add_adjoint [CompleteSpace H] lemma adjoint_sub_le_sub_adjoint [CompleteSpace H] (U₁ U₂ : H →ₗ.[ℂ] H') (h₁₂ : (U₁ - U₂).HasDenseDomain) : U₁† - U₂† ≤ (U₁ - U₂)† := by - simp only [sub_eq_add_neg, ← adjoint_neg] - exact adjoint_add_le_add_adjoint U₁ (-U₂) h₁₂ + simpa only [sub_eq_add_neg, ← adjoint_neg] using adjoint_add_le_add_adjoint U₁ (-U₂) h₁₂ lemma adjoint_compRestricted_le_compRestricted_adjoint [CompleteSpace H] [CompleteSpace H'] (hV : V.HasDenseDomain) (hVU : (V ∘ᵣ U).HasDenseDomain) : U† ∘ᵣ V† ≤ (V ∘ᵣ U)† := by diff --git a/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean b/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean index c2644baa3..475c1c1f6 100644 --- a/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean +++ b/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean @@ -77,8 +77,7 @@ def polyBddSchwartzMap (d : ℕ) (a : ℕ∞) : Submodule ℂ 𝓢(Space d, ℂ) obtain ⟨C₂, hC₂_pos, hC₂⟩ := hg k hk refine ⟨C₁ + C₂, by positivity, fun x ↦ ?_⟩ refine le_trans ?_ (add_le_add (hC₁ x) (hC₂ x)) - rw [← mul_add] - exact mul_le_mul_of_nonneg_left (norm_add_le (f x) (g x)) (by positivity) + simpa [← mul_add] using mul_le_mul_of_nonneg_left (norm_add_le (f x) (g x)) (by positivity) zero_mem' := fun _ _ ↦ ⟨1, by simp⟩ smul_mem' := by intro c f hf k hk diff --git a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean index 2c9a82d7a..1dbba481e 100644 --- a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Basic.lean @@ -38,8 +38,7 @@ lemma Complex.ofReal_hasDerivAt : HasDerivAt Complex.ofReal 1 x := by let f1 : ℂ → ℂ := id change HasDerivAt (f1 ∘ Complex.ofReal) 1 x apply HasDerivAt.comp_ofReal - simp only [f1] - exact hasDerivAt_id _ + simpa only [f1] using hasDerivAt_id _ @[simp] lemma Complex.deriv_ofReal : deriv Complex.ofReal x = 1 := by diff --git a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean index 8009ddc91..42180c32f 100644 --- a/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean +++ b/Physlib/QuantumMechanics/OneDimension/HarmonicOscillator/Completeness.lean @@ -108,8 +108,7 @@ lemma mul_polynomial_integrable (f : ℝ → ℂ) (hf : MemHS f) (P : Polynomial funext x simp only [Complex.ofReal_exp, Complex.ofReal_div, Complex.ofReal_neg, Complex.ofReal_pow, Complex.ofReal_mul, Complex.ofReal_ofNat, Complex.real_smul] - rw [hf'] - exact (Q.mul_physHermite_integrable f hf i).fun_smul (a i) + simpa [hf'] using (Q.mul_physHermite_integrable f hf i).fun_smul (a i) lemma mul_power_integrable (f : ℝ → ℂ) (hf : MemHS f) (r : ℕ) : MeasureTheory.Integrable (fun x => x ^ r * (f x * Real.exp (- x^2 / (2 * Q.ξ^2)))) volume := by diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Modules.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Modules.lean index ff5bf5b72..9a1a24891 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Modules.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Modules.lean @@ -164,8 +164,7 @@ def lorentzGroupRep : Representation ℂ (LorentzGroup 3) CoℂModule where LinearEquiv.apply_symm_apply, mulVec_mulVec, EmbeddingLike.apply_eq_iff_eq] refine (congrFun (congrArg _ ?_) _) simp only [_root_.map_mul] - rw [Matrix.mul_inv_rev] - exact transpose_mul _ _ + simp [Matrix.mul_inv_rev] /-- The representation of the SL(2, ℂ) on `ContrℂModule` induced by the representation of the Lorentz group. -/ diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean index 0a3c356a8..b4e9f216c 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean @@ -92,8 +92,7 @@ def dualLeftHandedRep : Representation ℂ SL(2,ℂ) DualLeftHandedWeyl where simp only [SpecialLinearGroup.coe_mul, LinearMap.coe_mk, AddHom.coe_mk, Module.End.mul_apply, LinearEquiv.apply_symm_apply, mulVec_mulVec, EmbeddingLike.apply_eq_iff_eq] refine (congrFun (congrArg _ ?_) _) - rw [Matrix.mul_inv_rev] - exact transpose_mul _ _ + simp [Matrix.mul_inv_rev] /-- The standard basis on dual-left-handed Weyl fermions. -/ def dualLeftBasis : Basis (Fin 2) ℂ DualLeftHandedWeyl := Basis.ofEquivFun diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean index e9636635c..ffe5c83d2 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Basic.lean @@ -79,8 +79,7 @@ instance isNormedAddCommGroup (d : ℕ) : NormedAddCommGroup (CoVector d) where instance isNormedSpace (d : ℕ) : NormedSpace ℝ (CoVector d) where norm_smul_le c v := by - simp only [norm_eq_equivEuclid, map_smul] - exact norm_smul_le c (equivEuclid d v) + simpa only [norm_eq_equivEuclid, map_smul] using norm_smul_le c (equivEuclid d v) open InnerProductSpace diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean index 2148ab349..6d0363dbb 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean @@ -91,8 +91,7 @@ instance isNormedAddCommGroup (d : ℕ) : NormedAddCommGroup (Vector d) where instance isNormedSpace (d : ℕ) : NormedSpace ℝ (Vector d) where norm_smul_le c v := by - simp only [norm_eq_equivEuclid, map_smul] - exact norm_smul_le c (equivEuclid d v) + simpa only [norm_eq_equivEuclid, map_smul] using norm_smul_le c (equivEuclid d v) open InnerProductSpace instance (d : ℕ) : Inner ℝ (Vector d) where diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/Basic.lean index 028fafe7d..d066f5eec 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Causality/Basic.lean @@ -56,8 +56,7 @@ lemma spaceLike_iff_norm_sq_neg {d : ℕ} (p : Vector d) : simp only [reduceCtorEq, h, lt_self_iff_false] · split · rename_i h - simp only [reduceCtorEq, false_iff, not_lt] - exact le_of_lt h + simpa only [reduceCtorEq, false_iff, not_lt] using le_of_lt h · rename_i h1 h2 simp only [true_iff] rw [not_lt_iff_eq_or_lt] at h2 diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index 9905eb2f8..875a95427 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -97,8 +97,7 @@ lemma minkowskiProduct_continuous_fst (u : Vector d) : (fun (x : Velocity d) => ⟪u, x.1⟫ₘ) := by ext x rw [minkowskiProduct_symm] - rw [h1] - exact minkowskiProduct_continuous_snd u + simpa [h1] using minkowskiProduct_continuous_snd u /-! From c5f2cfa13205296fd026f71c13e7a316e7b4b5c2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:18:58 -0700 Subject: [PATCH 356/498] refactor: golf QuantumInfo follow-up exact proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Unbundled.lean | 3 +-- QuantumInfo/ClassicalInfo/Distribution.lean | 3 +-- QuantumInfo/Entropy/DPI.lean | 3 +-- QuantumInfo/Entropy/SSA.lean | 3 +-- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Trace.lean | 3 +-- QuantumInfo/ForMathlib/Majorization.lean | 3 +-- QuantumInfo/ResourceTheory/FreeState.lean | 3 +-- QuantumInfo/States/Entanglement.lean | 3 +-- 9 files changed, 9 insertions(+), 18 deletions(-) diff --git a/QuantumInfo/Channels/Unbundled.lean b/QuantumInfo/Channels/Unbundled.lean index 8174091fe..df0315d23 100644 --- a/QuantumInfo/Channels/Unbundled.lean +++ b/QuantumInfo/Channels/Unbundled.lean @@ -310,8 +310,7 @@ theorem of_Fintype {M : MatrixMap A B R} (h : IsCompletelyPositive M) · intro h x hx specialize h (hx.submatrix (fun p : A × Fin n => (p.1, e.symm p.2))) rw [h_submatrix] - simp only [LinearMap.coe_comp, Function.comp_apply, submatrix_apply] - exact h.submatrix _ + simpa only [LinearMap.coe_comp, Function.comp_apply, submatrix_apply] using h.submatrix _ /- Every `MatrixMap` that `IsCompletelyPositive` also `IsPositiveMap`. -/ theorem IsPositive {M : MatrixMap A B R} diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index edd754ef8..aa61a262e 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -46,8 +46,7 @@ sum is 1. The fact that the values are at most 1 is derived as a consequence. -/ def mk' (f : α → ℝ) (h₁ : ∀i, 0 ≤ f i) (hN : ∑ i, f i = 1) : ProbDistribution α := have h₃ : ∀x, f x ≤ 1 := by intro x - simp [← hN, Fintype.sum_eq_sum_compl_add x] - exact Finset.sum_nonneg' h₁ + simpa [← hN, Fintype.sum_eq_sum_compl_add x] using Finset.sum_nonneg' h₁ ⟨ fun i ↦ ⟨f i, ⟨h₁ i, h₃ i⟩⟩, hN⟩ instance instFunLikeProb : FunLike (ProbDistribution α) α Prob where diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 5c0531dbf..de8febf8a 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -431,8 +431,7 @@ theorem traceFunctional_eq_iSup_f_alpha (hα : 1 < α) (ρ σ : MState d) (hker Q̃_ α(ρ‖σ) = ⨆ (H : {H : HermitianMat d ℂ // 0 ≤ H}), f_alpha α H.1 ρ σ := by rw [@ciSup_eq_of_forall_le_of_forall_lt_exists_gt] · intro i - rw [← f_alpha_at_optimizer hα ρ σ] - exact f_alpha_le_at_optimizer hα ρ σ i i.2 hker + simpa [← f_alpha_at_optimizer hα ρ σ] using f_alpha_le_at_optimizer hα ρ σ i i.2 hker · intro w hw exact ⟨⟨H_hat α ρ σ, H_hat_nonneg ρ σ⟩, hw.trans_le (f_alpha_at_optimizer hα ρ σ ▸ le_rfl)⟩ diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 1452ff06b..e9011a35d 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -199,8 +199,7 @@ theorem V_rho_isometry [Nonempty dB] (ρAB : HermitianMat (dA × dB) ℂ) (hρ : have h_pos_def : (ρAB.traceRight⁻¹.sqrt : Matrix dA dA ℂ) * (ρAB.traceRight : Matrix dA dA ℂ) * (ρAB.traceRight⁻¹.sqrt : Matrix dA dA ℂ) = 1 := by convert HermitianMat.sqrt_inv_mul_self_mul_sqrt_inv_eq_one _; exact PosDef_traceRight _ hρ - rw [← h_pos_def] - exact V_rho_conj_mul_self_eq ρAB hρ + simpa [← h_pos_def] using V_rho_conj_mul_self_eq ρAB hρ /-- V_sigma is an isometry. diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 77fa226b2..96ff0e205 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -415,8 +415,7 @@ theorem one_div_operatorConvexOn_Ioi : -- rewrite the middle block matrix as `M` simpa [← hM] using posConj -- rewrite the goal using the computed conjugation - rw [← hconj] - exact posConj' + simpa [← hconj] using posConj' have hinvC : invC ≤ D := by have hDinvC : 0 ≤ D - invC := by simpa using diff --git a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean index a647151f9..49043a307 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Trace.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Trace.lean @@ -141,8 +141,7 @@ theorem trace_eq_zero_iff (A : HermitianMat n 𝕜) : A.trace = 0 ↔ A.mat.trac simp [← trace_eq_trace_rc] theorem trace_eq_one_iff (A : HermitianMat n 𝕜) : A.trace = 1 ↔ A.mat.trace = 1 := by - rw [← trace_eq_trace_rc] - exact ⟨mod_cast id, mod_cast id⟩ + simp [← trace_eq_trace_rc] @[simp] theorem trace_reindex (A : HermitianMat n ℂ) (e : n ≃ m) : diff --git a/QuantumInfo/ForMathlib/Majorization.lean b/QuantumInfo/ForMathlib/Majorization.lean index c97c42f30..d0adaa010 100644 --- a/QuantumInfo/ForMathlib/Majorization.lean +++ b/QuantumInfo/ForMathlib/Majorization.lean @@ -914,8 +914,7 @@ lemma weak_log_maj_sum_le {n : ℕ} · simp [Fin.sum_univ_castSucc, h_last] refine le_add_of_le_of_nonneg (ih (fun i => hx_nn _) (fun i => hy_nn _) (fun i j hij => hx_anti hij) (fun i j hij => hy_anti hij) ?_) (hy_nn _) intro k hk - simp - exact h_log_maj k (by linarith) + simpa using h_log_maj k (by linarith) · -- Since $x_{\text{last}} > 0$, we have $x_i > 0$ for all $i$. have hx_pos : ∀ i, 0 < x i := by exact fun i => lt_of_lt_of_le (lt_of_le_of_ne (hx_nn _) (Ne.symm h_last)) (hx_anti (Fin.le_last _)) diff --git a/QuantumInfo/ResourceTheory/FreeState.lean b/QuantumInfo/ResourceTheory/FreeState.lean index 063939b33..2e0c2210d 100644 --- a/QuantumInfo/ResourceTheory/FreeState.lean +++ b/QuantumInfo/ResourceTheory/FreeState.lean @@ -117,8 +117,7 @@ open ComplexOrder in theorem PosDef.prod {ρ : MState (H i)} {σ : MState (H j)} (hρ : ρ.m.PosDef) (hσ : σ.m.PosDef) : (ρ ⊗ᵣ σ).m.PosDef := by have : (ρ ⊗ᴹ σ).m.PosDef := MState.PosDef.kron hρ hσ - rw [prodRelabel] - exact MState.PosDef.relabel this (prodEquiv i j) + simpa [prodRelabel] using MState.PosDef.relabel this (prodEquiv i j) --BAD old attempt at PNat powers -- /-- Powers of spaces. Defined for `PNat` so that we don't have zeroth powers. -/ diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 3723eb546..76667a7b0 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -84,8 +84,7 @@ theorem convex_roof_ne_top : ∀ ρ, convex_roof_ENNReal g ρ ≠ ∞ := fun ρ simp only [convex_roof_ENNReal, ne_eq, iInf_eq_top, coe_ne_top, imp_false, not_forall] use ⟨Fintype.card d, Fintype.card_pos⟩ have ed : d ≃ Fin ↑(⟨Fintype.card d, Fintype.card_pos⟩ : ℕ+) := by - simp only - exact Fintype.equivFin d + simpa only using Fintype.equivFin d use (congrPEnsemble ed) <| spectral_ensemble ρ rw [mix_congrPEnsemble_eq_mix ed] push Not From 4a2da0362b8f7091312997065ddce671eb075a7d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:36:23 -0700 Subject: [PATCH 357/498] refactor: golf unfold setup proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/AdjFDeriv.lean | 3 +-- Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean | 1 - Physlib/Relativity/PauliMatrices/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/ToComplex.lean | 3 +-- Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean | 3 +-- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 3 +-- Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean | 3 +-- QuantumInfo/ClassicalInfo/Distribution.lean | 3 +-- .../TraceInequality/GeneralizedPerspectiveFunction.lean | 3 +-- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 3 +-- 10 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Physlib/Mathematics/Calculus/AdjFDeriv.lean b/Physlib/Mathematics/Calculus/AdjFDeriv.lean index cc035313e..2c9e2a65e 100644 --- a/Physlib/Mathematics/Calculus/AdjFDeriv.lean +++ b/Physlib/Mathematics/Calculus/AdjFDeriv.lean @@ -130,8 +130,7 @@ lemma gradient_eq_adjFDeriv {f : U → 𝕜} {x : U} (hf : DifferentiableAt 𝕜 f x) : gradient f x = adjFDeriv 𝕜 f x 1 := by apply ext_inner_right 𝕜 - unfold gradient - simp [hf.hasAdjFDerivAt.hasAdjoint_fderiv.adjoint_inner_left] + simp [gradient, hf.hasAdjFDerivAt.hasAdjoint_fderiv.adjoint_inner_left] attribute [fun_prop] HasAdjFDerivAt.differentiableAt diff --git a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean index 57ecc5cec..9927e1cc3 100644 --- a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean @@ -197,7 +197,6 @@ lemma norm_eq_norm_of_metricNormedAddCommGroup (g : RiemannianMetric I n M) (x : (@NormedAddCommGroup.toNorm _ (TangentSpace.metricNormedAddCommGroup g x)) v := by unfold norm let normed_group := TangentSpace.metricNormedAddCommGroup g x - unfold TangentSpace.metricNormedAddCommGroup simp only [inner_apply] rfl diff --git a/Physlib/Relativity/PauliMatrices/Basic.lean b/Physlib/Relativity/PauliMatrices/Basic.lean index 7e4e7b5b9..e6afd7670 100644 --- a/Physlib/Relativity/PauliMatrices/Basic.lean +++ b/Physlib/Relativity/PauliMatrices/Basic.lean @@ -92,8 +92,7 @@ lemma pauliMatrix_mul_self (μ : Fin 1 ⊕ Fin 3) : (σ μ) * (σ μ) = 1 := by fin_cases μ all_goals - dsimp [pauliMatrix] - simp [one_fin_two] + simp [pauliMatrix, one_fin_two] instance pauliMatrixInvertiable (μ : Fin 1 ⊕ Fin 3) : Invertible (σ μ) := by use σ μ diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index 3b8987abf..9ca468166 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -836,8 +836,7 @@ lemma contrT_toComplex {n : ℕ} (p := Pure.basisVector (colorToComplex ∘ c) (ComponentIdx.complexify b))] exact toComplex_contrP_basisVector h b · -- zero tensor - dsimp [P] - simp + simp [P] · -- scalar multiplication intro r t ht dsimp [P] at ht ⊢ diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean index b5f108620..d681ac10e 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean @@ -248,8 +248,7 @@ lemma RotationsAbout.fromOrigin_comp_toOrigin : apply Subtype.ext simp only [MonoidHom.coe_comp, Function.comp_apply, MonoidHom.id_apply, SetLike.coe_eq_coe] unfold RotationsAbout.toOrigin - unfold RotationsAbout.fromOrigin - simp [mul_assoc] + simp [RotationsAbout.fromOrigin, mul_assoc] /-- `RotationsAbout.fromOrigin p` followed by `RotationsAbout.toOrigin p` is the identity; the backward leg of the isomorphism `RotationsAboutEquiv`. -/ diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index 0bbc463e8..60197119f 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -1157,8 +1157,7 @@ lemma distDiv_norm_zpow_smul_repr_self_eq_smul ext η let p : ℕ := Int.toNat (q + (d : ℤ)) have hp_int : (p : ℤ) = q + (d : ℤ) := by - dsimp [p] - exact Int.toNat_of_nonneg (le_of_lt hq) + simpa [p] using Int.toNat_of_nonneg (le_of_lt hq) have hp_pos : 0 < p := by have : (0 : ℤ) < (p : ℤ) := by simpa [hp_int] using hq exact_mod_cast this diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index 9adbbc32d..dc57eaef1 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -121,8 +121,7 @@ lemma log_probability Real.log (𝓒.probability T i) = - (β T) * 𝓒.energy i - Real.log (𝓒.mathematicalPartitionFunction T) := by have hZpos := mathematicalPartitionFunction_pos (𝓒:=𝓒) (T:=T) - unfold probability - simp [Real.log_div, hZpos.ne', Real.log_exp, sub_eq_add_neg] + simp [probability, Real.log_div, hZpos.ne', Real.log_exp, sub_eq_add_neg] /-- Auxiliary identity: `kB · β = 1 / T`. `β` is defined as `1 / (kB · T)` (see `Temperature.β`). -/ diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index aa61a262e..70d097a7f 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -169,8 +169,7 @@ def congr (σ : α ≃ β) : ProbDistribution α ≃ ProbDistribution β := by case left_inv => intro d ext i - unfold relabel - simp only [← fun_eq_val, Equiv.symm_apply_apply, Subtype.coe_eta] + simp only [relabel, ← fun_eq_val, Equiv.symm_apply_apply, Subtype.coe_eta] case right_inv => intro d ext i diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean index 65d99b379..8e5402d94 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean @@ -172,8 +172,7 @@ private lemma hpow_continuousOn omit [Nontrivial ℋ] in private lemma hSqrt_selfAdjoint (h : ℝ → ℝ) (B : L ℋ) : IsSelfAdjoint (hSqrt (ℋ := ℋ) h B) := by - dsimp [hSqrt, cfcR] - exact cfc_predicate _ _ + simp [hSqrt, cfcR] omit [Nontrivial ℋ] in private lemma hInvSqrt_selfAdjoint (h : ℝ → ℝ) (B : L ℋ) : diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 96ff0e205..7329fd069 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -231,8 +231,7 @@ private lemma posSemidef_block_one_inv {A : 𝓐} (hA : IsSelfAdjoint A) have posV : Matrix.PosSemidef (Matrix.vecMulVec v (star v)) := by simpa using (Matrix.posSemidef_vecMulVec_self_star (R := 𝓐) v) have hsqrtA : IsSelfAdjoint sqrtA := by - dsimp [sqrtA, cfcR] - exact cfc_predicate _ _ + simp [sqrtA, cfcR] have hinvSqrtA : IsSelfAdjoint invSqrtA := by dsimp [invSqrtA, cfcR] exact cfc_predicate _ _ From f465d59015d6b46fc2318738a4bdc430a6d5d82b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:39:10 -0700 Subject: [PATCH 358/498] refactor: golf follow-up unfold setup proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean | 3 +-- Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean | 3 +-- QuantumInfo/ClassicalInfo/Distribution.lean | 3 +-- .../TraceInequality/GeneralizedPerspectiveFunction.lean | 3 +-- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean index d681ac10e..16b64dd06 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean @@ -247,8 +247,7 @@ lemma RotationsAbout.fromOrigin_comp_toOrigin : intro x apply Subtype.ext simp only [MonoidHom.coe_comp, Function.comp_apply, MonoidHom.id_apply, SetLike.coe_eq_coe] - unfold RotationsAbout.toOrigin - simp [RotationsAbout.fromOrigin, mul_assoc] + simp [RotationsAbout.toOrigin, RotationsAbout.fromOrigin, mul_assoc] /-- `RotationsAbout.fromOrigin p` followed by `RotationsAbout.toOrigin p` is the identity; the backward leg of the isomorphism `RotationsAboutEquiv`. -/ diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index dc57eaef1..804ea72a7 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -153,8 +153,7 @@ lemma thermodynamicEntropy_eq_differentialEntropy_sub_correction - Real.log (𝓒.mathematicalPartitionFunction T) := by intro i have : 0 < 𝓒.mathematicalPartitionFunction T := hZpos - unfold probability - simp [Real.log_div (Real.exp_pos _).ne' this.ne', Real.log_exp, sub_eq_add_neg] + simp [probability, Real.log_div (Real.exp_pos _).ne' this.ne', Real.log_exp, sub_eq_add_neg] have h_log_phys_pt : ∀ i, Real.log (𝓒.physicalProbability T i) = Real.log (𝓒.probability T i) diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 70d097a7f..9f8220d49 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -173,8 +173,7 @@ def congr (σ : α ≃ β) : ProbDistribution α ≃ ProbDistribution β := by case right_inv => intro d ext i - unfold relabel - simp only [← fun_eq_val, Equiv.apply_symm_apply, Subtype.coe_eta] + simp only [relabel, ← fun_eq_val, Equiv.apply_symm_apply, Subtype.coe_eta] @[simp] theorem congr_apply (σ : α ≃ β) (d : ProbDistribution α) (j : β): (congr σ d) j = d (σ.symm j) := rfl diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean index 8e5402d94..90f39e3df 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean @@ -177,8 +177,7 @@ private lemma hSqrt_selfAdjoint (h : ℝ → ℝ) (B : L ℋ) : omit [Nontrivial ℋ] in private lemma hInvSqrt_selfAdjoint (h : ℝ → ℝ) (B : L ℋ) : IsSelfAdjoint (hInvSqrt (ℋ := ℋ) h B) := by - dsimp [hInvSqrt, cfcR] - exact cfc_predicate _ _ + simp [hInvSqrt, cfcR] omit [Nontrivial ℋ] in private lemma hSqrt_mul_hInvSqrt_eq_one diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 7329fd069..a4e818f1b 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -233,8 +233,7 @@ private lemma posSemidef_block_one_inv {A : 𝓐} (hA : IsSelfAdjoint A) have hsqrtA : IsSelfAdjoint sqrtA := by simp [sqrtA, cfcR] have hinvSqrtA : IsSelfAdjoint invSqrtA := by - dsimp [invSqrtA, cfcR] - exact cfc_predicate _ _ + simp [invSqrtA, cfcR] have hcont_sqrt : ContinuousOn (fun x : ℝ ↦ x ^ ((1 : ℝ) / 2)) (spectrum ℝ A) := fun x hx => (Real.continuousAt_rpow_const x _ (Or.inl (ne_of_gt (As hx)))).continuousWithinAt have hcont_invSqrt : ContinuousOn (fun x : ℝ ↦ x ^ ((-1 : ℝ) / 2)) (spectrum ℝ A) := From a17605e4f6c306de33e593881c0b9c51a78024b9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:44:25 -0700 Subject: [PATCH 359/498] refactor: golf remaining unfold setup proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean | 4 +--- .../StatisticalMechanics/CanonicalEnsemble/Lemmas.lean | 3 +-- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 9 +++------ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean index 16b64dd06..935684d49 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean @@ -258,9 +258,7 @@ lemma RotationsAbout.toOrigin_comp_fromOrigin : intro x apply Subtype.ext simp only [MonoidHom.coe_comp, Function.comp_apply, MonoidHom.id_apply, SetLike.coe_eq_coe] - unfold RotationsAbout.toOrigin - unfold RotationsAbout.fromOrigin - simp [mul_assoc] + simp [RotationsAbout.toOrigin, RotationsAbout.fromOrigin, mul_assoc] /-- API feature: conjugation by the translation `T(p)` exhibits the rotations about `p` as isomorphic to the rotations about the origin `RotationGroup n`. -/ diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index 804ea72a7..81e163e82 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -698,8 +698,7 @@ lemma heatCapacity_eq_deriv_meanEnergyBeta unfold heatCapacity meanEnergy_T have h_U_eq_comp : (𝓒.meanEnergy_T) = fun t : ℝ => (𝓒.meanEnergyBeta) (betaFromReal t) := by funext t - dsimp [meanEnergy_T, meanEnergyBeta, betaFromReal] - simp + simp [meanEnergy_T, meanEnergyBeta, betaFromReal] let dUdβ := derivWithin (𝓒.meanEnergyBeta) (Set.Ioi 0) (T.β : ℝ) have h_chain := chain_rule_T_beta (F:=𝓒.meanEnergyBeta) (F':=dUdβ) T hT_pos hU_deriv have h_UD : diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index a4e818f1b..28f26e690 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -372,8 +372,7 @@ theorem one_div_operatorConvexOn_Ioi : star U * (!![C, 1; 1, D] : Matrix (Fin 2) (Fin 2) (𝓐)) * U = Matrix.diagonal (fun i : Fin 2 => if i = 0 then C else D - invC) := by have hInvC_sa : IsSelfAdjoint invC := by - dsimp [invC, cfcR] - exact cfc_predicate _ _ + simp [invC, cfcR] have hcont_inv : ContinuousOn (fun x : ℝ ↦ x⁻¹) (spectrum ℝ C) := fun x hx => (continuousAt_inv₀ (ne_of_gt (specC hx))).continuousWithinAt have invC_mul_C : invC * C = (1 : 𝓐) := by @@ -778,8 +777,7 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → have hB0 : 0 ≤ B := nonneg_of_spectrum_subset_Ici0 (T := B) hB Bs have hAB0 : 0 ≤ AB := by - dsimp [AB] - exact add_nonneg (smul_nonneg hu0' hA0) (smul_nonneg hu0 hB0) + simpa [AB] using add_nonneg (smul_nonneg hu0' hA0) (smul_nonneg hu0 hB0) have ABs : spectrum ℝ AB ⊆ Set.Ici (0 : ℝ) := by intro x hx have hx0 : (0 : ℝ) ≤ x := @@ -1991,8 +1989,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using Bs hx exact le_of_lt (Real.rpow_pos_of_pos hx0 r) have hDr0 : 0 ≤ Dr := by - dsimp [Dr] - exact add_nonneg (smul_nonneg (sub_nonneg.mpr ht1) hAr0) (smul_nonneg ht0 hBr0) + simpa [Dr] using add_nonneg (smul_nonneg (sub_nonneg.mpr ht1) hAr0) (smul_nonneg ht0 hBr0) have hCr_sa : IsSelfAdjoint Cr := by dsimp [Cr, cfcR] exact cfc_predicate _ _ From 524f1833db8e38f40ad168b6c9c4cdc99f8e0b9e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:45:54 -0700 Subject: [PATCH 360/498] refactor: golf Lowner-Heinz self-adjoint witnesses Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 28f26e690..de33a2b1b 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1991,14 +1991,11 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 have hDr0 : 0 ≤ Dr := by simpa [Dr] using add_nonneg (smul_nonneg (sub_nonneg.mpr ht1) hAr0) (smul_nonneg ht0 hBr0) have hCr_sa : IsSelfAdjoint Cr := by - dsimp [Cr, cfcR] - exact cfc_predicate _ _ + simp [Cr, cfcR] have hAr_sa : IsSelfAdjoint Ar := by - dsimp [Ar, cfcR] - exact cfc_predicate _ _ + simp [Ar, cfcR] have hBr_sa : IsSelfAdjoint Br := by - dsimp [Br, cfcR] - exact cfc_predicate _ _ + simp [Br, cfcR] have hspCr : spectrum ℝ Cr ⊆ Set.Ioi (0 : ℝ) := by have hcontC : ContinuousOn (fun x : ℝ ↦ x ^ r) (spectrum ℝ C) := by intro x hx @@ -2058,11 +2055,9 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 ≤ (1 - t) • cfcR (fun x : ℝ ↦ 1 / x) Ar + t • cfcR (fun x : ℝ ↦ 1 / x) Br := by have hAr_sa : IsSelfAdjoint Ar := by - dsimp [Ar, cfcR] - exact cfc_predicate _ _ + simp [Ar, cfcR] have hBr_sa : IsSelfAdjoint Br := by - dsimp [Br, cfcR] - exact cfc_predicate _ _ + simp [Br, cfcR] have hspAr : spectrum ℝ Ar ⊆ Set.Ioi (0 : ℝ) := by have hcontA : ContinuousOn (fun x : ℝ ↦ x ^ r) (spectrum ℝ A) := by intro x hx From 0110d0c3f818c30a0d25ae8d1cc5a1f31fbc10c7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:47:17 -0700 Subject: [PATCH 361/498] refactor: golf Lowner-Heinz interval setup proofs Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index de33a2b1b..de95ee4f2 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -752,8 +752,7 @@ theorem ratio_add_t_operatorConcaveOn_Ici : ∀ (t : ℝ), 0 < t → + t • cfcR (fun x : ℝ ↦ 1 / (x + t)) T := by simp [invfun] set AB : 𝓐 := (1 - u) • A + u • B have hAB : IsSelfAdjoint AB := by - dsimp [AB] - simpa using + simpa [AB] using (IsSelfAdjoint.smul (by simp [IsSelfAdjoint]) hA).add (IsSelfAdjoint.smul (by simp [IsSelfAdjoint]) hB) -- apply operator convexity of `-(x/(x+t))` @@ -1766,10 +1765,8 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- let q : ℝ := -p have hq : q ∈ Set.Icc (0 : ℝ) 1 := by constructor - · dsimp [q] - exact neg_nonneg.mpr hp.2 - · dsimp [q] - simpa using (neg_le_neg hp.1) + · simpa [q] using neg_nonneg.mpr hp.2 + · simpa [q] using (neg_le_neg hp.1) have hBAq : cfcR (fun x : ℝ ↦ x ^ q) B ≤ cfcR (fun x : ℝ ↦ x ^ q) A := by have hspA' : spectrum ℝ A ⊆ Set.Ici (0 : ℝ) := by intro x hx @@ -1930,10 +1927,8 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 let r : ℝ := -p have hr : r ∈ Set.Icc (0 : ℝ) 1 := by constructor - · dsimp [r] - exact neg_nonneg.mpr hp.2 - · dsimp [r] - simpa using (neg_le_neg hp.1) + · simpa [r] using neg_nonneg.mpr hp.2 + · simpa [r] using (neg_le_neg hp.1) -- convex combination set C : 𝓐 := (1 - t) • A + t • B have hC : IsSelfAdjoint C := by From 259cd1650ef6388c55352ea8f7c1056bf64725e6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:48:30 -0700 Subject: [PATCH 362/498] refactor: golf Lowner-Heinz spectrum witnesses Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index de95ee4f2..63ad07825 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1799,8 +1799,7 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- exact (Real.continuousAt_rpow_const x q (Or.inl (ne_of_gt hx0))).continuousWithinAt have hspec : spectrum ℝ Aq = (fun x : ℝ ↦ x ^ q) '' spectrum ℝ A := by - dsimp [Aq, cfcR] - simpa using + simpa [Aq, cfcR] using (cfc_map_spectrum (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x ^ q) (a := A) (ha := hA_sa) (hf := hcontA)) intro y hy @@ -1816,8 +1815,7 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- exact (Real.continuousAt_rpow_const x q (Or.inl (ne_of_gt hx0))).continuousWithinAt have hspec : spectrum ℝ Bq = (fun x : ℝ ↦ x ^ q) '' spectrum ℝ B := by - dsimp [Bq, cfcR] - simpa using + simpa [Bq, cfcR] using (cfc_map_spectrum (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x ^ q) (a := B) (ha := hB_sa) (hf := hcontB)) intro y hy @@ -1998,8 +1996,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 exact (Real.continuousAt_rpow_const x r (Or.inl (ne_of_gt hx0))).continuousWithinAt have hspec : spectrum ℝ Cr = (fun x : ℝ ↦ x ^ r) '' spectrum ℝ C := by - dsimp [Cr, cfcR] - simpa using + simpa [Cr, cfcR] using (cfc_map_spectrum (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x ^ r) (a := C) (ha := hC) (hf := hcontC)) intro y hy @@ -2014,8 +2011,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 exact (Real.continuousAt_rpow_const x r (Or.inl (ne_of_gt hx0))).continuousWithinAt have hspec : spectrum ℝ Ar = (fun x : ℝ ↦ x ^ r) '' spectrum ℝ A := by - dsimp [Ar, cfcR] - simpa using + simpa [Ar, cfcR] using (cfc_map_spectrum (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x ^ r) (a := A) (ha := hA) (hf := hcontA)) intro y hy @@ -2030,8 +2026,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 exact (Real.continuousAt_rpow_const x r (Or.inl (ne_of_gt hx0))).continuousWithinAt have hspec : spectrum ℝ Br = (fun x : ℝ ↦ x ^ r) '' spectrum ℝ B := by - dsimp [Br, cfcR] - simpa using + simpa [Br, cfcR] using (cfc_map_spectrum (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x ^ r) (a := B) (ha := hB) (hf := hcontB)) intro y hy From 857d2de63cb2e02518302a8e714769c0a4b37b44 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:50:01 -0700 Subject: [PATCH 363/498] refactor: golf Lowner-Heinz CFC composition witnesses Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 63ad07825..2e77c0ad2 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -2055,8 +2055,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 exact (Real.continuousAt_rpow_const x r (Or.inl (ne_of_gt hx0))).continuousWithinAt have hspec : spectrum ℝ Ar = (fun x : ℝ ↦ x ^ r) '' spectrum ℝ A := by - dsimp [Ar, cfcR] - simpa using + simpa [Ar, cfcR] using (cfc_map_spectrum (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x ^ r) (a := A) (ha := hA) (hf := hcontA)) intro y hy @@ -2071,8 +2070,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 exact (Real.continuousAt_rpow_const x r (Or.inl (ne_of_gt hx0))).continuousWithinAt have hspec : spectrum ℝ Br = (fun x : ℝ ↦ x ^ r) '' spectrum ℝ B := by - dsimp [Br, cfcR] - simpa using + simpa [Br, cfcR] using (cfc_map_spectrum (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x ^ r) (a := B) (ha := hB) (hf := hcontB)) intro y hy @@ -2101,8 +2099,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 have hcomp : cfcR (fun y : ℝ ↦ 1 / y) (cfcR (fun x : ℝ ↦ x ^ r) A) = cfcR (fun x : ℝ ↦ 1 / (x ^ r)) A := by - dsimp [cfcR] - simpa [Function.comp] using + simpa [cfcR, Function.comp] using (cfc_comp' (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (g := fun y : ℝ ↦ 1 / y) (f := fun x : ℝ ↦ x ^ r) (a := A) (hg := hg) (hf := hcontA) (ha := hA)).symm have hL : @@ -2136,8 +2133,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 have hcomp : cfcR (fun y : ℝ ↦ 1 / y) (cfcR (fun x : ℝ ↦ x ^ r) B) = cfcR (fun x : ℝ ↦ 1 / (x ^ r)) B := by - dsimp [cfcR] - simpa [Function.comp] using + simpa [cfcR, Function.comp] using (cfc_comp' (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (g := fun y : ℝ ↦ 1 / y) (f := fun x : ℝ ↦ x ^ r) (a := B) (hg := hg) (hf := hcontB) (ha := hB)).symm have hL : @@ -2171,8 +2167,7 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 have hcomp : cfcR (fun y : ℝ ↦ 1 / y) (cfcR (fun x : ℝ ↦ x ^ r) C) = cfcR (fun x : ℝ ↦ 1 / (x ^ r)) C := by - dsimp [cfcR] - simpa [Function.comp] using + simpa [cfcR, Function.comp] using (cfc_comp' (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (g := fun y : ℝ ↦ 1 / y) (f := fun x : ℝ ↦ x ^ r) (a := C) (hg := hg) (hf := hcontC) (ha := hC)).symm have hL : From c24d1451d68d37c4a2fc8a1c2e3a8a328ef01f84 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:51:22 -0700 Subject: [PATCH 364/498] refactor: golf Lowner-Heinz shifted CFC witnesses Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 2e77c0ad2..91a8cedf7 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -501,18 +501,15 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → have C_nonneg : 0 ≤ C := by simpa [C] using add_nonneg (smul_nonneg (sub_nonneg.mpr hθ1) A_nonneg) (smul_nonneg hθ0 B_nonneg) have hA_shift : cfcR shift A = A + T := by - dsimp [cfcR, shift, T] - simpa [cfc_id' (R := ℝ) (a := A) (ha := hA)] using + simpa [cfcR, shift, T, cfc_id' (R := ℝ) (a := A) (ha := hA)] using (cfc_add_const (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (r := t) (f := fun x : ℝ ↦ x) (a := A) (ha := hA)) have hB_shift : cfcR shift B = B + T := by - dsimp [cfcR, shift, T] - simpa [cfc_id' (R := ℝ) (a := B) (ha := hB)] using + simpa [cfcR, shift, T, cfc_id' (R := ℝ) (a := B) (ha := hB)] using (cfc_add_const (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (r := t) (f := fun x : ℝ ↦ x) (a := B) (ha := hB)) have hC_shift : cfcR shift C = C + T := by - dsimp [cfcR, shift, T] - simpa [cfc_id' (R := ℝ) (a := C) (ha := hC)] using + simpa [cfcR, shift, T, cfc_id' (R := ℝ) (a := C) (ha := hC)] using (cfc_add_const (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (r := t) (f := fun x : ℝ ↦ x) (a := C) (ha := hC)) set A1 : 𝓐 := A + T @@ -1846,8 +1843,7 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- have hcomp : cfcR (fun y : ℝ ↦ 1 / y) (cfcR (fun x : ℝ ↦ x ^ q) A) = cfcR (fun x : ℝ ↦ 1 / (x ^ q)) A := by - dsimp [cfcR] - simpa [Function.comp] using + simpa [cfcR, Function.comp] using (cfc_comp' (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (g := fun y : ℝ ↦ 1 / y) (f := fun x : ℝ ↦ x ^ q) (a := A) (hg := hg) (hf := hcontA) (ha := hA_sa)).symm have hL : @@ -1882,8 +1878,7 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- have hcomp : cfcR (fun y : ℝ ↦ 1 / y) (cfcR (fun x : ℝ ↦ x ^ q) B) = cfcR (fun x : ℝ ↦ 1 / (x ^ q)) B := by - dsimp [cfcR] - simpa [Function.comp] using + simpa [cfcR, Function.comp] using (cfc_comp' (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (g := fun y : ℝ ↦ 1 / y) (f := fun x : ℝ ↦ x ^ q) (a := B) (hg := hg) (hf := hcontB) (ha := hB_sa)).symm have hL : From cf352ec033d3b155f6e9096ebd714d012e45bb21 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:53:02 -0700 Subject: [PATCH 365/498] refactor: golf Lowner-Heinz inverse witnesses Co-authored-by: Claude Opus 4.8 --- .../TraceInequality/LownerHeinzCore.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 91a8cedf7..2efdf024f 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -364,10 +364,8 @@ theorem one_div_operatorConvexOn_Ioi : have hU : IsUnit U := by let V : Matrix (Fin 2) (Fin 2) (𝓐) := !![(1 : 𝓐), invC; 0, 1] refine ⟨⟨U, V, ?_, ?_⟩, rfl⟩ - · dsimp [U, V] - simp [Matrix.one_fin_two] - · dsimp [U, V] - simp [Matrix.one_fin_two] + · simp [U, V, Matrix.one_fin_two] + · simp [U, V, Matrix.one_fin_two] have hconj : star U * (!![C, 1; 1, D] : Matrix (Fin 2) (Fin 2) (𝓐)) * U = Matrix.diagonal (fun i : Fin 2 => if i = 0 then C else D - invC) := by @@ -579,13 +577,11 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → have hval : cfc shift C = C + T := by simpa [cfcR, shift] using hC_shift simpa [cfcR, shift, hval] using h' have hA1_inv : cfcR (fun x : ℝ ↦ x⁻¹) A1 = Ring.inverse A1 := by - dsimp [cfcR] - simpa [cfc_id' (R := ℝ) (a := A1) (ha := hA1_sa)] using + simpa [cfcR, cfc_id' (R := ℝ) (a := A1) (ha := hA1_sa)] using (cfc_inv (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x) (a := A1) (fun x hx ↦ ne_of_gt (specA1 hx)) (ha := hA1_sa)) have hB1_inv : cfcR (fun x : ℝ ↦ x⁻¹) B1 = Ring.inverse B1 := by - dsimp [cfcR] - simpa [cfc_id' (R := ℝ) (a := B1) (ha := hB1_sa)] using + simpa [cfcR, cfc_id' (R := ℝ) (a := B1) (ha := hB1_sa)] using (cfc_inv (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x) (a := B1) (fun x hx ↦ ne_of_gt (specB1 hx)) (ha := hB1_sa)) have hA_eq : cfcR (fun x : ℝ ↦ (x + t)⁻¹) A = cfcR (fun x : ℝ ↦ x⁻¹) A1 := by @@ -611,8 +607,7 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → have hC1_ne0 : ∀ x ∈ spectrum ℝ C1, (x : ℝ) ≠ 0 := fun x hx ↦ ne_of_gt (specC1 hx) have hC1_sa : IsSelfAdjoint C1 := by simpa [hC1] using (hC.add hT) have hC1_inv : cfcR (fun x : ℝ ↦ x⁻¹) C1 = Ring.inverse C1 := by - dsimp [cfcR] - simpa [cfc_id' (R := ℝ) (a := C1) (ha := hC1_sa)] using + simpa [cfcR, cfc_id' (R := ℝ) (a := C1) (ha := hC1_sa)] using (cfc_inv (R := ℝ) (A := 𝓐) (p := IsSelfAdjoint) (f := fun x : ℝ ↦ x) (a := C1) hC1_ne0 (ha := hC1_sa)) have hC_eq : cfcR (fun x : ℝ ↦ (x + t)⁻¹) C = cfcR (fun x : ℝ ↦ x⁻¹) C1 := by From 445ce36e1f1c1c7216f5e53233e060060025ac4b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:54:22 -0700 Subject: [PATCH 366/498] refactor: golf Lowner-Heinz positivity witnesses Co-authored-by: Claude Opus 4.8 --- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 5 ----- 1 file changed, 5 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 2efdf024f..77a8dc8c5 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1772,13 +1772,11 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- let Aq : 𝓐 := cfcR (fun x : ℝ ↦ x ^ q) A let Bq : 𝓐 := cfcR (fun x : ℝ ↦ x ^ q) B have hAq0 : 0 ≤ Aq := by - dsimp [Aq, cfcR] refine cfc_nonneg ?_ intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using hspA hx exact le_of_lt (Real.rpow_pos_of_pos hx0 _) have hBq0 : 0 ≤ Bq := by - dsimp [Bq, cfcR] refine cfc_nonneg ?_ intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using hspB hx @@ -1954,19 +1952,16 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 have h_inv1 : cfcR (fun x : ℝ ↦ 1 / x) Cr ≤ cfcR (fun x : ℝ ↦ 1 / x) Dr := by have hCr0 : 0 ≤ Cr := by - dsimp [Cr, cfcR] refine cfc_nonneg ?_ intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using Cs hx exact le_of_lt (Real.rpow_pos_of_pos hx0 r) have hAr0 : 0 ≤ Ar := by - dsimp [Ar, cfcR] refine cfc_nonneg ?_ intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using As hx exact le_of_lt (Real.rpow_pos_of_pos hx0 r) have hBr0 : 0 ≤ Br := by - dsimp [Br, cfcR] refine cfc_nonneg ?_ intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using Bs hx From 089ceba437c0a26f4abc93a6a430507e539a2a14 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:55:36 -0700 Subject: [PATCH 367/498] refactor: golf Lowner-Heinz CFC congruence witnesses Co-authored-by: Claude Opus 4.8 --- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 5 ----- 1 file changed, 5 deletions(-) diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 77a8dc8c5..4bdf25a76 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -1847,7 +1847,6 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ q) A) = cfcR (fun x : ℝ ↦ (x ^ q)⁻¹) A := by simpa [one_div] using hcomp rw [hcomp'] - dsimp [cfcR] apply cfc_congr intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using hspA hx @@ -1882,7 +1881,6 @@ theorem power_Icc_neg_one_zero_neg_operatorMonotoneOn_Ioi : ∀ p ∈ Set.Icc (- cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ q) B) = cfcR (fun x : ℝ ↦ (x ^ q)⁻¹) B := by simpa [one_div] using hcomp rw [hcomp'] - dsimp [cfcR] apply cfc_congr intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using hspB hx @@ -2095,7 +2093,6 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) A) = cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) A := by simpa [one_div] using hcomp rw [hcomp'] - dsimp [cfcR] apply cfc_congr intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using As hx @@ -2129,7 +2126,6 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) B) = cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) B := by simpa [one_div] using hcomp rw [hcomp'] - dsimp [cfcR] apply cfc_congr intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using Bs hx @@ -2163,7 +2159,6 @@ theorem power_Icc_neg_one_zero_neg_operatorConcaveOn_Ioi : ∀ p ∈ Set.Icc (-1 cfcR (fun y : ℝ ↦ y⁻¹) (cfcR (fun x : ℝ ↦ x ^ r) C) = cfcR (fun x : ℝ ↦ (x ^ r)⁻¹) C := by simpa [one_div] using hcomp rw [hcomp'] - dsimp [cfcR] apply cfc_congr intro x hx have hx0 : (0 : ℝ) < x := by simpa [Set.Ioi] using Cs hx From eef3570d557c48ea08324ef89f34fd8c054f8305 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 05:57:04 -0700 Subject: [PATCH 368/498] refactor: golf redundant local unfold witnesses Co-authored-by: Claude Opus 4.8 --- .../Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean | 2 -- Physlib/QuantumMechanics/DDimensions/Operators/Position.lean | 1 - Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean | 1 - .../ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean | 1 - 4 files changed, 5 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean index 45c94f84c..3f2eff3c7 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean @@ -293,7 +293,6 @@ lemma self_subset_mem_completions (S5 S10 : Finset 𝓩) (x y : ChargeSpectrum (hy : y ∈ completions S5 S10 x) : x ⊆ y := by simp [mem_completions_iff] at hy rw [Subset] - dsimp [hasSubset] refine ⟨?_, ?_, ?_, ?_⟩ · by_cases h : x.qHd.isSome · simp_all @@ -352,7 +351,6 @@ lemma exist_completions_subset_of_complete (S5 S10 : Finset 𝓩) (x y : ChargeS · split_ifs with h3 <;> simp_all · split_ifs with h4 <;> simp_all · rw [Subset] - dsimp [hasSubset] refine ⟨by simp_all, by simp_all, ?_, ?_⟩ · split_ifs with h3 <;> simp_all [Finset.singleton_subset_iff] · split_ifs with h4 <;> simp_all [Finset.singleton_subset_iff] diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean index e6d2308c2..ede732380 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean @@ -110,7 +110,6 @@ notation "𝐫₀[" d' "]" => radiusRegPowCLM (d := d') lemma radiusRegPowCLM_apply_fun {d : ℕ} (ε : ℝˣ) (s : ℝ) (ψ : 𝓢(Space d, ℂ)) : 𝐫₀ ε s ψ = fun x ↦ (‖x‖ ^ 2 + ε ^ 2) ^ (s / 2) • ψ x := by ext x - dsimp [radiusRegPowCLM] refine smulLeftCLM_apply_apply ?_ ψ x exact HasTemperateGrowth.comp (by fun_prop) (normRegularizedPow_hasTemperateGrowth d ε s) diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 57fe0448b..2e9de4fbd 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -152,7 +152,6 @@ lemma time_integral_hasFDerivAt {d : ℕ} (η : 𝓢(Time × Space d, ℝ)) (x fun x₀ t => fderiv ℝ (fun x : Space d => η (t, x)) x₀ have hF : ∀ t, ∀ x, HasFDerivAt (F · t) (F' x t) x := by intro t x - dsimp [F, F'] refine DifferentiableAt.hasFDerivAt ?_ have hf := η.smooth' apply Differentiable.differentiableAt diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 4bdf25a76..843ab8bd7 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -271,7 +271,6 @@ private lemma posSemidef_block_one_inv {A : 𝓐} (hA : IsSelfAdjoint A) rw [← Real.rpow_add (As hx), show ((1 : ℝ) / 2 + (1 : ℝ) / 2 : ℝ) = 1 from by ring, Real.rpow_one] _ = A := cfc_id' (R := ℝ) (a := A) (ha := hA) have invA_eq : cfcR (fun x : ℝ ↦ x ^ (-1 : ℝ)) A = cfcR (fun x : ℝ ↦ x⁻¹) A := by - dsimp [cfcR] apply cfc_congr intro x hx have hxne : x ≠ 0 := ne_of_gt (As hx) From 38387a827695d793f9e9919ea300a276115d3592 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:03:31 -0700 Subject: [PATCH 369/498] refactor: golf trace inequality setup witnesses Co-authored-by: Claude Opus 4.8 --- .../MicroCanonicalEnsemble/IdealGas.lean | 3 +-- .../TraceInequality/GeneralizedPerspectiveFunction.lean | 6 ++---- .../HayataGroup/TraceInequality/LownerHeinzCore.lean | 2 -- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean b/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean index ce13bf5eb..4713b123c 100644 --- a/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean +++ b/Physlib/StatisticalMechanics/MicroCanonicalEnsemble/IdealGas.lean @@ -195,8 +195,7 @@ theorem ideal_gas_law (hV : 0 < V) (hT : 0 < T) : let P := IdealGas.pressure (n,V) T; let R := 1; P * V = n * R * T := by - dsimp [pressure] - rw [← derivWithin_of_isOpen (s := Set.Ioi 0) isOpen_Ioi hV] + rw [pressure, ← derivWithin_of_isOpen (s := Set.Ioi 0) isOpen_Ioi hV] rw [derivWithin_congr (f := fun V' ↦ -n * T * (Real.log V' + (3/2) * Real.log (2 * Real.pi * T))) ?_ ?_] rw [derivWithin_of_isOpen (s := Set.Ioi 0) isOpen_Ioi hV] diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean index 90f39e3df..cca85cffe 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/GeneralizedPerspectiveFunction.lean @@ -321,11 +321,9 @@ private theorem theorem_2_5_forward_jointlyConvexOn_psd_pd_of_condV have hIR₂S₂ : IR₂ * S₂ = (1 : L ℋ) := hInvSqrt_mul_hSqrt_eq_one (ℋ := ℋ) hB₂_sa hB₂_spec hcont hpos have hM₁_nonneg : (0 : L ℋ) ≤ M₁ := by - dsimp [M₁] - simpa [mul_assoc] using hIR₁_sa.conjugate_nonneg hA₁_nonneg + simpa [M₁, mul_assoc] using hIR₁_sa.conjugate_nonneg hA₁_nonneg have hM₂_nonneg : (0 : L ℋ) ≤ M₂ := by - dsimp [M₂] - simpa [mul_assoc] using hIR₂_sa.conjugate_nonneg hA₂_nonneg + simpa [M₂, mul_assoc] using hIR₂_sa.conjugate_nonneg hA₂_nonneg have hM₁_sa : IsSelfAdjoint M₁ := IsSelfAdjoint.of_nonneg hM₁_nonneg have hM₂_sa : IsSelfAdjoint M₂ := IsSelfAdjoint.of_nonneg hM₂_nonneg have hM₁_spec : spectrum ℝ M₁ ⊆ Set.Ici (0 : ℝ) := by diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean index 843ab8bd7..cab27837e 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LownerHeinzCore.lean @@ -483,14 +483,12 @@ theorem one_div_add_t_operatorConvexOn_Ici : ∀ (t : ℝ), 0 < t → (hr := IsSelfAdjoint.all (t : ℝ))) have A_nonneg : 0 ≤ A := by have h0 : 0 ≤ cfcR (fun x : ℝ ↦ x) A := by - dsimp [cfcR] apply cfc_nonneg intro x hx simpa [Set.Ici] using (As hx) simpa [cfcR, cfc_id' (R := ℝ) (a := A) (ha := hA)] using h0 have B_nonneg : 0 ≤ B := by have h0 : 0 ≤ cfcR (fun x : ℝ ↦ x) B := by - dsimp [cfcR] apply cfc_nonneg intro x hx simpa [Set.Ici] using (Bs hx) From ee140db555c74952b20e7ab94eee4536cf77c50f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:07:51 -0700 Subject: [PATCH 370/498] refactor: golf one-dimensional operator rewrites Co-authored-by: Claude Opus 4.8 --- .../QuantumMechanics/OneDimension/Operators/Momentum.lean | 3 +-- .../QuantumMechanics/OneDimension/Operators/Position.lean | 3 +-- Physlib/Relativity/PauliMatrices/Basic.lean | 6 ++---- .../SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean b/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean index 9ee54dcb7..eaf4d2488 100644 --- a/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean +++ b/Physlib/QuantumMechanics/OneDimension/Operators/Momentum.lean @@ -94,8 +94,7 @@ def momentumOperatorUnbounded : UnboundedOperator schwartzIncl schwartzIncl_inje lemma planeWaveFunctional_generalized_eigenvector_momentumOperatorUnbounded (k : ℝ) : momentumOperatorUnbounded.IsGeneralizedEigenvector (planewaveFunctional k) (2 * Real.pi * ℏ * k) := by - dsimp [momentumOperatorUnbounded] - rw [UnboundedOperator.isGeneralizedEigenvector_ofSelfCLM_iff] + rw [momentumOperatorUnbounded, UnboundedOperator.isGeneralizedEigenvector_ofSelfCLM_iff] intro ψ trans (-((Complex.I * ↑↑ℏ) • (SchwartzMap.fourierTransformCLM ℂ) ((SchwartzMap.derivCLM ℂ ℂ) ψ) k)) diff --git a/Physlib/QuantumMechanics/OneDimension/Operators/Position.lean b/Physlib/QuantumMechanics/OneDimension/Operators/Position.lean index 66af1751c..5db2c171a 100644 --- a/Physlib/QuantumMechanics/OneDimension/Operators/Position.lean +++ b/Physlib/QuantumMechanics/OneDimension/Operators/Position.lean @@ -82,8 +82,7 @@ def positionOperatorUnbounded : UnboundedOperator schwartzIncl schwartzIncl_inje lemma positionStates_generalized_eigenvector_positionOperatorUnbounded (x : ℝ) : positionOperatorUnbounded.IsGeneralizedEigenvector (positionState x) x := by - dsimp [positionOperatorUnbounded] - rw [UnboundedOperator.isGeneralizedEigenvector_ofSelfCLM_iff] + rw [positionOperatorUnbounded, UnboundedOperator.isGeneralizedEigenvector_ofSelfCLM_iff] intro ψ simp [positionState_apply] diff --git a/Physlib/Relativity/PauliMatrices/Basic.lean b/Physlib/Relativity/PauliMatrices/Basic.lean index e6afd7670..1f5c31824 100644 --- a/Physlib/Relativity/PauliMatrices/Basic.lean +++ b/Physlib/Relativity/PauliMatrices/Basic.lean @@ -60,8 +60,7 @@ scoped[PauliMatrix] notation "σ2" => σ (Sum.inr 1) /-- The Pauli matrix corresponding to the matrix `!![1, 0; 0, -1]`. -/ scoped[PauliMatrix] notation "σ3" => σ (Sum.inr 2) -lemma pauliMatrix_inl_zero_eq_one : pauliMatrix (Sum.inl 0) = 1 := by - dsimp [pauliMatrix] +lemma pauliMatrix_inl_zero_eq_one : pauliMatrix (Sum.inl 0) = 1 := rfl /-! @@ -73,8 +72,7 @@ lemma pauliMatrix_selfAdjoint (μ : Fin 1 ⊕ Fin 3) : (σ μ)ᴴ = σ μ := by fin_cases μ all_goals - dsimp [pauliMatrix] - rw [eta_fin_two _ᴴ] + rw [pauliMatrix.eq_def, eta_fin_two _ᴴ] simp ext i j fin_cases i <;> fin_cases j diff --git a/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean b/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean index 3ed16ea71..741c371fc 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/RadialAngularMeasure.lean @@ -102,8 +102,7 @@ lemma integral_radialAngularMeasure {d : ℕ} (f : Space d → F) : lemma lintegral_radialMeasure {d : ℕ} (f : Space d → ENNReal) (hf : Measurable f) : ∫⁻ x, f x ∂radialAngularMeasure = ∫⁻ x, ENNReal.ofReal (1 / ‖x‖ ^ (d - 1)) * f x := by - dsimp [radialAngularMeasure] - rw [lintegral_withDensity_eq_lintegral_mul] + rw [radialAngularMeasure, lintegral_withDensity_eq_lintegral_mul] simp only [one_div, Pi.mul_apply] all_goals fun_prop From 09a7527090322a89288df776b6f6e5cf789d7afc Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:09:52 -0700 Subject: [PATCH 371/498] refactor: golf divergence unfold proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/Divergence.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Calculus/Divergence.lean b/Physlib/Mathematics/Calculus/Divergence.lean index a538a0e6b..8e7434a00 100644 --- a/Physlib/Mathematics/Calculus/Divergence.lean +++ b/Physlib/Mathematics/Calculus/Divergence.lean @@ -39,8 +39,7 @@ lemma divergence_zero : divergence 𝕜 (fun _ : E => 0) = fun _ => 0 := by lemma divergence_eq_sum_fderiv {s : Finset E} (b : Basis s 𝕜 E) {f : E → E} : divergence 𝕜 f = fun x => ∑ i : s, b.repr (fderiv 𝕜 f x (b i)) i := by funext x - unfold divergence - rw[LinearMap.trace_eq_matrix_trace_of_finset (s:=s) _ b] + rw [divergence, LinearMap.trace_eq_matrix_trace_of_finset (s := s) _ b] simp only [Matrix.trace, Matrix.diag, LinearMap.toMatrix_apply] rfl @@ -108,29 +107,25 @@ lemma divergence_add {f g : E → E} {x : E} divergence 𝕜 (fun x => f x + g x) x = divergence 𝕜 f x + divergence 𝕜 g x := by - unfold divergence - simp [fderiv_fun_add hf hg] + simp [divergence, fderiv_fun_add hf hg] lemma divergence_neg {f : E → E} {x : E} : divergence 𝕜 (fun x => -f x) x = -divergence 𝕜 f x := by - unfold divergence - simp + simp [divergence] lemma divergence_sub {f g : E → E} {x : E} (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : divergence 𝕜 (fun x => f x - g x) x = divergence 𝕜 f x - divergence 𝕜 g x := by - unfold divergence - simp [fderiv_fun_sub hf hg] + simp [divergence, fderiv_fun_sub hf hg] lemma divergence_const_smul {f : E → E} {x : E} {c : 𝕜} (hf : DifferentiableAt 𝕜 f x) : divergence 𝕜 (fun x => c • f x) x = c * divergence 𝕜 f x := by - unfold divergence - simp [fderiv_fun_const_smul hf] + simp [divergence, fderiv_fun_const_smul hf] open InnerProductSpace' in lemma divergence_smul [InnerProductSpace' 𝕜 E] {f : E → 𝕜} {g : E → E} {x : E} From 527d64b64c7f93eadb2859288696ab4d5bb079b0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:12:45 -0700 Subject: [PATCH 372/498] refactor: golf Weyl tensor smul fields Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Weyl/Metric.lean | 4 +--- .../Tensors/ComplexTensor/Weyl/Unit.lean | 16 ++++------------ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean index 377d28433..4e7e1a466 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean @@ -92,9 +92,7 @@ def leftMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap a' • leftMetricVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • leftMetricVal = diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean index 87d7c225b..c396f1d47 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean @@ -47,9 +47,7 @@ def leftDualLeftUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMa a' • leftDualLeftUnitVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • leftDualLeftUnitVal = @@ -87,9 +85,7 @@ def dualLeftLeftUnit : a' • dualLeftLeftUnitVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • dualLeftLeftUnitVal = @@ -130,9 +126,7 @@ def rightDualRightUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).Intertwining a' • rightDualRightUnitVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • rightDualRightUnitVal = @@ -177,9 +171,7 @@ def dualRightRightUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).Intertwining a' • dualRightRightUnitVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • dualRightRightUnitVal = From 5a2d69ab17f89665a551d3462c4f98d7fecc95f2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:15:30 -0700 Subject: [PATCH 373/498] refactor: golf complex tensor smul fields Co-authored-by: Claude Opus 4.8 --- .../Relativity/Tensors/ComplexTensor/Units/Pre.lean | 8 ++------ .../Tensors/ComplexTensor/Weyl/Metric.lean | 12 +++--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean index ff2cdb12c..f257126b5 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean @@ -57,9 +57,7 @@ def contrCoUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap a' • contrCoUnitVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • contrCoUnitVal = @@ -108,9 +106,7 @@ def coContrUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap a' • coContrUnitVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • coContrUnitVal = diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean index 4e7e1a466..4e842a7cd 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean @@ -133,9 +133,7 @@ def dualLeftMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap a' • dualLeftMetricVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • dualLeftMetricVal = @@ -180,9 +178,7 @@ def rightMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap a' • rightMetricVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • rightMetricVal = @@ -231,9 +227,7 @@ def dualRightMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap a' • dualRightMetricVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • dualRightMetricVal = From 760287164601ef4d1c9fbe0da010f7496e2b8e43 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:18:41 -0700 Subject: [PATCH 374/498] refactor: golf tensor unit smul fields Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean | 8 ++------ Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean | 8 ++------ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean index 0be7cec11..8758e0e7b 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean @@ -55,9 +55,7 @@ def contrMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap a' • contrMetricVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • contrMetricVal = @@ -105,9 +103,7 @@ def coMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap a' • coMetricVal map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • coMetricVal = diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean index b4e9f216c..ec573a3ec 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean @@ -206,8 +206,7 @@ def leftHandedToDual : leftHandedRep.IntertwiningMap dualLeftHandedRep where simp only [mulVec_add, LinearEquiv.map_add] map_smul' := by intro a ψ - simp only [mulVec_smul, LinearEquiv.map_smul] - rfl + simp only [mulVec_smul, LinearEquiv.map_smul, RingHom.id_apply] isIntertwining' := by intro M refine LinearMap.ext (fun ψ => ?_) diff --git a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean index 9798fa1f4..f758fda38 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean @@ -53,9 +53,7 @@ def preContrCoUnit (d : ℕ := 3) : toFun := fun a => a • preContrCoUnitVal d map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℝ => ?_ simp only [LinearMap.coe_comp, Function.comp_apply] @@ -104,9 +102,7 @@ def preCoContrUnit (d : ℕ) : (Representation.trivial ℝ (LorentzGroup d) ℝ) toFun := fun a => a • preCoContrUnitVal d map_add' := fun x y => by simp only [add_smul] - map_smul' := fun m x => by - simp only [smul_smul] - rfl + map_smul' := fun m x => by simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℝ => ?_ simp only [LinearMap.coe_comp, Function.comp_apply] From 2babb115813e38e6783d472f17251b345c1015cd Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:27:05 -0700 Subject: [PATCH 375/498] refactor: golf representation identity proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/AnomalyCancellation/GroupActions.lean | 9 +++------ Physlib/Relativity/PauliMatrices/AsTensor.lean | 3 +-- Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean | 4 +--- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Physlib/QFT/AnomalyCancellation/GroupActions.lean b/Physlib/QFT/AnomalyCancellation/GroupActions.lean index 09f91bde5..afc7eee76 100644 --- a/Physlib/QFT/AnomalyCancellation/GroupActions.lean +++ b/Physlib/QFT/AnomalyCancellation/GroupActions.lean @@ -66,8 +66,7 @@ def linSolRep {χ : ACCSystem} (G : ACCSystemGroupAction χ) : map_one' := by refine LinearMap.ext fun S ↦ ACCSystemLinear.LinSols.ext ?_ change (G.rep.toFun 1) S.val = _ - rw [G.rep.map_one'] - rfl + simp only [G.rep.map_one', Module.End.one_apply] /-- The representation on the charges and anomaly free solutions commutes with the inclusion. -/ @@ -88,8 +87,7 @@ instance quadSolAction {χ : ACCSystem} (G : ACCSystemGroupAction χ) : one_smul S := by apply ACCSystemQuad.QuadSols.ext change (G.rep.toFun 1) S.val = _ - rw [G.rep.map_one'] - rfl + simp only [G.rep.map_one', Module.End.one_apply] lemma linSolRep_quadSolAction_commute {χ : ACCSystem} (G : ACCSystemGroupAction χ) (g : G.group) (S : χ.QuadSols) : χ.quadSolsInclLinSols (G.quadSolAction.toFun _ _ S g) = @@ -113,8 +111,7 @@ instance solAction {χ : ACCSystem} (G : ACCSystemGroupAction χ) : MulAction G. one_smul S := by apply ACCSystem.Sols.ext change (G.rep.toFun 1) S.val = _ - rw [G.rep.map_one'] - rfl + simp only [G.rep.map_one', Module.End.one_apply] lemma quadSolAction_solAction_commute {χ : ACCSystem} (G : ACCSystemGroupAction χ) (g : G.group) (S : χ.Sols) : χ.solsInclQuadSols (G.solAction.toFun _ _ S g) = diff --git a/Physlib/Relativity/PauliMatrices/AsTensor.lean b/Physlib/Relativity/PauliMatrices/AsTensor.lean index ab34afa10..9234420b1 100644 --- a/Physlib/Relativity/PauliMatrices/AsTensor.lean +++ b/Physlib/Relativity/PauliMatrices/AsTensor.lean @@ -99,8 +99,7 @@ def asConsTensor : map_add' := fun x y => by simp only [add_smul] map_smul' := fun m x => by - simp only [smul_smul] - rfl + simp only [smul_eq_mul, smul_smul, RingHom.id_apply] isIntertwining' M := by refine LinearMap.ext fun x : ℂ => ?_ change x • asTensor = diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean index ec573a3ec..d05ec8e7c 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean @@ -235,9 +235,7 @@ def leftHandedDualTo : dualLeftHandedRep.IntertwiningMap leftHandedRep where rw [mulVec_add, LinearEquiv.map_add] map_smul' := by intro a ψ - simp only [LinearEquiv.map_smul] - rw [mulVec_smul, LinearEquiv.map_smul] - rfl + simp only [mulVec_smul, LinearEquiv.map_smul, RingHom.id_apply] isIntertwining' := by intro M refine LinearMap.ext (fun ψ => ?_) From f560fd12f07db1d5deed72eced7a4f8b4a3f9aee Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:31:48 -0700 Subject: [PATCH 376/498] refactor: golf contraction scalar proofs Co-authored-by: Claude Opus 4.8 --- .../ComplexTensor/Vector/Pre/Contraction.lean | 18 ++++++------------ Physlib/Units/FDeriv.lean | 3 +-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean index 03e42a64a..59d50aee4 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Contraction.lean @@ -35,18 +35,15 @@ def contrCoContrBi : ContrℂModule →ₗ[ℂ] CoℂModule →ₗ[ℂ] ℂ wher rw [dotProduct_add] map_smul' := by intro r φ - simp only [LinearEquiv.map_smul] - rw [dotProduct_smul] - rfl} + simp only [LinearEquiv.map_smul, dotProduct_smul, RingHom.id_apply]} map_add' ψ ψ':= by refine LinearMap.ext (fun φ => ?_) simp only [map_add, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply] rw [add_dotProduct] map_smul' r ψ := by refine LinearMap.ext (fun φ => ?_) - simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk] - rw [smul_dotProduct] - rfl + simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk, smul_dotProduct, + LinearMap.smul_apply, RingHom.id_apply] /-- The bi-linear map corresponding to contraction of a covariant Lorentz vector with a contravariant Lorentz vector. -/ @@ -59,18 +56,15 @@ def contrContrCoBi : CoℂModule →ₗ[ℂ] ContrℂModule →ₗ[ℂ] ℂ wher rw [dotProduct_add] map_smul' := by intro r ψ - simp only [LinearEquiv.map_smul] - rw [dotProduct_smul] - rfl} + simp only [LinearEquiv.map_smul, dotProduct_smul, RingHom.id_apply]} map_add' φ φ' := by refine LinearMap.ext (fun ψ => ?_) simp only [map_add, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply] rw [add_dotProduct] map_smul' r φ := by refine LinearMap.ext (fun ψ => ?_) - simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk] - rw [smul_dotProduct] - rfl + simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk, smul_dotProduct, + LinearMap.smul_apply, RingHom.id_apply] /-- The linear map from complexContr ⊗ complexCo to ℂ given by summing over components of contravariant Lorentz vector and diff --git a/Physlib/Units/FDeriv.lean b/Physlib/Units/FDeriv.lean index f015b8ebe..eeb028d08 100644 --- a/Physlib/Units/FDeriv.lean +++ b/Physlib/Units/FDeriv.lean @@ -42,8 +42,7 @@ lemma fderiv_apply_scaleUnit (u1 u2 : UnitChoices) (x dm : M1) change (fderiv ℝ ((u2.dimScale u1 (dim M2)).1 • fun mx => f ((u1.dimScale u2 (dim M1)).1 • mx)) ((u2.dimScale u1 (dim M1)).1 • x)) dm = _ rw [fderiv_const_smul (by fun_prop), fderiv_comp_smul] - simp [smul_smul] - rfl + simp [smul_smul, NNReal.smul_def] open ContinuousLinearUnitDependent in /-- If a function is dimensionally valid then so is it's derivative. -/ From ff0c1f0add44febf7cce75e648325a02fd1a2d8c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:34:33 -0700 Subject: [PATCH 377/498] refactor: golf vector contraction scalar proofs Co-authored-by: Claude Opus 4.8 --- .../ComplexTensor/Weyl/Contraction.lean | 26 ++++++------------- .../RealTensor/Vector/Pre/Contraction.lean | 18 +++++-------- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean index 71ff7c07d..69a6f5724 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Contraction.lean @@ -42,18 +42,15 @@ def leftDualBi : LeftHandedWeyl →ₗ[ℂ] DualLeftHandedWeyl →ₗ[ℂ] ℂ w rw [dotProduct_add] map_smul' := by intro r φ - simp only [LinearEquiv.map_smul] - rw [dotProduct_smul] - rfl} + simp only [LinearEquiv.map_smul, dotProduct_smul, RingHom.id_apply]} map_add' ψ ψ':= by refine LinearMap.ext (fun φ => ?_) simp only [map_add, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply] rw [add_dotProduct] map_smul' r ψ := by refine LinearMap.ext (fun φ => ?_) - simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk] - rw [smul_dotProduct] - rfl + simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk, smul_dotProduct, + LinearMap.smul_apply, RingHom.id_apply] /-- The bi-linear map corresponding to contraction of a dual-left-handed Weyl fermion with a left-handed Weyl fermion. -/ @@ -66,9 +63,7 @@ def dualLeftBi : DualLeftHandedWeyl →ₗ[ℂ] LeftHandedWeyl →ₗ[ℂ] ℂ w rw [dotProduct_add] map_smul' := by intro r φ - simp only [LinearEquiv.map_smul] - rw [dotProduct_smul] - rfl} + simp only [LinearEquiv.map_smul, dotProduct_smul, RingHom.id_apply]} map_add' ψ ψ':= by refine LinearMap.ext (fun φ => ?_) simp only [map_add, add_dotProduct, vec2_dotProduct, Fin.isValue, LinearMap.coe_mk, @@ -89,18 +84,15 @@ def rightDualBi : RightHandedWeyl →ₗ[ℂ] DualRightHandedWeyl →ₗ[ℂ] rw [dotProduct_add] map_smul' := by intro r φ - simp only [LinearEquiv.map_smul] - rw [dotProduct_smul] - rfl} + simp only [LinearEquiv.map_smul, dotProduct_smul, RingHom.id_apply]} map_add' ψ ψ':= by refine LinearMap.ext (fun φ => ?_) simp only [map_add, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply] rw [add_dotProduct] map_smul' r ψ := by refine LinearMap.ext (fun φ => ?_) - simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk] - rw [smul_dotProduct] - rfl + simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk, smul_dotProduct, + LinearMap.smul_apply, RingHom.id_apply] /-- The bi-linear map corresponding to contraction of a dual-right-handed Weyl fermion with a right-handed Weyl fermion. -/ @@ -113,9 +105,7 @@ def dualRightBi : DualRightHandedWeyl →ₗ[ℂ] RightHandedWeyl →ₗ[ℂ] rw [dotProduct_add] map_smul' := by intro r φ - simp only [LinearEquiv.map_smul] - rw [dotProduct_smul] - rfl} + simp only [LinearEquiv.map_smul, dotProduct_smul, RingHom.id_apply]} map_add' ψ ψ':= by refine LinearMap.ext (fun φ => ?_) simp only [map_add, add_dotProduct, vec2_dotProduct, Fin.isValue, LinearMap.coe_mk, diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 3678ae947..908f51c55 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -38,18 +38,15 @@ def contrModCoModBi (d : ℕ) : ContrMod d →ₗ[ℝ] CoMod d →ₗ[ℝ] ℝ w rw [dotProduct_add] map_smul' := by intro r φ - simp only [LinearEquiv.map_smul] - rw [dotProduct_smul] - rfl} + simp only [LinearEquiv.map_smul, dotProduct_smul, RingHom.id_apply]} map_add' ψ ψ':= by refine LinearMap.ext (fun φ => ?_) simp only [map_add, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply] rw [add_dotProduct] map_smul' r ψ := by refine LinearMap.ext (fun φ => ?_) - simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk] - rw [smul_dotProduct] - rfl + simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk, smul_dotProduct, + LinearMap.smul_apply, RingHom.id_apply] /-- The bi-linear map corresponding to contraction of a covariant Lorentz vector with a contravariant Lorentz vector. -/ @@ -62,18 +59,15 @@ def coModContrModBi (d : ℕ) : CoMod d →ₗ[ℝ] ContrMod d →ₗ[ℝ] ℝ w rw [dotProduct_add] map_smul' := by intro r ψ - simp only [LinearEquiv.map_smul] - rw [dotProduct_smul] - rfl} + simp only [LinearEquiv.map_smul, dotProduct_smul, RingHom.id_apply]} map_add' φ φ' := by refine LinearMap.ext (fun ψ => ?_) simp only [map_add, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply] rw [add_dotProduct] map_smul' r φ := by refine LinearMap.ext (fun ψ => ?_) - simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk] - rw [smul_dotProduct] - rfl + simp only [LinearEquiv.map_smul, LinearMap.coe_mk, AddHom.coe_mk, smul_dotProduct, + LinearMap.smul_apply, RingHom.id_apply] /-- The linear map from Contr d ⊗ Co d to ℝ given by summing over components of contravariant Lorentz vector and From 689cfb67207c0ad10deec051e14d545b7e4b3de9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:49:37 -0700 Subject: [PATCH 378/498] refactor: golf QFT field proof wrappers Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/NormalOrder.lean | 12 ++++-------- .../FieldSpecification/CrAnSection.lean | 1 - .../FieldSpecification/TimeOrder.lean | 2 -- .../PerturbationTheory/FieldStatistics/Basic.lean | 7 ++----- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean index f59af014a..c61ef1936 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean @@ -260,23 +260,19 @@ lemma normalOrderF_swap_crPartF_anPartF (φ φ' : 𝓕.FieldOp) (a b : FieldOpFr | .position φ, .position φ' => simp only [crPartF_position, anPartF_position] rw [normalOrderF_swap_create_annihilate] - simp only [crAnStatistics, Function.comp_apply, crAnFieldOpToFieldOp_prod] - rfl; rfl + all_goals rfl | .inAsymp φ, .outAsymp φ' => simp only [crPartF_negAsymp, anPartF_posAsymp] rw [normalOrderF_swap_create_annihilate] - simp only [crAnStatistics, Function.comp_apply, crAnFieldOpToFieldOp_prod] - rfl; rfl + all_goals rfl | .inAsymp φ, .position φ' => simp only [crPartF_negAsymp, anPartF_position] rw [normalOrderF_swap_create_annihilate] - simp only [crAnStatistics, Function.comp_apply, crAnFieldOpToFieldOp_prod] - rfl; rfl + all_goals rfl | .position φ, .outAsymp φ' => simp only [crPartF_position, anPartF_posAsymp] rw [normalOrderF_swap_create_annihilate] - simp only [crAnStatistics, Function.comp_apply, crAnFieldOpToFieldOp_prod] - rfl; rfl + all_goals rfl /-! diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index b8d24e787..29e06e917 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -127,7 +127,6 @@ def singletonEquiv {φ : 𝓕.FieldOp} : CrAnSection [φ] ≃ simp only [List.tail_cons, List.map_eq_nil_iff] at h2 simp [h2] right_inv ψ := by - simp only [head] rfl /-- An equivalence separating the head of a creation and annihilation section diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean index f7279f161..4726a1aff 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean @@ -136,7 +136,6 @@ def timeOrderSign (φs : List 𝓕.FieldOp) : ℂ := @[simp] lemma timeOrderSign_nil : timeOrderSign (𝓕 := 𝓕) [] = 1 := by - simp only [timeOrderSign] rfl lemma timeOrderSign_pair_ordered {φ ψ : 𝓕.FieldOp} (h : timeOrderRel φ ψ) : @@ -237,7 +236,6 @@ def crAnTimeOrderSign (φs : List 𝓕.CrAnFieldOp) : ℂ := @[simp] lemma crAnTimeOrderSign_nil : crAnTimeOrderSign (𝓕 := 𝓕) [] = 1 := by - simp only [crAnTimeOrderSign] rfl lemma crAnTimeOrderSign_pair_ordered {φ ψ : 𝓕.CrAnFieldOp} (h : crAnTimeOrderRel φ ψ) : diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean index 42b733966..7289124f6 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean @@ -239,8 +239,7 @@ lemma ofList_map_eq_finset_prod (s : 𝓕 → FieldStatistic) : rfl simp only [List.length_cons, List.nodup_cons] at hl exact hl.1 - · simp only [ha, ↓reduceIte, false_or] - rfl + · simp only [ha, ↓reduceIte, false_or, Fin.getElem_fin] simp only [List.length_cons, List.nodup_cons] at hl exact hl.2 @@ -269,7 +268,6 @@ lemma ofList_take_eraseIdx (n : ℕ) (φs : List 𝓕) : lemma ofList_take_zero (φs : List 𝓕) : ofList q (List.take 0 φs) = 1 := by - simp only [List.take_zero, ofList_empty] rfl lemma ofList_take_succ_cons (n : ℕ) (φ1 : 𝓕) (φs : List 𝓕) : @@ -307,8 +305,7 @@ instance : AddMonoid FieldStatistic where add_assoc a b c := by cases a <;> cases b <;> cases c <;> rfl nsmul_zero a := by - simp only [Finset.univ_eq_empty, Finset.prod_const, Finset.card_empty, pow_zero] - rfl + cases a <;> rfl nsmul_succ a n := by simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin] rfl From d64c6f00b4f04efbf224af5875798305e69f25e9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 06:55:57 -0700 Subject: [PATCH 379/498] refactor: golf QFT grading proofs Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean | 4 +--- .../QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean | 1 - Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean | 4 +--- .../PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean | 4 +--- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean index 230ba3ea6..de54ee5f1 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/Grading.lean @@ -252,9 +252,7 @@ instance fieldOpFreeAlgebraGrade : simp only [statisticSubmodule] refine Submodule.mem_span.mpr fun p a => a ?_ simp only [Set.mem_setOf_eq] - use [] - simp only [ofCrAnListF_nil, ofList_empty, true_and] - rfl + exact ⟨[], rfl, rfl⟩ mul_mem f1 f2 a1 a2 h1 h2 := by let p (a2 : 𝓕.FieldOpFreeAlgebra) (hx : a2 ∈ statisticSubmodule f2) : Prop := a1 * a2 ∈ statisticSubmodule (f1 + f2) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean index 4726a1aff..5acd8379d 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean @@ -155,7 +155,6 @@ lemma timerOrderSign_of_eraseMaxTimeField (φ : 𝓕.FieldOp) (φs : List 𝓕.F 𝓢(𝓕 |>ₛ maxTimeField φ φs, 𝓕 |>ₛ (φ :: φs).take (maxTimeFieldPos φ φs)) := by rw [eraseMaxTimeField, insertionSortDropMinPos, timeOrderSign, Wick.koszulSign_eraseIdx_insertionSortMinPos] - rw [← timeOrderSign, ← maxTimeField] rfl /-- The time ordering of a list of states. A schematic example is: diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean index 3d9fcf200..97a7f729b 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean @@ -394,9 +394,7 @@ instance WickAlgebraGrade : GradedAlgebra (A := 𝓕.WickAlgebra) statSubmodule simp only [statSubmodule] refine Submodule.mem_span.mpr fun p a => a ?_ simp only [Set.mem_setOf_eq] - use [] - simp only [ofCrAnList, ofCrAnListF_nil, map_one, ofList_empty, true_and] - rfl + exact ⟨[], rfl, rfl⟩ mul_mem f1 f2 a1 a2 h1 h2 := by let p (a2 : 𝓕.WickAlgebra) (hx : a2 ∈ statSubmodule f2) : Prop := a1 * a2 ∈ statSubmodule (f1 + f2) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index e672a1c55..a977452d7 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -34,8 +34,7 @@ lemma normalOrder_eq_ι_normalOrderF (a : 𝓕.FieldOpFreeAlgebra) : lemma normalOrder_ofCrAnList (φs : List 𝓕.CrAnFieldOp) : 𝓝(ofCrAnList φs) = normalOrderSign φs • ofCrAnList (normalOrderList φs) := by - rw [ofCrAnList, normalOrder_eq_ι_normalOrderF, normalOrderF_ofCrAnListF] - rfl + simp only [ofCrAnList, normalOrder_eq_ι_normalOrderF, normalOrderF_ofCrAnListF, map_smul] @[simp] lemma normalOrder_one_eq_one : normalOrder (𝓕 := 𝓕) 1 = 1 := by @@ -192,7 +191,6 @@ lemma anPart_mul_normalOrder_ofFieldOpList_eq_superCommute (φ : 𝓕.FieldOp) [anPart φ, 𝓝(ofFieldOpList φs')]ₛ := by rw [anPart, ofFieldOpList, normalOrder_eq_ι_normalOrderF, ← map_mul] rw [anPartF_mul_normalOrderF_ofFieldOpListF_eq_superCommuteF] - simp only [map_add, map_smul] rfl /-! From be45582a5a52e6c965ba9ad5de863bde80aecb5b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 07:01:51 -0700 Subject: [PATCH 380/498] refactor: golf quantum info wrapper proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/SSA.lean | 1 - QuantumInfo/States/Mixed/MState.lean | 2 -- QuantumInfo/States/Pure/Braket.lean | 2 -- 3 files changed, 5 deletions(-) diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index e9011a35d..f93407498 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -291,7 +291,6 @@ theorem Matrix.opNorm_conjTranspose_eq_opNorm {m n : Type*} [Fintype m] [Fintype Matrix.opNorm Aᴴ = Matrix.opNorm A := by unfold Matrix.opNorm rw [← ContinuousLinearMap.adjoint.norm_map (toEuclideanLin A).toContinuousLinearMap] - rw [toEuclideanLin_conjTranspose_eq_adjoint] rfl theorem isometry_mul_conjTranspose_le_one {m n : Type*} [Fintype m] [Fintype n] diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 9e2f90cef..54a64f808 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -477,7 +477,6 @@ theorem spectralDecomposition (ρ : MState d) : simp only [Matrix.mul_diagonal, Matrix.IsHermitian.eigenvectorUnitary_apply, mul_comm, Matrix.star_apply, RCLike.star_def] simp only [Function.comp_apply, mat_M, mat_apply, HermitianMat.smul_apply, Complex.real_smul] - rw [mul_assoc] rfl end pure @@ -552,7 +551,6 @@ lemma default_eq [Nonempty d] : (default : MState d) = uniform := rfl @[simp] theorem M_default [Unique d] : (default : MState d).M = 1 := by - simp [default_eq, uniform] rfl section ptrace diff --git a/QuantumInfo/States/Pure/Braket.lean b/QuantumInfo/States/Pure/Braket.lean index 949555aab..342aba6e9 100644 --- a/QuantumInfo/States/Pure/Braket.lean +++ b/QuantumInfo/States/Pure/Braket.lean @@ -110,12 +110,10 @@ theorem Bra.ext {ξ ψ : Bra d} (h : ∀ x, ξ x = ψ x) : ξ = ψ := theorem Ket.normalized (ψ : Ket d) : ∑ x, Complex.normSq (ψ x) = 1 := by convert ψ.normalized' - rw [Complex.normSq_eq_norm_sq] rfl theorem Bra.normalized (ψ : Bra d) : ∑ x, Complex.normSq (ψ x) = 1 := by convert ψ.normalized' - rw [Complex.normSq_eq_norm_sq] rfl /-- Any Bra can be turned into a Ket by conjugating the elements. -/ From a508cbbd4638f5108914bb0592c8b6d2bff3d26a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 07:07:15 -0700 Subject: [PATCH 381/498] refactor: golf electromagnetism wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Distributional/Basic.lean | 1 - Physlib/Electromagnetism/Distributional/FieldStrength.lean | 3 +-- Physlib/Electromagnetism/Kinematics/EMPotential.lean | 1 - Physlib/Electromagnetism/Kinematics/FieldStrength.lean | 5 +---- Physlib/Electromagnetism/Kinematics/ScalarPotential.lean | 1 - Physlib/Electromagnetism/Kinematics/VectorPotential.lean | 1 - 6 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Basic.lean b/Physlib/Electromagnetism/Distributional/Basic.lean index 49c214689..8f29038c3 100644 --- a/Physlib/Electromagnetism/Distributional/Basic.lean +++ b/Physlib/Electromagnetism/Distributional/Basic.lean @@ -203,7 +203,6 @@ lemma toTensor_distTensorDeriv_basis_repr_apply {d} (A : DistElectromagneticPote | ⟨i, j⟩ => simp rw [hb] - rw [Module.Basis.repr_reindex_apply, distTensorDeriv_basis_repr_apply] rfl end DistElectromagneticPotential diff --git a/Physlib/Electromagnetism/Distributional/FieldStrength.lean b/Physlib/Electromagnetism/Distributional/FieldStrength.lean index ba0f947ef..48c02baae 100644 --- a/Physlib/Electromagnetism/Distributional/FieldStrength.lean +++ b/Physlib/Electromagnetism/Distributional/FieldStrength.lean @@ -80,8 +80,7 @@ lemma fieldStrengthAux_eq_add {d} (A : DistElectromagneticPotential d) (ε : rw [sub_eq_add_neg] apply congrArg₂ · rfl - · rw [permT_permT] - rfl + · rfl lemma toTensor_fieldStrengthAux {d} (A : DistElectromagneticPotential d) (ε : 𝓢(SpaceTime d, ℝ)) : diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index 677cfdb92..ed3a4c9e5 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -631,7 +631,6 @@ lemma toTensor_deriv_basis_repr_apply {d} (A : ElectromagneticPotential d) ext ⟨i, j⟩ simp rw [hb] - rw [Module.Basis.repr_reindex_apply, deriv_basis_repr_apply] rfl end ElectromagneticPotential diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index a4eeb96ee..5c5b1aef8 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -118,8 +118,7 @@ lemma toFieldStrength_eq_add {d} (A : ElectromagneticPotential d) (x : SpaceTime rw [sub_eq_add_neg] apply congrArg₂ · rfl - · rw [permT_permT] - rfl + · rfl lemma toFieldStrength_eq_sub_tensorDeriv {d} {A : ElectromagneticPotential d} (hA : Differentiable ℝ A) (x : SpaceTime d) : @@ -127,7 +126,6 @@ lemma toFieldStrength_eq_sub_tensorDeriv {d} {A : ElectromagneticPotential d} Tensorial.toTensor.symm (permT id IsReindexing.auto {η d | μ μ' ⊗ tensorDeriv A x | μ' ν}ᵀ) - Tensorial.toTensor.symm (permT ![1, 0] IsReindexing.auto {η d | μ μ' ⊗ tensorDeriv A x | μ' ν}ᵀ) := by - simp only [toFieldStrength_eq_tensorDeriv hA, map_add, map_neg, sub_eq_add_neg, permT_permT] rfl lemma toTensor_toFieldStrength {d} (A : ElectromagneticPotential d) (x : SpaceTime d) : @@ -536,7 +534,6 @@ lemma toFieldStrength_antisymmetric {d} (A : ElectromagneticPotential d) (x : Sp rw [toTensor_toFieldStrength_basis_repr] rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl (fun κ _ => ?_) - simp only [Fin.isValue, neg_sub] rfl lemma fieldStrengthMatrix_antisymm {d} (A : ElectromagneticPotential d) (x : SpaceTime d) diff --git a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean index 9e9e0093a..5dc8875ea 100644 --- a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean @@ -86,7 +86,6 @@ lemma ofStaticScalarPotential_scalarPotential {d} (c : SpeedOfLight) lemma ofVectorPotential_scalarPotential {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) : (ofVectorPotential c A).scalarPotential = 0 := by - simp only [scalarPotential, SpeedOfLight.val_one, ofVectorPotential, Fin.isValue, mul_zero] rfl @[simp] diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index c20d2563f..bad8bee77 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -74,7 +74,6 @@ noncomputable def vectorPotential {d} (c : SpeedOfLight := 1) (A : Electromagnet @[simp] lemma ofScalarPotential_vectorPotential {d} (c : SpeedOfLight) (φ : Time → Space d → ℝ) : (ofScalarPotential c φ).vectorPotential c = 0 := by - simp only [vectorPotential, ofScalarPotential] rfl @[simp] From 6837c24260c6e44430144fac3d4e37b6f5dfbdf8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 07:09:59 -0700 Subject: [PATCH 382/498] refactor: golf electromagnetic derivative wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Kinematics/Boosts.lean | 1 - Physlib/Electromagnetism/Kinematics/FieldStrength.lean | 2 -- Physlib/Electromagnetism/Kinematics/MagneticField.lean | 5 +---- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/Boosts.lean b/Physlib/Electromagnetism/Kinematics/Boosts.lean index e8359f484..3168bc707 100644 --- a/Physlib/Electromagnetism/Kinematics/Boosts.lean +++ b/Physlib/Electromagnetism/Kinematics/Boosts.lean @@ -191,7 +191,6 @@ lemma magneticFieldMatrix_apply_x_boost_succ_succ {d : ℕ} {c : SpeedOfLight} ( simp only rw [fieldStrengthMatrix_equivariant _ _ hA] simp [Fintype.sum_sum_type, boost_zero_inr_succ_inr_succ, Fin.sum_univ_succ] - rw [SpaceTime.boost_zero_apply_time_space] rfl end ElectromagneticPotential diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index 5c5b1aef8..edd3b44e8 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -340,7 +340,6 @@ lemma toFieldStrength_basis_repr_apply {d} {μν : (Fin 1 ⊕ Fin d) × (Fin 1 trans (Tensor.basis _).repr (Tensorial.toTensor (toFieldStrength A x)) (fun | 0 => μ | 1 => ν); swap · rw [toTensor_toFieldStrength_basis_repr] - rw [toFieldStrength_tensor_basis_eq_basis] rfl lemma toFieldStrength_basis_repr_apply_eq_single {d} {μν : (Fin 1 ⊕ Fin d) × (Fin 1 ⊕ Fin d)} @@ -433,7 +432,6 @@ lemma fieldStrengthMatrix_eq_tensor_basis_repr {d} (A : ElectromagneticPotential A.fieldStrengthMatrix x (μ, ν) = (Tensor.basis _).repr (Tensorial.toTensor (toFieldStrength A x)) (fun | 0 => μ | 1 => ν) := by - rw [toFieldStrength_tensor_basis_eq_basis] rfl lemma toFieldStrength_eq_fieldStrengthMatrix {d} (A : ElectromagneticPotential d) : diff --git a/Physlib/Electromagnetism/Kinematics/MagneticField.lean b/Physlib/Electromagnetism/Kinematics/MagneticField.lean index dfeeb0f5f..64c1836a2 100644 --- a/Physlib/Electromagnetism/Kinematics/MagneticField.lean +++ b/Physlib/Electromagnetism/Kinematics/MagneticField.lean @@ -101,7 +101,6 @@ lemma magneticField_coord_eq_fieldStrengthMatrix {i : Fin 3} {c : SpeedOfLight} all_goals · rw [SpaceTime.deriv_sum_inr c _ hA] simp only [Fin.isValue, ContinuousLinearEquiv.apply_symm_apply] - rw [Space.deriv_eq, Space.deriv_eq, Lorentz.Vector.fderiv_apply] rfl · fun_prop @@ -306,8 +305,7 @@ lemma magneticFieldMatrix_eq_vectorPotential {c : SpeedOfLight} (A : Electromagn rw [add_comm] congr all_goals - · rw [← Space.deriv_lorentz_vector] - rfl + · rfl fun_prop /-! @@ -396,7 +394,6 @@ lemma time_deriv_magneticFieldMatrix {d : ℕ} {c : SpeedOfLight} (A : Electroma conv_lhs => enter [1, t] rw [magneticFieldMatrix_eq_vectorPotential _ (hA.differentiable (by simp))] - rw [Time.deriv, fderiv_fun_sub] rfl all_goals · apply Differentiable.differentiableAt From 1f7106e937a61975e75272dd3dd27f1e2b771cd3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 07:14:43 -0700 Subject: [PATCH 383/498] refactor: golf electromagnetic dynamics wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Distributional/Basic.lean | 1 - Physlib/Electromagnetism/Dynamics/Hamiltonian.lean | 1 - Physlib/Electromagnetism/Dynamics/IsExtrema.lean | 1 - Physlib/Electromagnetism/Dynamics/KineticTerm.lean | 8 ++------ Physlib/Electromagnetism/Kinematics/EMPotential.lean | 1 - 5 files changed, 2 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Basic.lean b/Physlib/Electromagnetism/Distributional/Basic.lean index 8f29038c3..7d016b011 100644 --- a/Physlib/Electromagnetism/Distributional/Basic.lean +++ b/Physlib/Electromagnetism/Distributional/Basic.lean @@ -202,7 +202,6 @@ lemma toTensor_distTensorDeriv_basis_repr_apply {d} (A : DistElectromagneticPote match b with | ⟨i, j⟩ => simp - rw [hb] rfl end DistElectromagneticPotential diff --git a/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean b/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean index d05778a75..f8b42031c 100644 --- a/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean +++ b/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean @@ -208,7 +208,6 @@ lemma hamiltonian_eq_electricField_vectorPotential {d} {𝓕 : FreeSpace} simp [vectorPotential, timeSlice] ring_nf congr - rw [← Time.deriv_lorentzVector] rfl · exact (hA.differentiable (by simp)).comp (by fun_prop) · exact vectorPotential_differentiable_time A (hA.differentiable (by simp)) x.space diff --git a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean index dff99ce3f..7c2820229 100644 --- a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean @@ -417,7 +417,6 @@ lemma time_deriv_time_deriv_electricField_of_isExtrema {A : ElectromagneticPoten congr rw [Time.deriv_eq] rw [fderiv_fun_sum fun i _ => (hBt i).differentiableAt] - simp only [FunLike.coe_sum, Finset.sum_apply] rfl _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * (∑ j, ∂[j] (fun x => ∂ₜ (A.magneticFieldMatrix 𝓕.c · x (j, i)) t)) x - 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by diff --git a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean index 1aa213689..f5e11d91a 100644 --- a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean @@ -758,11 +758,9 @@ lemma gradKineticTerm_eq_fieldStrength {d} {𝓕 : FreeSpace} (A : Electromagnet apply Finset.sum_congr rfl (fun ν _ => ?_) apply Finset.sum_congr rfl (fun μ _ => ?_) congr - · rw [SpaceTime.deriv_eq, SpaceTime.deriv_eq, fderiv_const_mul] - rfl + · rfl fun_prop - · rw [SpaceTime.deriv_eq, SpaceTime.deriv_eq, fderiv_const_mul] - rfl + · rfl fun_prop _ = ∑ (ν : (Fin 1 ⊕ Fin d)), ∑ (μ : (Fin 1 ⊕ Fin d)), ((1/𝓕.μ₀ * η ν ν) * (∂_ μ (fun x' => η μ μ * ∂_ μ A x' ν - @@ -871,7 +869,6 @@ lemma gradKineticTerm_add {d} {𝓕 : FreeSpace} (A1 A2 : ElectromagneticPotenti rw [fieldStrengthMatrix_add _ _ _ (hA1.differentiable (by simp)) (hA2.differentiable (by simp))] simp [Finsupp.coe_add, Pi.add_apply] - rw [fderiv_fun_add] rfl · apply fieldStrengthMatrix_differentiable <| hA1.of_le (ENat.LEInfty.out) · apply fieldStrengthMatrix_differentiable <| hA2.of_le (ENat.LEInfty.out) @@ -902,7 +899,6 @@ lemma gradKineticTerm_smul {d} {𝓕 : FreeSpace} (A : ElectromagneticPotential rw [← SpaceTime.deriv_eq] congr funext x - rw [fieldStrengthMatrix_smul _ _ _] rfl · exact hA.differentiable (by simp) · exact hA diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index ed3a4c9e5..d947c02c2 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -630,7 +630,6 @@ lemma toTensor_deriv_basis_repr_apply {d} (A : ElectromagneticPotential d) (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by ext ⟨i, j⟩ simp - rw [hb] rfl end ElectromagneticPotential From e1aaef1d654ae7ebe03782e2ad7cf6471d80591e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 07:23:25 -0700 Subject: [PATCH 384/498] refactor: golf relativity tensor wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/Basic.lean | 5 +---- Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean | 6 ++---- .../Tensors/RealTensor/Vector/Pre/Contraction.lean | 7 ++----- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index cba125320..29ef226c1 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -478,7 +478,6 @@ lemma drop_actionP {n : ℕ} {c : Fin (n + 1) → C} {i : Fin (n + 1)} {p : Pure (g • p).drop i = g • (p.drop i) := by ext j rw [drop, actionP_eq, actionP_eq] - simp only [Function.comp_apply] rfl end Pure @@ -524,9 +523,7 @@ lemma actionT_zero {g : G} : g • (0 : S.Tensor c) = 0 := by simp [actionT_eq] lemma actionT_neg {g : G} {t : S.Tensor c} : g • (-t) = -(g • t) := by - rw [actionT_eq] - simp only [map_neg, neg_inj] - rfl + simp [actionT_eq] noncomputable instance : DistribMulAction G (S.Tensor c) where smul_zero g := by simp [actionT_zero] diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean index d05ec8e7c..12c5b0c2e 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Basic.lean @@ -263,16 +263,14 @@ def leftHandedDualEquiv : leftHandedRep.Equiv dualLeftHandedRep := by rw [leftHandedDualTo_hom_apply, leftHandedToDual_hom_apply] rw [DualLeftHandedWeyl.toFin2ℂ, LinearEquiv.apply_symm_apply, mulVec_mulVec] rw [show (!![0, -1; (1 : ℂ), 0] * !![0, 1; -1, 0]) = 1 by simpa using Eq.symm one_fin_two] - rw [one_mulVec] - rfl + simp · intro ψ simp only [AddHom.toFun_eq_coe, LinearMap.coe_toAddHom, Representation.IntertwiningMap.coe_toLinearMap] rw [leftHandedDualTo_hom_apply, leftHandedToDual_hom_apply, LeftHandedWeyl.toFin2ℂ, LinearEquiv.apply_symm_apply, mulVec_mulVec] rw [show (!![0, (1 : ℂ); -1, 0] * !![0, -1; 1, 0]) = 1 by simpa using Eq.symm one_fin_two] - rw [one_mulVec] - rfl + simp /-- `leftHandedDualEquiv` acting on an element `ψ : leftHanded` corresponds to multiplying `ψ` by the matrix `!![0, 1; -1, 0]`. -/ diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 908f51c55..414d2a8f6 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -85,8 +85,7 @@ def contrCoContract : ((ContrMod.rep).tprod (CoMod.rep)).IntertwiningMap change (Λ.1 *ᵥ ψ.toFin1dℝ) ⬝ᵥ ((LorentzGroup.transpose Λ⁻¹).1 *ᵥ φ.toFin1dℝ) = _ rw [dotProduct_mulVec, LorentzGroup.transpose_val, vecMul_transpose, mulVec_mulVec, LorentzGroup.coe_inv, inv_mul_of_invertible Λ.1] - simp only [one_mulVec] - rfl + simp [contrModCoModBi] /-- Notation for `contrCoContract` acting on a tmul. -/ local notation "⟪" ψ "," φ "⟫ₘ" => contrCoContract (ψ ⊗ₜ φ) @@ -106,8 +105,7 @@ def coContrContract : ((CoMod.rep (d := d)).tprod (ContrMod.rep (d := d))).Inter change ((LorentzGroup.transpose Λ⁻¹).1 *ᵥ ψ.toFin1dℝ) ⬝ᵥ (Λ.1 *ᵥ φ.toFin1dℝ) = _ rw [dotProduct_mulVec, LorentzGroup.transpose_val, mulVec_transpose, vecMul_vecMul, LorentzGroup.coe_inv, inv_mul_of_invertible Λ.1] - simp only [vecMul_one] - rfl + simp [coModContrModBi] /-- Notation for `coContrContract` acting on a tmul. -/ local notation "⟪" φ "," ψ "⟫ₘ" => coContrContract (φ ⊗ₜ ψ) @@ -151,7 +149,6 @@ local notation "⟪" ψ "," φ "⟫ₘ" => contrContrContractField (ψ ⊗ₜ φ lemma contrContrContract_hom_tmul (φ : Contr d) (ψ : Contr d) : ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ:= by simp only [contrContrContractField] - erw [contrCoContract_hom_tmul] rfl /-- The linear map from Co d ⊗ Co d to ℝ induced by the homomorphism From 9c557a355d4f310639ee1889583da0df9731a8a1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 07:32:54 -0700 Subject: [PATCH 385/498] refactor: golf quantum info wrapper endings Co-authored-by: Claude Opus 4.8 --- .../Lagrangian/TotalDerivativeEquivalence.lean | 3 +-- QuantumInfo/Channels/MatrixMap.lean | 1 - QuantumInfo/Channels/Pinching.lean | 1 - QuantumInfo/Entropy/Relative.lean | 1 - QuantumInfo/States/Mixed/MState.lean | 1 - 5 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean index e2d64f984..362582769 100644 --- a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean +++ b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean @@ -121,8 +121,7 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : (1, ∂ₜ q t).2 = fderiv ℝ (fun t' => (tq q t').2) t 1 := by rfl _ = (∂ₜ (tq q) t).2 := by rw [fderiv.snd] - · simp only [ContinuousLinearMap.comp_apply, ContinuousLinearMap.coe_snd'] - rfl + · rfl · apply ContDiffAt.differentiableAt · exact (h_tq_contDiff q h_ContDiff_q).contDiffAt · by_contra diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index ba94eb425..acaf43ef2 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -233,7 +233,6 @@ theorem kron_def [CommSemiring R] (M₁ : MatrixMap A B R) (M₂ : MatrixMap C D rw [Finset.sum_eq_single a₁, Finset.sum_eq_single a₂, Finset.sum_eq_single c₁, Finset.sum_eq_single c₂] <;> simp +contextual nth_rw 1 [h_expand] - simp only [map_sum, LinearMap.map_smulₛₗ] rfl rw [h_expand] clear h_expand diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index c7b4b5746..70d1a786b 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -151,7 +151,6 @@ theorem pinching_self (ρ : MState d) : pinching_map ρ ρ = ρ := by change (pinching_kraus ρ x ^ 2).mat rw [pinching_sq_eq_self] simp_rw [← Finset.mul_sum, ← HermitianMat.mat_finset_sum] - simp only [pinching_sum, HermitianMat.mat_one, mul_one] rfl set_option backward.isDefEq.respectTransparency false in diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 739081379..d5fe2ce04 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -1493,7 +1493,6 @@ private theorem sandwichedRelRentropy_additive_alpha_one (ρ₁ σ₁ : MState d <;> by_cases h2 : σ₂.M.ker ≤ ρ₂.M.ker · simp only [SandwichedRelRentropy, ↓reduceIte, ↓reduceDIte, h1, h2] split_ifs <;> simp_all [ ker_prod_le_iff ]; - simp only [sandwichedRelRentropy_additive_alpha_one_aux ρ₁ σ₁ ρ₂ σ₂ h1 h2] rfl · simp only [SandwichedRelRentropy, zero_lt_one, ↓reduceDIte, ↓reduceIte, h1, h2, add_top, dite_eq_right_iff, ENNReal.coe_ne_top, imp_false] diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 54a64f808..52c1ad535 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -476,7 +476,6 @@ theorem spectralDecomposition (ρ : MState d) : congr! simp only [Matrix.mul_diagonal, Matrix.IsHermitian.eigenvectorUnitary_apply, mul_comm, Matrix.star_apply, RCLike.star_def] - simp only [Function.comp_apply, mat_M, mat_apply, HermitianMat.smul_apply, Complex.real_smul] rfl end pure From d0004308bca11f5e84603e48107e448954e8caf2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 07:36:15 -0700 Subject: [PATCH 386/498] refactor: golf math and QFT wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean | 4 +--- Physlib/Mathematics/List/InsertionSort.lean | 2 -- Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean index 9927e1cc3..f9828f87b 100644 --- a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean @@ -119,8 +119,7 @@ noncomputable def tangentInnerCore (g : RiemannianMetric I n M) (x : M) : add_left := λ u v w => by simp only [inner_apply, map_add, add_apply] smul_left := λ r u v => by - simp only [inner_apply, map_smul, conj_trivial] - rfl + simp [inner_apply] definite := fun v (h_inner_zero : g.inner x v v = 0) => by by_contra h_v_ne_zero have h_pos : g.inner x v v > 0 := g.pos_def x v h_v_ne_zero @@ -197,7 +196,6 @@ lemma norm_eq_norm_of_metricNormedAddCommGroup (g : RiemannianMetric I n M) (x : (@NormedAddCommGroup.toNorm _ (TangentSpace.metricNormedAddCommGroup g x)) v := by unfold norm let normed_group := TangentSpace.metricNormedAddCommGroup g x - simp only [inner_apply] rfl end InnerProductSpace diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index 468dc7af2..34f91e049 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -74,7 +74,6 @@ lemma insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt {α : Type} (r : α simp only [Fin.getElem_fin, List.get_eq_getElem] simp only [insertionSortDropMinPos, List.length_cons, Nat.succ_eq_add_one, finCongr_apply] rw [eraseIdx_get] - simp only [List.length_cons, Function.comp_apply, List.get_eq_getElem, Fin.val_cast] rfl erw [h1] simp only [List.length_cons, Nat.succ_eq_add_one, List.get_eq_getElem] @@ -332,7 +331,6 @@ lemma insertionSortEquiv_insertionSort_append {α : Type} (r : α → α → Pro have hl : (List.insertionSort r (List.insertionSort r l1 ++ a :: l2)) = (List.insertionSort r (l1 ++ a :: l2)) := insertionSort_insertionSort_append r l1 (a :: l2) erw [orderedInsertEquiv_congr _ _ _ hl] - simp only [List.foldr_cons, finCongr_apply] rfl /-! diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index db1fa564a..7f5a272fc 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -463,7 +463,6 @@ lemma timeOrder_ofFieldOp_ofFieldOp_not_ordered_eq_timeOrder {φ ψ : 𝓕.Field 𝓣(ofFieldOp φ * ofFieldOp ψ) = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ ψ) • 𝓣(ofFieldOp ψ * ofFieldOp φ) := by rw [ofFieldOp, ofFieldOp, ← map_mul, timeOrder_eq_ι_timeOrderF, timeOrderF_ofFieldOpF_ofFieldOpF_not_ordered_eq_timeOrderF h] - simp only [map_smul] rfl lemma timeOrder_ofFieldOpList_nil : 𝓣(ofFieldOpList (𝓕 := 𝓕) []) = 1 := by From e55bfdfde48cdbacc6518b865ee870e15629f793 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 07:53:04 -0700 Subject: [PATCH 387/498] refactor: golf math and Wick wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/Divergence.lean | 3 +-- .../Mathematics/VariationalCalculus/IsTestFunction.lean | 7 +++---- .../PerturbationTheory/FieldSpecification/CrAnSection.lean | 3 +-- .../PerturbationTheory/WickAlgebra/StaticWickTheorem.lean | 3 +-- QuantumInfo/Channels/Pinching.lean | 1 - 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Physlib/Mathematics/Calculus/Divergence.lean b/Physlib/Mathematics/Calculus/Divergence.lean index 8e7434a00..525524212 100644 --- a/Physlib/Mathematics/Calculus/Divergence.lean +++ b/Physlib/Mathematics/Calculus/Divergence.lean @@ -40,8 +40,7 @@ lemma divergence_eq_sum_fderiv {s : Finset E} (b : Basis s 𝕜 E) {f : E → E} divergence 𝕜 f = fun x => ∑ i : s, b.repr (fderiv 𝕜 f x (b i)) i := by funext x rw [divergence, LinearMap.trace_eq_matrix_trace_of_finset (s := s) _ b] - simp only [Matrix.trace, Matrix.diag, LinearMap.toMatrix_apply] - rfl + simp [Matrix.trace, Matrix.diag, LinearMap.toMatrix_apply] lemma divergence_eq_sum_fderiv' {ι} [Fintype ι] (b : Basis ι 𝕜 E) {f : E → E} : divergence 𝕜 f = fun x => ∑ i, b.repr (fderiv 𝕜 f x (b i)) i := by diff --git a/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean b/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean index 8261d64fb..109616792 100644 --- a/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean +++ b/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean @@ -85,10 +85,9 @@ lemma IsTestFunction.pi {ι} [Fintype ι] {φ : X → ι → U} (hφ : ∀ i, Is refine exists_compact_iff_hasCompactSupport.mp ⟨⋃ i, K i, isCompact_iUnion (fun i => (hK i).1), fun x hx => ?_⟩ simp at hx - conv_lhs => - enter [i] - rw [(hK i).2 x (hx i)] - rfl + apply funext + intro i + exact (hK i).2 x (hx i) lemma IsTestFunction.space_component {φ : X → Space d} (hφ : IsTestFunction φ) : IsTestFunction (fun x => φ x i) where diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 29e06e917..942f520b3 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -197,8 +197,7 @@ lemma sum_nil (f : CrAnSection (𝓕 := 𝓕) [] → M) [AddCommMonoid M] : lemma sum_cons (f : CrAnSection (φ :: φs) → M) [AddCommMonoid M] : ∑ (s : CrAnSection (φ :: φs)), f s = ∑ (a : 𝓕.fieldOpToCrAnType φ), ∑ (s : CrAnSection φs), f (cons a s) := by - rw [← consEquiv.symm.sum_comp, Fintype.sum_prod_type] - rfl + simpa [Fintype.sum_prod_type, consEquiv] using Eq.symm (consEquiv.symm.sum_comp f) lemma sum_over_length {s : CrAnSection φs} (f : Fin s.1.length → M) [AddCommMonoid M] : ∑ (n : Fin s.1.length), f n = diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/StaticWickTheorem.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/StaticWickTheorem.lean index 3261bf4f4..5a7f83d96 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/StaticWickTheorem.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/StaticWickTheorem.lean @@ -68,8 +68,7 @@ theorem static_wick_theorem : (φs : List 𝓕.FieldOp) → rw [Finset.mul_sum] apply Finset.sum_congr rfl intro c _ - rw [mul_staticWickTerm_eq_sum] - rfl + simp [mul_staticWickTerm_eq_sum] end WickAlgebra end FieldSpecification diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 70d1a786b..59b2734ec 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -150,7 +150,6 @@ theorem pinching_self (ρ : MState d) : pinching_map ρ ρ = ρ := by enter [1, 2, x, 2] change (pinching_kraus ρ x ^ 2).mat rw [pinching_sq_eq_self] - simp_rw [← Finset.mul_sum, ← HermitianMat.mat_finset_sum] rfl set_option backward.isDefEq.respectTransparency false in From 6262e7fbb9dc4b548b5bebb50570fd9072a94540 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:02:59 -0700 Subject: [PATCH 388/498] refactor: golf wave and quantum wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/WaveEquation/Basic.lean | 3 +-- Physlib/CondensedMatter/TightBindingChain/Basic.lean | 3 +-- Physlib/Relativity/SL2C/Basic.lean | 3 +-- Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean | 3 +-- QuantumInfo/Measurements/POVM.lean | 2 -- QuantumInfo/States/Pure/Braket.lean | 6 ++---- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Physlib/ClassicalMechanics/WaveEquation/Basic.lean b/Physlib/ClassicalMechanics/WaveEquation/Basic.lean index 8b85f180a..b6713b9d7 100644 --- a/Physlib/ClassicalMechanics/WaveEquation/Basic.lean +++ b/Physlib/ClassicalMechanics/WaveEquation/Basic.lean @@ -138,8 +138,7 @@ lemma planeWave_time_deriv {d f₀ c x} {s : Direction d} FunLike.coe_smul, Pi.smul_apply, PiLp.neg_apply, PiLp.smul_apply, smul_eq_mul, neg_mul, neg_inj, mul_eq_mul_left_iff] left - simp - rfl + simp [planeWave] repeat fun_prop lemma planeWave_time_deriv_time_deriv {d f₀ c x} {s : Direction d} diff --git a/Physlib/CondensedMatter/TightBindingChain/Basic.lean b/Physlib/CondensedMatter/TightBindingChain/Basic.lean index 60bd6a73d..df9bee055 100644 --- a/Physlib/CondensedMatter/TightBindingChain/Basic.lean +++ b/Physlib/CondensedMatter/TightBindingChain/Basic.lean @@ -386,8 +386,7 @@ lemma quantaWaveNumber_exp_N (n : ℕ) (k : T.QuantaWaveNumber) : field_simp ring_nf congr 1 - rw [mul_comm] - rfl + exact mul_comm _ _ lemma quantaWaveNumber_exp_sub_one (n : Fin T.N) (k : T.QuantaWaveNumber) : Complex.exp (Complex.I * k * (n - 1).val * T.a) = diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index 4d0d9f937..3f6ebcdd3 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -167,8 +167,7 @@ lemma toMatrix_mem_lorentzGroup (M : SL(2, ℂ)) : toMatrix M ∈ LorentzGroup 3 def toLorentzGroup : SL(2, ℂ) →* LorentzGroup 3 where toFun M := ⟨toMatrix M, toMatrix_mem_lorentzGroup M⟩ map_one' := by - simp only [_root_.map_one] - rfl + exact Subtype.ext (by simp) map_mul' M N := by ext1 simp only [_root_.map_mul, lorentzGroupIsGroup_mul_coe] diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean index a0388a8f4..1b3b04e0d 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Finite.lean @@ -184,8 +184,7 @@ lemma μProd_of_fintype (T : Temperature) [IsFinite 𝓒] (i : ι) : (𝓒.μProd T).real {i} = 𝓒.probability T i := by rw [μProd] simp [probability] - rw [inv_mul_eq_div] - rfl + rw [inv_mul_eq_div, mathematicalPartitionFunction, measureReal_def] lemma meanEnergy_of_fintype [IsFinite 𝓒] (T : Temperature) : 𝓒.meanEnergy T = ∑ i, 𝓒.energy i * 𝓒.probability T i := by diff --git a/QuantumInfo/Measurements/POVM.lean b/QuantumInfo/Measurements/POVM.lean index c2c7c32e0..362f09848 100644 --- a/QuantumInfo/Measurements/POVM.lean +++ b/QuantumInfo/Measurements/POVM.lean @@ -103,8 +103,6 @@ open Kronecker in theorem measurementMap_apply_matrix (Λ : POVM X d) (m : Matrix d d ℂ) : Λ.measurementMap.map m = ∑ x : X, ((((Λ.mats x) ^ (1/2:ℝ)).mat * m * ((Λ.mats x)^(1/2:ℝ)).mat) ⊗ₖ Matrix.single x x 1) := by - dsimp [measurementMap, HPMap.map] - rw [LinearMap.sum_apply] rfl open HermitianMat in diff --git a/QuantumInfo/States/Pure/Braket.lean b/QuantumInfo/States/Pure/Braket.lean index 342aba6e9..e8ffe83b2 100644 --- a/QuantumInfo/States/Pure/Braket.lean +++ b/QuantumInfo/States/Pure/Braket.lean @@ -109,12 +109,10 @@ theorem Bra.ext {ξ ψ : Bra d} (h : ∀ x, ξ x = ψ x) : ξ = ψ := DFunLike.ext ξ ψ h theorem Ket.normalized (ψ : Ket d) : ∑ x, Complex.normSq (ψ x) = 1 := by - convert ψ.normalized' - rfl + exact ψ.normalized' theorem Bra.normalized (ψ : Bra d) : ∑ x, Complex.normSq (ψ x) = 1 := by - convert ψ.normalized' - rfl + exact ψ.normalized' /-- Any Bra can be turned into a Ket by conjugating the elements. -/ @[coe] From ee28cbcbd15f3f0b9c0d1bd485d4546b98484d85 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:09:44 -0700 Subject: [PATCH 389/498] refactor: golf electromagnetic wrapper endings Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Distributional/Basic.lean | 6 +----- Physlib/Electromagnetism/Dynamics/Hamiltonian.lean | 1 - Physlib/Electromagnetism/Kinematics/EMPotential.lean | 3 +-- Physlib/Electromagnetism/Kinematics/ElectricField.lean | 1 - Physlib/Electromagnetism/Kinematics/MagneticField.lean | 1 - Physlib/Electromagnetism/Vacuum/HarmonicWave.lean | 1 - Physlib/SpaceAndTime/Space/IsDistBounded.lean | 3 +-- Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean | 3 +-- 8 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Basic.lean b/Physlib/Electromagnetism/Distributional/Basic.lean index 7d016b011..09865a083 100644 --- a/Physlib/Electromagnetism/Distributional/Basic.lean +++ b/Physlib/Electromagnetism/Distributional/Basic.lean @@ -154,7 +154,6 @@ lemma distTensorDeriv_eq_sum_sum {d} (A : DistElectromagneticPotential d) rw [tmul_sum] congr funext ν - simp rfl /-! @@ -198,10 +197,7 @@ lemma toTensor_distTensorDeriv_basis_repr_apply {d} (A : DistElectromagneticPote (Lorentz.Vector.basis.reindex Lorentz.Vector.indexEquiv.symm)) = ((Lorentz.CoVector.basis (d := d)).tensorProduct (Lorentz.Vector.basis (d := d))).reindex (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by - ext b - match b with - | ⟨i, j⟩ => - simp + rfl rfl end DistElectromagneticPotential diff --git a/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean b/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean index f8b42031c..ffda4f069 100644 --- a/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean +++ b/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean @@ -207,7 +207,6 @@ lemma hamiltonian_eq_electricField_vectorPotential {d} {𝓕 : FreeSpace} rw [← Time.deriv_euclid] simp [vectorPotential, timeSlice] ring_nf - congr rfl · exact (hA.differentiable (by simp)).comp (by fun_prop) · exact vectorPotential_differentiable_time A (hA.differentiable (by simp)) x.space diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index d947c02c2..ed0bf6a1b 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -628,8 +628,7 @@ lemma toTensor_deriv_basis_repr_apply {d} (A : ElectromagneticPotential d) (Lorentz.Vector.basis.reindex Lorentz.Vector.indexEquiv.symm)) = ((Lorentz.CoVector.basis (d := d)).tensorProduct (Lorentz.Vector.basis (d := d))).reindex (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by - ext ⟨i, j⟩ - simp + rfl rfl end ElectromagneticPotential diff --git a/Physlib/Electromagnetism/Kinematics/ElectricField.lean b/Physlib/Electromagnetism/Kinematics/ElectricField.lean index 8e4bcc04a..4e10e653a 100644 --- a/Physlib/Electromagnetism/Kinematics/ElectricField.lean +++ b/Physlib/Electromagnetism/Kinematics/ElectricField.lean @@ -293,7 +293,6 @@ lemma time_deriv_comp_vectorPotential_eq_electricField {d} {A : ElectromagneticP ∂ₜ (fun t => A.vectorPotential c t x i) t = - A.electricField c t x i - ∂[i] (A.scalarPotential c t) x := by rw [Time.deriv_euclid, time_deriv_vectorPotential_eq_electricField] - simp rfl apply vectorPotential_differentiable_time A hA x diff --git a/Physlib/Electromagnetism/Kinematics/MagneticField.lean b/Physlib/Electromagnetism/Kinematics/MagneticField.lean index 64c1836a2..1e1b603b3 100644 --- a/Physlib/Electromagnetism/Kinematics/MagneticField.lean +++ b/Physlib/Electromagnetism/Kinematics/MagneticField.lean @@ -471,7 +471,6 @@ lemma curl_magneticFieldMatrix_eq_electricField_fieldStrengthMatrix {d : ℕ} {c field_simp · funext j rw [SpaceTime.deriv_sum_inr c] - simp rfl · apply fieldStrengthMatrix_differentiable hA diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index 853e51de0..4c815b318 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -92,7 +92,6 @@ lemma harmonicWaveX_inl_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → lemma harmonicWaveX_inr_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) (x : SpaceTime d.succ) : harmonicWaveX 𝓕 k E₀ φ x (Sum.inr 0) = 0 := by - simp [harmonicWaveX] rfl /-! diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index 2c986f325..4aae3598a 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -902,8 +902,7 @@ lemma pow_shift {d : ℕ} (n : ℤ) · simp exact hn · intro x - simp - rfl + simp [sub_eq_add_neg] @[fun_prop] lemma inv_shift {d : ℕ} (g : Space d) (hd : 2 ≤ d := by omega) : diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 1c7529463..7892bf305 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -648,8 +648,7 @@ lemma meanEnergy_add {T : Temperature} simp rw [integral_add h1 (integrable_const _)] rw [integral_const] - simp - rfl + simp [meanEnergy] · have h1 := integrable_energy_add 𝓒 𝓒1 T h1 h2 simp_all only [μProd_add] exact h1 From 39d4d620eec766ebd85dec41635fff9631be7158 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:13:22 -0700 Subject: [PATCH 390/498] refactor: golf electromagnetic zero wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Dynamics/CurrentDensity.lean | 2 -- Physlib/Electromagnetism/Kinematics/MagneticField.lean | 2 -- Physlib/Electromagnetism/Vacuum/HarmonicWave.lean | 5 ----- 3 files changed, 9 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean index a5879a637..54306087a 100644 --- a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean @@ -91,7 +91,6 @@ lemma chargeDensity_eq_timeSlice {d : ℕ} {c : SpeedOfLight} {J : LorentzCurren @[simp] lemma chargeDensity_zero {d : ℕ} {c : SpeedOfLight}: chargeDensity c (0 : LorentzCurrentDensity d) = 0 := by - simp [chargeDensity_eq_timeSlice, timeSlice] rfl /-! @@ -146,7 +145,6 @@ lemma currentDensity_eq_timeSlice {d : ℕ} {J : LorentzCurrentDensity d} : @[simp] lemma currentDensity_zero {d : ℕ} {c : SpeedOfLight}: currentDensity c (0 : LorentzCurrentDensity d) = 0 := by - simp [currentDensity_eq_timeSlice, timeSlice] rfl /-! diff --git a/Physlib/Electromagnetism/Kinematics/MagneticField.lean b/Physlib/Electromagnetism/Kinematics/MagneticField.lean index 1e1b603b3..faf91c126 100644 --- a/Physlib/Electromagnetism/Kinematics/MagneticField.lean +++ b/Physlib/Electromagnetism/Kinematics/MagneticField.lean @@ -100,7 +100,6 @@ lemma magneticField_coord_eq_fieldStrengthMatrix {i : Fin 3} {c : SpeedOfLight} congr all_goals · rw [SpaceTime.deriv_sum_inr c _ hA] - simp only [Fin.isValue, ContinuousLinearEquiv.apply_symm_apply] rfl · fun_prop @@ -150,7 +149,6 @@ lemma ofElectromagneticField_magneticField {c : SpeedOfLight} (u • basis.repr x) ⨯ₑ₃ B t (u • x) suffices h : ContDiff ℝ 1 (fun x => C x i) by convert! h using 1 - simp [C] rfl fin_cases i all_goals diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index 4c815b318..ef8a273f3 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -143,8 +143,6 @@ The scalar potential of the harmonic wave is zero. lemma harmonicWaveX_scalarPotential_eq_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) : (harmonicWaveX 𝓕 k E₀ φ).scalarPotential 𝓕.c = 0 := by - ext x - simp [harmonicWaveX, scalarPotential] rfl /-! @@ -163,7 +161,6 @@ lemma harmonicWaveX_scalarPotential_eq_zero {d} (𝓕 : FreeSpace) (k : ℝ) lemma harmonicWaveX_vectorPotential_zero_eq_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) (t : Time) (x : Space d.succ) : (harmonicWaveX 𝓕 k E₀ φ).vectorPotential 𝓕.c t x 0 = 0 := by - simp [harmonicWaveX, vectorPotential, SpaceTime.timeSlice] rfl lemma harmonicWaveX_vectorPotential_succ {d} (𝓕 : FreeSpace) (k : ℝ) @@ -518,7 +515,6 @@ lemma harmonicWaveX_isPlaneWave {d} (𝓕 : FreeSpace) (k : ℝ) (hk : k ≠ 0) ext t x i match i with | 0 => - simp [harmonicWaveX_electricField_zero, planeWave] rfl | ⟨Nat.succ i, h⟩ => simp only [Nat.succ_eq_add_one, neg_mul] @@ -540,7 +536,6 @@ lemma harmonicWaveX_isPlaneWave {d} (𝓕 : FreeSpace) (k : ℝ) (hk : k ≠ 0) ext ij match ij with | (0, 0) => - simp only [Nat.succ_eq_add_one, magneticFieldMatrix_diag_eq_zero, inner_basis, neg_mul] rfl | (⟨0, h0⟩, ⟨Nat.succ j, hj⟩) => simp only [Nat.succ_eq_add_one, Fin.zero_eta, inner_basis, neg_mul] From c6d94cc9f167c6cb151882684291f18f7cb80233 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:17:17 -0700 Subject: [PATCH 391/498] refactor: golf fin and variational wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Fin.lean | 3 +-- Physlib/Mathematics/Fin/Involutions.lean | 4 +--- Physlib/Mathematics/List/InsertionSort.lean | 4 +--- Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean | 2 -- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index b4a4171bc..6e09ebbb9 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -101,8 +101,7 @@ lemma finExtractOne_symm_inr {n : ℕ} (i : Fin n.succ) : · generalize_proofs hp have h1 : (finSumFinEquiv.symm (Fin.cast hp x)) = Sum.inl ⟨x, hi⟩ := by - rw [← finSumFinEquiv_symm_apply_castAdd] - rfl + exact finSumFinEquiv_symm_apply_castAdd (n := n - i.1) (⟨x, hi⟩ : Fin i.1) rw [h1] simp only [Nat.succ_eq_add_one, Equiv.sumAssoc_symm_apply_inr_inl, Sum.map_inl, Equiv.symm_trans_apply, Equiv.symm_symm, Equiv.sumComm_symm, Equiv.sumComm_apply, diff --git a/Physlib/Mathematics/Fin/Involutions.lean b/Physlib/Mathematics/Fin/Involutions.lean index 8a6af2743..cd47697fb 100644 --- a/Physlib/Mathematics/Fin/Involutions.lean +++ b/Physlib/Mathematics/Fin/Involutions.lean @@ -155,7 +155,6 @@ lemma involutionCons_ext {n : ℕ} {f1 f2 : (f : {f : Fin n → Fin n // Functio obtain ⟨val, property⟩ := fst obtain ⟨val_1, property_1⟩ := snd obtain ⟨val_2, property_2⟩ := snd_1 - simp_all only rfl /-- Given an involution of `Fin n`, the optional choice of an element in `Fin n` which @@ -201,8 +200,7 @@ lemma involutionAddEquiv_cast {n : ℕ} {f1 f2 : {f : Fin n → Fin n // Functio involutionAddEquiv f1 = (Equiv.subtypeEquivRight (by rw [hf]; simp)).trans ((involutionAddEquiv f2).trans (Equiv.optionCongr (finCongr (by rw [hf])))) := by subst hf - rw [finCongr_refl, Equiv.optionCongr_refl] - rfl + simp [Equiv.subtypeEquivRight] lemma involutionAddEquiv_cast' {m : ℕ} {f1 f2 : {f : Fin m → Fin m // Function.Involutive f}} {N : ℕ} (hf : f1 = f2) (n : Option (Fin N)) diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index 34f91e049..b19b778dc 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -73,8 +73,7 @@ lemma insertionSortMin_lt_mem_insertionSortDropMinPos_of_lt {α : Type} (r : α trans (insertionSortDropMinPos r a l).get i simp only [Fin.getElem_fin, List.get_eq_getElem] simp only [insertionSortDropMinPos, List.length_cons, Nat.succ_eq_add_one, finCongr_apply] - rw [eraseIdx_get] - rfl + exact congr_fun (eraseIdx_get (a :: l) (insertionSortMinPos r a l)) i erw [h1] simp only [List.length_cons, Nat.succ_eq_add_one, List.get_eq_getElem] apply insertionSortEquiv_order @@ -307,7 +306,6 @@ lemma insertionSortEquiv_orderedInsert_append {α : Type} (r : α → α → Pro simp only [List.insertionSort, List.length_cons, hl] conv_rhs => erw [insertionSortEquiv_commute _ _ _ h _ _] - simp rfl set_option backward.isDefEq.respectTransparency false in diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index 7f4d2e80d..3d8dbd900 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -709,14 +709,12 @@ protected lemma gradient {d} (u : Space d → ℝ) (hu : ContDiff ℝ ∞ u) : · intro φ1 φ2 h1 h2 rw [Space.gradient_eq_grad] rw [Space.grad_add, Space.grad_eq_gradient, Space.grad_eq_gradient] - simp rfl · exact h1.differentiable (by simp) · exact h2.differentiable (by simp) · intro c φ hφ rw [Space.gradient_eq_grad] rw [Space.grad_smul, Space.grad_eq_gradient] - simp rfl exact hφ.differentiable (by simp) · intro φ hφ x From 5edd11062ccce79f3f62837607f4da4ad95b1ed7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:31:44 -0700 Subject: [PATCH 392/498] refactor: golf tensor and unit rewrites Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/SchurTriangulation.lean | 3 +-- .../OneDimension/HilbertSpace/SchwartzSubmodule.lean | 3 +-- Physlib/Relativity/Tensors/Basic.lean | 3 +-- Physlib/Relativity/Tensors/Constructors.lean | 9 ++------- .../Tensors/RealTensor/Vector/Pre/Contraction.lean | 3 +-- Physlib/Relativity/Tensors/Reindexing.lean | 6 ++---- Physlib/SpaceAndTime/Time/Basic.lean | 3 +-- Physlib/Units/UnitDependent.lean | 3 +-- 8 files changed, 10 insertions(+), 23 deletions(-) diff --git a/Physlib/Mathematics/SchurTriangulation.lean b/Physlib/Mathematics/SchurTriangulation.lean index 0ec7fb8e3..2aff6aae3 100644 --- a/Physlib/Mathematics/SchurTriangulation.lean +++ b/Physlib/Mathematics/SchurTriangulation.lean @@ -180,8 +180,7 @@ protected noncomputable def SchurTriangulationAux.of have hf {bi i' bj j'} (hi : e i = ⟨bi, i'⟩) (hj : e j = ⟨bj, j'⟩) := calc toMatrixOrthonormal basis f i j _ = toMatrixOrthonormal bE f (e i) (e j) := by - rw [f.toMatrixOrthonormal_reindex] - rfl + exact congr_fun (congr_fun (f.toMatrixOrthonormal_reindex bE e.symm) i) j _ = ⟪bE (e i), f (bE (e j))⟫_𝕜 := f.toMatrixOrthonormal_apply_apply .. _ = ⟪(B bi i' : E), f (B bj j')⟫_𝕜 := by rw [hB, hB, hi, hj] diff --git a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/SchwartzSubmodule.lean b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/SchwartzSubmodule.lean index 85891c6f9..51b3e4335 100644 --- a/Physlib/QuantumMechanics/OneDimension/HilbertSpace/SchwartzSubmodule.lean +++ b/Physlib/QuantumMechanics/OneDimension/HilbertSpace/SchwartzSubmodule.lean @@ -48,8 +48,7 @@ lemma schwartzIncl_inner (ψ1 ψ2 : 𝓢(ℝ, ℂ)) : filter_upwards [h1, h2] with _ h1 h2 rw [← h1, ← h2] simp only [RCLike.inner_apply] - rw [mul_comm] - rfl + exact mul_comm _ _ end HilbertSpace end diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index 29ef226c1..c4447d0fa 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -213,8 +213,7 @@ lemma component_eq_drop {n : ℕ} {c : Fin (n + 1) → C} (p : Pure S c) (i : Fi p.component φ = ((b (c i)).repr (p i) (φ i)) * ((drop p i).component (fun j => φ (i.succAbove j))) := by simp only [component, Function.comp_apply] - rw [Fin.prod_univ_succAbove _ i] - rfl + exact Fin.prod_univ_succAbove _ i @[simp] lemma component_update_add {n : ℕ} [inst : DecidableEq (Fin n)] diff --git a/Physlib/Relativity/Tensors/Constructors.lean b/Physlib/Relativity/Tensors/Constructors.lean index d5c23960b..b57ae0e9c 100644 --- a/Physlib/Relativity/Tensors/Constructors.lean +++ b/Physlib/Relativity/Tensors/Constructors.lean @@ -412,8 +412,7 @@ lemma fromPairT_basis_repr {c c1 : C} rw [prodT_pure, permT_pure] rw [basis_repr_pure] simp [Pure.component] - rw [mul_comm] - rfl + exact mul_comm _ _ · intro x y hx hy simp_all [P] @@ -535,11 +534,7 @@ lemma fromTripleT_basis_repr {c c1 c2 : C} rw [prodT_pure, prodT_pure, permT_pure] rw [basis_repr_pure] simp [Pure.component, Fin.prod_univ_three] - conv_rhs => - rw [mul_assoc, mul_comm] - enter [1] - rw [mul_comm] - rfl + ac_rfl · intro y1 y2 hx hy simp only [Nat.succ_eq_add_one, Nat.reduceAdd, Fin.isValue, Basis.tensorProduct_repr_tmul_apply, smul_eq_mul, P1, P] at hx hy diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 414d2a8f6..8baa92014 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -193,8 +193,7 @@ lemma as_sum_toSpace : ⟪x, y⟫ₘ = x.val (Sum.inl 0) * y.val (Sum.inl 0) - rw [as_sum] congr funext i - rw [mul_comm] - rfl + exact mul_comm _ _ lemma stdBasis_inl {d : ℕ} : ⟪@ContrMod.stdBasis d (Sum.inl 0), ContrMod.stdBasis (Sum.inl 0)⟫ₘ = (1 : ℝ) := by diff --git a/Physlib/Relativity/Tensors/Reindexing.lean b/Physlib/Relativity/Tensors/Reindexing.lean index 4f42a3e19..3a8eaa34d 100644 --- a/Physlib/Relativity/Tensors/Reindexing.lean +++ b/Physlib/Relativity/Tensors/Reindexing.lean @@ -123,8 +123,7 @@ lemma inv_perserve_color {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} obtain ⟨x, rfl⟩ := h.toEquiv.symm.surjective x change c1 (h.toEquiv _) = _ simp only [Equiv.apply_symm_apply] - rw [h.preserve_color] - rfl + exact h.preserve_color _ set_option warning.simp.varHead false in @[simp, nolint simpVarHead] @@ -132,8 +131,7 @@ lemma toEquiv_symm_perserve_color {n m : ℕ} {c : Fin n → C} {c1 : Fin m → {σ : Fin m → Fin n} (h : IsReindexing c c1 σ) (x : Fin m) : c (h.toEquiv.symm x) = c1 x := by obtain ⟨x, rfl⟩ := h.toEquiv.surjective x - rw [h.preserve_color] - rfl + exact (h.preserve_color (h.toEquiv x)).symm /-! diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index 812e5784e..e6d5e389d 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -384,8 +384,7 @@ noncomputable def basis : OrthonormalBasis (Fin 1) ℝ Time where rw [@PiLp.norm_eq_of_L2] simp only [Finset.univ_unique, Fin.default_eq_zero, Fin.isValue, Real.norm_eq_abs, sq_abs, Finset.sum_const, Finset.card_singleton, one_smul] - rw [Real.sqrt_sq_eq_abs] - rfl + exact Real.sqrt_sq_eq_abs _ } @[simp] diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 271c42a04..36e1253aa 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -266,8 +266,7 @@ noncomputable instance {M : Type} [AddCommMonoid M] [Module ℝ M] [HasDim M] : scaleUnit_smul u1 u2 r m := by change (toDimensionful u1 (r • m)).1 u2 = _ rw [toDimensionful_apply_apply] - rw [smul_comm] - rfl + exact smul_comm _ _ _ noncomputable instance {M : Type} [AddCommMonoid M] [Module ℝ M] [HasDim M] [TopologicalSpace M] From d3168f61019653827a4e699634dfbbc0aa11df53 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:40:34 -0700 Subject: [PATCH 393/498] refactor: golf tensor and anomaly rewrites Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List.lean | 7 +++---- Physlib/QFT/AnomalyCancellation/GroupActions.lean | 9 +++------ .../QFT/PerturbationTheory/FieldStatistics/Basic.lean | 7 +++---- Physlib/QFT/QED/AnomalyCancellation/Sorts.lean | 6 ++---- Physlib/Relativity/Tensors/Basic.lean | 1 - Physlib/Relativity/Tensors/Contraction/Products.lean | 3 +-- .../Relativity/Tensors/Contraction/SuccSuccAbove.lean | 3 +-- Physlib/Relativity/Tensors/MetricTensor.lean | 3 +-- 8 files changed, 14 insertions(+), 25 deletions(-) diff --git a/Physlib/Mathematics/List.lean b/Physlib/Mathematics/List.lean index 18a2036a0..de6348251 100644 --- a/Physlib/Mathematics/List.lean +++ b/Physlib/Mathematics/List.lean @@ -175,10 +175,9 @@ lemma orderedInsertPos_take_eq_orderedInsert {I : Type} (le1 : I → I → Prop) exact Nat.le_of_lt_succ (orderedInsertPos_lt_length le1 r r0) · intro n h1 h2 simp only [List.get_eq_getElem, List.getElem_take] - rw [orderedInsert_get_lt le1 r r0 n] - rfl - simp only [List.length_take, lt_inf_iff] at h1 - exact h1.1 + exact (orderedInsert_get_lt le1 r r0 n (by + simp only [List.length_take, lt_inf_iff] at h1 + exact h1.1)).symm lemma orderedInsertPos_drop_eq_orderedInsert {I : Type} (le1 : I → I → Prop) [DecidableRel le1] (r : List I) (r0 : I) : diff --git a/Physlib/QFT/AnomalyCancellation/GroupActions.lean b/Physlib/QFT/AnomalyCancellation/GroupActions.lean index afc7eee76..bb1345b20 100644 --- a/Physlib/QFT/AnomalyCancellation/GroupActions.lean +++ b/Physlib/QFT/AnomalyCancellation/GroupActions.lean @@ -61,8 +61,7 @@ def linSolRep {χ : ACCSystem} (G : ACCSystemGroupAction χ) : map_mul' g1 g2 := by refine LinearMap.ext fun S ↦ ACCSystemLinear.LinSols.ext ?_ change (G.rep (g1 * g2)) S.val = _ - rw [G.rep.map_mul] - rfl + exact LinearMap.congr_fun (G.rep.map_mul g1 g2) S.val map_one' := by refine LinearMap.ext fun S ↦ ACCSystemLinear.LinSols.ext ?_ change (G.rep.toFun 1) S.val = _ @@ -82,8 +81,7 @@ instance quadSolAction {χ : ACCSystem} (G : ACCSystemGroupAction χ) : mul_smul f1 f2 S := by apply ACCSystemQuad.QuadSols.ext change (G.rep.toFun (f1 * f2)) S.val = _ - rw [G.rep.map_mul'] - rfl + exact LinearMap.congr_fun (G.rep.map_mul' f1 f2) S.val one_smul S := by apply ACCSystemQuad.QuadSols.ext change (G.rep.toFun 1) S.val = _ @@ -106,8 +104,7 @@ instance solAction {χ : ACCSystem} (G : ACCSystemGroupAction χ) : MulAction G. mul_smul f1 f2 S := by apply ACCSystem.Sols.ext change (G.rep.toFun (f1 * f2)) S.val = _ - rw [G.rep.map_mul'] - rfl + exact LinearMap.congr_fun (G.rep.map_mul' f1 f2) S.val one_smul S := by apply ACCSystem.Sols.ext change (G.rep.toFun 1) S.val = _ diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean index 7289124f6..0b871969f 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean @@ -235,10 +235,9 @@ lemma ofList_map_eq_finset_prod (s : 𝓕 → FieldStatistic) : simp only [List.length_cons, mul_ite, ite_mul, one_mul, mul_one] by_cases ha : a = i · simp only [ha, ↓reduceIte, mul_self, true_or] - rw [if_neg] - rfl - simp only [List.length_cons, List.nodup_cons] at hl - exact hl.1 + exact if_neg (by + simp only [List.length_cons, List.nodup_cons] at hl + exact hl.1) · simp only [ha, ↓reduceIte, false_or, Fin.getElem_fin] simp only [List.length_cons, List.nodup_cons] at hl exact hl.2 diff --git a/Physlib/QFT/QED/AnomalyCancellation/Sorts.lean b/Physlib/QFT/QED/AnomalyCancellation/Sorts.lean index 581a3e31e..5befe83f3 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Sorts.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Sorts.lean @@ -54,8 +54,7 @@ lemma sort_zero {n : ℕ} (S : (PureU1 n).Charges) (hS : sort S = 0) : S = 0 := have hi := hj ((Tuple.sort S).invFun i) rw [sort_apply] at hi simp only [Equiv.invFun_as_coe, Equiv.apply_symm_apply] at hi - rw [hi] - rfl + exact hi lemma sort_projection {n : ℕ} (S : (PureU1 n).Charges) : sort (sort S) = sort S := sort_perm S (Tuple.sort S).symm @@ -70,8 +69,7 @@ lemma sortAFL_zero {n : ℕ} (S : (PureU1 n).LinSols) (hS : sortAFL S = 0) : S = apply ACCSystemLinear.LinSols.ext have h1 : sort S.val = 0 := by rw [← sortAFL_val] - rw [hS] - rfl + exact congrArg ACCSystemLinear.LinSols.val hS exact sort_zero S.val h1 end PureU1 diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index c4447d0fa..dbe6b2959 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -476,7 +476,6 @@ lemma actionP_cast {g : G} {p : Pure S c} (h : c = c1) : lemma drop_actionP {n : ℕ} {c : Fin (n + 1) → C} {i : Fin (n + 1)} {p : Pure S c} (g : G) : (g • p).drop i = g • (p.drop i) := by ext j - rw [drop, actionP_eq, actionP_eq] rfl end Pure diff --git a/Physlib/Relativity/Tensors/Contraction/Products.lean b/Physlib/Relativity/Tensors/Contraction/Products.lean index 0d95a6abb..2451026a3 100644 --- a/Physlib/Relativity/Tensors/Contraction/Products.lean +++ b/Physlib/Relativity/Tensors/Contraction/Products.lean @@ -133,8 +133,7 @@ lemma prodT_contrT_snd {n n1 : ℕ} {c : Fin (n + 1 + 1) → C} apply induction_on_pure · intro p1 simp only [Nat.add_eq, finSumFinEquiv_apply_right, contrT_pure, P2, P] - rw [Pure.prodP_contrP_snd, prodT_pure, contrT_pure] - rfl + simp [Pure.prodP_contrP_snd, prodT_pure, contrT_pure] · intro r t h1 simp_all only [map_smul, LinearMap.smul_apply, P2, P] · intro t1 t2 h1 h2 diff --git a/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean b/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean index 065e0eaeb..a602bdba3 100644 --- a/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean +++ b/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean @@ -342,8 +342,7 @@ lemma succSuccAbove_comm_apply (i1 j1 : Fin (n + 1 + 1 + 1 + 1)) (i2 j2 : Fin (n succSuccAbove i1 j1 (succSuccAbove i2 j2 m) := by intro i2' j2' hi2j2' i1' j1' change _ = (succSuccAbove i1 j1 ∘ succSuccAbove i2 j2) m - rw [succSuccAbove_comm i1 j1 i2 j2 hij1 hij2] - rfl + exact (congr_fun (succSuccAbove_comm i1 j1 i2 j2 hij1 hij2) m).symm /-! diff --git a/Physlib/Relativity/Tensors/MetricTensor.lean b/Physlib/Relativity/Tensors/MetricTensor.lean index dcbfe32e7..93f636ed0 100644 --- a/Physlib/Relativity/Tensors/MetricTensor.lean +++ b/Physlib/Relativity/Tensors/MetricTensor.lean @@ -45,8 +45,7 @@ lemma permT_fromPairTContr_metric_metric {c : C} : ((S.metric ((S.τ c))) (1 : k))) = (unitTensor c) := by rw [fromPairTContr, ← fromPairT_comm] change _ = fromPairT ((S.unit c) (1 : k)) - rw [← S.contr_metric] - rfl + exact congr_arg fromPairT (S.contr_metric c) lemma fromPairTContr_metric_metric_eq_permT_unit {c : C} : fromPairTContr ((S.metric c) (1 : k)) From 23b11af7f25dafde183b9373eed8d2a5f463418c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:47:53 -0700 Subject: [PATCH 394/498] refactor: golf action and scalar wrappers Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/FamilyMaps.lean | 3 +-- .../RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean | 3 +-- .../StandardModel/AnomalyCancellation/FamilyMaps.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean | 3 +-- Physlib/Relativity/LorentzGroup/Basic.lean | 3 +-- Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean | 3 +-- Physlib/Relativity/Tensors/ComponentIdx/Single.lean | 2 -- Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean | 3 +-- Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean | 3 +-- Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean | 3 +-- .../TimeAndSpace/EuclideanGroup/SchwartzAction.lean | 3 +-- 11 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean index 2a7277f93..724d22982 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean @@ -32,8 +32,7 @@ def chargesMapOfSpeciesMap {n m : ℕ} (f : (SMνSpecies n).Charges →ₗ[ℚ] map_smul' a S := by rw [charges_eq_toSpecies_eq] intro i - rw [map_smul, toSMSpecies_toSpecies_inv, toSMSpecies_toSpecies_inv, map_smul] - rfl + simp [toSMSpecies_toSpecies_inv] lemma chargesMapOfSpeciesMap_toSpecies {n m : ℕ} (f : (SMνSpecies n).Charges →ₗ[ℚ] (SMνSpecies m).Charges) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean index 594c080ce..098e15395 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean @@ -61,8 +61,7 @@ def generic (S : (PlusU1 n).QuadSols) : (PlusU1 n).Sols := lemma generic_on_AF (S : (PlusU1 n).Sols) : generic S.1 = (α₁ S.1) • S := by apply ACCSystem.Sols.ext change (BL.addQuad S.1 (α₁ S.1) (α₂ S.1)).val = _ - rw [BL_add_α₁_α₂_AF] - rfl + exact congrArg (fun Q : (PlusU1 n).QuadSols => Q.val) (BL_add_α₁_α₂_AF S) lemma generic_on_AF_α₁_ne_zero (S : (PlusU1 n).Sols) (h : α₁ S.1 ≠ 0) : (α₁ S.1)⁻¹ • generic S.1 = S := by diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/FamilyMaps.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/FamilyMaps.lean index 6e5eed1fc..62a33bcfa 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/FamilyMaps.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/FamilyMaps.lean @@ -36,8 +36,7 @@ def chargesMapOfSpeciesMap {n m : ℕ} (f : (SMSpecies n).Charges →ₗ[ℚ] (S intro i rw [map_smul] rw [toSMSpecies_toSpecies_inv, toSMSpecies_toSpecies_inv] - rw [map_smul] - rfl + exact (f.comp (toSpecies i)).map_smul a S /-- The projection of the `m`-family charges onto the first `n`-family charges for species. -/ @[simps!] diff --git a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean index 4e33e354c..176226b29 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean @@ -73,8 +73,7 @@ def coordinateMap : (PureU1 n.succ).LinSols ≃ₗ[ℚ] Fin n →₀ ℚ where toFun S := (Finsupp.linearEquivFunOnFinite ℚ ℚ (Fin n)).symm (S.1 ∘ Fin.castSucc) map_add' S T := map_add _ _ _ map_smul' a S := by - rw [← map_smul] - rfl + exact (Finsupp.linearEquivFunOnFinite ℚ ℚ (Fin n)).symm.map_smul a (S.1 ∘ Fin.castSucc) invFun f := ∑ i : Fin n, f i • asLinSols i left_inv S := by simp only [Nat.succ_eq_add_one, diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 2e87cc375..73d6152f7 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -394,8 +394,7 @@ lemma toComplex_mulVec_ofReal (v : Fin 1 ⊕ Fin d → ℝ) (Λ : LorentzGroup d toComplex Λ *ᵥ (ofRealHom ∘ v) = ofRealHom ∘ (Λ *ᵥ v) := by simp only [toComplex, MonoidHom.coe_mk, OneHom.coe_mk] funext i - rw [← RingHom.map_mulVec] - rfl + exact (RingHom.map_mulVec ofRealHom Λ.val v i).symm /-- The parity transformation. -/ def parity : LorentzGroup d := ⟨minkowskiMatrix, by diff --git a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean index 84e1cf0cf..3db8ce3fb 100644 --- a/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Orthochronous/Basic.lean @@ -163,8 +163,7 @@ lemma orthchroMap_not_IsOrthochronous {Λ : LorentzGroup d} (h : ¬ IsOrthochron orthchroMap Λ = Additive.toMul (1 : ZMod 2) := by simp only [orthchroMap, ContinuousMap.comp_apply, ContinuousMap.coe_mk, orthchroMapReal_on_not_IsOrthochronous h, coeForℤ₂_apply, Subtype.mk.injEq, Nat.reduceAdd] - rw [if_neg (by norm_num)] - rfl + exact if_neg (by norm_num) /-- The product of two orthochronous Lorentz transformations is orthochronous. -/ lemma isOrthochronous_mul {Λ Λ' : LorentzGroup d} (h : IsOrthochronous Λ) diff --git a/Physlib/Relativity/Tensors/ComponentIdx/Single.lean b/Physlib/Relativity/Tensors/ComponentIdx/Single.lean index cb521a7ad..42773a904 100644 --- a/Physlib/Relativity/Tensors/ComponentIdx/Single.lean +++ b/Physlib/Relativity/Tensors/ComponentIdx/Single.lean @@ -61,10 +61,8 @@ def ComponentIdx.single {c : C} : left_inv b := by ext i cases Fin.fin_one_eq_zero i - simp [basisIdxCongr] rfl right_inv b := by - simp [basisIdxCongr] rfl @[simp] diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean index c0cfc4827..bbffbfde9 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/AffineGroup.lean @@ -170,8 +170,7 @@ this proves `right_inv` of `toAffineIsometryMulEquiv`. -/ show Matrix.toLin _ _ (LinearMap.toMatrix _ _ (L.toLinearEquiv : EuclideanSpace ℝ (Fin n) →ₗ[ℝ] EuclideanSpace ℝ (Fin n))) x = L x - rw [Matrix.toLin_toMatrix] - rfl + exact LinearMap.congr_fun (Matrix.toLin_toMatrix _ _ _) x /-- `EuclideanGroup n ≃* AffineIsometryEquiv ℝ (EuclideanSpace ℝ (Fin n)) _`: the Euclidean group is the full group of affine isometries of Euclidean space. This upgrades `toAffineIsometryHom` to diff --git a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean index 935684d49..30342bed7 100644 --- a/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean +++ b/Physlib/SpaceAndTime/Space/EuclideanGroup/Basic.lean @@ -142,8 +142,7 @@ lemma translationVector.incl_range : constructor · rintro ⟨v, hv⟩ show g.linear.val = 1 - rw [← hv] - rfl + exact congrArg (fun g : EuclideanGroup n => g.linear.val) hv.symm · intro h rw [Set.mem_range] refine ⟨g.translation, ?_⟩ diff --git a/Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean b/Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean index e7f5cb00a..9ba4c507f 100644 --- a/Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean +++ b/Physlib/SpaceAndTime/SpaceTime/LorentzAction.lean @@ -81,8 +81,7 @@ def schwartzAction {d} : LorentzGroup d →* 𝓢(SpaceTime d, ℝ) →L[ℝ] ext η x simp only [_root_.mul_inv_rev, compCLM_apply, Function.comp_apply, Lorentz.Vector.actionCLM_apply] - rw [SemigroupAction.mul_smul] - rfl + exact congr_arg η (SemigroupAction.mul_smul Λ₂⁻¹ Λ₁⁻¹ x) /-! diff --git a/Physlib/SpaceAndTime/TimeAndSpace/EuclideanGroup/SchwartzAction.lean b/Physlib/SpaceAndTime/TimeAndSpace/EuclideanGroup/SchwartzAction.lean index e4e3b76ef..db3528f69 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/EuclideanGroup/SchwartzAction.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/EuclideanGroup/SchwartzAction.lean @@ -70,8 +70,7 @@ noncomputable def schwartzEuclideanAction {d : ℕ} : ext η tx simp only [_root_.mul_inv_rev, SchwartzMap.compCLMOfAntilipschitz_apply, Function.comp_apply] - rw [mul_smul] - rfl + exact congrArg η (mul_smul _ _ _) /-- Pointwise formula for the monoid-homomorphism form of the Schwartz-map pullback action. -/ @[simp] From 60c857a1b77ed99471b80b88ccfd650e992dbd3a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:54:51 -0700 Subject: [PATCH 395/498] refactor: golf derivative wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/FluidDynamics/NavierStokes/Momentum.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 9 ++------- Physlib/SpaceAndTime/Space/Derivatives/Div.lean | 7 ++----- Physlib/SpaceAndTime/Time/Derivatives.lean | 1 - Physlib/Thermodynamics/Temperature/Basic.lean | 3 +-- 5 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Physlib/FluidDynamics/NavierStokes/Momentum.lean b/Physlib/FluidDynamics/NavierStokes/Momentum.lean index 1a99743b5..32b0baa9d 100644 --- a/Physlib/FluidDynamics/NavierStokes/Momentum.lean +++ b/Physlib/FluidDynamics/NavierStokes/Momentum.lean @@ -135,8 +135,7 @@ lemma timeDeriv_smul_velocity (d : ℕ) (rhoAtPosition : Time → ℝ) change (fderiv ℝ (rhoAtPosition • velocityAtPosition) t) 1 = rhoAtPosition t • (fderiv ℝ velocityAtPosition t) 1 + (fderiv ℝ rhoAtPosition t) 1 • velocityAtPosition t - rw [fderiv_smul hRho hVelocity] - rfl + exact congrArg (fun L => L 1) (fderiv_smul hRho hVelocity) /-- Product rule for the time derivative of the momentum density `rho u`. -/ lemma timeDeriv_momentumDensity (d : ℕ) (fluid : FluidState d) diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index 40edd79ec..f497d5896 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -170,9 +170,7 @@ lemma deriv_add [NormedAddCommGroup M] [NormedSpace ℝ M] ∂[u] (f1 + f2) = ∂[u] f1 + ∂[u] f2 := by rw [deriv_eq_fderiv_fun] ext x - rw [fderiv_add] - rfl - repeat fun_prop + exact congrArg (fun L => L (basis u)) (fderiv_add (hf1 x) (hf2 x)) /-- Derivatives on space distribute coordinate-wise over addition. -/ lemma deriv_coord_add (f1 f2 : Space d → EuclideanSpace ℝ (Fin d)) @@ -193,9 +191,7 @@ lemma deriv_sub [NormedAddCommGroup M] [NormedSpace ℝ M] ∂[u] (f1 - f2) = ∂[u] f1 - ∂[u] f2 := by rw [deriv_eq_fderiv_fun] ext x - rw [fderiv_sub] - rfl - repeat fun_prop + exact congrArg (fun L => L (basis u)) (fderiv_sub (hf1 x) (hf2 x)) /-! @@ -320,7 +316,6 @@ lemma deriv_lorentz_vector {d ν μ} {f : Space d → Lorentz.Vector d} change fderiv ℝ (Lorentz.Vector.coordCLM μ ∘ fun x => f x) x (basis ν) = _ rw [fderiv_comp] · simp - rw [← deriv_eq_fderiv_basis] rfl · fun_prop · fun_prop diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Div.lean b/Physlib/SpaceAndTime/Space/Derivatives/Div.lean index 1fe06db93..0ab99f354 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Div.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Div.lean @@ -71,9 +71,7 @@ lemma div_eq_sum_fderiv {d} (f : Space d → EuclideanSpace ℝ (Fin d)) congr funext i rw [← Space.deriv_eq] - rw [deriv_euclid] - rfl - fun_prop + exact deriv_euclid (ν := i) hf x /-! @@ -209,8 +207,7 @@ lemma distDiv_apply_eq_sum_fderivD {d} lemma distDiv_apply_eq_sum_distDeriv {d} (f : (Space d) →d[ℝ] EuclideanSpace ℝ (Fin d)) (η : 𝓢(Space d, ℝ)) : (∇ᵈ ⬝ f) η = ∑ i, ∂ᵈ[i] f η i := by - rw [distDiv_apply_eq_sum_fderivD] - rfl + exact distDiv_apply_eq_sum_fderivD f η /-! diff --git a/Physlib/SpaceAndTime/Time/Derivatives.lean b/Physlib/SpaceAndTime/Time/Derivatives.lean index ca89a95e2..b2bba85c4 100644 --- a/Physlib/SpaceAndTime/Time/Derivatives.lean +++ b/Physlib/SpaceAndTime/Time/Derivatives.lean @@ -225,7 +225,6 @@ lemma deriv_lorentzVector {d : ℕ} {f : Time → Lorentz.Vector d} change fderiv ℝ (Lorentz.Vector.coordCLM i ∘ fun x => f x) t 1 = _ rw [fderiv_comp] · simp - rw [← deriv_eq] rfl · fun_prop · fun_prop diff --git a/Physlib/Thermodynamics/Temperature/Basic.lean b/Physlib/Thermodynamics/Temperature/Basic.lean index 7e3b30466..d28ece09f 100644 --- a/Physlib/Thermodynamics/Temperature/Basic.lean +++ b/Physlib/Thermodynamics/Temperature/Basic.lean @@ -223,8 +223,7 @@ lemma chain_rule_T_beta {F : ℝ → ℝ} {F' : ℝ} rw [beta_fun_T_eq_on_Ioi ht] exact one_div_pos.mpr (mul_pos kB_pos ht) have h_beta_at_T : betaFromReal (T.val : ℝ) = (T.β : ℝ) := by - rw [beta_fun_T_eq_on_Ioi (show (T.val : ℝ) ∈ Set.Ioi 0 from hT_pos), β_toReal] - rfl + exact (beta_fun_T_eq_on_Ioi (show (T.val : ℝ) ∈ Set.Ioi 0 from hT_pos)).trans (β_toReal T).symm have hF_deriv' : HasDerivWithinAt F F' (Set.Ioi 0) (betaFromReal (T.val : ℝ)) := by simpa [h_beta_at_T] using hF_deriv exact hF_deriv'.comp (T.val : ℝ) (deriv_beta_wrt_T (T := T) hT_pos) h_map From 5d0e64183f88e308c646056cba6d56d32c38fa7e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 08:59:19 -0700 Subject: [PATCH 396/498] refactor: golf QED and unit wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/Mass/MassUnit.lean | 3 +-- Physlib/Electromagnetism/Charge/ChargeUnit.lean | 3 +-- .../PerturbationTheory/FieldSpecification/NormalOrder.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 6 ++---- Physlib/SpaceAndTime/Space/LengthUnit.lean | 3 +-- Physlib/SpaceAndTime/Time/TimeUnit.lean | 3 +-- Physlib/Thermodynamics/Temperature/TemperatureUnits.lean | 3 +-- 8 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Physlib/ClassicalMechanics/Mass/MassUnit.lean b/Physlib/ClassicalMechanics/Mass/MassUnit.lean index b1a3430ee..bb2d31510 100644 --- a/Physlib/ClassicalMechanics/Mass/MassUnit.lean +++ b/Physlib/ClassicalMechanics/Mass/MassUnit.lean @@ -73,8 +73,7 @@ lemma div_pos (x y : MassUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : MassUnit) : x / x = (1 : ℝ≥0) := by - simp [div_eq_val, x.val_ne_zero] - rfl + exact NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : MassUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by diff --git a/Physlib/Electromagnetism/Charge/ChargeUnit.lean b/Physlib/Electromagnetism/Charge/ChargeUnit.lean index c73a4977e..120dcc230 100644 --- a/Physlib/Electromagnetism/Charge/ChargeUnit.lean +++ b/Physlib/Electromagnetism/Charge/ChargeUnit.lean @@ -78,8 +78,7 @@ lemma div_pos (x y : ChargeUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : ChargeUnit) : x / x = (1 : ℝ≥0) := by - simp [div_eq_val, x.val_ne_zero] - rfl + exact NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : ChargeUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index 9c09a429e..67fab4928 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -356,8 +356,7 @@ lemma normalOrderSign_eraseIdx (φs : List 𝓕.CrAnFieldOp) (i : Fin φs.length normalOrderSign (φs.eraseIdx i) = normalOrderSign φs * 𝓢(𝓕 |>ₛ (φs.get i), 𝓕 |>ₛ (φs.take i)) * 𝓢(𝓕 |>ₛ (φs.get i), 𝓕 |>ₛ ((normalOrderList φs).take (normalOrderEquiv i))) := by - rw [normalOrderSign, Wick.koszulSign_eraseIdx, ← normalOrderSign] - rfl + exact Wick.koszulSign_eraseIdx 𝓕.crAnStatistics normalOrderRel φs i lemma orderedInsert_createFilter_append_annihilate (φ : 𝓕.CrAnFieldOp) (hφ : 𝓕 |>ᶜ φ = CreateAnnihilate.annihilate) : (φs φs' : List 𝓕.CrAnFieldOp) → diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index 9c9a0e17a..74e653134 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -404,8 +404,7 @@ lemma P_accCube (f : Fin n.succ → ℚ) : accCube (2 * n.succ) (P f) = 0 := by lemma P_zero (f : Fin n.succ → ℚ) (h : P f = 0) : ∀ i, f i = 0 := by intro i erw [← P_evenFst f] - rw [h] - rfl + exact congr_fun h (evenFst i) /-! @@ -684,8 +683,7 @@ lemma P!_accCube (f : Fin n → ℚ) : accCube (2 * n.succ) (P! f) = 0 := by lemma P!_zero (f : Fin n → ℚ) (h : P! f = 0) : ∀ i, f i = 0 := by intro i rw [← P!_evenShiftFst f] - rw [h] - rfl + exact congr_fun h (evenShiftFst i) /-! diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 1f661f2f0..8f0f896e2 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -452,8 +452,7 @@ lemma P_accCube (f : Fin n → ℚ) : accCube (2 * n +1) (P f) = 0 := by lemma P_zero (f : Fin n → ℚ) (h : P f = 0) : ∀ i, f i = 0 := by intro i erw [← P_oddFst f] - rw [h] - rfl + exact congr_fun h (oddFst i) /-- A point in the span of the first part of the basis. -/ def P' (f : Fin n → ℚ) : (PureU1 (2 * n + 1)).LinSols := ∑ i, f i • basis i @@ -696,8 +695,7 @@ lemma P!_accCube (f : Fin n → ℚ) : accCube (2 * n +1) (P! f) = 0 := by lemma P!_zero (f : Fin n → ℚ) (h : P! f = 0) : ∀ i, f i = 0 := by intro i rw [← P!_oddShiftFst f] - rw [h] - rfl + exact congr_fun h (oddShiftFst i) /-! diff --git a/Physlib/SpaceAndTime/Space/LengthUnit.lean b/Physlib/SpaceAndTime/Space/LengthUnit.lean index bed428461..4ecad76f3 100644 --- a/Physlib/SpaceAndTime/Space/LengthUnit.lean +++ b/Physlib/SpaceAndTime/Space/LengthUnit.lean @@ -72,8 +72,7 @@ lemma div_pos (x y : LengthUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : LengthUnit) : x / x = (1 : ℝ≥0) := by - simp [div_eq_val, x.val_ne_zero] - rfl + exact NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : LengthUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by diff --git a/Physlib/SpaceAndTime/Time/TimeUnit.lean b/Physlib/SpaceAndTime/Time/TimeUnit.lean index 03a5a7d78..a69f39016 100644 --- a/Physlib/SpaceAndTime/Time/TimeUnit.lean +++ b/Physlib/SpaceAndTime/Time/TimeUnit.lean @@ -75,8 +75,7 @@ lemma div_pos (x y : TimeUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : TimeUnit) : x / x = (1 : ℝ≥0) := by - simp [div_eq_val, x.val_ne_zero] - rfl + exact NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : TimeUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by diff --git a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean index e99a74a05..54368085b 100644 --- a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean +++ b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean @@ -74,8 +74,7 @@ lemma div_pos (x y : TemperatureUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : TemperatureUnit) : x / x = (1 : ℝ≥0) := by - simp [div_eq_val, x.val_ne_zero] - rfl + exact NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : TemperatureUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by From 7d259d465bc2d6964dde9ff28fb38440e93db04d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:02:30 -0700 Subject: [PATCH 397/498] refactor: golf tensor matrix wrappers Co-authored-by: Claude Opus 4.8 --- .../Relativity/Tensors/ComplexTensor/Matrix/Pre.lean | 12 ++++-------- .../Relativity/Tensors/RealTensor/Matrix/Pre.lean | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean index d0175eb43..576b8bde7 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Matrix/Pre.lean @@ -118,8 +118,7 @@ lemma contrContrToMatrix_ρ (v : (ContrℂModule ⊗[ℂ] ContrℂModule)) (M : have h1 := (LinearMap.toMatrix_mulVec_repr (complexContrBasis.tensorProduct complexContrBasis) (complexContrBasis.tensorProduct complexContrBasis) (TensorProduct.map (ContrℂModule.SL2CRep M) (ContrℂModule.SL2CRep M)) v) - erw [h1] - rfl + exact h1.symm rw [TensorProduct.toMatrix_map] funext i j change ∑ k, ((kroneckerMap (fun x1 x2 => x1 * x2) @@ -162,8 +161,7 @@ lemma coCoToMatrix_ρ (v : (CoℂModule ⊗[ℂ] CoℂModule)) (M : SL(2,ℂ)) : have h1 := (LinearMap.toMatrix_mulVec_repr (complexCoBasis.tensorProduct complexCoBasis) (complexCoBasis.tensorProduct complexCoBasis) (TensorProduct.map (CoℂModule.SL2CRep M) (CoℂModule.SL2CRep M)) v) - erw [h1] - rfl + exact h1.symm rw [TensorProduct.toMatrix_map] funext i j change ∑ k, ((kroneckerMap (fun x1 x2 => x1 * x2) @@ -205,8 +203,7 @@ lemma contrCoToMatrix_ρ (v : (ContrℂModule ⊗[ℂ] CoℂModule)) (M : SL(2, have h1 := (LinearMap.toMatrix_mulVec_repr (complexContrBasis.tensorProduct complexCoBasis) (complexContrBasis.tensorProduct complexCoBasis) (TensorProduct.map (ContrℂModule.SL2CRep M) (CoℂModule.SL2CRep M)) v) - erw [h1] - rfl + exact h1.symm rw [TensorProduct.toMatrix_map] funext i j change ∑ k, ((kroneckerMap (fun x1 x2 => x1 * x2) @@ -248,8 +245,7 @@ lemma coContrToMatrix_ρ (v : (CoℂModule ⊗[ℂ] ContrℂModule)) (M : SL(2, have h1 := (LinearMap.toMatrix_mulVec_repr (complexCoBasis.tensorProduct complexContrBasis) (complexCoBasis.tensorProduct complexContrBasis) (TensorProduct.map (CoℂModule.SL2CRep M) (ContrℂModule.SL2CRep M)) v) - erw [h1] - rfl + exact h1.symm rw [TensorProduct.toMatrix_map] funext i j change ∑ k, ((kroneckerMap (fun x1 x2 => x1 * x2) diff --git a/Physlib/Relativity/Tensors/RealTensor/Matrix/Pre.lean b/Physlib/Relativity/Tensors/RealTensor/Matrix/Pre.lean index bd205a693..4766b187e 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Matrix/Pre.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Matrix/Pre.lean @@ -117,8 +117,7 @@ lemma contrContrToMatrixRe_ρ {d : ℕ} (v : (Contr d ⊗ Contr d).V) (M : Loren have h1 := (LinearMap.toMatrix_mulVec_repr ((contrBasis d).tensorProduct (contrBasis d)) ((contrBasis d).tensorProduct (contrBasis d)) (TensorProduct.map ((Contr d).ρ M) ((Contr d).ρ M)) v) - erw [h1] - rfl + exact h1.symm rw [TensorProduct.toMatrix_map] funext i j change ∑ k, ((kroneckerMap (fun x1 x2 => x1 * x2) @@ -154,8 +153,7 @@ lemma coCoToMatrixRe_ρ {d : ℕ} (v : ((Co d) ⊗ (Co d)).V) (M : LorentzGroup have h1 := (LinearMap.toMatrix_mulVec_repr ((coBasis d).tensorProduct (coBasis d)) ((coBasis d).tensorProduct (coBasis d)) (TensorProduct.map ((Co d).ρ M) ((Co d).ρ M)) v) - erw [h1] - rfl + exact h1.symm rw [TensorProduct.toMatrix_map] funext i j change ∑ k, ((kroneckerMap (fun x1 x2 => x1 * x2) @@ -191,8 +189,7 @@ lemma contrCoToMatrixRe_ρ {d : ℕ} (v : ((Contr d) ⊗ (Co d)).V) (M : Lorentz have h1 := (LinearMap.toMatrix_mulVec_repr ((contrBasis d).tensorProduct (coBasis d)) ((contrBasis d).tensorProduct (coBasis d)) (TensorProduct.map ((Contr d).ρ M) ((Co d).ρ M)) v) - erw [h1] - rfl + exact h1.symm rw [TensorProduct.toMatrix_map] funext i j change ∑ k, ((kroneckerMap (fun x1 x2 => x1 * x2) @@ -228,8 +225,7 @@ lemma coContrToMatrixRe_ρ {d : ℕ} (v : ((Co d) ⊗ (Contr d)).V) (M : Lorentz have h1 := (LinearMap.toMatrix_mulVec_repr ((coBasis d).tensorProduct (contrBasis d)) ((coBasis d).tensorProduct (contrBasis d)) (TensorProduct.map ((Co d).ρ M) ((Contr d).ρ M)) v) - erw [h1] - rfl + exact h1.symm rw [TensorProduct.toMatrix_map] funext i j change ∑ k, ((kroneckerMap (fun x1 x2 => x1 * x2) From 705b83728e814c25a84df0d188f77fbfb40b1b34 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:07:49 -0700 Subject: [PATCH 398/498] refactor: golf tensor units and Hermite wrappers Co-authored-by: Claude Opus 4.8 --- .../Mathematics/SpecialFunctions/PhysHermite.lean | 5 ++--- Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean | 12 ++++-------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean index cc34efc22..e7104beed 100644 --- a/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean +++ b/Physlib/Mathematics/SpecialFunctions/PhysHermite.lean @@ -211,9 +211,8 @@ lemma deriv_physHermite' (x : ℝ) (f : ℝ → ℝ) (hf : DifferentiableAt ℝ f x) (n : ℕ) : deriv (fun x => physHermite n (f x)) x = (2 * n * physHermite (n - 1) (f x)) * deriv f x := by - unfold deriv - rw [fderiv_physHermite (hf := by fun_prop)] - rfl + simpa only [deriv, FunLike.coe_smul, Pi.smul_apply, smul_eq_mul] using + congrArg (fun g : ℝ →L[ℝ] ℝ => g 1) (fderiv_physHermite x f hf n) lemma physHermite_parity: (n : ℕ) → (x : ℝ) → physHermite n (-x) = (-1)^n * physHermite n x diff --git a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean index f758fda38..49acd2329 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean @@ -144,8 +144,7 @@ lemma contr_preContrCoUnit {d : ℕ} (x : CoMod d) : rw [h1] have h2 : coContrContract.toLinearMap.rTensor _ (∑ i, (x ⊗ₜ[ℝ] contrBasis d i) ⊗ₜ[ℝ] coBasis d i) = ∑ i, ((coContrContract) (x ⊗ₜ[ℝ] contrBasis d i)) ⊗ₜ[ℝ] coBasis d i := by - rw [map_sum] - rfl + exact map_sum _ _ _ erw [h2] obtain ⟨c, rfl⟩ := (Submodule.mem_span_range_iff_exists_fun ℝ).mp (Basis.mem_span (coBasis d) x) have h3 (i : Fin 1 ⊕ Fin d) : (coContrContract) @@ -158,8 +157,7 @@ lemma contr_preContrCoUnit {d : ℕ} (x : CoMod d) : conv_lhs => enter [2, 2, i] rw [h3 i] - rw [map_sum] - rfl + exact map_sum _ _ _ /-- Contraction on the right with `coContrUnit`. -/ lemma contr_preCoContrUnit {d : ℕ} (x : ContrMod d) : @@ -178,8 +176,7 @@ lemma contr_preCoContrUnit {d : ℕ} (x : ContrMod d) : rw [h1] have h2 :contrCoContract.toLinearMap.rTensor _ (∑ i, (x ⊗ₜ[ℝ] coBasis d i) ⊗ₜ[ℝ] contrBasis d i) = ∑ i, ((contrCoContract) (x ⊗ₜ[ℝ] coBasis d i)) ⊗ₜ[ℝ] contrBasis d i := by - rw [map_sum] - rfl + exact map_sum _ _ _ erw [h2] obtain ⟨c, rfl⟩ := (Submodule.mem_span_range_iff_exists_fun ℝ).mp (Basis.mem_span (contrBasis d) x) @@ -193,8 +190,7 @@ lemma contr_preCoContrUnit {d : ℕ} (x : ContrMod d) : conv_lhs => enter [2, 2, i] rw [h3 i] - rw [map_sum] - rfl + exact map_sum _ _ _ /-! From d2bc2304c1ef2072b1edb2dd24f373f20bda78d0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:12:41 -0700 Subject: [PATCH 399/498] refactor: golf QFT and F-theory sum wrappers Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean | 6 ++---- Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean | 3 +-- Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean | 3 +-- Physlib/Units/UnitDependent.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index b10359eb5..14f522673 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -432,8 +432,7 @@ lemma superCommute_ofCrAnList_ofCrAnList_eq_sum (φs φs' : List 𝓕.CrAnFieldO conv_lhs => rw [ofCrAnList, ofCrAnList, superCommute_eq_ι_superCommuteF, superCommuteF_ofCrAnListF_ofCrAnListF_eq_sum] - rw [map_sum] - rfl + exact map_sum _ _ _ lemma superCommute_ofCrAnOp_ofCrAnList_eq_sum (φ : 𝓕.CrAnFieldOp) (φs' : List 𝓕.CrAnFieldOp) : [ofCrAnOp φ, ofCrAnList φs']ₛ = @@ -458,8 +457,7 @@ lemma superCommute_ofCrAnList_ofFieldOpList_eq_sum (φs : List 𝓕.CrAnFieldOp) conv_lhs => rw [ofCrAnList, ofFieldOpList, superCommute_eq_ι_superCommuteF, superCommuteF_ofCrAnListF_ofFieldOpListF_eq_sum] - rw [map_sum] - rfl + exact map_sum _ _ _ lemma superCommute_ofCrAnOp_ofFieldOpList_eq_sum (φ : 𝓕.CrAnFieldOp) (φs' : List 𝓕.FieldOp) : [ofCrAnOp φ, ofFieldOpList φs']ₛ = diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean index 551ae074a..6ea02abd0 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/FiveQuanta.lean @@ -252,8 +252,7 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : FiveQuanta 𝓩) (f (((x.filter (fun f => f.1 = q5)).map (fun y => f q5 y.2))).sum := by congr funext q5 - rw [AddMonoidHom.map_multiset_sum, Multiset.map_map] - rfl + simp [AddMonoidHom.map_multiset_sum, Multiset.map_map] _ = (x.toCharges.dedup.bind fun q5 => ((x.filter (fun f => f.1 = q5)).map (fun y => f q5 y.2))).sum := by rw [Multiset.sum_bind] diff --git a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean index f2ebbb3b6..544a5085c 100644 --- a/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean +++ b/Physlib/StringTheory/FTheory/SU5/Quanta/TenQuanta.lean @@ -266,8 +266,7 @@ lemma reduce_sum_eq_sum_toCharges {M} [AddCommMonoid M] (x : TenQuanta 𝓩) (f (((x.filter (fun f => f.1 = q)).map (fun y => f q y.2))).sum := by congr funext q5 - rw [AddMonoidHom.map_multiset_sum, Multiset.map_map] - rfl + simp [AddMonoidHom.map_multiset_sum, Multiset.map_map] _ = (x.toCharges.dedup.bind fun q => ((x.filter (fun f => f.1 = q)).map (fun y => f q y.2))).sum := by rw [Multiset.sum_bind] diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 36e1253aa..1a8d4a8a1 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -261,8 +261,7 @@ noncomputable instance {M : Type} [AddCommMonoid M] [Module ℝ M] [HasDim M] : scaleUnit_add u1 u2 m1 m2 := by change (toDimensionful u1 (m1 + m2)).1 u2 = _ rw [toDimensionful_apply_apply] - simp - rfl + exact smul_add _ _ _ scaleUnit_smul u1 u2 r m := by change (toDimensionful u1 (r • m)).1 u2 = _ rw [toDimensionful_apply_apply] From 11a1fea491ba81290fec0b4ec6195874218a4357 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:18:18 -0700 Subject: [PATCH 400/498] refactor: golf tensor vector wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/Basic.lean | 3 +-- Physlib/Relativity/Tensors/Contraction/Pure.lean | 1 - Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean | 1 - Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean | 2 -- .../Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean | 1 - 5 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index dbe6b2959..d80cf0671 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -503,8 +503,7 @@ noncomputable instance actionT : MulAction G (S.Tensor c) where lemma actionT_pure {g : G} {p : Pure S c} : g • p.toTensor = Pure.toTensor (g • p) := by - rw [actionT_eq, Pure.toTensor, PiTensorProduct.map_tprod] - rfl + exact PiTensorProduct.map_tprod (R := k) (fun i => rep (c i) g) p lemma actionT_add {g : G} {t1 t2 : S.Tensor c} : g • (t1 + t2) = g • t1 + g • t2 := by diff --git a/Physlib/Relativity/Tensors/Contraction/Pure.lean b/Physlib/Relativity/Tensors/Contraction/Pure.lean index c17ec33d9..1f39f39e0 100644 --- a/Physlib/Relativity/Tensors/Contraction/Pure.lean +++ b/Physlib/Relativity/Tensors/Contraction/Pure.lean @@ -52,7 +52,6 @@ lemma dropPair_equivariant {n : ℕ} {c : Fin (n + 1 + 1) → C} (i j : Fin (n + 1 + 1)) (hij : i ≠ j) (p : Pure S c) (g : G) : dropPair i j hij (g • p) = g • dropPair i j hij p := by ext m - simp only [dropPair, actionP_eq] rfl lemma dropPair_symm (i j : Fin (n + 1 + 1)) (hij : i ≠ j) diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean index 6d0363dbb..f4f59992b 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Basic.lean @@ -152,7 +152,6 @@ lemma apply_sum {d : ℕ} {ι : Type} [Fintype ι] (f : ι → Vector d) (i : Fi simp at h' rw [← @e.sum_comp, ← @e.sum_comp, h'] · intro f i - simp only [Finset.univ_eq_empty, Finset.sum_empty] rfl · intro ι _ h f i rw [Fintype.sum_option, apply_add, h, Fintype.sum_option] diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index d2bc01600..9c50bb511 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -49,7 +49,6 @@ lemma contrBasis_toFin1dℝ {d : ℕ} (i : Fin 1 ⊕ Fin d) : lemma contrBasis_repr_apply {d : ℕ} (p : Contr d) (i : Fin 1 ⊕ Fin d) : (contrBasis d).repr p i = p.val i := by - simp only [contrBasis, Basis.ofEquivFun_repr_apply] rfl /-- The standard basis of contravariant Lorentz vectors indexed by `Fin (1 + d)`. -/ @@ -99,7 +98,6 @@ lemma coBasis_ρ_apply {d : ℕ} (M : LorentzGroup d) (i j : Fin 1 ⊕ Fin d) : lemma coBasis_repr_apply {d : ℕ} (p : Co d) (i : Fin 1 ⊕ Fin d) : (coBasis d).repr p i = p.val i := by - simp only [coBasis, Basis.ofEquivFun_repr_apply] rfl @[simp] diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 8baa92014..c9602e322 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -148,7 +148,6 @@ local notation "⟪" ψ "," φ "⟫ₘ" => contrContrContractField (ψ ⊗ₜ φ lemma contrContrContract_hom_tmul (φ : Contr d) (ψ : Contr d) : ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ:= by - simp only [contrContrContractField] rfl /-- The linear map from Co d ⊗ Co d to ℝ induced by the homomorphism From fb2bc54bfe43aa399a1ecf333f02af62a6e7c0b6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:25:41 -0700 Subject: [PATCH 401/498] refactor: golf real tensor complexification wrappers Co-authored-by: Claude Opus 4.8 --- .../Relativity/Tensors/RealTensor/ToComplex.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index 9ca468166..ce2ed0476 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -311,14 +311,12 @@ noncomputable def toComplexVector (c : realLorentzTensor.Color) : simp only [map_add, Finsupp.coe_add, Pi.add_apply, Nat.reduceAdd, ← Finset.sum_add_distrib] congr funext x - rw [add_smul] - rfl + exact add_smul _ _ _ | Color.down => simp only [map_add, Finsupp.coe_add, Pi.add_apply, Nat.reduceAdd, ← Finset.sum_add_distrib] congr funext x - rw [add_smul] - rfl + exact add_smul _ _ _ map_smul' r v := by match c with | Color.up => @@ -327,16 +325,14 @@ noncomputable def toComplexVector (c : realLorentzTensor.Color) : rw [Finset.smul_sum] congr funext x - rw [← smul_smul] - rfl + exact (smul_smul _ _ _).symm | Color.down => simp only [map_smul, Finsupp.coe_smul, Pi.smul_apply, smul_eq_mul, Nat.reduceAdd, Complex.ofRealHom_eq_coe, Complex.coe_smul] rw [Finset.smul_sum] congr funext x - rw [← smul_smul] - rfl + exact (smul_smul _ _ _).symm lemma toComplexVector_up_eq_inclCongrRealLorentz (v : Lorentz.ContrMod 3) : toComplexVector Color.up v = Lorentz.inclCongrRealLorentz v := by @@ -510,8 +506,7 @@ lemma toComplex_equivariant {n} {c : Fin n → realLorentzTensor.Color} · simp rw [← h] change Λ • (r : ℂ) • toComplex t = _ - rw [actionT_smul] - rfl + exact actionT_smul (g := Λ) (r := (r : ℂ)) (t := toComplex t) · simp_all /-! From 6ca99286d31dca7f1067c12a8d591373cdae5c66 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:40:26 -0700 Subject: [PATCH 402/498] refactor: golf tensor action wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Basic.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/ToComplex.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean | 3 +-- Physlib/Relativity/Tensors/Tensorial.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index d80cf0671..c36acf78a 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -498,8 +498,7 @@ noncomputable instance actionT : MulAction G (S.Tensor c) where simp [actionT_eq] change _ = (PiTensorProduct.map (fun i => rep (c i) g) ∘ₗ (PiTensorProduct.map (fun i => rep (c i) g'))) t - rw [← PiTensorProduct.map_comp] - rfl + exact LinearMap.congr_fun (PiTensorProduct.map_comp _ _) t lemma actionT_pure {g : G} {p : Pure S c} : g • p.toTensor = Pure.toTensor (g • p) := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Basic.lean index c726e8a62..8628b4f45 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Basic.lean @@ -222,8 +222,7 @@ lemma contrT_toField {d} (c : Fin 2 → Color) rw [contrT_eq_sum_evalT, map_sum, Tensorial.self_toTensor_apply] congr ext μ - simp only [toField_permT] - rfl + exact toField_permT _ _ _ open ComponentIdx in lemma contrT_basis_repr_apply_eq_fin {n d: ℕ} {c : Fin (n + 1 + 1) → realLorentzTensor.Color} diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index ce2ed0476..85e259c6e 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -154,8 +154,7 @@ noncomputable def toComplex {n} {c : Fin n → realLorentzTensor.Color} : rw [Finset.smul_sum] congr funext i - rw [← smul_smul] - rfl + exact (smul_smul _ _ _).symm map_add' c v := by simp only [map_add, Finsupp.coe_add, Pi.add_apply] rw [← Finset.sum_add_distrib] diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean index 245f32c5f..0eb8fdaac 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean @@ -138,8 +138,7 @@ lemma smul_eq_sum {d : ℕ} (i : Fin 1 ⊕ Fin d) (Λ : LorentzGroup d) (p : Vec · intro p have toTensor_symm_pure_val : ∀ (q : Pure (realLorentzTensor d) ![.up]) (j : Fin 1 ⊕ Fin d), (toTensor (self := tensorial)).symm q.toTensor j = (q 0).val j := fun q j => by - rw [toTensor_symm_pure, contrBasis_repr_apply] - rfl + exact toTensor_symm_pure q j rw [actionT_pure] simp only [toTensor_symm_pure_val] show (Λ.1 *ᵥ (p 0)).val i = ∑ j, Λ.1 i j * (p 0).val j diff --git a/Physlib/Relativity/Tensors/Tensorial.lean b/Physlib/Relativity/Tensors/Tensorial.lean index 1f83952f8..6f1794119 100644 --- a/Physlib/Relativity/Tensors/Tensorial.lean +++ b/Physlib/Relativity/Tensors/Tensorial.lean @@ -139,8 +139,7 @@ noncomputable instance mulAction [Tensorial S c M] : MulAction G M where mul_smul g h m := by change _ = toTensor.symm (g • toTensor (toTensor.symm (h • toTensor m))) simp only [LinearEquiv.apply_symm_apply] - rw [← mul_smul] - rfl + exact congrArg toTensor.symm (mul_smul g h (toTensor m)) /-! From 191597ac33157fff269c2d92022f997c53d85778 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:44:44 -0700 Subject: [PATCH 403/498] refactor: golf unit and derivative wrappers Co-authored-by: Claude Opus 4.8 --- .../Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean | 3 +-- Physlib/Relativity/Tensors/UnitTensor.lean | 3 +-- Physlib/SpaceAndTime/SpaceTime/Basic.lean | 3 +-- Physlib/SpaceAndTime/Time/Derivatives.lean | 4 +--- Physlib/Units/UnitDependent.lean | 3 +-- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index 181fe0200..2e7829ac1 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -192,8 +192,7 @@ lemma inclCongrRealLorentz_ρ (M : SL(2, ℂ)) (v : ContrMod 3) : inclCongrRealLorentz ((Contr 3).ρ (SL2C.toLorentzGroup M) v) := by apply Lorentz.ContrℂModule.ext rw [complexContrBasis_ρ_val, inclCongrRealLorentz_val, inclCongrRealLorentz_val] - rw [LorentzGroup.toComplex_mulVec_ofReal] - rfl + exact LorentzGroup.toComplex_mulVec_ofReal _ _ lemma SL2CRep_ρ_basis (M : SL(2, ℂ)) (i : Fin 1 ⊕ Fin 3) : (ContrℂModule.SL2CRep M) (complexContrBasis i) = diff --git a/Physlib/Relativity/Tensors/UnitTensor.lean b/Physlib/Relativity/Tensors/UnitTensor.lean index fa197d681..dd54652c4 100644 --- a/Physlib/Relativity/Tensors/UnitTensor.lean +++ b/Physlib/Relativity/Tensors/UnitTensor.lean @@ -70,8 +70,7 @@ lemma dual_unitTensor_eq_permT_unitTensor (c : C) : lemma unit_fromSingleTContrFromPairT_eq_fromSingleT {c : C} (x : V c) : fromSingleTContrFromPairT x ((S.unit c) (1 : k)) = fromSingleT x := by - conv_rhs => rw [← S.contr_unit c x] - rfl + exact congrArg fromSingleT (S.contr_unit c x) /-- This lemma represents the de-categorification of `S.contr_unit`. -/ @[simp] diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index ca4866a79..827eef081 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -577,8 +577,7 @@ lemma toTimeAndSpace_symm_measurePreserving {d : ℕ} (c : SpeedOfLight) : · fun_prop rw [Space.volume_eq_addHaar, Time.volume_eq_basis_addHaar, ← Module.Basis.prod_addHaar, Module.Basis.map_addHaar] - rw [← timeSpaceBasis_addHaar c] - rfl + exact timeSpaceBasis_addHaar c /-! diff --git a/Physlib/SpaceAndTime/Time/Derivatives.lean b/Physlib/SpaceAndTime/Time/Derivatives.lean index b2bba85c4..5f3eb6b6e 100644 --- a/Physlib/SpaceAndTime/Time/Derivatives.lean +++ b/Physlib/SpaceAndTime/Time/Derivatives.lean @@ -118,9 +118,7 @@ lemma manifoldDeriv_const {E H N : Type} [NormedAddCommGroup E] [NormedSpace ℝ lemma deriv_smul (f : Time → EuclideanSpace ℝ (Fin d)) (k : ℝ) (hf : Differentiable ℝ f) : ∂ₜ (fun t => k • f t) t = k • ∂ₜ (fun t => f t) t := by - rw [deriv, fderiv_fun_const_smul] - rfl - fun_prop + exact congrArg (fun g => g 1) (fderiv_fun_const_smul (c := k) hf.differentiableAt) lemma deriv_neg [NormedAddCommGroup M] [NormedSpace ℝ M] (f : Time → M) : ∂ₜ (-f) t = -∂ₜ f t := by simp [deriv, fderiv_neg] diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 1a8d4a8a1..13c35a853 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -520,8 +520,7 @@ instance (M : Type) [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) : lemma scaleUnit_dimSet_val {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) (m : DimSet M d) (u1 u2 : UnitChoices) : (scaleUnit u1 u2 m).1 = scaleUnit u1 u2 m.1 := by - rw [HasDim.scaleUnit_apply, m.2] - rfl + exact (m.2 u1 u2).symm lemma DimSet.mem_iff {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) (m : M) : m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := by rfl From 727a7fa52997dd48189f87a9980ecf73e32174ee Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:53:17 -0700 Subject: [PATCH 404/498] refactor: golf normal-order and unit wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean | 3 +-- .../PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 3 +-- Physlib/Units/Integral.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean b/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean index 761811058..3cb20dafd 100644 --- a/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean +++ b/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean @@ -152,8 +152,7 @@ lemma electricFunction_unique {d : ℕ} {𝓕 : FreeSpace} funext x obtain ⟨t, rfl⟩ : ∃ t, x = ⟪0, s.unit⟫_ℝ - 𝓕.c * t := by use (- x/𝓕.c); field_simp; simp trans A.electricField 𝓕.c t (0 : Space d) - · rw [hE₁] - rfl + · exact congrFun hE₁ _ · rw [P.electricField_eq_electricFunction] /-! diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index a977452d7..cf1db0c26 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -63,8 +63,7 @@ lemma normalOrder_normalOrder_mid (a b c : 𝓕.WickAlgebra) : rw [normalOrder_eq_ι_normalOrderF] simp only [← map_mul] rw [normalOrder_eq_ι_normalOrderF] - rw [normalOrderF_normalOrderF_mid] - rfl + exact congrArg ι (normalOrderF_normalOrderF_mid a b c) lemma normalOrder_normalOrder_left (a b : 𝓕.WickAlgebra) : 𝓝(a * b) = 𝓝(𝓝(a) * b) := by simpa using normalOrder_normalOrder_mid (1 : 𝓕.WickAlgebra) a b @@ -83,8 +82,7 @@ lemma normalOrder_normalOrder (a : 𝓕.WickAlgebra) : 𝓝(𝓝(a)) = 𝓝(a) : lemma normalOrder_mul_anPart (φ : 𝓕.FieldOp) (a : 𝓕.WickAlgebra) : 𝓝(a * anPart φ) = 𝓝(a) * anPart φ := by obtain ⟨a, rfl⟩ := ι_surjective a - rw [anPart, ← map_mul, normalOrder_eq_ι_normalOrderF, normalOrderF_mul_anPartF] - rfl + exact congrArg ι (normalOrderF_mul_anPartF _ _) lemma crPart_mul_normalOrder (φ : 𝓕.FieldOp) (a : 𝓕.WickAlgebra) : 𝓝(crPart φ * a) = crPart φ * 𝓝(a) := by diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index 74e653134..5b8073fcc 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -457,8 +457,7 @@ lemma vectorLikeEven_in_span (S : (PureU1 (2 * n.succ)).LinSols) erw [P'_val] apply ext_even · intro i - rw [P_evenFst] - rfl + exact P_evenFst f i · intro i rw [P_evenSnd] have ht := hS i diff --git a/Physlib/Units/Integral.lean b/Physlib/Units/Integral.lean index 970ea055c..083ce84ce 100644 --- a/Physlib/Units/Integral.lean +++ b/Physlib/Units/Integral.lean @@ -92,8 +92,7 @@ lemma integral_isDimensionallyCorrect (d : Dimension) : u2.dimScale u1 (dim G * d⁻¹) • ∫ (x : M), f x ∂ μ) := by rw [hf] congr - erw [MeasureTheory.integral_smul] - rfl + exact MeasureTheory.integral_smul _ _ /- What remains is a simple cancellation of the dimensional scales. -/ _ = (u1.dimScale u2 (dim G)) • ((u2.dimScale u1 d) • u2.dimScale u1 (dim G * d⁻¹) • ∫ (x : M), f x ∂ μ) := by From b8475670fb17261a7d5d78cad679808bafc1af54 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 09:55:57 -0700 Subject: [PATCH 405/498] refactor: golf normal-order swap wrappers Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/NormalOrder/Lemmas.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index cf1db0c26..dc013a6e0 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -87,8 +87,7 @@ lemma normalOrder_mul_anPart (φ : 𝓕.FieldOp) (a : 𝓕.WickAlgebra) : lemma crPart_mul_normalOrder (φ : 𝓕.FieldOp) (a : 𝓕.WickAlgebra) : 𝓝(crPart φ * a) = crPart φ * 𝓝(a) := by obtain ⟨a, rfl⟩ := ι_surjective a - rw [crPart, ← map_mul, normalOrder_eq_ι_normalOrderF, normalOrderF_crPartF_mul] - rfl + exact congrArg ι (normalOrderF_crPartF_mul _ _) /-! @@ -165,12 +164,10 @@ lemma normalOrder_anPart_ofFieldOpList_swap (φ : 𝓕.FieldOp) (φ' : List 𝓕 module | .position φ => simp only [anPart_position] - rw [normalOrder_ofCrAnOp_ofFieldOpList_swap] - rfl + exact normalOrder_ofCrAnOp_ofFieldOpList_swap _ _ | .outAsymp φ => simp only [anPart_outAsymp] - rw [normalOrder_ofCrAnOp_ofFieldOpList_swap] - rfl + exact normalOrder_ofCrAnOp_ofFieldOpList_swap _ _ lemma normalOrder_ofFieldOpList_anPart_swap (φ : 𝓕.FieldOp) (φ' : List 𝓕.FieldOp) : 𝓝(ofFieldOpList φ' * anPart φ) = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • 𝓝(anPart φ * ofFieldOpList φ') := by @@ -188,8 +185,7 @@ lemma anPart_mul_normalOrder_ofFieldOpList_eq_superCommute (φ : 𝓕.FieldOp) 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φs') • 𝓝(ofFieldOpList φs' * anPart φ) + [anPart φ, 𝓝(ofFieldOpList φs')]ₛ := by rw [anPart, ofFieldOpList, normalOrder_eq_ι_normalOrderF, ← map_mul] - rw [anPartF_mul_normalOrderF_ofFieldOpListF_eq_superCommuteF] - rfl + exact congrArg ι (anPartF_mul_normalOrderF_ofFieldOpListF_eq_superCommuteF _ _) /-! @@ -233,8 +229,7 @@ lemma ofCrAnOp_superCommute_normalOrder_ofCrAnList_sum (φ : 𝓕.CrAnFieldOp) 𝓢(𝓕 |>ₛ (φs.get n), 𝓕 |>ₛ ((normalOrderList φs).take (normalOrderEquiv n)))) * 𝓢(𝓕 |>ₛ (φs.get n), 𝓕 |>ₛ (φs.take n)) · ring_nf - rw [hs] - rfl + simp [hs] · simp [hs] · erw [superCommute_diff_statistic hs] simp only [zero_mul, smul_zero] From c239a2d1e64e8a50123186b804522ad950183c43 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:06:35 -0700 Subject: [PATCH 406/498] refactor: golf normal-order and SL2C wrappers Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean | 3 +-- .../QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean | 3 +-- Physlib/Relativity/SL2C/Basic.lean | 3 +-- Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean | 3 +-- QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean index c61ef1936..c9a25faab 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/NormalOrder.lean @@ -214,8 +214,7 @@ lemma normalOrderF_swap_create_annihilate_ofCrAnListF (φc φa : 𝓕.CrAnFieldO refine LinearMap.congr_fun (ofCrAnListFBasis.ext fun l ↦ ?_) a simp only [mulLinearMap, LinearMap.coe_mk, AddHom.coe_mk, ofListBasis_eq_ofList, LinearMap.coe_comp, Function.comp_apply] - rw [normalOrderF_swap_create_annihilate_ofCrAnListF_ofCrAnListF φc φa hφc hφa] - rfl + exact normalOrderF_swap_create_annihilate_ofCrAnListF_ofCrAnListF _ _ hφc hφa _ _ lemma normalOrderF_swap_create_annihilate (φc φa : 𝓕.CrAnFieldOp) (hφc : 𝓕 |>ᶜ φc = CreateAnnihilate.create) (hφa : 𝓕 |>ᶜ φa = CreateAnnihilate.annihilate) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean index 67fab4928..d501ea7e9 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/NormalOrder.lean @@ -409,8 +409,7 @@ lemma normalOrderList_eq_createFilter_append_annihilateFilter : (φs : List 𝓕 rw [List.filter_cons_of_neg] swap simp only [hφ, reduceCtorEq, decide_false, Bool.false_eq_true, not_false_eq_true] - rw [normalOrderList_eq_createFilter_append_annihilateFilter φs] - rfl + exact congrArg (List.cons φ) (normalOrderList_eq_createFilter_append_annihilateFilter φs) · simp only [normalOrderList, List.insertionSort_cons] rw [← normalOrderList] have hφ' : 𝓕 |>ᶜ φ = CreateAnnihilate.annihilate := by diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index 3f6ebcdd3..52604c4c6 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -151,8 +151,7 @@ lemma toMatrix_apply_contrMod (M : SL(2, ℂ)) (v : ContrMod 3) : *ᵥ (((Finsupp.linearEquivFunOnFinite ℝ ℝ (Fin 1 ⊕ Fin 3)) (PauliMatrix.pauliBasis'.repr a)))) = _ apply congrArg - erw [LinearMap.toMatrix_mulVec_repr] - rfl + exact LinearMap.toMatrix_mulVec_repr PauliMatrix.pauliBasis' _ _ a lemma toMatrix_mem_lorentzGroup (M : SL(2, ℂ)) : toMatrix M ∈ LorentzGroup 3 := by rw [LorentzGroup.mem_iff_norm] diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index 9167e2313..7522c07b5 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -135,8 +135,7 @@ lemma rightDualRightUnit_eq_fromPairT : δR = fromPairT (Fermion.rightDualRightU open Lorentz in lemma coContrUnit_eq_complexCoBasis_complexContrBasis : δ' = ∑ i, fromPairT (complexCoBasis i ⊗ₜ[ℂ] complexContrBasis i) := by - rw [coContrUnit_eq_fromPairT, coContrUnitVal_expand_tmul] - rfl + exact (coContrUnit_eq_fromPairT.trans (congrArg fromPairT coContrUnitVal_expand_tmul)).trans rfl open Lorentz in lemma coContrUnit_eq_complexCoBasisFin4_complexContrBasisFin4 : δ' = diff --git a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean index f8ff8353a..9a6bbbe6c 100644 --- a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean +++ b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean @@ -140,8 +140,7 @@ theorem measurable_complexLaplaceIntegrand apply WithTop.coe_inj.mp rw [WithTop.coe_untop, ← he] have hUntopD : y.untopD 0 = e := by - rw [← he] - rfl + exact he ▸ rfl rw [hUntop, hUntopD]] exact Measurable.ite (hE (measurableSet_singleton (⊤ : WithTop ℝ))) measurable_const (Complex.continuous_exp.measurable.comp (by fun_prop : From 2c6dcbf285970bf31fa1e375ba4ce420cadff879 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:11:21 -0700 Subject: [PATCH 407/498] refactor: golf quantum information wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/Pinching.lean | 9 ++------- QuantumInfo/ResourceTheory/FreeState.lean | 3 +-- QuantumInfo/States/Ensemble.lean | 3 +-- QuantumInfo/States/Mixed/MState.lean | 3 +-- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 59b2734ec..2074bc8f0 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -146,11 +146,7 @@ theorem pinching_self (ρ : MState d) : pinching_map ρ ρ = ρ := by simp only [HermitianMat.conjTranspose_mat, MState.mat_M, LinearMap.coe_sum, LinearMap.coe_mk, AddHom.coe_mk, Finset.sum_apply] simp_rw [(pinching_kraus_commutes ρ _).eq, mul_assoc, ← sq] - conv_lhs => - enter [1, 2, x, 2] - change (pinching_kraus ρ x ^ 2).mat - rw [pinching_sq_eq_self] - rfl + simp_rw [pinching_sq_eq_self] set_option backward.isDefEq.respectTransparency false in /-- Lemma 3.10 of Hayashi's book "Quantum Information Theory - Mathematical Foundations". @@ -387,8 +383,7 @@ theorem ker_le_ker_pinching_map_ker (ρ σ : MState d) (h : σ.M.ker ≤ ρ.M.ke rw! [← hk_zero] at h_proj_one simp only [Subtype.coe_eta] at h_proj_one simp only [← Matrix.mul_assoc, ← Matrix.mulVec_mulVec, ContinuousLinearMap.coe_coe] - rw [h_proj_one] - rfl + exact h_proj_one · simp · simp [← Matrix.mulVec_mulVec, h_proj_zero _ hk_zero] diff --git a/QuantumInfo/ResourceTheory/FreeState.lean b/QuantumInfo/ResourceTheory/FreeState.lean index 2e0c2210d..b40e7f5bb 100644 --- a/QuantumInfo/ResourceTheory/FreeState.lean +++ b/QuantumInfo/ResourceTheory/FreeState.lean @@ -90,8 +90,7 @@ theorem prodRelabel_assoc (ρ₁ : MState (H i)) (ρ₂ : MState (H j)) (ρ₃ : rw [← MState.relabel_cast]; swap · rw [mul_assoc] rw [MState.kron_relabel, MState.prod_assoc] - rw [MState.relabel_comp, MState.relabel_comp, MState.relabel_comp] - rfl + simp [MState.relabel_comp] /-- A `MState.relabel` can be distributed across a `prodRelabel`, if you have proofs that the factors correspond correctly. -/ diff --git a/QuantumInfo/States/Ensemble.lean b/QuantumInfo/States/Ensemble.lean index 2fe0e9ddf..d1e2df14b 100644 --- a/QuantumInfo/States/Ensemble.lean +++ b/QuantumInfo/States/Ensemble.lean @@ -137,8 +137,7 @@ theorem mix_pEnsemble_pure_iff_pure {e : PEnsemble d α} : refine Finset.sum_congr rfl fun i _ => ?_ by_cases hi : e.distr i = 0 · simp [hi] - · rw [← h i hi] - rfl + · exact h i hi simp [MState.ext_iff, h_sum, ← Finset.sum_smul] /- The theorem below is also false for the same reason as the original `mix_pEnsemble_pure_iff_pure`: diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 52c1ad535..076b2b354 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -1139,8 +1139,7 @@ def spectrum_SWAP (ρ : MState (d₁ × d₂)) : ∃ e, ρ.SWAP.spectrum.relabel (ρ.multiset_spectrum_relabel_eq (Equiv.prodComm _ _).symm ▸ rfl) use w ext x - simp_rw [h] - rfl + exact h x @[simp] theorem SWAP_SWAP (ρ : MState (d₁ × d₂)) : ρ.SWAP.SWAP = ρ := From 2b1a644ac53bb46c4db0b1cc89d762f3f6509425 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:18:43 -0700 Subject: [PATCH 408/498] refactor: golf space-time analytic wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/InnerProductSpace/Basic.lean | 6 ++---- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 3 +-- Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean | 7 ++----- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Physlib/Mathematics/InnerProductSpace/Basic.lean b/Physlib/Mathematics/InnerProductSpace/Basic.lean index e05b555a8..034bbfbc6 100644 --- a/Physlib/Mathematics/InnerProductSpace/Basic.lean +++ b/Physlib/Mathematics/InnerProductSpace/Basic.lean @@ -574,10 +574,8 @@ lemma _root_.isBoundedBilinearMap_inner' : apply h1.trans apply le_of_eq congr - · rw [norm_withLp2_eq_norm2] - rfl - · rw [norm_withLp2_eq_norm2] - rfl + · exact norm_withLp2_eq_norm2 _ + · exact norm_withLp2_eq_norm2 _ · have key (z : E) : |‖z‖₂| ≤ √ d * ‖z‖ := by apply le_of_sq_le_sq · simp [@mul_pow] diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index 4aae3598a..72c98dac7 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -220,8 +220,7 @@ lemma integrable_space {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) simp [zero_pow_eq, zero_zpow_eq, hp'] omega field_simp - rw [zpow_add₀ hr] - rfl + exact (zpow_add₀ hr p d).symm convert integrable_pow_mul_iteratedFDeriv radialAngularMeasure η (p + d).toNat 0 using 1 funext x simp only [Real.norm_eq_abs, norm_iteratedFDeriv_zero] diff --git a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean index 2e9de4fbd..56358bdbe 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/ConstantTimeDist.lean @@ -750,9 +750,7 @@ lemma time_integral_iteratedFDeriv_eq {d : ℕ} (n : ℕ) (η : 𝓢(Time × Spa (ContinuousLinearMap.id ℝ (Space d)))) := by ext y rw [time_integral_iteratedFDeriv_apply] - rw [← ContinuousMultilinearMap.integral_apply] - rfl - exact iteratedFDeriv_integrable η x + exact (ContinuousMultilinearMap.integral_apply (iteratedFDeriv_integrable η x) _).symm /-! @@ -957,8 +955,7 @@ lemma constantTime_distSpaceDiv {d : ℕ} (f : (Space d) →d[ℝ] EuclideanSpac rw [Space.distSpaceDiv_apply_eq_sum_distSpaceDeriv, Space.distDiv_apply_eq_sum_distDeriv] congr funext i - rw [constantTime_distSpaceDeriv] - rfl + exact congrArg (fun g => (g η).ofLp i) (constantTime_distSpaceDeriv i f) /-! From 69acf14e63067cae9e755d6d3535a52aa63b3d84 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:22:06 -0700 Subject: [PATCH 409/498] refactor: golf tensor matrix wrappers Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Units/Basic.lean | 3 +-- .../Relativity/Tensors/RealTensor/Matrix/Pre.lean | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index 7522c07b5..21e12c5bb 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -146,8 +146,7 @@ lemma coContrUnit_eq_complexCoBasisFin4_complexContrBasisFin4 : δ' = open Lorentz in lemma contrCoUnit_eq_complexContrBasis_complexCoBasis : δ = ∑ i, fromPairT (complexContrBasis i ⊗ₜ[ℂ] complexCoBasis i) := by - rw [contrCoUnit_eq_fromPairT, contrCoUnitVal_expand_tmul] - rfl + exact (contrCoUnit_eq_fromPairT.trans (congrArg fromPairT contrCoUnitVal_expand_tmul)).trans rfl open Lorentz in lemma contrCoUnit_eq_complexContrBasisFin4_complexCoBasisFin4 : δ = diff --git a/Physlib/Relativity/Tensors/RealTensor/Matrix/Pre.lean b/Physlib/Relativity/Tensors/RealTensor/Matrix/Pre.lean index 4766b187e..92ca7eac8 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Matrix/Pre.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Matrix/Pre.lean @@ -35,8 +35,7 @@ lemma contrContrToMatrixRe_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 rw [Finsupp.linearCombination_apply_of_mem_supported ℝ (s := Finset.univ)] · rw [Fintype.sum_prod_type] refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - erw [Basis.tensorProduct_apply (contrBasis d) (contrBasis d) i j] - rfl + exact congrArg₂ (· • ·) rfl (Basis.tensorProduct_apply (contrBasis d) (contrBasis d) i j) · simp /-- Equivalence of `Co ⊗ Co` to `(1 + d) x (1 + d)` real matrices. -/ @@ -53,8 +52,7 @@ lemma coCoToMatrixRe_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ F rw [Finsupp.linearCombination_apply_of_mem_supported ℝ (s := Finset.univ)] · rw [Fintype.sum_prod_type] refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - erw [Basis.tensorProduct_apply (coBasis d) (coBasis d) i j] - rfl + exact congrArg₂ (· • ·) rfl (Basis.tensorProduct_apply (coBasis d) (coBasis d) i j) · simp /-- Equivalence of `Contr d ⊗ Co d` to `(1 + d) x (1 + d)` real matrices. -/ @@ -72,8 +70,7 @@ lemma contrCoToMatrixRe_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 rw [Finsupp.linearCombination_apply_of_mem_supported ℝ (s := Finset.univ)] · rw [Fintype.sum_prod_type] refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - erw [Basis.tensorProduct_apply _ _ i j] - rfl + exact congrArg₂ (· • ·) rfl (Basis.tensorProduct_apply _ _ i j) · simp /-- Equivalence of `Co d ⊗ Contr d` to `(1 + d) x (1 + d)` real matrices. -/ @@ -91,8 +88,7 @@ lemma coContrToMatrixRe_symm_expand_tmul (M : Matrix (Fin 1 ⊕ Fin d) (Fin 1 rw [Finsupp.linearCombination_apply_of_mem_supported ℝ (s := Finset.univ)] · rw [Fintype.sum_prod_type] refine Finset.sum_congr rfl (fun i _ => Finset.sum_congr rfl (fun j _ => ?_)) - erw [Basis.tensorProduct_apply _ _ i j] - rfl + exact congrArg₂ (· • ·) rfl (Basis.tensorProduct_apply _ _ i j) · simp /-! From 9fade67e0d86c93d9ae5cc6e73277b9a4ac26498 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:25:14 -0700 Subject: [PATCH 410/498] refactor: golf anomaly cancellation wrappers Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/FamilyMaps.lean | 6 ++---- .../MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean index 724d22982..40d49aed1 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/FamilyMaps.lean @@ -98,8 +98,7 @@ def familyUniversal (n : ℕ) : (SMνCharges 1).Charges →ₗ[ℚ] (SMνCharges lemma toSpecies_familyUniversal {n : ℕ} (j : Fin 6) (S : (SMνCharges 1).Charges) (i : Fin n) : toSpecies j (familyUniversal n S) i = toSpecies j S ⟨0, by simp⟩ := by - rw [familyUniversal, chargesMapOfSpeciesMap_toSpecies] - rfl + exact congrFun (chargesMapOfSpeciesMap_toSpecies (speciesFamilyUniversial n) S j) i set_option backward.isDefEq.respectTransparency false in lemma sum_familyUniversal {n : ℕ} (m : ℕ) (S : (SMνCharges 1).Charges) (j : Fin 6) : @@ -128,8 +127,7 @@ lemma sum_familyUniversal_two {n : ℕ} (S : (SMνCharges 1).Charges) Fin.isValue, Nat.reduceMul] rw [Finset.mul_sum] refine Finset.sum_congr rfl (fun i _ => ?_) - erw [toSpecies_familyUniversal] - rfl + exact congrArg (fun x => x * T (finProdFinEquiv (j, i))) (toSpecies_familyUniversal j S i) set_option backward.isDefEq.respectTransparency false in lemma sum_familyUniversal_three {n : ℕ} (S : (SMνCharges 1).Charges) diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean index 4101c3322..6a28f9e20 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean @@ -258,8 +258,7 @@ lemma inLineEqTo_smul (R : InLineEq) (c₁ c₂ c₃ d : ℚ) : inLineEqToSol (R, (d * c₁), (d * c₂), (d * c₃)) = d • inLineEqToSol (R, c₁, c₂, c₃) := by apply ACCSystem.Sols.ext change (lineQuad _ _ _ _).val = _ - rw [lineQuad_smul] - rfl + exact congrArg (fun x => x.val) (lineQuad_smul R.val c₁ c₂ c₃ d) lemma inLineEqToSol_proj (T : InLineEqSol) : inLineEqToSol (inLineEqProj T) = T.val := by rw [inLineEqProj, inLineEqTo_smul] @@ -290,8 +289,7 @@ lemma inQuadToSol_smul (R : InQuad) (c₁ c₂ c₃ d : ℚ) : inQuadToSol (R, (d * c₁), (d * c₂), (d * c₃)) = d • inQuadToSol (R, c₁, c₂, c₃) := by apply ACCSystem.Sols.ext change (lineCube _ _ _ _).val = _ - rw [lineCube_smul] - rfl + exact congrArg (fun x => x.val) (lineCube_smul R.val.val c₁ c₂ c₃ d) /-- On elements of `inQuadSol` a right-inverse to `inQuadToSol`. -/ def inQuadProj (T : InQuadSol) : InQuad × ℚ × ℚ × ℚ := @@ -330,8 +328,7 @@ lemma inQuadCubeToSol_smul (R : InQuadCube) (c₁ c₂ c₃ d : ℚ) : inQuadCubeToSol (R, (d * c₁), (d * c₂), (d * c₃)) = d • inQuadCubeToSol (R, c₁, c₂, c₃) := by apply ACCSystem.Sols.ext change (planeY₃B₃ _ _ _ _).val = _ - rw [planeY₃B₃_smul] - rfl + exact congrArg (fun x => x.val) (planeY₃B₃_smul R.val.val.val c₁ c₂ c₃ d) /-- On elements of `inQuadCubeSol` a right-inverse to `inQuadCubeToSol`. -/ def inQuadCubeProj (T : InQuadCubeSol) : InQuadCube × ℚ × ℚ × ℚ := From 7333ce11852345dc435195589ed593085952c1e2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:27:40 -0700 Subject: [PATCH 411/498] refactor: golf QED basis wrappers Co-authored-by: Claude Opus 4.8 --- .../QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 9 +++------ Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index 5b8073fcc..ecae20095 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -418,8 +418,7 @@ def P' (f : Fin n.succ → ℚ) : (PureU1 (2 * n.succ)).LinSols := ∑ i, f i lemma P'_val (f : Fin n.succ → ℚ) : (P' f).val = P f := by simp only [succ_eq_add_one, P', P] funext i - rw [sum_of_anomaly_free_linear, sum_of_charges] - rfl + exact (sum_of_anomaly_free_linear _ i).trans (sum_of_charges _ i).symm /-! @@ -465,8 +464,7 @@ lemma vectorLikeEven_in_span (S : (PureU1 (2 * n.succ)).LinSols) have h : sort S.val (evenSnd i) = - sort S.val (evenFst i) := by rw [ht] ring - rw [h] - rfl + exact h.symm /-! @@ -707,8 +705,7 @@ def P!' (f : Fin n → ℚ) : (PureU1 (2 * n.succ)).LinSols := ∑ i, f i • ba lemma P!'_val (f : Fin n → ℚ) : (P!' f).val = P! f := by simp only [succ_eq_add_one, P!', P!] funext i - rw [sum_of_anomaly_free_linear, sum_of_charges] - rfl + exact (sum_of_anomaly_free_linear _ i).trans (sum_of_charges _ i).symm /-! diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 8f0f896e2..571a6eba0 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -460,8 +460,7 @@ def P' (f : Fin n → ℚ) : (PureU1 (2 * n + 1)).LinSols := ∑ i, f i • basi lemma P'_val (f : Fin n → ℚ) : (P' f).val = P f := by simp only [P', P] funext i - rw [sum_of_anomaly_free_linear, sum_of_charges] - rfl + exact (sum_of_anomaly_free_linear _ i).trans (sum_of_charges _ i).symm /-! @@ -709,8 +708,7 @@ def P!' (f : Fin n → ℚ) : (PureU1 (2 * n + 1)).LinSols := ∑ i, f i • bas lemma P!'_val (f : Fin n → ℚ) : (P!' f).val = P! f := by simp only [P!', P!] funext i - rw [sum_of_anomaly_free_linear, sum_of_charges] - rfl + exact (sum_of_anomaly_free_linear _ i).trans (sum_of_charges _ i).symm /-! From c06c484d6d55a1987c48d31426ec927d39fbeb52 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:31:48 -0700 Subject: [PATCH 412/498] refactor: golf analytic wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Kinematics/ElectricField.lean | 4 +--- Physlib/Electromagnetism/Kinematics/FieldStrength.lean | 5 +---- Physlib/Mathematics/InnerProductSpace/Submodule.lean | 3 +-- Physlib/Particles/SuperSymmetry/N1/Basic.lean | 3 +-- Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean | 3 +-- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/ElectricField.lean b/Physlib/Electromagnetism/Kinematics/ElectricField.lean index 4e10e653a..ae0b79dbc 100644 --- a/Physlib/Electromagnetism/Kinematics/ElectricField.lean +++ b/Physlib/Electromagnetism/Kinematics/ElectricField.lean @@ -292,9 +292,7 @@ lemma time_deriv_comp_vectorPotential_eq_electricField {d} {A : ElectromagneticP (t : Time) (x : Space d) (i : Fin d) : ∂ₜ (fun t => A.vectorPotential c t x i) t = - A.electricField c t x i - ∂[i] (A.scalarPotential c t) x := by - rw [Time.deriv_euclid, time_deriv_vectorPotential_eq_electricField] - rfl - apply vectorPotential_differentiable_time A hA x + exact time_deriv_vectorPotential_eq_electricField A hA c t x i /-! diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index edd3b44e8..c8dbff398 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -337,10 +337,7 @@ lemma toFieldStrength_basis_repr_apply {d} {μν : (Fin 1 ⊕ Fin d) × (Fin 1 ∑ κ, ((η μν.1 κ * ∂_ κ A x μν.2) - η μν.2 κ * ∂_ κ A x μν.1) := by match μν with | (μ, ν) => - trans (Tensor.basis _).repr (Tensorial.toTensor (toFieldStrength A x)) - (fun | 0 => μ | 1 => ν); swap - · rw [toTensor_toFieldStrength_basis_repr] - rfl + simpa using toTensor_toFieldStrength_basis_repr A x μ ν lemma toFieldStrength_basis_repr_apply_eq_single {d} {μν : (Fin 1 ⊕ Fin d) × (Fin 1 ⊕ Fin d)} (A : ElectromagneticPotential d) (x : SpaceTime d) : diff --git a/Physlib/Mathematics/InnerProductSpace/Submodule.lean b/Physlib/Mathematics/InnerProductSpace/Submodule.lean index ab9159c31..d0189e440 100644 --- a/Physlib/Mathematics/InnerProductSpace/Submodule.lean +++ b/Physlib/Mathematics/InnerProductSpace/Submodule.lean @@ -71,8 +71,7 @@ lemma submoduleToLp_closure : lemma mem_submodule_closure_iff_mem_submoduleToLp_closure : f ∈ M.topologicalClosure ↔ (WithLp.toLp 2 f) ∈ (submoduleToLp M).topologicalClosure := by - rw [← submoduleToLp_closure] - rfl + simpa [submoduleToLp_closure] using mem_submodule_iff_mem_submoduleToLp M.topologicalClosure f lemma mem_submodule_adjoint_iff_mem_submoduleToLp_orthogonal : g ∈ M.adjoint ↔ WithLp.toLp 2 (g.2, -g.1) ∈ (submoduleToLp M)ᗮ := by diff --git a/Physlib/Particles/SuperSymmetry/N1/Basic.lean b/Physlib/Particles/SuperSymmetry/N1/Basic.lean index f7cd6350b..a27b42f1f 100644 --- a/Physlib/Particles/SuperSymmetry/N1/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/N1/Basic.lean @@ -417,8 +417,7 @@ lemma toField_conjScalar (t : (chiralTensor (ι := ι)).Tensor ![]) : change componentMap (S := (chiralTensor (ι := ι)).toTensorSpecies) ((chiralTensor (ι := ι)).bar ∘ ![]) ((chiralTensor (ι := ι)).conjT t) (fun j => Fin.elim0 j) = star ((basis (S := (chiralTensor (ι := ι)).toTensorSpecies) ![]).repr t (fun j => Fin.elim0 j)) - rw [ConjTensorSpecies.componentMap_conjT (S := chiralTensor (ι := ι))] - rfl + exact ConjTensorSpecies.componentMap_conjT (S := chiralTensor (ι := ι)) t (fun j => Fin.elim0 j) /-- Component formula for the holomorphic covector conjugate: the `![I]` basis component of `conjChiralCovector t` is the complex conjugate of the `![I]` component of `t`. -/ diff --git a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean index 7b5f0e181..9c10b89ad 100644 --- a/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean +++ b/Physlib/Relativity/LorentzAlgebra/ExponentialMap.lean @@ -61,8 +61,7 @@ lemma exp_transpose_of_mem_algebra (A : lorentzAlgebra) : val_inv := minkowskiMatrix.sq, inv_val := minkowskiMatrix.sq } rw [show -(η * A.1 * η) = η * (-A.1) * η by noncomm_ring] - erw [NormedSpace.exp_units_conj P_gl (-A.1)] - rfl + exact NormedSpace.exp_units_conj P_gl (-A.1) set_option backward.isDefEq.respectTransparency false in /-- From 34d4251074fee555a58bfa6d9c40bc5d4f2408fd Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:41:02 -0700 Subject: [PATCH 413/498] refactor: golf relative entropy wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 12 ++++-------- QuantumInfo/States/Mixed/MState.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index d5fe2ce04..201b5fc83 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -462,8 +462,7 @@ private lemma hasDerivAt_trace_rpow_at_one (B : HermitianMat d ℂ) (hB : 0 ≤ simp [pow_one, HermitianMat.log] rw [h_log] exact (B.mat_cfc_mul_apply id Real.log).symm - rw [h_trace, ← HermitianMat.trace_eq_trace_rc] - rfl + exact h_trace.trans HermitianMat.trace_eq_trace_rc.symm simp_all [ HermitianMat.trace_cfc_eq ]; exact_mod_cast h_inner_def.trans h_trace; have h_deriv : ∀ i, HasDerivAt (fun α : ℝ => (B.H.eigenvalues i) ^ α) (B.H.eigenvalues i * Real.log (B.H.eigenvalues i)) 1 := by @@ -1665,8 +1664,7 @@ private theorem sandwichedRelRentropy.continuousOn_Ioi_1 (ρ σ : MState d) : have hα₀ : 0 < α := by linarith have hα₁ : α ≠ 1 := by linarith simp only [dif_pos hα₀, if_neg hα₁, ENNReal.ofReal] - rw [Real.toNNReal_of_nonneg] - rfl + exact Real.toNNReal_of_nonneg _ · rw [continuousOn_congr (f := fun α ↦ ⊤)] · fun_prop · clear ρ σ hρ; @@ -1711,8 +1709,7 @@ private theorem sandwichedRelRentropy.continuousOn_Ioo_0_1 (ρ σ : MState d) : have hα₁ : α ≠ 1 := ne_of_lt hα.2 split_ifs · norm_cast - · rw [ENNReal.ofReal, Real.toNNReal_of_nonneg] - rfl + · exact Real.toNNReal_of_nonneg _ · rw [continuousOn_congr (f := fun α ↦ ⊤)] · fun_prop · intro x hx @@ -1969,8 +1966,7 @@ private lemma ker_le_iff_eigenWeight_zero (ρ x : MState d) : replace h_eigenvalue := congr(WithLp.toLp 2 $h_eigenvalue) simp only [HermitianMat.val_eq_coe, MState.mat_M, WithLp.ofLp_sum, WithLp.ofLp_smul, WithLp.toLp_sum, WithLp.toLp_smul, WithLp.toLp_ofLp] at h_eigenvalue - rw [← h_eigenvalue, ← hv] - rfl + exact h_eigenvalue.symm.trans hv.symm have h_eigenvalue_zero : ∀ i, (x.M.H.eigenvalues i) • w i = 0 := by intro i have h_eigenvalue_zero : (x.M.H.eigenvalues i) • w i = inner ℂ (x.M.H.eigenvectorBasis i) (∑ j, (x.M.H.eigenvalues j) • w j • x.M.H.eigenvectorBasis j) := by diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 076b2b354..35fefd2fa 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -788,8 +788,7 @@ theorem pure_separable_imp_IsProd {d₁ d₂ : Type*} [Fintype d₁] [Fintype d · intro a exact MState.ext_iff.mpr a.symm · intro a - rw [← a] - rfl + exact MState.ext_iff.mpr a -- Since `pure ψ` is pure (`purity = 1`), by `MState.pure_iff_purity_one`, `ρL_k = pure ξ` and `ρR_k = pure φ` for some `ξ, φ`. obtain ⟨ξ, hξ⟩ : ∃ ξ : MState d₁, k.val.1 = ξ ∧ ξ.purity = 1 := by have h_purity : (pure ψ).purity = (k.val.1).purity * (k.val.2).purity := by From 532504bf5b8fd2f46da107111f584cd1b269c14d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:47:14 -0700 Subject: [PATCH 414/498] refactor: golf physics wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/WaveEquation/Basic.lean | 4 +--- .../Electromagnetism/Distributional/Dynamics/KineticTerm.lean | 3 +-- Physlib/Mathematics/SchurTriangulation.lean | 3 +-- Physlib/Particles/StandardModel/HiggsBoson/Basic.lean | 3 +-- .../PerturbationTheory/WickContraction/SubContraction.lean | 3 +-- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Physlib/ClassicalMechanics/WaveEquation/Basic.lean b/Physlib/ClassicalMechanics/WaveEquation/Basic.lean index b6713b9d7..0ad1fb828 100644 --- a/Physlib/ClassicalMechanics/WaveEquation/Basic.lean +++ b/Physlib/ClassicalMechanics/WaveEquation/Basic.lean @@ -198,9 +198,7 @@ lemma planeWave_apply_space_deriv {d f₀ c} {s : Direction d} rw [fderiv_comp] simp only [ContinuousLinearMap.fderiv, ContinuousLinearMap.coe_comp, Function.comp_apply, PiLp.proj_apply, fderiv_eq_smul_deriv, one_smul, Pi.smul_apply, smul_eq_mul] - rw [← Space.deriv_eq_fderiv_basis, planeWave_space_deriv] - rfl - · fun_prop + exact congrArg (fun y => y.ofLp j) (congrFun (planeWave_space_deriv h' i) x) · fun_prop · fun_prop diff --git a/Physlib/Electromagnetism/Distributional/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Distributional/Dynamics/KineticTerm.lean index e47af046f..344d498cc 100644 --- a/Physlib/Electromagnetism/Distributional/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Distributional/Dynamics/KineticTerm.lean @@ -209,8 +209,7 @@ lemma gradKineticTerm_eq_distTensorDeriv {d} {𝓕 : FreeSpace} (Lorentz.Vector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by ext ⟨i, j⟩ simp - rw [hb, Module.Basis.repr_reindex_apply] - rfl + simpa [hb] using Module.Basis.repr_reindex_apply _ _ _ apply congr · simp rfl diff --git a/Physlib/Mathematics/SchurTriangulation.lean b/Physlib/Mathematics/SchurTriangulation.lean index 2aff6aae3..fec1510ec 100644 --- a/Physlib/Mathematics/SchurTriangulation.lean +++ b/Physlib/Mathematics/SchurTriangulation.lean @@ -251,8 +251,7 @@ noncomputable def schurTriangulationAux : fun i j (hji : j < i) => calc LinearMap.toMatrixOrthonormal b' f i j _ = LinearMap.toMatrixOrthonormal b f (e.symm i) (e.symm j) := by - rw [f.toMatrixOrthonormal_reindex] - rfl + exact congrFun (congrFun (f.toMatrixOrthonormal_reindex b e.toEquiv) i) j _ = 0 := hut (e.symm.lt_iff_lt.mpr hji) /-- The change of basis that induces the upper triangular form `A.schurTriangulation` of a matrix diff --git a/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean b/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean index 408aa4370..47bdbd260 100644 --- a/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean +++ b/Physlib/Particles/StandardModel/HiggsBoson/Basic.lean @@ -223,8 +223,7 @@ lemma gaugeGroupI_smul_inner (g : StandardModel.GaugeGroupI) (φ ψ : HiggsVec) _ = (g.toSU2.1 *ᵥ (g.toU1 ^ 3 • ψ)) ⬝ᵥ star (g.toSU2.1 *ᵥ (g.toU1 ^ 3 • φ)) := by rw [gaugeGroupI_smul_eq_U1_mul_SU2, gaugeGroupI_smul_eq_U1_mul_SU2] _ = (g.toSU2.1 *ᵥ (g.toU1 ^ 3 • ψ)) ⬝ᵥ (star ((g.toU1 ^ 3 • φ)) ᵥ* star (g.toSU2.1)) := by - rw [star_mulVec] - rfl + exact congrArg (fun v => _ ⬝ᵥ v) (star_mulVec (g.toSU2.1) (g.toU1 ^ 3 • φ)) _ = ((star (g.toSU2.1) * g.toSU2.1) *ᵥ (g.toU1 ^ 3 • ψ)) ⬝ᵥ star ((g.toU1 ^ 3 • φ)) := by rw [dotProduct_comm, ← Matrix.dotProduct_mulVec, dotProduct_comm, mulVec_mulVec] rfl diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean index f8b8b0570..7a37667b9 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean @@ -101,8 +101,7 @@ lemma mem_subContraction_or_quotContraction {S : Finset (Finset (Fin φs.length) lemma subContraction_uncontractedList_get {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} {a : Fin [subContraction S hs]ᵘᶜ.length} : [subContraction S hs]ᵘᶜ[a] = φs[uncontractedListEmd a] := by - erw [← getElem_uncontractedListEmd] - rfl + exact (getElem_uncontractedListEmd a).symm @[simp] lemma subContraction_fstFieldOfContract {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} From 70f02e24acdb0b8c5bb3d1977b021519d3969b76 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:50:49 -0700 Subject: [PATCH 415/498] refactor: golf complex tensor unit basis wrappers Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Units/Basic.lean | 30 ++++--------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index 21e12c5bb..b6ab14fcf 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -184,55 +184,35 @@ lemma coContrUnit_eq_basis : δ' = ∑ i, Tensor.basis (S := complexLorentzTensor) ![Color.down, Color.up] (fun | 0 => i | 1 => i) := by rw [coContrUnit_eq_complexCoBasisFin4_complexContrBasisFin4] - conv_lhs => - enter [2, x] - change fromPairT ((complexLorentzTensor.basis .down x) ⊗ₜ[ℂ] - (complexLorentzTensor.basis .up _)) - rw [fromPairT_apply_basis_repr] + simp [fromPairT_apply_basis_repr] rfl lemma contrCoUnit_eq_basis : δ = ∑ i, Tensor.basis (S := complexLorentzTensor) ![Color.up, Color.down] (fun | 0 => i | 1 => i) := by rw [contrCoUnit_eq_complexContrBasisFin4_complexCoBasisFin4] - conv_lhs => - enter [2, x] - change fromPairT ((complexLorentzTensor.basis .up x) ⊗ₜ[ℂ] - (complexLorentzTensor.basis .down _)) - rw [fromPairT_apply_basis_repr] + simp [fromPairT_apply_basis_repr] rfl lemma dualLeftLeftUnit_eq_basis : δL' = ∑ i, Tensor.basis (S := complexLorentzTensor) ![Color.downL, Color.upL] (fun | 0 => i | 1 => i) := by rw [dualLeftLeftUnit_eq_dualLeftBasis_leftBasis] - conv_lhs => - enter [2, x] - change fromPairT ((complexLorentzTensor.basis .downL x) ⊗ₜ[ℂ] - (complexLorentzTensor.basis .upL _)) - rw [fromPairT_apply_basis_repr] + simp [fromPairT_apply_basis_repr] rfl lemma leftDualLeftUnit_eq_basis : δL = ∑ i, Tensor.basis (S := complexLorentzTensor) ![Color.upL, Color.downL] (fun | 0 => i | 1 => i) := by rw [leftDualLeftUnit_eq_leftBasis_dualLeftBasis] - conv_lhs => - enter [2, x] - change fromPairT ((complexLorentzTensor.basis .upL x) ⊗ₜ[ℂ] - (complexLorentzTensor.basis .downL _)) - rw [fromPairT_apply_basis_repr] + simp [fromPairT_apply_basis_repr] rfl lemma dualRightRightUnit_eq_basis : δR' = ∑ i, Tensor.basis (S := complexLorentzTensor) ![Color.downR, Color.upR] (fun | 0 => i | 1 => i) := by rw [dualRightRightUnit_eq_dualRightBasis_rightBasis] - conv_lhs => - enter [2, x] - change fromPairT ((complexLorentzTensor.basis .downR x) ⊗ₜ[ℂ] - (complexLorentzTensor.basis .upR _)) - rw [fromPairT_apply_basis_repr] + simp [fromPairT_apply_basis_repr] rfl lemma rightDualRightUnit_eq_basis : δR = From ce171cbb8d96da7e71f4394a296c275dad26230d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 10:55:18 -0700 Subject: [PATCH 416/498] refactor: golf tensor and QED wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/QED/AnomalyCancellation/Basic.lean | 6 ++---- Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean | 3 +-- Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean | 6 +----- Physlib/SpaceAndTime/Space/Derivatives/Basic.lean | 3 +-- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Basic.lean b/Physlib/QFT/QED/AnomalyCancellation/Basic.lean index 2d916725b..3a9e802a6 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Basic.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Basic.lean @@ -161,8 +161,7 @@ lemma sum_of_charges {n : ℕ} (f : Fin k → (PureU1 n).Charges) (j : Fin n) : · rfl · rename_i k hl rw [Fin.sum_univ_castSucc, Fin.sum_univ_castSucc] - erw [← hl (f ∘ Fin.castSucc)] - rfl + exact congrArg₂ (· + ·) (hl (f ∘ Fin.castSucc)) rfl /-- The `j`th charge of a sum of solutions to the linear ACC is equal to the sum of their `j`th charges. -/ @@ -172,7 +171,6 @@ lemma sum_of_anomaly_free_linear {n : ℕ} (f : Fin k → (PureU1 n).LinSols) (j · rfl · rename_i k hl rw [Fin.sum_univ_castSucc, Fin.sum_univ_castSucc] - erw [← hl (f ∘ Fin.castSucc)] - rfl + exact congrArg₂ (· + ·) (hl (f ∘ Fin.castSucc)) rfl end PureU1 diff --git a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean index a20f1113f..660d09e74 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/ConstAbs.lean @@ -233,8 +233,7 @@ lemma AFL_even_below (A : (PureU1 (2 * n.succ)).LinSols) (h : ConstAbsSorted A.v A.val (Fin.cast (split_equal n.succ) (Fin.castAdd n.succ i)) = A.val (0 : Fin (2*n.succ)) := by by_cases hA : A.val (0 : Fin (2*n.succ)) = 0 - · rw [is_zero h hA] - rfl + · exact (congrFun (is_zero h hA) _).trans hA.symm · exact AFL_even_below' h hA i lemma AFL_even_above' {A : (PureU1 (2 * n.succ)).LinSols} (h : ConstAbsSorted A.val) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean index b6ab14fcf..0ad7057c2 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Basic.lean @@ -219,11 +219,7 @@ lemma rightDualRightUnit_eq_basis : δR = ∑ i, Tensor.basis (S := complexLorentzTensor) ![Color.upR, Color.downR] (fun | 0 => i | 1 => i) := by rw [rightDualRightUnit_eq_rightBasis_dualRightBasis] - conv_lhs => - enter [2, x] - change fromPairT ((complexLorentzTensor.basis .upR x) ⊗ₜ[ℂ] - (complexLorentzTensor.basis .downR _)) - rw [fromPairT_apply_basis_repr] + simp [fromPairT_apply_basis_repr] rfl /-! diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean index f497d5896..f8d3087a5 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Basic.lean @@ -138,8 +138,7 @@ lemma deriv_eq_mfderiv_manifoldStructure {M d} [NormedAddCommGroup M] [NormedSpa (modelDiffeo.mdifferentiable WithTop.top_ne_zero).mdifferentiableAt] simp only [Function.comp_apply, modelDiffeo_apply, mfderiv_eq_fderiv, ContinuousLinearMap.coe_comp] - rw [basis_eq_mfderiv_modelDiffeo_single] - rfl + exact congrArg (fun v => (fderiv ℝ f x) v) (basis_eq_mfderiv_modelDiffeo_single (d := d) μ x) · rw [deriv_eq, fderiv_zero_of_not_differentiableAt hf, mfderiv_zero_of_not_mdifferentiableAt <| mdifferentiable_manifoldStructure_iff_differentiable.mp.mt hf] From 8124214719ede962be6618eed859beda6ac537f1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 11:08:38 -0700 Subject: [PATCH 417/498] refactor: golf finite sum and electromagnetic wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Kinematics/Boosts.lean | 3 +-- Physlib/Electromagnetism/Kinematics/FieldStrength.lean | 3 +-- .../BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean | 3 +-- Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean | 3 +-- .../SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Kinematics/Boosts.lean b/Physlib/Electromagnetism/Kinematics/Boosts.lean index 3168bc707..c902e270e 100644 --- a/Physlib/Electromagnetism/Kinematics/Boosts.lean +++ b/Physlib/Electromagnetism/Kinematics/Boosts.lean @@ -190,8 +190,7 @@ lemma magneticFieldMatrix_apply_x_boost_succ_succ {d : ℕ} {c : SpeedOfLight} ( rw [magneticFieldMatrix_eq] simp only rw [fieldStrengthMatrix_equivariant _ _ hA] - simp [Fintype.sum_sum_type, boost_zero_inr_succ_inr_succ, Fin.sum_univ_succ] - rfl + simpa [Fintype.sum_sum_type, boost_zero_inr_succ_inr_succ, Fin.sum_univ_succ] end ElectromagneticPotential end Electromagnetism diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index c8dbff398..a2a21d0d0 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -440,8 +440,7 @@ lemma toFieldStrength_eq_fieldStrengthMatrix {d} (A : ElectromagneticPotential d ext κ match κ with | (μ', ν') => - simp [Finsupp.single_apply] - rfl + simpa [Finsupp.single_apply] /-! diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean index 9ec3f3678..f81cc1ad7 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean @@ -35,8 +35,7 @@ variable {n : ℕ} lemma sum_one [AddCommMonoid M] (f : Fin (SMνSpecies 1).numberCharges → M) : ∑ i, f i = f ⟨0, by simp⟩ := by change ∑ (i : Fin 1), f i = _ - simp only [Finset.univ_unique, Fin.default_eq_zero, Fin.isValue, Finset.sum_singleton] - rfl + exact Fin.sum_univ_one f /-- An equivalence between `(SMνCharges n).charges` and `(Fin 6 → Fin n → ℚ)` splitting the charges into species. -/ diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index bfddec06f..eb4e78a4d 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -35,8 +35,7 @@ lemma sum_SMSpecies_numberCharges_one {M} [AddCommMonoid M] (f : Fin (SMSpecies 1).numberCharges → M) : ∑ i, f i = f ⟨0, by simp⟩ := by change ∑ (i : Fin 1), f i = _ - simp only [Finset.univ_unique, Fin.default_eq_zero, Fin.isValue, Finset.sum_singleton] - rfl + exact Fin.sum_univ_one f /-- An equivalence between the set `(SMCharges n).charges` and the set `(Fin 5 → Fin n → ℚ)`. -/ diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean index b69a5c1cd..c1b3d5f86 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean @@ -33,8 +33,7 @@ lemma sum_MSSMSpecies_numberCharges_eq_expand [AddCommMonoid M] (f : Fin MSSMSpecies.numberCharges → M) : ∑ i, f i = f ⟨0, by simp⟩ + f ⟨1, by simp⟩ + f ⟨2, by simp⟩ := by change ∑ (i : Fin 3), f i = f ⟨0, by simp⟩ + f ⟨1, by simp⟩ + f ⟨2, by simp⟩ - simp only [Fin.sum_univ_three] - rfl + exact Fin.sum_univ_three f /-- An equivalence between `MSSMCharges.charges` and the space of maps `(Fin 18 ⊕ Fin 2 → ℚ)`. The first 18 factors corresponds to the SM fermions, while the last two From 6574c30d8ee7d9a5a119f9c4e66d9b47a166605c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 11:18:32 -0700 Subject: [PATCH 418/498] refactor: golf dimension and completion wrappers Co-authored-by: Claude Opus 4.8 --- .../SuperSymmetry/SU5/ChargeSpectrum/Completions.lean | 3 +-- Physlib/Units/UnitDependent.lean | 9 +++------ QuantumInfo/States/Entanglement.lean | 1 - 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean index 3f2eff3c7..ec1e993d8 100644 --- a/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean +++ b/Physlib/Particles/SuperSymmetry/SU5/ChargeSpectrum/Completions.lean @@ -209,8 +209,7 @@ lemma completions_eq_singleton_of_complete {S5 S10 : Finset 𝓩} (x : ChargeSpe case' neg => simp_all by_cases h4 : x.Q10 ≠ ∅ case' neg => simp_all - simp_all - rfl + simp_all [toProd] /-! diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 13c35a853..cf6eee82a 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -449,24 +449,21 @@ lemma isDimensionallyCorrect_fun_iff {M1 M2 : Type} [UnitDependent M1] [UnitDepe {f : M1 → M2} : IsDimensionallyCorrect f ↔ ∀ u1 u2 : UnitChoices, ∀ m, scaleUnit u1 u2 (f (scaleUnit u2 u1 m)) = f m := by - simp only [IsDimensionallyCorrect, funext_iff] - rfl + simp [IsDimensionallyCorrect, funext_iff] @[simp] lemma isDimensionallyCorrect_fun_left {M1 M2 : Type} [UnitDependent M1] {f : M1 → M2} : IsDimensionallyCorrect f ↔ ∀ u1 u2 : UnitChoices, ∀ m, (f (scaleUnit u2 u1 m)) = f m := by - simp only [IsDimensionallyCorrect, funext_iff] - rfl + simp [IsDimensionallyCorrect, funext_iff] @[simp] lemma isDimensionallyCorrect_fun_right {M1 M2 : Type} [UnitDependent M2] {f : M1 → M2} : IsDimensionallyCorrect f ↔ ∀ u1 u2 : UnitChoices, ∀ m, scaleUnit u1 u2 (f m) = f m := by - simp only [IsDimensionallyCorrect, funext_iff] - rfl + simp [IsDimensionallyCorrect, funext_iff] /-! ## Some type classes to help track dimensions diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 76667a7b0..5257701a5 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -254,7 +254,6 @@ theorem traceRight_pure_MES (d : Type*) [Fintype d] [DecidableEq d] [Nonempty d] coe_ofClassical, ProbDistribution.uniform_def, Finset.card_univ] unfold HermitianMat.diagonal simp_all only [map_inv₀, map_natCast] - rfl /- The von Neumann entropy of a state is equal to the trace of `ρ log ρ` (technically `cfc ρ negMulLog`). From 3092208e247b0df0caeded43c716525c85f347fd Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 11:22:59 -0700 Subject: [PATCH 419/498] refactor: golf complex basis wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean | 3 +-- Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean | 6 ++---- .../Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index e9f0c716e..95c43fcb8 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -46,8 +46,7 @@ lemma koszulSign_mul_self (l : List 𝓕) : koszulSign q le l * koszulSign q le @[simp] lemma koszulSign_freeMonoid_of (φ : 𝓕) : koszulSign q le (FreeMonoid.of φ) = 1 := by change koszulSign q le [φ] = 1 - simp only [koszulSign, mul_one] - rfl + simp [koszulSign, koszulSignInsert, mul_one] lemma koszulSignInsert_erase_boson {𝓕 : Type} (q : 𝓕 → FieldStatistic) (le : 𝓕 → 𝓕 → Prop) [DecidableRel le] (φ : 𝓕) : diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean index bdee85a44..13fc2fb0e 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Basic.lean @@ -150,8 +150,7 @@ lemma coMetric_eq_complexCoBasisFin4 : η' = - fromPairT (complexCoBasisFin4 2 ⊗ₜ[ℂ] complexCoBasisFin4 2) - fromPairT (complexCoBasisFin4 3 ⊗ₜ[ℂ] complexCoBasisFin4 3) := by rw [coMetric_eq_complexCoBasis] - simp [complexCoBasisFin4] - rfl + simp [complexCoBasisFin4, finSumFinEquiv, Fin.addCases] open Lorentz in lemma contrMetric_eq_complexContrBasis : η = @@ -169,8 +168,7 @@ lemma contrMetric_eq_complexContrBasisFin4 : η = - fromPairT (complexContrBasisFin4 2 ⊗ₜ[ℂ] complexContrBasisFin4 2) - fromPairT (complexContrBasisFin4 3 ⊗ₜ[ℂ] complexContrBasisFin4 3) := by rw [contrMetric_eq_complexContrBasis] - simp [complexContrBasisFin4] - rfl + simp [complexContrBasisFin4, finSumFinEquiv, Fin.addCases] open Fermion in lemma leftMetric_eq_leftBasis : εL = diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index 2e7829ac1..0eb8daa24 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -61,14 +61,12 @@ lemma complexContrBasis_reindex_apply_eq_fin4 (j : Fin 4) : @[simp] lemma complexContrBasisFin4_apply_zero : complexContrBasisFin4 0 = complexContrBasis (Sum.inl 0) := by - simp only [complexContrBasisFin4, Basis.reindex_apply] - rfl + simp [complexContrBasisFin4, finSumFinEquiv, Fin.addCases] @[simp] lemma complexContrBasisFin4_apply_one : complexContrBasisFin4 1 = complexContrBasis (Sum.inr 0) := by - simp only [complexContrBasisFin4, Basis.reindex_apply] - rfl + simp [complexContrBasisFin4, finSumFinEquiv, Fin.addCases] @[simp] lemma complexContrBasisFin4_apply_two : From 9e8e7002f6ae5c2c4c020c4ebd59435251cb56a7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 11:24:37 -0700 Subject: [PATCH 420/498] refactor: golf complex vector basis wrappers Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Vector/Pre/Basic.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index 0eb8daa24..a096a194a 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -71,14 +71,12 @@ lemma complexContrBasisFin4_apply_one : @[simp] lemma complexContrBasisFin4_apply_two : complexContrBasisFin4 2 = complexContrBasis (Sum.inr 1) := by - simp only [complexContrBasisFin4, Basis.reindex_apply] - rfl + simp [complexContrBasisFin4, finSumFinEquiv, Fin.addCases] @[simp] lemma complexContrBasisFin4_apply_three : complexContrBasisFin4 3 = complexContrBasis (Sum.inr 2) := by - simp only [complexContrBasisFin4, Basis.reindex_apply] - rfl + simp [complexContrBasisFin4, finSumFinEquiv, Fin.addCases] @[simp] lemma complexContrBasisFin4_apply_succ (i : Fin 3) : @@ -123,20 +121,17 @@ lemma complexCoBasis_reindex_apply_eq_fin4 (j : Fin 4) : @[simp] lemma complexCoBasisFin4_apply_zero : complexCoBasisFin4 0 = complexCoBasis (Sum.inl 0) := by - simp only [complexCoBasisFin4, Basis.reindex_apply] - rfl + simp [complexCoBasisFin4, finSumFinEquiv, Fin.addCases] @[simp] lemma complexCoBasisFin4_apply_one : complexCoBasisFin4 1 = complexCoBasis (Sum.inr 0) := by - simp only [complexCoBasisFin4, Basis.reindex_apply] - rfl + simp [complexCoBasisFin4, finSumFinEquiv, Fin.addCases] @[simp] lemma complexCoBasisFin4_apply_two : complexCoBasisFin4 2 = complexCoBasis (Sum.inr 1) := by - simp only [complexCoBasisFin4, Basis.reindex_apply] - rfl + simp [complexCoBasisFin4, finSumFinEquiv, Fin.addCases] @[simp] lemma complexCoBasisFin4_apply_three : From c4be73370544afb8642badb3a34a65329889b6c9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 11:33:11 -0700 Subject: [PATCH 421/498] refactor: golf Lorentz and QuantumInfo wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Basic.lean | 3 +-- Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean | 3 +-- QuantumInfo/Entropy/DPI.lean | 1 - QuantumInfo/Entropy/SSA.lean | 1 - QuantumInfo/States/Entanglement.lean | 1 - 5 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Basic.lean b/Physlib/Relativity/LorentzGroup/Basic.lean index 73d6152f7..8b90f6530 100644 --- a/Physlib/Relativity/LorentzGroup/Basic.lean +++ b/Physlib/Relativity/LorentzGroup/Basic.lean @@ -349,8 +349,7 @@ def toComplex : LorentzGroup d →* Matrix (Fin 1 ⊕ Fin d) (Fin 1 ⊕ Fin d) map_mul' Λ Λ' := by ext i j simp only [lorentzGroupIsGroup_mul_coe, map_apply, ofRealHom_eq_coe] - simp only [← Matrix.map_mul] - rfl + simp [← Matrix.map_mul] /-- The image of a Lorentz transformation under `toComplex` is invertible. -/ instance (M : LorentzGroup d) : Invertible (toComplex M) where diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index a096a194a..20376fe2d 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -136,8 +136,7 @@ lemma complexCoBasisFin4_apply_two : @[simp] lemma complexCoBasisFin4_apply_three : complexCoBasisFin4 3 = complexCoBasis (Sum.inr 2) := by - simp only [complexCoBasisFin4, Basis.reindex_apply] - rfl + simp [complexCoBasisFin4, finSumFinEquiv, Fin.addCases] /-! diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index de8febf8a..4a344a49b 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -755,7 +755,6 @@ private lemma twirling_identity [Nonempty dB] (X : HermitianMat dB ℂ) : · rename_i a s a_1 a_2 obtain ⟨fst, snd⟩ := a simp only [not_false_eq_true, Finset.sum_insert, *] - rfl · norm_num [Matrix.one_apply] rw [show X.trace = ∑ k, X k k from X.trace_eq_trace] rcases n : Fintype.card dB with (_ | n) diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index f93407498..486d6b8db 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -868,7 +868,6 @@ private lemma inner_one_kron_eq_inner_traceLeft refine' Finset.sum_bij ( fun x y => ( x.2, x.1 ) ) _ _ _ _ <;> simp [ Matrix.mul_apply ]; intro a b; rw [ ← Equiv.sum_comp ( Equiv.prodComm d₁ d₂ ) ] simp [mul_comm] - rfl open HermitianMat in private lemma hermitianMat_log_inv_eq_neg diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 5257701a5..13cb8ed40 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -191,7 +191,6 @@ theorem convex_roof_of_pure (ψ : Ket d) : convex_roof g (pure ψ) = g (KetUpToP congr 1 exact congrArg g (Quotient.sound hab) simp [mix_pEnsemble_pure_average (NNReal.toReal ∘ g ∘ KetUpToPhase.mk) hphase_inv hmix] - rfl omit [Nonempty d] in /-- The mixed convex roof extension of `f : MState d → ℝ≥0` applied to a pure state `ψ` is `f (pure ψ)`. -/ From 4227a54556eb75847060a7cfe182d7f6c1d00140 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 11:42:53 -0700 Subject: [PATCH 422/498] refactor: golf normalization closers Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Dynamics/KineticTerm.lean | 1 - Physlib/Electromagnetism/Kinematics/EMPotential.lean | 1 - Physlib/SpaceAndTime/Space/Translations.lean | 6 ++---- QuantumInfo/ResourceTheory/SteinsLemma.lean | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean index f5e11d91a..724d587d4 100644 --- a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean @@ -986,7 +986,6 @@ lemma gradKineticTerm_eq_tensorDeriv {d} {𝓕 : FreeSpace} rw [gradKineticTerm_eq_fieldStrength A x hA] simp [Lorentz.Vector.apply_sum] ring_nf - rfl end ElectromagneticPotential diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index ed0bf6a1b..28bc87640 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -484,7 +484,6 @@ lemma hasVarAdjDerivAt_component {d : ℕ} (μ : Fin 1 ⊕ Fin d) (A : SpaceTime intro u v simp [f, f', inner_smul_left, Lorentz.Vector.basis_inner] ring_nf - rfl /-! diff --git a/Physlib/SpaceAndTime/Space/Translations.lean b/Physlib/SpaceAndTime/Space/Translations.lean index 6864fc56e..f42cb3d85 100644 --- a/Physlib/SpaceAndTime/Space/Translations.lean +++ b/Physlib/SpaceAndTime/Space/Translations.lean @@ -68,8 +68,7 @@ noncomputable def translateSchwartz {d : ℕ} (a : EuclideanSpace ℝ (Fin d)) : trans (1 + (‖x‖ + ‖a‖)) + ‖x‖ * ‖a‖ · simp positivity - ring_nf - rfl) (by + nlinarith) (by use 1, (1 + ‖a‖) intro x simp only [pow_one] @@ -79,8 +78,7 @@ noncomputable def translateSchwartz {d : ℕ} (a : EuclideanSpace ℝ (Fin d)) : trans (1 + (‖a‖ + ‖x - basis.repr.symm a‖)) + ‖a‖ * ‖x - basis.repr.symm a‖ · simp positivity - ring_nf - rfl) + nlinarith) @[simp] lemma translateSchwartz_apply {d : ℕ} (a : EuclideanSpace ℝ (Fin d)) diff --git a/QuantumInfo/ResourceTheory/SteinsLemma.lean b/QuantumInfo/ResourceTheory/SteinsLemma.lean index b5d4edadd..30ef6d375 100644 --- a/QuantumInfo/ResourceTheory/SteinsLemma.lean +++ b/QuantumInfo/ResourceTheory/SteinsLemma.lean @@ -2026,7 +2026,6 @@ theorem GeneralizedQSteinsLemma {i : ι} (ρ : MState (H i)) {ε : Prob} (hε : rw [← add_assoc, σₖ_succ, pow_succ] grw [Lemma7_gap ρ hε hε' (σₖ (m + k)), ih m] ring_nf - rfl replace hσₖ_gap : Filter.atTop.liminf (fun k ↦ R2 ρ (σₖ k)) ≤ R1 ρ ε := by rw [ENNReal.tendsto_sub_const_nhds_zero_iff] at hσₖ_gap From 2874b7545045178d02d6d95db6ffde85db396e69 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 11:49:15 -0700 Subject: [PATCH 423/498] refactor: golf QuantumInfo proof closers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Entropy/Relative.lean | 1 - QuantumInfo/ResourceTheory/HypothesisTesting.lean | 1 - QuantumInfo/States/Entanglement.lean | 2 -- QuantumInfo/States/Mixed/MState.lean | 1 - 4 files changed, 5 deletions(-) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 201b5fc83..489979a99 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -1255,7 +1255,6 @@ lemma ker_le_of_ker_kron_le_left (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSta convert! congr(WithLp.ofLp $(h_top (WithLp.toLp 2 ( Pi.single j 1 )) ) i) using 1 simp simp [ HermitianMat.lin ]; - rfl exact ρ₂.pos.ne' h_contra; have h_union : ∀ (U V : Submodule ℂ (EuclideanSpace ℂ d₂)), U ≠ ⊤ → V ≠ ⊤ → ∃ v : EuclideanSpace ℂ d₂, v ∉ U ∧ v ∉ V := by intros U V hU hV; diff --git a/QuantumInfo/ResourceTheory/HypothesisTesting.lean b/QuantumInfo/ResourceTheory/HypothesisTesting.lean index e6bec24a8..6e4c51410 100644 --- a/QuantumInfo/ResourceTheory/HypothesisTesting.lean +++ b/QuantumInfo/ResourceTheory/HypothesisTesting.lean @@ -100,7 +100,6 @@ theorem iInf_IsConvex (ρ : MState d) (ε : Prob) : Convex ℝ { m | ρ.exp_val @[simp] theorem of_empty {ρ : MState d} (ε : Prob) : β_ ε(ρ‖∅) = 0 := by simp [OptimalHypothesisRate] - rfl set_option backward.isDefEq.respectTransparency false in theorem le_sup_exp_val {ρ : MState d} (ε : Prob) {S : Set (MState d)} diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 13cb8ed40..336a033e8 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -179,7 +179,6 @@ theorem convex_roof_of_pure (ψ : Ket d) : convex_roof g (pure ψ) = g (KetUpToP conv_lhs => enter [1, 1] rw [trivial_pEnsemble_average ψ _ 0] - rfl · apply le_convex_roof intro n hnpos e hmix apply le_of_eq @@ -205,7 +204,6 @@ theorem mixed_convex_roof_of_pure (ψ : Ket d) : mixed_convex_roof f (pure ψ) = conv_lhs => enter [1, 1] rw [trivial_mEnsemble_average _ (pure ψ) 0] - rfl · apply le_mixed_convex_roof intro n hnpos e hmix replace hpure := mix_mEnsemble_pure_iff_pure.mp hmix diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 35fefd2fa..4b6923ccd 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -407,7 +407,6 @@ theorem pure_of_constant_spectrum (h : ∃ i, ρ.spectrum = ProbDistribution.con rw [if_neg hxnoti, Complex.ofReal_zero] ring simp_rw [←Finset.sum_subset (Finset.subset_univ {i}) hsum, Finset.sum_singleton, reduceIte, Complex.ofReal_one, mul_one] - rfl /-- A state ρ is pure iff its spectrum is (1,0,0,...) i.e. a constant distribution. -/ theorem pure_iff_constant_spectrum : (∃ ψ, ρ = pure ψ) ↔ From 2d0b2686f930fdf84bc5de77983a9528423d11c8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 11:59:34 -0700 Subject: [PATCH 424/498] refactor: golf QED and QuantumInfo rewrite closers Co-authored-by: Claude Opus 4.8 --- .../QED/AnomalyCancellation/Odd/BasisLinear.lean | 13 ++++++------- QuantumInfo/Entropy/Relative.lean | 1 - QuantumInfo/Entropy/SSA.lean | 1 - QuantumInfo/ResourceTheory/HypothesisTesting.lean | 1 - QuantumInfo/States/Entanglement.lean | 1 - 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 571a6eba0..89a2b62aa 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -522,13 +522,12 @@ lemma basis!_on_oddShiftFst_other {k j : Fin n} (h : k ≠ j) : simp_all rw [Fin.ext_iff] at h simp_all - · split - · rename_i h1 h2 - simp_all - rw [Fin.ext_iff] at h2 - simp only [Fin.val_castAdd, Fin.val_natAdd] at h2 - omega - rfl + · split <;> try rfl + rename_i h1 h2 + simp_all + rw [Fin.ext_iff] at h2 + simp only [Fin.val_castAdd, Fin.val_natAdd] at h2 + omega set_option backward.isDefEq.respectTransparency false in lemma basis!_on_other {k : Fin n} {j : Fin (2 * n + 1)} diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index 489979a99..e25b23bfd 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -290,7 +290,6 @@ lemma HermitianMat.supportProj_mul_self (A : HermitianMat d ℂ) : have hsup : A.support = (Matrix.toEuclideanLin (↑A : Matrix d d ℂ)).range := by simp [HermitianMat.support, HermitianMat.lin] rw [key, LinearMap.comp_apply, Submodule.subtype_apply, hsup] - rfl rw [h_supportProj_mul_A] exact Submodule.eq_starProjection_of_mem_of_inner_eq_zero (by simpa using hv) (by simp) exact congr(WithLp.ofLp $(h_supportProj_mul_A _ h_range)) diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 486d6b8db..47d6d0b9d 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -291,7 +291,6 @@ theorem Matrix.opNorm_conjTranspose_eq_opNorm {m n : Type*} [Fintype m] [Fintype Matrix.opNorm Aᴴ = Matrix.opNorm A := by unfold Matrix.opNorm rw [← ContinuousLinearMap.adjoint.norm_map (toEuclideanLin A).toContinuousLinearMap] - rfl theorem isometry_mul_conjTranspose_le_one {m n : Type*} [Fintype m] [Fintype n] [DecidableEq m] [DecidableEq n] diff --git a/QuantumInfo/ResourceTheory/HypothesisTesting.lean b/QuantumInfo/ResourceTheory/HypothesisTesting.lean index 6e4c51410..f7186f5ff 100644 --- a/QuantumInfo/ResourceTheory/HypothesisTesting.lean +++ b/QuantumInfo/ResourceTheory/HypothesisTesting.lean @@ -304,7 +304,6 @@ theorem Lemma3 {ρ : MState d} (ε : Prob) {S : Set (MState d)} (hS₁ : IsCompa have hi := iSup_range' (ι := S) (fun x ↦ (f x) ↑y) (·) rw [← Set.image_eq_range] at hi rw [← iSup_subtype'', Set.Icc.coe_iSup zero_le_one, hi] - rfl --Maybe should be phrased in terms of `0 < ...` instead? Maybe belongs in another file? It's kiinnnd of specialized.. theorem ker_diagonal_prob_eq_bot {q : Prob} (hq₁ : 0 < q) (hq₂ : q < 1) : diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 336a033e8..83ff9af20 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -212,7 +212,6 @@ theorem mixed_convex_roof_of_pure (ψ : Ket d) : mixed_convex_roof f (pure ψ) = conv_rhs => enter [1, 1] rw [mix_mEnsemble_pure_average (toReal ∘ f) hmix, Function.comp_apply] - rfl /-- Entanglement of Formation of bipartite systems. It is the convex roof extension of the von Neumann entropy of one of the subsystems (here chosen to be the left one, but see `Entropy.Sᵥₙ_of_partial_eq`). From d3e2a7c0d28b95ad79c0a8f4248f18ea7c39fc9e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:02:10 -0700 Subject: [PATCH 425/498] refactor: golf definitional rfl proofs Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/FieldSpecification/CrAnSection.lean | 3 +-- .../PerturbationTheory/FieldSpecification/TimeOrder.lean | 6 ++---- Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 942f520b3..f006367fe 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -126,8 +126,7 @@ def singletonEquiv {φ : 𝓕.FieldOp} : CrAnSection [φ] ≃ have h2 := ψs.tail.2 simp only [List.tail_cons, List.map_eq_nil_iff] at h2 simp [h2] - right_inv ψ := by - rfl + right_inv ψ := rfl /-- An equivalence separating the head of a creation and annihilation section from the tail. -/ diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean index 5acd8379d..2144fc7a2 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/TimeOrder.lean @@ -135,8 +135,7 @@ def timeOrderSign (φs : List 𝓕.FieldOp) : ℂ := Wick.koszulSign 𝓕.fieldOpStatistic 𝓕.timeOrderRel φs @[simp] -lemma timeOrderSign_nil : timeOrderSign (𝓕 := 𝓕) [] = 1 := by - rfl +lemma timeOrderSign_nil : timeOrderSign (𝓕 := 𝓕) [] = 1 := rfl lemma timeOrderSign_pair_ordered {φ ψ : 𝓕.FieldOp} (h : timeOrderRel φ ψ) : timeOrderSign [φ, ψ] = 1 := by @@ -234,8 +233,7 @@ def crAnTimeOrderSign (φs : List 𝓕.CrAnFieldOp) : ℂ := Wick.koszulSign 𝓕.crAnStatistics 𝓕.crAnTimeOrderRel φs @[simp] -lemma crAnTimeOrderSign_nil : crAnTimeOrderSign (𝓕 := 𝓕) [] = 1 := by - rfl +lemma crAnTimeOrderSign_nil : crAnTimeOrderSign (𝓕 := 𝓕) [] = 1 := rfl lemma crAnTimeOrderSign_pair_ordered {φ ψ : 𝓕.CrAnFieldOp} (h : crAnTimeOrderRel φ ψ) : crAnTimeOrderSign [φ, ψ] = 1 := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean index 9c50bb511..7c1f1f647 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Basic.lean @@ -48,8 +48,7 @@ lemma contrBasis_toFin1dℝ {d : ℕ} (i : Fin 1 ⊕ Fin d) : (contrBasis d i).toFin1dℝ = Pi.single i 1 := by simp [ContrMod.toFin1dℝ, contrBasis] lemma contrBasis_repr_apply {d : ℕ} (p : Contr d) (i : Fin 1 ⊕ Fin d) : - (contrBasis d).repr p i = p.val i := by - rfl + (contrBasis d).repr p i = p.val i := rfl /-- The standard basis of contravariant Lorentz vectors indexed by `Fin (1 + d)`. -/ def contrBasisFin (d : ℕ := 3) : Basis (Fin (1 + d)) ℝ (ContrMod d) := @@ -97,8 +96,7 @@ lemma coBasis_ρ_apply {d : ℕ} (M : LorentzGroup d) (i j : Fin 1 ⊕ Fin d) : simp [LorentzGroup.transpose, ← LorentzGroup.coe_inv] lemma coBasis_repr_apply {d : ℕ} (p : Co d) (i : Fin 1 ⊕ Fin d) : - (coBasis d).repr p i = p.val i := by - rfl + (coBasis d).repr p i = p.val i := rfl @[simp] lemma coBasis_toFin1dℝ {d : ℕ} (i : Fin 1 ⊕ Fin d) : From 33d5175e7607f4a230db0e516ee15a44deebe253 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:06:04 -0700 Subject: [PATCH 426/498] refactor: golf more definitional rfl proofs Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/WaveEquation/Basic.lean | 3 +-- Physlib/Electromagnetism/Kinematics/ScalarPotential.lean | 3 +-- Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean | 3 +-- .../Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean | 3 +-- QuantumInfo/States/Mixed/MState.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/WaveEquation/Basic.lean b/Physlib/ClassicalMechanics/WaveEquation/Basic.lean index 0ad1fb828..38a2663ab 100644 --- a/Physlib/ClassicalMechanics/WaveEquation/Basic.lean +++ b/Physlib/ClassicalMechanics/WaveEquation/Basic.lean @@ -78,8 +78,7 @@ noncomputable def planeWave (f₀ : ℝ → EuclideanSpace ℝ (Fin d)) fun t x => f₀ (⟪x, s.unit⟫_ℝ - c * t) lemma planeWave_eq {d f₀ c x} {s : Direction d} : - planeWave f₀ c s t x = f₀ (⟪x, s.unit⟫_ℝ - c * t) := - rfl + planeWave f₀ c s t x = f₀ (⟪x, s.unit⟫_ℝ - c * t) := rfl /-! diff --git a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean index 5dc8875ea..0c0fe07ff 100644 --- a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean @@ -85,8 +85,7 @@ lemma ofStaticScalarPotential_scalarPotential {d} (c : SpeedOfLight) @[simp] lemma ofVectorPotential_scalarPotential {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) : - (ofVectorPotential c A).scalarPotential = 0 := by - rfl + (ofVectorPotential c A).scalarPotential = 0 := rfl @[simp] lemma ofStaticVectorPotential_scalarPotential {d} (c : SpeedOfLight) diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean index 0b871969f..63981c10a 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean @@ -266,8 +266,7 @@ lemma ofList_take_eraseIdx (n : ℕ) (φs : List 𝓕) : rw [take_eraseIdx_same] lemma ofList_take_zero (φs : List 𝓕) : - ofList q (List.take 0 φs) = 1 := by - rfl + ofList q (List.take 0 φs) = 1 := rfl lemma ofList_take_succ_cons (n : ℕ) (φ1 : 𝓕) (φs : List 𝓕) : ofList q ((φ1 :: φs).take (n + 1)) = q φ1 * ofList q (φs.take n) := by diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index c9602e322..57b6cac79 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -147,8 +147,7 @@ def contrContrContractField : (Contr d).V ⊗[ℝ] (Contr d).V →ₗ[ℝ] ℝ : local notation "⟪" ψ "," φ "⟫ₘ" => contrContrContractField (ψ ⊗ₜ φ) lemma contrContrContract_hom_tmul (φ : Contr d) (ψ : Contr d) : - ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ:= by - rfl + ⟪φ, ψ⟫ₘ = φ.toFin1dℝ ⬝ᵥ η *ᵥ ψ.toFin1dℝ := rfl /-- The linear map from Co d ⊗ Co d to ℝ induced by the homomorphism `Co.toContr` and the contraction `coContrContract`. -/ diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index 4b6923ccd..ff7181a5d 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -548,8 +548,7 @@ instance instInhabited [Nonempty d] : Inhabited (MState d) where lemma default_eq [Nonempty d] : (default : MState d) = uniform := rfl @[simp] -theorem M_default [Unique d] : (default : MState d).M = 1 := by - rfl +theorem M_default [Unique d] : (default : MState d).M = 1 := rfl section ptrace From efa4cd97c513061c6671afdf2231361650827cf6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:08:14 -0700 Subject: [PATCH 427/498] refactor: golf Electromagnetism rfl proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Dynamics/CurrentDensity.lean | 6 ++---- Physlib/Electromagnetism/Vacuum/HarmonicWave.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean index 54306087a..bd18aba23 100644 --- a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean @@ -90,8 +90,7 @@ lemma chargeDensity_eq_timeSlice {d : ℕ} {c : SpeedOfLight} {J : LorentzCurren @[simp] lemma chargeDensity_zero {d : ℕ} {c : SpeedOfLight}: - chargeDensity c (0 : LorentzCurrentDensity d) = 0 := by - rfl + chargeDensity c (0 : LorentzCurrentDensity d) = 0 := rfl /-! @@ -144,8 +143,7 @@ lemma currentDensity_eq_timeSlice {d : ℕ} {J : LorentzCurrentDensity d} : @[simp] lemma currentDensity_zero {d : ℕ} {c : SpeedOfLight}: - currentDensity c (0 : LorentzCurrentDensity d) = 0 := by - rfl + currentDensity c (0 : LorentzCurrentDensity d) = 0 := rfl /-! ### C.2. Differentiability of the current density diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index ef8a273f3..6f91e1b41 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -91,8 +91,7 @@ lemma harmonicWaveX_inl_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → @[simp] lemma harmonicWaveX_inr_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) (x : SpaceTime d.succ) : - harmonicWaveX 𝓕 k E₀ φ x (Sum.inr 0) = 0 := by - rfl + harmonicWaveX 𝓕 k E₀ φ x (Sum.inr 0) = 0 := rfl /-! @@ -142,8 +141,7 @@ The scalar potential of the harmonic wave is zero. @[simp] lemma harmonicWaveX_scalarPotential_eq_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) : - (harmonicWaveX 𝓕 k E₀ φ).scalarPotential 𝓕.c = 0 := by - rfl + (harmonicWaveX 𝓕 k E₀ φ).scalarPotential 𝓕.c = 0 := rfl /-! @@ -160,8 +158,7 @@ lemma harmonicWaveX_scalarPotential_eq_zero {d} (𝓕 : FreeSpace) (k : ℝ) @[simp] lemma harmonicWaveX_vectorPotential_zero_eq_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) (t : Time) (x : Space d.succ) : - (harmonicWaveX 𝓕 k E₀ φ).vectorPotential 𝓕.c t x 0 = 0 := by - rfl + (harmonicWaveX 𝓕 k E₀ φ).vectorPotential 𝓕.c t x 0 = 0 := rfl lemma harmonicWaveX_vectorPotential_succ {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) (t : Time) (x : Space d.succ) (i : Fin d) : From c62018755d4527e9687ddf326fb45dc4d06e6c80 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:10:44 -0700 Subject: [PATCH 428/498] refactor: golf Electromagnetism kinematics rfl proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Distributional/Basic.lean | 3 +-- Physlib/Electromagnetism/Kinematics/EMPotential.lean | 3 +-- Physlib/Electromagnetism/Kinematics/FieldStrength.lean | 6 ++---- Physlib/Electromagnetism/Kinematics/VectorPotential.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Basic.lean b/Physlib/Electromagnetism/Distributional/Basic.lean index 09865a083..a6b81c39b 100644 --- a/Physlib/Electromagnetism/Distributional/Basic.lean +++ b/Physlib/Electromagnetism/Distributional/Basic.lean @@ -196,8 +196,7 @@ lemma toTensor_distTensorDeriv_basis_repr_apply {d} (A : DistElectromagneticPote Lorentz.CoVector.indexEquiv.symm).tensorProduct (Lorentz.Vector.basis.reindex Lorentz.Vector.indexEquiv.symm)) = ((Lorentz.CoVector.basis (d := d)).tensorProduct (Lorentz.Vector.basis (d := d))).reindex - (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by - rfl + (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := rfl rfl end DistElectromagneticPotential diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index 28bc87640..1875182ac 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -626,8 +626,7 @@ lemma toTensor_deriv_basis_repr_apply {d} (A : ElectromagneticPotential d) Lorentz.CoVector.indexEquiv.symm).tensorProduct (Lorentz.Vector.basis.reindex Lorentz.Vector.indexEquiv.symm)) = ((Lorentz.CoVector.basis (d := d)).tensorProduct (Lorentz.Vector.basis (d := d))).reindex - (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by - rfl + (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := rfl rfl end ElectromagneticPotential diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index a2a21d0d0..ec5c4d78a 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -125,8 +125,7 @@ lemma toFieldStrength_eq_sub_tensorDeriv {d} {A : ElectromagneticPotential d} toFieldStrength A x = Tensorial.toTensor.symm (permT id IsReindexing.auto {η d | μ μ' ⊗ tensorDeriv A x | μ' ν}ᵀ) - Tensorial.toTensor.symm (permT ![1, 0] IsReindexing.auto - {η d | μ μ' ⊗ tensorDeriv A x | μ' ν}ᵀ) := by - rfl + {η d | μ μ' ⊗ tensorDeriv A x | μ' ν}ᵀ) := rfl lemma toTensor_toFieldStrength {d} (A : ElectromagneticPotential d) (x : SpaceTime d) : Tensorial.toTensor (toFieldStrength A x) = @@ -428,8 +427,7 @@ lemma fieldStrengthMatrix_eq_tensor_basis_repr {d} (A : ElectromagneticPotential (x : SpaceTime d) (μ ν : (Fin 1 ⊕ Fin d)) : A.fieldStrengthMatrix x (μ, ν) = (Tensor.basis _).repr (Tensorial.toTensor (toFieldStrength A x)) - (fun | 0 => μ | 1 => ν) := by - rfl + (fun | 0 => μ | 1 => ν) := rfl lemma toFieldStrength_eq_fieldStrengthMatrix {d} (A : ElectromagneticPotential d) : toFieldStrength A = fun x => ∑ μ, ∑ ν, diff --git a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean index bad8bee77..a909c266a 100644 --- a/Physlib/Electromagnetism/Kinematics/VectorPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/VectorPotential.lean @@ -73,8 +73,7 @@ noncomputable def vectorPotential {d} (c : SpeedOfLight := 1) (A : Electromagnet @[simp] lemma ofScalarPotential_vectorPotential {d} (c : SpeedOfLight) - (φ : Time → Space d → ℝ) : (ofScalarPotential c φ).vectorPotential c = 0 := by - rfl + (φ : Time → Space d → ℝ) : (ofScalarPotential c φ).vectorPotential c = 0 := rfl @[simp] lemma ofStaticScalarPotential_vectorPotential {d} (c : SpeedOfLight) From af1346d07196d6dc0d347467098f99a9cb54681f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:12:38 -0700 Subject: [PATCH 429/498] refactor: golf Relativity tensor rfl proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Vector/Pre/Basic.lean | 12 ++++-------- Physlib/Relativity/Tensors/LeviCivita/Basic.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean index 20376fe2d..41bcc5513 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Vector/Pre/Basic.lean @@ -51,12 +51,10 @@ def complexContrBasisFin4 : Basis (Fin 4) ℂ ContrℂModule := Basis.reindex complexContrBasis finSumFinEquiv lemma complexContrBasisFin4_eq_reindex : - complexContrBasisFin4 = complexContrBasis.reindex finSumFinEquiv := - rfl + complexContrBasisFin4 = complexContrBasis.reindex finSumFinEquiv := rfl lemma complexContrBasis_reindex_apply_eq_fin4 (j : Fin 4) : - (complexContrBasis.reindex finSumFinEquiv) j = complexContrBasisFin4 j := - rfl + (complexContrBasis.reindex finSumFinEquiv) j = complexContrBasisFin4 j := rfl @[simp] lemma complexContrBasisFin4_apply_zero : @@ -111,12 +109,10 @@ def complexCoBasisFin4 : Basis (Fin 4) ℂ CoℂModule := Basis.reindex complexCoBasis finSumFinEquiv lemma complexCoBasisFin4_eq_reindex : - complexCoBasisFin4 = complexCoBasis.reindex finSumFinEquiv := - rfl + complexCoBasisFin4 = complexCoBasis.reindex finSumFinEquiv := rfl lemma complexCoBasis_reindex_apply_eq_fin4 (j : Fin 4) : - (complexCoBasis.reindex finSumFinEquiv) j = complexCoBasisFin4 j := - rfl + (complexCoBasis.reindex finSumFinEquiv) j = complexCoBasisFin4 j := rfl @[simp] lemma complexCoBasisFin4_apply_zero : diff --git a/Physlib/Relativity/Tensors/LeviCivita/Basic.lean b/Physlib/Relativity/Tensors/LeviCivita/Basic.lean index 51876bc4a..a02b1b222 100644 --- a/Physlib/Relativity/Tensors/LeviCivita/Basic.lean +++ b/Physlib/Relativity/Tensors/LeviCivita/Basic.lean @@ -50,8 +50,7 @@ scoped[realLorentzTensor] notation "ε4" => leviCivita lemma leviCivita_eq_ofInt : ε4 = TensorInt.toTensor (S := realLorentzTensor 3) (c := ![Color.up, Color.up, Color.up, Color.up]) fun f => - generalizedKroneckerDelta (fun i => finSumFinEquiv (f i)) (id : Fin 4 → Fin 4) := - rfl + generalizedKroneckerDelta (fun i => finSumFinEquiv (f i)) (id : Fin 4 → Fin 4) := rfl /-- The components of the Levi-Civita tensor in the standard basis are the generalized Kronecker delta of the multi-index against the identity. -/ From 241b411bccf735a9b5a03cd01edb958b2fea3db1 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:14:16 -0700 Subject: [PATCH 430/498] refactor: golf QuantumMechanics rfl proofs Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/StateObservables/Variance.lean | 9 +++------ .../SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean | 3 +-- .../OneDimension/GeneralPotential/Basic.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean index 48d0dfc24..4916268b4 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/Variance.lean @@ -52,14 +52,12 @@ def variance (T : H →ₗ.[ℂ] H) (ψ : T.domain) : ℝ := /-- The variance is the squared norm of the centered vector. -/ lemma variance_eq_centered_norm_sq (T : H →ₗ.[ℂ] H) (ψ : T.domain) : - variance T ψ = ‖centered T ψ‖ ^ 2 := - rfl + variance T ψ = ‖centered T ψ‖ ^ 2 := rfl /-- `variance` with `centered` unfolded to `Tψ - ⟨T⟩_ψ • ψ`. -/ lemma variance_eq_norm_sub_sq (T : H →ₗ.[ℂ] H) (ψ : T.domain) : variance T ψ = - ‖T ψ - (expectedValue T ψ : ℂ) • (ψ : H)‖ ^ 2 := - rfl + ‖T ψ - (expectedValue T ψ : ℂ) • (ψ : H)‖ ^ 2 := rfl /-- For symmetric `T` and `‖ψ‖ = 1`, variance equals `‖Tψ‖ ^ 2 - ⟨T⟩_ψ ^ 2`. -/ lemma variance_eq_norm_sq_sub_expectedValue_sq (T : H →ₗ.[ℂ] H) @@ -120,8 +118,7 @@ def standardDeviation (T : H →ₗ.[ℂ] H) (ψ : T.domain) : ℝ := /-- The standard deviation, unfolded to the square root of the variance. -/ lemma standardDeviation_eq_sqrt_variance (T : H →ₗ.[ℂ] H) (ψ : T.domain) : - standardDeviation T ψ = Real.sqrt (variance T ψ) := - rfl + standardDeviation T ψ = Real.sqrt (variance T ψ) := rfl /-- Standard deviation is nonnegative. -/ lemma standardDeviation_nonneg (T : H →ₗ.[ℂ] H) (ψ : T.domain) : diff --git a/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean b/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean index 475c1c1f6..a037f61ed 100644 --- a/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean +++ b/Physlib/QuantumMechanics/DDimensions/SpaceDHilbertSpace/PolyBddSchwartzSubmodule.lean @@ -118,8 +118,7 @@ instance {d : ℕ} {a : ℕ∞} : CoeFun (polyBddSchwartzMap d a) (fun _ ↦ Spa @[simp] lemma toFun_eq_coe {d : ℕ} {a : ℕ∞} (f : polyBddSchwartzMap d a) (x : Space d) : - f.val.toFun x = f.val x := - rfl + f.val.toFun x = f.val x := rfl lemma polyBddSchwartzEquiv_symm_apply_coe {d : ℕ} {a : ℕ∞} {ψ : schwartzSubmodule d} (hψ : ↑ψ ∈ polyBddSchwartzSubmodule d a) : diff --git a/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean b/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean index b690bb167..231b6ccff 100644 --- a/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean +++ b/Physlib/QuantumMechanics/OneDimension/GeneralPotential/Basic.lean @@ -100,8 +100,7 @@ noncomputable def schrodingerOperator (ψ : ℝ → ℂ) : ℝ → ℂ := fun x ↦ 1 / (2 * Q.m) * (momentumOperator (momentumOperator ψ) x) + (Q.V x) * ψ x private lemma eval_add (f g : ℝ → ℂ) : - (f + g) x = f x + g x := - rfl + (f + g) x = f x + g x := rfl lemma schrodingerOperator_linear (a1 a2 : ℂ) (ψ1 ψ2 : ℝ → ℂ) (hψ1_x: Differentiable ℝ ψ1) (hψ2_x: Differentiable ℝ ψ2) From d529a158acf0435100c83aafc2826b8cc92de123 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:15:45 -0700 Subject: [PATCH 431/498] refactor: golf mathematics rfl proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Distribution/Basic.lean | 18 +++++++----------- Physlib/Mathematics/SO3/Basic.lean | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Physlib/Mathematics/Distribution/Basic.lean b/Physlib/Mathematics/Distribution/Basic.lean index 2f6b8201c..15ab17811 100644 --- a/Physlib/Mathematics/Distribution/Basic.lean +++ b/Physlib/Mathematics/Distribution/Basic.lean @@ -145,11 +145,10 @@ def ofLinear (s : Finset (ℕ × ℕ)) (u : 𝓢(E, 𝕜) →ₗ[𝕜] F) (f := fun kn : ℕ × ℕ ↦ (⟨SchwartzMap.seminorm 𝕜 kn.1 kn.2 η, apply_nonneg _ _⟩ : ℝ≥0)) @[simp] lemma ofLinear_apply (s : Finset (ℕ × ℕ)) (u : 𝓢(E, 𝕜) →ₗ[𝕜] F) - (hu : ∃ C : ℝ, 0 ≤ C ∧ ∀ η : 𝓢(E, 𝕜), ∃ (k : ℕ) (n : ℕ) (x : E), (k, n) ∈ s ∧ - ‖u η‖ ≤ C * (‖x‖ ^ k * ‖iteratedFDeriv ℝ n η x‖)) - (η : 𝓢(E, 𝕜)) : - ofLinear 𝕜 s u hu η = u η := - rfl + (hu : ∃ C : ℝ, 0 ≤ C ∧ ∀ η : 𝓢(E, 𝕜), ∃ (k : ℕ) (n : ℕ) (x : E), (k, n) ∈ s ∧ + ‖u η‖ ≤ C * (‖x‖ ^ k * ‖iteratedFDeriv ℝ n η x‖)) + (η : 𝓢(E, 𝕜)) : + ofLinear 𝕜 s u hu η = u η := rfl end NormedSpace @@ -272,8 +271,7 @@ def fourierTransform : (E →d[ℂ] F) →ₗ[ℂ] (E →d[ℂ] F) where map_smul' c u := by simp @[simp] lemma fourierTransform_apply (u : E →d[ℂ] F) (η : 𝓢(E, ℂ)) : - u.fourierTransform E F η = u (fourierTransformCLM ℂ η) := - rfl + u.fourierTransform E F η = u (fourierTransformCLM ℂ η) := rfl end Complex @@ -402,8 +400,7 @@ def diracDelta (a : E) : E →d[𝕜] 𝕜 := (BoundedContinuousFunction.evalCLM 𝕜 a).comp (toBoundedContinuousFunctionCLM 𝕜 E 𝕜) @[simp] lemma diracDelta_apply (a : E) (η : 𝓢(E, 𝕜)) : - diracDelta 𝕜 a η = η a := - rfl + diracDelta 𝕜 a η = η a := rfl /-- Dirac delta in a given direction `v : F`. `diracDelta' 𝕜 a v` takes in a test function `η : 𝓢(E, 𝕜)` and outputs `η a • v`. Intuitively this is an infinitely intense vector field @@ -412,8 +409,7 @@ def diracDelta' (a : E) (v : F) : E →d[𝕜] F := ContinuousLinearMap.smulRight (diracDelta 𝕜 a) v @[simp] lemma diracDelta'_apply (a : E) (v : F) (η : 𝓢(E, 𝕜)) : - diracDelta' 𝕜 a v η = η a • v := - rfl + diracDelta' 𝕜 a v η = η a • v := rfl end DiracDelta /-! diff --git a/Physlib/Mathematics/SO3/Basic.lean b/Physlib/Mathematics/SO3/Basic.lean index 69b497e9c..4f74e3d7b 100644 --- a/Physlib/Mathematics/SO3/Basic.lean +++ b/Physlib/Mathematics/SO3/Basic.lean @@ -57,8 +57,7 @@ def toGL : SO(3) →* GL (Fin 3) ℝ where map_mul' _ _ := (GeneralLinearGroup.ext_iff _ _).mpr fun _ => congrFun rfl lemma subtype_val_eq_toGL : (Subtype.val : SO3 → Matrix (Fin 3) (Fin 3) ℝ) = - Units.val ∘ toGL.toFun := - rfl + Units.val ∘ toGL.toFun := rfl /-- The inclusion of `SO(3)` into `GL(3,ℝ)` is an injection. -/ lemma toGL_injective : Function.Injective toGL := by From 590eab8c8ffbd190cebb19dc397c463328930279 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:17:31 -0700 Subject: [PATCH 432/498] refactor: golf operator rfl proofs Co-authored-by: Claude Opus 4.8 --- .../QuantumMechanics/DDimensions/Operators/Covariance.lean | 3 +-- .../QuantumMechanics/DDimensions/Operators/Momentum.lean | 3 +-- .../Operators/StateObservables/ExpectedValue.lean | 6 ++---- Physlib/Relativity/Tensors/RealTensor/ToComplex.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Covariance.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Covariance.lean index 95cc28043..39ddee379 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Covariance.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Covariance.lean @@ -62,8 +62,7 @@ def covariance : ℝ := /-- Covariance, unfolded to the real part of the centered inner product. -/ lemma covariance_eq_re_inner_centered : covariance A B ψ hψB = - (⟪centered A ψ, centered B ⟨ψ, hψB⟩⟫_ℂ).re := - rfl + (⟪centered A ψ, centered B ⟨ψ, hψB⟩⟫_ℂ).re := rfl /-- Swapping the two observables does not change the covariance. -/ lemma covariance_comm : diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean index e1b95f4c4..04a405ccd 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Momentum.lean @@ -69,8 +69,7 @@ notation "𝐩[" d' "]" => momentumCLM (d := d') lemma momentumCLM_apply_fun (ψ : 𝓢(Space d, ℂ)) : 𝐩 i ψ = (-I * ℏ) • ∂[i] ψ := rfl @[simp] -lemma momentumCLM_apply (ψ : 𝓢(Space d, ℂ)) (x : Space d) : 𝐩 i ψ x = -I * ℏ * ∂[i] ψ x := - rfl +lemma momentumCLM_apply (ψ : 𝓢(Space d, ℂ)) (x : Space d) : 𝐩 i ψ x = -I * ℏ * ∂[i] ψ x := rfl /-! diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean index e7e1346b0..250c088fa 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean @@ -51,8 +51,7 @@ def expectedValue (T : H →ₗ.[ℂ] H) (ψ : T.domain) : ℝ := /-- The expectation value, unfolded as a real part. -/ lemma expectedValue_eq_re_inner (T : H →ₗ.[ℂ] H) (ψ : T.domain) : - expectedValue T ψ = (⟪(ψ : H), T ψ⟫_ℂ).re := - rfl + expectedValue T ψ = (⟪(ψ : H), T ψ⟫_ℂ).re := rfl /-- If `T` is symmetric, `⟪ψ, Tψ⟫_ℂ` is the expectation value, coerced to `ℂ`. -/ lemma expectedValue_eq_inner (T : H →ₗ.[ℂ] H) (hT : T.IsSymmetric) (ψ : T.domain) : @@ -73,8 +72,7 @@ def centered (T : H →ₗ.[ℂ] H) (ψ : T.domain) : H := /-- The centered vector, unfolded to its raw expression. -/ lemma centered_eq (T : H →ₗ.[ℂ] H) (ψ : T.domain) : - centered T ψ = T ψ - (expectedValue T ψ : ℂ) • (ψ : H) := - rfl + centered T ψ = T ψ - (expectedValue T ψ : ℂ) • (ψ : H) := rfl /-- A centered vector vanishes exactly when `Tψ = ⟨T⟩_ψ ψ`. -/ lemma centered_eq_zero_iff (T : H →ₗ.[ℂ] H) (ψ : T.domain) : diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index 85e259c6e..ee5fab2fa 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -129,8 +129,7 @@ lemma ComponentIdx.complexify_apply {n} {c : Fin n → realLorentzTensor.Color} @[simp] lemma ComponentIdx.complexify_toFun_apply {n} {c : Fin n → realLorentzTensor.Color} (f : ComponentIdx (S := realLorentzTensor) c) (j : Fin n) : - (ComponentIdx.complexify.toFun f) j = (ComponentIdx.complexify f) j := - rfl + (ComponentIdx.complexify.toFun f) j = (ComponentIdx.complexify f) j := rfl /-! From 715f5def14081a17ec33f31cacfb4a46eea5ed42 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:20:00 -0700 Subject: [PATCH 433/498] refactor: golf more inline rfl proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/Wirtinger/Basic.lean | 6 ++---- Physlib/Mathematics/Trigonometry/Tanh.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 3 +-- Physlib/SpaceAndTime/Space/Basic.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean b/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean index 70ae62412..d6dbfaaef 100644 --- a/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean +++ b/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean @@ -663,13 +663,11 @@ private lemma fderiv_weightedDirDeriv (hf' : DifferentiableAt ℝ (fderiv ℝ f) /-- A directional derivative is a `weightedDirDeriv`: anti-holomorphic with `c = i`. -/ private lemma dWirtingerAntiDir_eq_weightedDirDeriv (w : V) : - (fun p => dWirtingerAntiDir f w p) = weightedDirDeriv f Complex.I w (Complex.I • w) := - rfl + (fun p => dWirtingerAntiDir f w p) = weightedDirDeriv f Complex.I w (Complex.I • w) := rfl /-- A directional derivative is a `weightedDirDeriv`: holomorphic with `c = -i`. -/ private lemma dWirtingerDir_eq_weightedDirDeriv (v : V) : - (fun p => dWirtingerDir f v p) = weightedDirDeriv f (-Complex.I) v (Complex.I • v) := - rfl + (fun p => dWirtingerDir f v p) = weightedDirDeriv f (-Complex.I) v (Complex.I • v) := rfl /-- Differentiating the anti-holomorphic directional derivative lands on the second real Fréchet derivative in the two slots. -/ diff --git a/Physlib/Mathematics/Trigonometry/Tanh.lean b/Physlib/Mathematics/Trigonometry/Tanh.lean index 9bf515d6a..733cc18cb 100644 --- a/Physlib/Mathematics/Trigonometry/Tanh.lean +++ b/Physlib/Mathematics/Trigonometry/Tanh.lean @@ -206,8 +206,7 @@ lemma iteratedDeriv_tanh_const_mul (n : ℕ) (κ : ℝ) : ∀ x : ℝ, lemma tanh_const_mul_hasTemperateGrowth (κ : ℝ) : Function.HasTemperateGrowth (fun x => Real.tanh (κ * x)) := by constructor - · have h : (fun x => Real.tanh (κ * x)) = (Real.tanh ∘ (fun x => κ * x)) := - rfl + · have h : (fun x => Real.tanh (κ * x)) = (Real.tanh ∘ (fun x => κ * x)) := rfl have h' : ContDiff ℝ ∞ (fun x => κ * x) := by have h'': (fun x : ℝ => κ * x) = fun x => κ • x := rfl rw [contDiff_infty, h''] diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 89a2b62aa..86b22e429 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -232,8 +232,7 @@ lemma oddShiftShiftSnd_eq_oddSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddSnd simp only [succ_eq_add_one, oddShiftShiftSnd, Fin.val_cast, Fin.val_natAdd, oddSnd, add_left_inj] exact Nat.add_comm 1 n -lemma oddShiftShiftSnd_eq_oddShiftSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddShiftSnd j := - rfl +lemma oddShiftShiftSnd_eq_oddShiftSnd (j : Fin n.succ) : oddShiftShiftSnd j = oddShiftSnd j := rfl lemma oddSnd_eq_oddShiftSnd (j : Fin n) : oddSnd j = oddShiftSnd j := by rw [Fin.ext_iff] diff --git a/Physlib/SpaceAndTime/Space/Basic.lean b/Physlib/SpaceAndTime/Space/Basic.lean index 0a600dbdf..aad41c358 100644 --- a/Physlib/SpaceAndTime/Space/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Basic.lean @@ -276,7 +276,6 @@ instance (d : ℕ) : IsManifold (𝓡 d) ⊤ (Space d) := lemma chartAt_eq (d : ℕ) (p : Space d) : chartAt (EuclideanSpace ℝ (Fin d)) p = - (homEuclideanSpaceSpace d).symm.toOpenPartialHomeomorph := - rfl + (homEuclideanSpaceSpace d).symm.toOpenPartialHomeomorph := rfl end Space From 8d3b327c1f3a8bef68a03f69611a29b917ad01c3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:21:36 -0700 Subject: [PATCH 434/498] refactor: golf Prob coercion proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ClassicalInfo/Prob.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ClassicalInfo/Prob.lean b/QuantumInfo/ClassicalInfo/Prob.lean index cf8adac49..bc49f26e5 100644 --- a/QuantumInfo/ClassicalInfo/Prob.lean +++ b/QuantumInfo/ClassicalInfo/Prob.lean @@ -53,24 +53,19 @@ instance instMul : Mul Prob := ⟨mul_nonneg x.2.1 y.2.1, mul_le_one₀ x.2.2 y.2.1 y.2.2⟩⟩⟩ @[simp, norm_cast] -theorem coe_zero : (0 : Prob).val = 0 := - rfl +theorem coe_zero : (0 : Prob).val = 0 := rfl @[simp, norm_cast] -theorem coe_one : (1 : Prob).val = 1 := - rfl +theorem coe_one : (1 : Prob).val = 1 := rfl @[simp, norm_cast] -theorem coe_mul (x y : Prob) : (x * y).val = x.val * y.val := - rfl +theorem coe_mul (x y : Prob) : (x * y).val = x.val * y.val := rfl @[simp, norm_cast] -theorem coe_inf (x y : Prob) : (x ⊓ y).val = x.val ⊓ y.val := - rfl +theorem coe_inf (x y : Prob) : (x ⊓ y).val = x.val ⊓ y.val := rfl @[simp, norm_cast] -theorem coe_sup (x y : Prob) : (x ⊔ y).val = x.val ⊔ y.val := - rfl +theorem coe_sup (x y : Prob) : (x ⊔ y).val = x.val ⊔ y.val := rfl instance instCommMonoidWithZero : CommMonoidWithZero Prob where mul_assoc := by intros; ext; simp [mul_assoc] From 7e7acae7f314943939459a3f0dac1de6bb5f7c48 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:23:14 -0700 Subject: [PATCH 435/498] refactor: golf Prob mixable proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ClassicalInfo/Prob.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ClassicalInfo/Prob.lean b/QuantumInfo/ClassicalInfo/Prob.lean index bc49f26e5..786718cb2 100644 --- a/QuantumInfo/ClassicalInfo/Prob.lean +++ b/QuantumInfo/ClassicalInfo/Prob.lean @@ -122,8 +122,7 @@ theorem toReal_mul (x y : Prob) : (x * y : Prob) = (x : ℝ) * (y : ℝ) := rfl fun p ↦ ⟨p.val, zero_le_coe⟩ @[simp] -theorem toNNReal_mk : toNNReal { val := x, property := hx} = { val := x, property := hx.1 } := - rfl +theorem toNNReal_mk : toNNReal { val := x, property := hx} = { val := x, property := hx.1 } := rfl instance : Coe Prob ℝ≥0 := ⟨toNNReal⟩ @@ -136,12 +135,10 @@ protected theorem eq_iff_nnreal (n m : Prob) : (n : ℝ≥0) = (m : ℝ≥0) ↔ simp only [toNNReal_mk, Subtype.mk.injEq, NNReal] @[simp, norm_cast] -theorem toNNReal_zero : (0 : Prob) = (0 : ℝ≥0) := - rfl +theorem toNNReal_zero : (0 : Prob) = (0 : ℝ≥0) := rfl @[simp, norm_cast] -theorem toNNReal_one : (1 : Prob) = (1 : ℝ≥0) := - rfl +theorem toNNReal_one : (1 : Prob) = (1 : ℝ≥0) := rfl theorem ofNNReal_toNNReal : ENNReal.ofNNReal (toNNReal p) = ENNReal.ofReal (p : ℝ) := by simp [toNNReal, ENNReal.ofReal_eq_coe_nnreal] @@ -285,8 +282,7 @@ theorem mkT_instUniv [AddCommMonoid T] [Module ℝ T] {t : T} (h : ∃ t', to_U rfl @[simp] -theorem to_U_instUniv [AddCommMonoid T] [Module ℝ T] {t : T} : instUniv.to_U t = t := - rfl +theorem to_U_instUniv [AddCommMonoid T] [Module ℝ T] {t : T} : instUniv.to_U t = t := rfl section pi @@ -315,8 +311,7 @@ instance instPi : Mixable ((i:D) → U i) ((i:D) → T i) where @[simp] theorem val_mkT_instPi (D : Type*) [inst : Mixable U T] {u : D → U} (h : ∃ t, to_U t = u) : - (instPi.mkT h).val = fun d ↦ (inst.mkT (instPi.lem_1 h d)).val := - rfl + (instPi.mkT h).val = fun d ↦ (inst.mkT (instPi.lem_1 h d)).val := rfl @[simp] theorem to_U_instPi (D : Type*) [inst : Mixable U T] {t : D → T} : From 496472aa606c5f6830948033a82da8d77fee88f0 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:25:13 -0700 Subject: [PATCH 436/498] refactor: golf probability definitional proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ClassicalInfo/Distribution.lean | 3 +-- QuantumInfo/ClassicalInfo/Prob.lean | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 9f8220d49..6c0da57d9 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -62,8 +62,7 @@ theorem normalized (d : ProbDistribution α) : Finset.sum Finset.univ (fun i ↦ abbrev prob (d : ProbDistribution α) := (d : α → Prob) @[simp] -theorem fun_eq_val (d : ProbDistribution α) : d.val = d := - rfl +theorem fun_eq_val (d : ProbDistribution α) : d.val = d := rfl @[simp] theorem funlike_apply (d : α → Prob) (h : _) (x : α) : diff --git a/QuantumInfo/ClassicalInfo/Prob.lean b/QuantumInfo/ClassicalInfo/Prob.lean index 786718cb2..b401b43fe 100644 --- a/QuantumInfo/ClassicalInfo/Prob.lean +++ b/QuantumInfo/ClassicalInfo/Prob.lean @@ -278,8 +278,7 @@ instance instUniv [AddCommMonoid T] [Module ℝ T] : Mixable T T where @[simp] theorem mkT_instUniv [AddCommMonoid T] [Module ℝ T] {t : T} (h : ∃ t', to_U t' = t) : - instUniv.mkT h = ⟨t, rfl⟩ := - rfl + instUniv.mkT h = ⟨t, rfl⟩ := rfl @[simp] theorem to_U_instUniv [AddCommMonoid T] [Module ℝ T] {t : T} : instUniv.to_U t = t := rfl @@ -315,8 +314,7 @@ theorem val_mkT_instPi (D : Type*) [inst : Mixable U T] {u : D → U} (h : ∃ t @[simp] theorem to_U_instPi (D : Type*) [inst : Mixable U T] {t : D → T} : - (instPi).to_U t = fun d ↦ inst.to_U (t d) := - rfl + (instPi).to_U t = fun d ↦ inst.to_U (t d) := rfl end pi @@ -364,13 +362,11 @@ instance instMixable : Mixable ℝ Prob where · nlinarith @[simp] -theorem to_U_mixable [AddCommMonoid T] [SMul ℝ T] (t : Prob) : instMixable.to_U t = t.val := - rfl +theorem to_U_mixable [AddCommMonoid T] [SMul ℝ T] (t : Prob) : instMixable.to_U t = t.val := rfl @[simp] theorem mkT_mixable (u : ℝ) (h : ∃ t : Prob, Mixable.to_U t = u) : Mixable.mkT h = - ⟨⟨u,Exists.casesOn h fun t ht ↦ ht ▸ t.2⟩, rfl⟩ := - rfl + ⟨⟨u,Exists.casesOn h fun t ht ↦ ht ▸ t.2⟩, rfl⟩ := rfl /-- `Prob.mix` is an alias of `Mixable.mix` so it can be accessed from a probability with dot notation, e.g. `p.mix x y`. -/ From e433dfb05ffa3829f30db69a5da09342fdc9c276 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:27:28 -0700 Subject: [PATCH 437/498] refactor: golf QuantumInfo definition proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ClassicalInfo/Distribution.lean | 6 ++---- QuantumInfo/ForMathlib/Filter.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ClassicalInfo/Distribution.lean b/QuantumInfo/ClassicalInfo/Distribution.lean index 6c0da57d9..ac1ab7088 100644 --- a/QuantumInfo/ClassicalInfo/Distribution.lean +++ b/QuantumInfo/ClassicalInfo/Distribution.lean @@ -66,8 +66,7 @@ theorem fun_eq_val (d : ProbDistribution α) : d.val = d := rfl @[simp] theorem funlike_apply (d : α → Prob) (h : _) (x : α) : - DFunLike.coe (self := instFunLikeProb) ⟨d, h⟩ x = d x := - rfl + DFunLike.coe (self := instFunLikeProb) ⟨d, h⟩ x = d x := rfl @[ext] theorem ext {p q : ProbDistribution α} (h : ∀ x, p x = q x) : p = q := @@ -132,8 +131,7 @@ def prod (d1 : ProbDistribution α) (d2 : ProbDistribution β) : ProbDistributio simp [← Finset.mul_sum, Fintype.sum_prod_type]⟩ @[simp] -theorem prod_def (x : α) (y : β) : prod d1 d2 ⟨x, y⟩ = (d1 x) * (d2 y) := - rfl +theorem prod_def (x : α) (y : β) : prod d1 d2 ⟨x, y⟩ = (d1 x) * (d2 y) := rfl /-- Given a distribution on α, extend it to a distribution on `Sum α β` by giving it no support on `β`. -/ diff --git a/QuantumInfo/ForMathlib/Filter.lean b/QuantumInfo/ForMathlib/Filter.lean index 503835a25..3691d1c66 100644 --- a/QuantumInfo/ForMathlib/Filter.lean +++ b/QuantumInfo/ForMathlib/Filter.lean @@ -53,7 +53,6 @@ theorem ENNReal.tendsto_toReal_iff_of_eventually_ne_top rw [EventuallyEq] peel hf with h simp [h] - have he₂ : (fun n ↦ (f n).toReal) = (fun n ↦ ((f n).toNNReal : ℝ≥0∞).toReal) := - rfl + have he₂ : (fun n ↦ (f n).toReal) = (fun n ↦ ((f n).toNNReal : ℝ≥0∞).toReal) := rfl rw [Filter.tendsto_congr' he₁, he₂] exact tendsto_toReal_iff (by finiteness) hx diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index fe921ec68..51f60edf9 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -52,11 +52,9 @@ theorem rpow_conj_unitary (A : HermitianMat d 𝕜) (U : Matrix.unitaryGroup d (HermitianMat.conj U.val A) ^ r = HermitianMat.conj U.val (A ^ r) := by exact A.cfc_conj_unitary (· ^ r) U -theorem pow_eq_rpow : A ^ r = A.rpow r := - rfl +theorem pow_eq_rpow : A ^ r = A.rpow r := rfl -theorem rpow_eq_cfc : A ^ r = A.cfc (· ^ r) := - rfl +theorem rpow_eq_cfc : A ^ r = A.cfc (· ^ r) := rfl theorem diagonal_pow (f : d → ℝ) : (diagonal 𝕜 f) ^ r = diagonal 𝕜 (fun i ↦ (f i) ^ r) := by From 5442af800cf3478bbac240506c2e701c9fef361e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:30:21 -0700 Subject: [PATCH 438/498] refactor: golf state rfl proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/States/Ensemble.lean | 3 +-- QuantumInfo/States/Pure/Braket.lean | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/States/Ensemble.lean b/QuantumInfo/States/Ensemble.lean index d1e2df14b..6875b8bdf 100644 --- a/QuantumInfo/States/Ensemble.lean +++ b/QuantumInfo/States/Ensemble.lean @@ -42,8 +42,7 @@ namespace Ensemble instance : Coe (PEnsemble d α) (MEnsemble d α) := ⟨toMEnsemble⟩ @[simp] -theorem toMEnsemble_mk : (toMEnsemble ⟨ps, distr⟩ : MEnsemble d α) = ⟨pure ∘ ps, distr⟩ := - rfl +theorem toMEnsemble_mk : (toMEnsemble ⟨ps, distr⟩ : MEnsemble d α) = ⟨pure ∘ ps, distr⟩ := rfl /-- A mixed-state ensemble comes from a pure-state ensemble if and only if all states are pure. -/ theorem coe_PEnsemble_iff_pure_states (me : MEnsemble d α): (∃ pe : PEnsemble d α, ↑pe = me) ↔ (∃ ψ : α → Ket d, me.states = MState.pure ∘ ψ) := by diff --git a/QuantumInfo/States/Pure/Braket.lean b/QuantumInfo/States/Pure/Braket.lean index e8ffe83b2..bd5724515 100644 --- a/QuantumInfo/States/Pure/Braket.lean +++ b/QuantumInfo/States/Pure/Braket.lean @@ -94,11 +94,9 @@ open Braket variable {d : Type*} [Fintype d] -theorem Ket.apply (ψ : Ket d) (i : d) : ψ i = ψ.vec i := - rfl +theorem Ket.apply (ψ : Ket d) (i : d) : ψ i = ψ.vec i := rfl -theorem Bra.apply (ψ : Bra d) (i : d) : ψ i = ψ.vec i := - rfl +theorem Bra.apply (ψ : Bra d) (i : d) : ψ i = ψ.vec i := rfl @[ext] theorem Ket.ext {ξ ψ : Ket d} (h : ∀ x, ξ x = ψ x) : ξ = ψ := @@ -129,11 +127,9 @@ instance instBraOfKet : Coe (Ket d) (Bra d) := ⟨Ket.to_bra⟩ instance instKetOfBra : Coe (Bra d) (Ket d) := ⟨Bra.to_ket⟩ @[simp] -theorem Bra.eq_conj (ψ : Ket d) (x : d) :〈ψ∣ x = conj (∣ψ〉 x) := - rfl +theorem Bra.eq_conj (ψ : Ket d) (x : d) :〈ψ∣ x = conj (∣ψ〉 x) := rfl -theorem Bra.apply' (ψ : Ket d) (i : d) : 〈ψ∣ i = conj (ψ.vec i) := - rfl +theorem Bra.apply' (ψ : Ket d) (i : d) : 〈ψ∣ i = conj (ψ.vec i) := rfl theorem Ket.exists_ne_zero (ψ : Ket d) : ∃ x, ψ x ≠ 0 := by have hzerolt : ∑ x : d, Complex.normSq (ψ x) > ∑ x : d, 0 := by rw [ψ.normalized, Finset.sum_const_zero]; exact zero_lt_one From 255e44caf4d03a7aa7cae58e29744817a8ba1c1c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:33:15 -0700 Subject: [PATCH 439/498] refactor: golf spectral and mixed-state rfl proofs Co-authored-by: Claude Opus 4.8 --- .../DDimensions/Operators/SpectralTheory/Basic.lean | 6 ++---- QuantumInfo/States/Mixed/MState.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean index 273c7ea5d..38d41d1f2 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/SpectralTheory/Basic.lean @@ -656,8 +656,7 @@ def resolventSet (T : H →ₗ.[ℂ] H) : Set ℂ := scoped notation "ρ" => resolventSet lemma resolventSet_eq (T : H →ₗ.[ℂ] H) : - ρ T = {z | (T - z • 1).toFun.ker = ⊥ ∧ (T - z • 1).toFun.range = ⊤ ∧ Continuous (𝑅 T z)} := - rfl + ρ T = {z | (T - z • 1).toFun.ker = ⊥ ∧ (T - z • 1).toFun.range = ⊤ ∧ Continuous (𝑅 T z)} := rfl lemma mem_resolventSet_iff {T : H →ₗ.[ℂ] H} {z : ℂ} : z ∈ ρ T ↔ (T - z • 1).toFun.ker = ⊥ ∧ (T - z • 1).toFun.range = ⊤ ∧ Continuous (𝑅 T z) := @@ -781,8 +780,7 @@ def residualSpectrum (T : H →ₗ.[ℂ] H) : Set ℂ := scoped notation "σʳ" => residualSpectrum lemma residualSpectrum_eq (T : H →ₗ.[ℂ] H) : - σʳ T = {z | (T - z • 1).toFun.ker = ⊥ ∧ (T - z • 1).toFun.range ≠ ⊤ ∧ Continuous (𝑅 T z)} := - rfl + σʳ T = {z | (T - z • 1).toFun.ker = ⊥ ∧ (T - z • 1).toFun.range ≠ ⊤ ∧ Continuous (𝑅 T z)} := rfl lemma mem_residualSpectrum_iff {T : H →ₗ.[ℂ] H} {z : ℂ} : z ∈ σʳ T ↔ (T - z • 1).toFun.ker = ⊥ ∧ (T - z • 1).toFun.range ≠ ⊤ ∧ Continuous (𝑅 T z) := diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index ff7181a5d..c160dc7cb 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -1139,16 +1139,13 @@ def spectrum_SWAP (ρ : MState (d₁ × d₂)) : ∃ e, ρ.SWAP.spectrum.relabel exact h x @[simp] -theorem SWAP_SWAP (ρ : MState (d₁ × d₂)) : ρ.SWAP.SWAP = ρ := - rfl +theorem SWAP_SWAP (ρ : MState (d₁ × d₂)) : ρ.SWAP.SWAP = ρ := rfl @[simp] -theorem traceLeft_SWAP (ρ : MState (d₁ × d₂)) : ρ.SWAP.traceLeft = ρ.traceRight := - rfl +theorem traceLeft_SWAP (ρ : MState (d₁ × d₂)) : ρ.SWAP.traceLeft = ρ.traceRight := rfl @[simp] -theorem traceRight_SWAP (ρ : MState (d₁ × d₂)) : ρ.SWAP.traceRight = ρ.traceLeft := - rfl +theorem traceRight_SWAP (ρ : MState (d₁ × d₂)) : ρ.SWAP.traceRight = ρ.traceLeft := rfl /-- The associator that re-clusters the parts of a quantum system. -/ def assoc (ρ : MState ((d₁ × d₂) × d₃)) : MState (d₁ × d₂ × d₃) := From 93ab278377667ba8ec9211cdb918e3bf8eb60d30 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:36:48 -0700 Subject: [PATCH 440/498] refactor: golf channel wrapper rfl proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/Channels/CPTP.lean | 9 +++------ .../HayataGroup/TraceInequality/BlockDiagonal.lean | 3 +-- QuantumInfo/ResourceTheory/FreeState.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/Channels/CPTP.lean b/QuantumInfo/Channels/CPTP.lean index fa1667d7b..e24ce945f 100644 --- a/QuantumInfo/Channels/CPTP.lean +++ b/QuantumInfo/Channels/CPTP.lean @@ -83,8 +83,7 @@ theorem choi_of_CPTP_of_choi (M : Matrix (dOut × dIn) (dOut × dIn) ℂ) {h₁} (CPTP_of_choi_PSD_Tr (M := M) h₁ h₂).choi = M := MatrixMap.map_choi_inv M -theorem mat_coe_eq_apply_mat [DecidableEq dOut] (ρ : MState dIn) : (Λ ρ).m = Λ.map ρ.m := - rfl +theorem mat_coe_eq_apply_mat [DecidableEq dOut] (ρ : MState dIn) : (Λ ρ).m = Λ.map ρ.m := rfl @[ext] theorem funext [DecidableEq dOut] {Λ₁ Λ₂ : CPTPMap dIn dOut} (h : ∀ ρ, Λ₁ ρ = Λ₂ ρ) : Λ₁ = Λ₂ := @@ -211,8 +210,7 @@ def assoc' : CPTPMap (d₁ × d₂ × d₃) ((d₁ × d₂) × d₃) := ofEquiv (Equiv.prodAssoc d₁ d₂ d₃).symm @[simp] -theorem SWAP_eq_MState_SWAP (ρ : MState (d₁ × d₂)) : SWAP (d₁ := d₁) (d₂ := d₂) ρ = ρ.SWAP := - rfl +theorem SWAP_eq_MState_SWAP (ρ : MState (d₁ × d₂)) : SWAP (d₁ := d₁) (d₂ := d₂) ρ = ρ.SWAP := rfl @[simp] theorem assoc_eq_MState_assoc (ρ : MState ((d₁ × d₂) × d₃)) : assoc (d₁ := d₁) (d₂ := d₂) (d₃ := d₃) ρ = ρ.assoc := @@ -423,8 +421,7 @@ def ofUnitary (U : 𝐔[dIn]) : CPTPMap dIn dIn where /-- The unitary channel U conjugated by U. -/ theorem ofUnitary_eq_conj (U : 𝐔[dIn]) (ρ : MState dIn) : - (ofUnitary U) ρ = ρ.U_conj U := - rfl + (ofUnitary U) ρ = ρ.U_conj U := rfl /-- A channel is unitary iff it is `ofUnitary U`. -/ def IsUnitary (Λ : CPTPMap dIn dIn) : Prop := diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean index ce2f64444..073f0bdf4 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/BlockDiagonal.lean @@ -165,8 +165,7 @@ noncomputable def blockDiagonalHom : (L ℋ × L ℋ) →⋆ₐ[ℝ] L (HSum ℋ omit [Nontrivial ℋ] in @[simp] theorem blockDiagonalHom_apply (p : L ℋ × L ℋ) : - blockDiagonalHom (ℋ := ℋ) p = blockDiagonal (ℋ := ℋ) p.1 p.2 := - rfl + blockDiagonalHom (ℋ := ℋ) p = blockDiagonal (ℋ := ℋ) p.1 p.2 := rfl omit [CompleteSpace ℋ] [Nontrivial ℋ] in @[simp] theorem hsumProj_blockDiagonal_zero (A B : L ℋ) (z : HSum ℋ) : diff --git a/QuantumInfo/ResourceTheory/FreeState.lean b/QuantumInfo/ResourceTheory/FreeState.lean index b40e7f5bb..bc1712a87 100644 --- a/QuantumInfo/ResourceTheory/FreeState.lean +++ b/QuantumInfo/ResourceTheory/FreeState.lean @@ -216,8 +216,7 @@ noncomputable def statePow (ρ : MState (H i)) (n : ℕ) : MState (H (i ^ n)) := scoped notation ρ " ⊗ᵣ^[" n "]" => statePow ρ n @[simp] -theorem statePow_zero (ρ : MState (H i)) : ρ ⊗ᵣ^[0] = default := - rfl +theorem statePow_zero (ρ : MState (H i)) : ρ ⊗ᵣ^[0] = default := rfl @[simp] theorem statePow_one (ρ : MState (H i)) : ρ ⊗ᵣ^[1] ≍ ρ := by From bc4251a8723fb1e78870c2514df7d786adeff3c8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 12:47:47 -0700 Subject: [PATCH 441/498] refactor: golf proof tails and wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean | 3 +-- Physlib/Electromagnetism/Distributional/Basic.lean | 2 -- .../TraceInequality/HilbertSchmidtOperatorSpace.lean | 3 +-- QuantumInfo/Measurements/POVM.lean | 3 +-- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index 12bcd416e..9658d400a 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -1179,8 +1179,7 @@ lemma trajectory_periodic (IC : InitialConditions) : have h : S.ω * (t.val + 2 * π / S.ω) = S.ω * t.val + 2 * π := by have := S.ω_ne_zero ring_nf; field_simp - rw [InitialConditions.trajectory, add_val, period_eq, h, cos_add_two_pi, sin_add_two_pi] - rfl + simp [InitialConditions.trajectory, add_val, period_eq, h, cos_add_two_pi, sin_add_two_pi] /-! diff --git a/Physlib/Electromagnetism/Distributional/Basic.lean b/Physlib/Electromagnetism/Distributional/Basic.lean index a6b81c39b..377f3740f 100644 --- a/Physlib/Electromagnetism/Distributional/Basic.lean +++ b/Physlib/Electromagnetism/Distributional/Basic.lean @@ -154,7 +154,6 @@ lemma distTensorDeriv_eq_sum_sum {d} (A : DistElectromagneticPotential d) rw [tmul_sum] congr funext ν - rfl /-! @@ -197,7 +196,6 @@ lemma toTensor_distTensorDeriv_basis_repr_apply {d} (A : DistElectromagneticPote (Lorentz.Vector.basis.reindex Lorentz.Vector.indexEquiv.symm)) = ((Lorentz.CoVector.basis (d := d)).tensorProduct (Lorentz.Vector.basis (d := d))).reindex (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := rfl - rfl end DistElectromagneticPotential diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean index e23a2fe49..1758b69bd 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/HilbertSchmidtOperatorSpace.lean @@ -515,8 +515,7 @@ noncomputable def rightMulHSStarAlgHom : (L ℋ)ᵐᵒᵖ →⋆ₐ[ℝ] L (HSOp simp [rightMulHS_star (ℋ := ℋ) (MulOpposite.unop A)] @[simp] theorem rightMulHSStarAlgHom_apply (A : (L ℋ)ᵐᵒᵖ) : - rightMulHSStarAlgHom (ℋ := ℋ) A = rightMulHS (ℋ := ℋ) (MulOpposite.unop A) := - rfl + rightMulHSStarAlgHom (ℋ := ℋ) A = rightMulHS (ℋ := ℋ) (MulOpposite.unop A) := rfl /-- The `⋆`-algebra hom sending `A` to `op (star A)`. On selfadjoint operators this is just `op`. -/ noncomputable def opStarHSStarAlgHom : L ℋ →⋆ₐ[ℝ] (L ℋ)ᵐᵒᵖ where diff --git a/QuantumInfo/Measurements/POVM.lean b/QuantumInfo/Measurements/POVM.lean index 362f09848..d9745cdda 100644 --- a/QuantumInfo/Measurements/POVM.lean +++ b/QuantumInfo/Measurements/POVM.lean @@ -102,8 +102,7 @@ def measurementMap (Λ : POVM X d) : CPTPMap d (d × X) where open Kronecker in theorem measurementMap_apply_matrix (Λ : POVM X d) (m : Matrix d d ℂ) : Λ.measurementMap.map m = ∑ x : X, - ((((Λ.mats x) ^ (1/2:ℝ)).mat * m * ((Λ.mats x)^(1/2:ℝ)).mat) ⊗ₖ Matrix.single x x 1) := by - rfl + ((((Λ.mats x) ^ (1/2:ℝ)).mat * m * ((Λ.mats x)^(1/2:ℝ)).mat) ⊗ₖ Matrix.single x x 1) := rfl open HermitianMat in theorem measurementMap_apply_hermitianMat (Λ : POVM X d) (m : HermitianMat d ℂ) : From c2df9bfa42343a4568b8219a954ffa289f1102a9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:01:21 -0700 Subject: [PATCH 442/498] refactor: golf geometry and tensor rfl proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean | 3 --- Physlib/Mathematics/PiTensorProduct.lean | 6 ++---- Physlib/SpaceAndTime/SpaceTime/Basic.lean | 3 +-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean index f9828f87b..ac04a2c3f 100644 --- a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean @@ -168,7 +168,6 @@ example (g : RiemannianMetric I n M) (x : M) (v : TangentSpace I x) : -- Example showing how to use the metric inner product space example (g : RiemannianMetric I n M) (x : M) (v w : TangentSpace I x) : (TangentSpace.metricInnerProductSpace g x).inner v w = g.inner x v w := by - letI := TangentSpace.metricInnerProductSpace g x rfl /-- Helper function to compute the norm on a tangent space from a Riemannian metric, @@ -194,8 +193,6 @@ example (g : RiemannianMetric I n M) (x : M) (v : TangentSpace I x) : ℝ := lemma norm_eq_norm_of_metricNormedAddCommGroup (g : RiemannianMetric I n M) (x : M) (v : TangentSpace I x) : norm g x v = @Norm.norm (TangentSpace I x) (@NormedAddCommGroup.toNorm _ (TangentSpace.metricNormedAddCommGroup g x)) v := by - unfold norm - let normed_group := TangentSpace.metricNormedAddCommGroup g x rfl end InnerProductSpace diff --git a/Physlib/Mathematics/PiTensorProduct.lean b/Physlib/Mathematics/PiTensorProduct.lean index a8bcc6cae..26cddfebc 100644 --- a/Physlib/Mathematics/PiTensorProduct.lean +++ b/Physlib/Mathematics/PiTensorProduct.lean @@ -199,8 +199,7 @@ lemma elimPureTensor_update_right (p : (i : ι1) → s1 i) (q : (i : ι2) → s2 Function.update (elimPureTensor p q) (Sum.inr y) r := by funext x match x with - | Sum.inl x => - rfl + | Sum.inl x => rfl | Sum.inr x => change Function.update q y r x = _ simp only [Function.update, Sum.inr.injEq, Sum.elim_inr] @@ -224,8 +223,7 @@ lemma elimPureTensor_update_left (p : (i : ι1) → s1 i) (q : (i : ι2) → s2 subst h rfl · rfl - | Sum.inr y => - rfl + | Sum.inr y => rfl end diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index 827eef081..ab6b47aa6 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -441,8 +441,7 @@ def timeSpaceBasisEquiv {d : ℕ} (c : SpeedOfLight) : match μ with | Sum.inl 0 => field_simp - | Sum.inr i => - rfl + | Sum.inr i => rfl right_inv x := by funext μ match μ with From da3392558a3cfbcd682be34285b2e74956c94a12 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:03:37 -0700 Subject: [PATCH 443/498] refactor: inline remaining simple rfl proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Vacuum/HarmonicWave.lean | 6 ++---- Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean | 6 ++---- Physlib/SpaceAndTime/SpaceTime/Basic.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index 6f91e1b41..a2dc73cb4 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -511,8 +511,7 @@ lemma harmonicWaveX_isPlaneWave {d} (𝓕 : FreeSpace) (k : ℝ) (hk : k ≠ 0) | ⟨Nat.succ i, h⟩ => E₀ ⟨i, by grind⟩ * cos (-k * u + φ ⟨i, by grind⟩) ext t x i match i with - | 0 => - rfl + | 0 => rfl | ⟨Nat.succ i, h⟩ => simp only [Nat.succ_eq_add_one, neg_mul] rw [← Fin.succ_mk _ _ (by grind)] @@ -532,8 +531,7 @@ lemma harmonicWaveX_isPlaneWave {d} (𝓕 : FreeSpace) (k : ℝ) (hk : k ≠ 0) intro t x ext ij match ij with - | (0, 0) => - rfl + | (0, 0) => rfl | (⟨0, h0⟩, ⟨Nat.succ j, hj⟩) => simp only [Nat.succ_eq_add_one, Fin.zero_eta, inner_basis, neg_mul] rw [← Fin.succ_mk _ _ (by grind)] diff --git a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean index ac04a2c3f..dec2bae22 100644 --- a/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/Riemannian/Defs.lean @@ -167,8 +167,7 @@ example (g : RiemannianMetric I n M) (x : M) (v : TangentSpace I x) : -- Example showing how to use the metric inner product space example (g : RiemannianMetric I n M) (x : M) (v w : TangentSpace I x) : - (TangentSpace.metricInnerProductSpace g x).inner v w = g.inner x v w := by - rfl + (TangentSpace.metricInnerProductSpace g x).inner v w = g.inner x v w := rfl /-- Helper function to compute the norm on a tangent space from a Riemannian metric, using the underlying `NormedAddCommGroup` structure. -/ @@ -192,8 +191,7 @@ example (g : RiemannianMetric I n M) (x : M) (v : TangentSpace I x) : ℝ := lemma norm_eq_norm_of_metricNormedAddCommGroup (g : RiemannianMetric I n M) (x : M) (v : TangentSpace I x) : norm g x v = @Norm.norm (TangentSpace I x) - (@NormedAddCommGroup.toNorm _ (TangentSpace.metricNormedAddCommGroup g x)) v := by - rfl + (@NormedAddCommGroup.toNorm _ (TangentSpace.metricNormedAddCommGroup g x)) v := rfl end InnerProductSpace diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index ab6b47aa6..fd327dbdf 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -447,8 +447,7 @@ def timeSpaceBasisEquiv {d : ℕ} (c : SpeedOfLight) : match μ with | Sum.inl 0 => field_simp - | Sum.inr i => - rfl + | Sum.inr i => rfl map_add' x y := by funext μ match μ with From 84af6c0b528fca848e30ff7eeb609d32863ec4c8 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:05:26 -0700 Subject: [PATCH 444/498] refactor: golf unit div_self proofs Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/Mass/MassUnit.lean | 3 +-- Physlib/Electromagnetism/Charge/ChargeUnit.lean | 3 +-- Physlib/SpaceAndTime/Space/LengthUnit.lean | 3 +-- Physlib/SpaceAndTime/Time/TimeUnit.lean | 3 +-- Physlib/Thermodynamics/Temperature/TemperatureUnits.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/Mass/MassUnit.lean b/Physlib/ClassicalMechanics/Mass/MassUnit.lean index bb2d31510..71b46fece 100644 --- a/Physlib/ClassicalMechanics/Mass/MassUnit.lean +++ b/Physlib/ClassicalMechanics/Mass/MassUnit.lean @@ -72,8 +72,7 @@ lemma div_pos (x y : MassUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : MassUnit) : - x / x = (1 : ℝ≥0) := by - exact NNReal.eq (_root_.div_self x.val_ne_zero) + x / x = (1 : ℝ≥0) := NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : MassUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by diff --git a/Physlib/Electromagnetism/Charge/ChargeUnit.lean b/Physlib/Electromagnetism/Charge/ChargeUnit.lean index 120dcc230..a6e0b7d98 100644 --- a/Physlib/Electromagnetism/Charge/ChargeUnit.lean +++ b/Physlib/Electromagnetism/Charge/ChargeUnit.lean @@ -77,8 +77,7 @@ lemma div_pos (x y : ChargeUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : ChargeUnit) : - x / x = (1 : ℝ≥0) := by - exact NNReal.eq (_root_.div_self x.val_ne_zero) + x / x = (1 : ℝ≥0) := NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : ChargeUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by diff --git a/Physlib/SpaceAndTime/Space/LengthUnit.lean b/Physlib/SpaceAndTime/Space/LengthUnit.lean index 4ecad76f3..12741e552 100644 --- a/Physlib/SpaceAndTime/Space/LengthUnit.lean +++ b/Physlib/SpaceAndTime/Space/LengthUnit.lean @@ -71,8 +71,7 @@ lemma div_pos (x y : LengthUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : LengthUnit) : - x / x = (1 : ℝ≥0) := by - exact NNReal.eq (_root_.div_self x.val_ne_zero) + x / x = (1 : ℝ≥0) := NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : LengthUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by diff --git a/Physlib/SpaceAndTime/Time/TimeUnit.lean b/Physlib/SpaceAndTime/Time/TimeUnit.lean index a69f39016..e88c95027 100644 --- a/Physlib/SpaceAndTime/Time/TimeUnit.lean +++ b/Physlib/SpaceAndTime/Time/TimeUnit.lean @@ -74,8 +74,7 @@ lemma div_pos (x y : TimeUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : TimeUnit) : - x / x = (1 : ℝ≥0) := by - exact NNReal.eq (_root_.div_self x.val_ne_zero) + x / x = (1 : ℝ≥0) := NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : TimeUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by diff --git a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean index 54368085b..fc27fab5d 100644 --- a/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean +++ b/Physlib/Thermodynamics/Temperature/TemperatureUnits.lean @@ -73,8 +73,7 @@ lemma div_pos (x y : TemperatureUnit) : (0 : ℝ≥0) < x/ y := by @[simp] lemma div_self (x : TemperatureUnit) : - x / x = (1 : ℝ≥0) := by - exact NNReal.eq (_root_.div_self x.val_ne_zero) + x / x = (1 : ℝ≥0) := NNReal.eq (_root_.div_self x.val_ne_zero) lemma div_symm (x y : TemperatureUnit) : x / y = (y / x)⁻¹ := NNReal.eq <| by From 03d2855703af5bcaf0218f65f12912dee8fb37e4 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:07:02 -0700 Subject: [PATCH 445/498] refactor: golf direct tensor proof terms Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Fin.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean | 6 ++---- Physlib/Relativity/Tensors/UnitTensor.lean | 3 +-- Physlib/Units/UnitDependent.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Fin.lean b/Physlib/Mathematics/Fin.lean index 6e09ebbb9..4404545d2 100644 --- a/Physlib/Mathematics/Fin.lean +++ b/Physlib/Mathematics/Fin.lean @@ -100,8 +100,7 @@ lemma finExtractOne_symm_inr {n : ℕ} (i : Fin n.succ) : by_cases hi : x.1 < i.1 · generalize_proofs hp have h1 : (finSumFinEquiv.symm (Fin.cast hp x)) = - Sum.inl ⟨x, hi⟩ := by - exact finSumFinEquiv_symm_apply_castAdd (n := n - i.1) (⟨x, hi⟩ : Fin i.1) + Sum.inl ⟨x, hi⟩ := finSumFinEquiv_symm_apply_castAdd (n := n - i.1) (⟨x, hi⟩ : Fin i.1) rw [h1] simp only [Nat.succ_eq_add_one, Equiv.sumAssoc_symm_apply_inr_inl, Sum.map_inl, Equiv.symm_trans_apply, Equiv.symm_symm, Equiv.sumComm_symm, Equiv.sumComm_apply, diff --git a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean index 49acd2329..fc51bb941 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean @@ -143,8 +143,7 @@ lemma contr_preContrCoUnit {d : ℕ} (x : CoMod d) : rfl rw [h1] have h2 : coContrContract.toLinearMap.rTensor _ (∑ i, (x ⊗ₜ[ℝ] contrBasis d i) ⊗ₜ[ℝ] coBasis d i) - = ∑ i, ((coContrContract) (x ⊗ₜ[ℝ] contrBasis d i)) ⊗ₜ[ℝ] coBasis d i := by - exact map_sum _ _ _ + = ∑ i, ((coContrContract) (x ⊗ₜ[ℝ] contrBasis d i)) ⊗ₜ[ℝ] coBasis d i := map_sum _ _ _ erw [h2] obtain ⟨c, rfl⟩ := (Submodule.mem_span_range_iff_exists_fun ℝ).mp (Basis.mem_span (coBasis d) x) have h3 (i : Fin 1 ⊕ Fin d) : (coContrContract) @@ -175,8 +174,7 @@ lemma contr_preCoContrUnit {d : ℕ} (x : ContrMod d) : rfl rw [h1] have h2 :contrCoContract.toLinearMap.rTensor _ (∑ i, (x ⊗ₜ[ℝ] coBasis d i) ⊗ₜ[ℝ] contrBasis d i) - = ∑ i, ((contrCoContract) (x ⊗ₜ[ℝ] coBasis d i)) ⊗ₜ[ℝ] contrBasis d i := by - exact map_sum _ _ _ + = ∑ i, ((contrCoContract) (x ⊗ₜ[ℝ] coBasis d i)) ⊗ₜ[ℝ] contrBasis d i := map_sum _ _ _ erw [h2] obtain ⟨c, rfl⟩ := (Submodule.mem_span_range_iff_exists_fun ℝ).mp (Basis.mem_span (contrBasis d) x) diff --git a/Physlib/Relativity/Tensors/UnitTensor.lean b/Physlib/Relativity/Tensors/UnitTensor.lean index dd54652c4..3da2d5c01 100644 --- a/Physlib/Relativity/Tensors/UnitTensor.lean +++ b/Physlib/Relativity/Tensors/UnitTensor.lean @@ -69,8 +69,7 @@ lemma dual_unitTensor_eq_permT_unitTensor (c : C) : lemma unit_fromSingleTContrFromPairT_eq_fromSingleT {c : C} (x : V c) : fromSingleTContrFromPairT x ((S.unit c) (1 : k)) = - fromSingleT x := by - exact congrArg fromSingleT (S.contr_unit c x) + fromSingleT x := congrArg fromSingleT (S.contr_unit c x) /-- This lemma represents the de-categorification of `S.contr_unit`. -/ @[simp] diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index cf6eee82a..26dca53ca 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -516,8 +516,7 @@ instance (M : Type) [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) : @[simp] lemma scaleUnit_dimSet_val {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) (m : DimSet M d) (u1 u2 : UnitChoices) : - (scaleUnit u1 u2 m).1 = scaleUnit u1 u2 m.1 := by - exact (m.2 u1 u2).symm + (scaleUnit u1 u2 m).1 = scaleUnit u1 u2 m.1 := (m.2 u1 u2).symm lemma DimSet.mem_iff {M : Type} [MulAction ℝ≥0 M] [MulUnitDependent M] (d : Dimension) (m : M) : m ∈ DimSet M d ↔ ∀ u1 u2, scaleUnit u1 u2 m = (UnitChoices.dimScale u1 u2 d) • m := by rfl From 4f0c8a0e0f1197b2d04c2a38340967049155876e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:08:33 -0700 Subject: [PATCH 446/498] refactor: golf list and contraction wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List.lean | 9 +++------ .../WickContraction/SubContraction.lean | 3 +-- Physlib/Relativity/SL2C/Basic.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/List.lean b/Physlib/Mathematics/List.lean index de6348251..f257eb8a7 100644 --- a/Physlib/Mathematics/List.lean +++ b/Physlib/Mathematics/List.lean @@ -33,8 +33,7 @@ lemma takeWile_eraseIdx {I : Type} (P : I → Prop) [DecidablePred P] : | a :: b :: l, 0, h => by simp only [List.takeWhile, List.eraseIdx_zero] by_cases hPb : P b - · have hPa : P a := by - simpa using h ⟨0, by simp⟩ ⟨1, by simp⟩ (by simp) (by simpa using hPb) + · have hPa : P a := by simpa using h ⟨0, by simp⟩ ⟨1, by simp⟩ (by simp) (by simpa using hPb) simp [hPb, hPa] · simp [hPb] split <;> rfl @@ -61,15 +60,13 @@ lemma dropWile_eraseIdx {I : Type} (P : I → Prop) [DecidablePred P] : by_cases hPa : P a <;> simp [hPa, List.eraseIdx_of_length_le] | a :: b :: l, 0, h => by by_cases hPb : P b - · have hPa : P a := by - simpa using h ⟨0, by simp⟩ ⟨1, by simp⟩ (by simp) (by simpa using hPb) + · have hPa : P a := by simpa using h ⟨0, by simp⟩ ⟨1, by simp⟩ (by simp) (by simpa using hPb) simp [hPb, hPa] · by_cases hPa : P a <;> simp [hPa, hPb] | a :: b :: l, Nat.succ n, h => by simp only [Nat.succ_eq_add_one, List.eraseIdx_cons_succ] by_cases hPb : P b - · have hPa : P a := by - simpa using h ⟨0, by simp⟩ ⟨1, by simp⟩ (by simp) (by simpa using hPb) + · have hPa : P a := by simpa using h ⟨0, by simp⟩ ⟨1, by simp⟩ (by simp) (by simpa using hPb) simp only [List.dropWhile, hPa, decide_true, List.takeWhile, hPb, List.length_cons, add_le_add_iff_right, Nat.reduceSubDiff] rw [dropWile_eraseIdx P (b :: l) n (fun i j hij hP => by diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean index 7a37667b9..6d7a1285f 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/SubContraction.lean @@ -100,8 +100,7 @@ lemma mem_subContraction_or_quotContraction {S : Finset (Finset (Fin φs.length) @[simp] lemma subContraction_uncontractedList_get {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} {a : Fin [subContraction S hs]ᵘᶜ.length} : - [subContraction S hs]ᵘᶜ[a] = φs[uncontractedListEmd a] := by - exact (getElem_uncontractedListEmd a).symm + [subContraction S hs]ᵘᶜ[a] = φs[uncontractedListEmd a] := (getElem_uncontractedListEmd a).symm @[simp] lemma subContraction_fstFieldOfContract {S : Finset (Finset (Fin φs.length))} {hs : S ⊆ φsΛ.1} diff --git a/Physlib/Relativity/SL2C/Basic.lean b/Physlib/Relativity/SL2C/Basic.lean index 52604c4c6..673763862 100644 --- a/Physlib/Relativity/SL2C/Basic.lean +++ b/Physlib/Relativity/SL2C/Basic.lean @@ -165,8 +165,7 @@ lemma toMatrix_mem_lorentzGroup (M : SL(2, ℂ)) : toMatrix M ∈ LorentzGroup 3 @[simps!] def toLorentzGroup : SL(2, ℂ) →* LorentzGroup 3 where toFun M := ⟨toMatrix M, toMatrix_mem_lorentzGroup M⟩ - map_one' := by - exact Subtype.ext (by simp) + map_one' := Subtype.ext (by simp) map_mul' M N := by ext1 simp only [_root_.map_mul, lorentzGroupIsGroup_mul_coe] From 3907bf4498756629641e16ac8047e89358305630 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:12:18 -0700 Subject: [PATCH 447/498] refactor: golf derivative and lagrangian wrappers Co-authored-by: Claude Opus 4.8 --- .../Lagrangian/TotalDerivativeEquivalence.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/Div.lean | 3 +-- Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean | 3 +-- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean index 362582769..348cad220 100644 --- a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean +++ b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean @@ -221,8 +221,7 @@ lemma isTotalTimeDerivativeVelocity [CompleteSpace X] have h0 : δL (0 : X) = fderiv ℝ ↿F ((0 : Time), (0 : X)) - ((1 : Time), (0 : X)) := by - simpa using (hEq (0 : Time) (0 : X) + ((1 : Time), (0 : X)) := by simpa using (hEq (0 : Time) (0 : X) (0 : X)) have : dF ((1 : Time), (0 : X)) = δL (0 : X) := by simpa [dF] using h0.symm diff --git a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean index 176226b29..7e9157988 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean @@ -72,8 +72,7 @@ noncomputable def coordinateMap : (PureU1 n.succ).LinSols ≃ₗ[ℚ] Fin n →₀ ℚ where toFun S := (Finsupp.linearEquivFunOnFinite ℚ ℚ (Fin n)).symm (S.1 ∘ Fin.castSucc) map_add' S T := map_add _ _ _ - map_smul' a S := by - exact (Finsupp.linearEquivFunOnFinite ℚ ℚ (Fin n)).symm.map_smul a (S.1 ∘ Fin.castSucc) + map_smul' a S := (Finsupp.linearEquivFunOnFinite ℚ ℚ (Fin n)).symm.map_smul a (S.1 ∘ Fin.castSucc) invFun f := ∑ i : Fin n, f i • asLinSols i left_inv S := by simp only [Nat.succ_eq_add_one, diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Div.lean b/Physlib/SpaceAndTime/Space/Derivatives/Div.lean index 0ab99f354..765495193 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Div.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Div.lean @@ -206,8 +206,7 @@ lemma distDiv_apply_eq_sum_fderivD {d} lemma distDiv_apply_eq_sum_distDeriv {d} (f : (Space d) →d[ℝ] EuclideanSpace ℝ (Fin d)) (η : 𝓢(Space d, ℝ)) : - (∇ᵈ ⬝ f) η = ∑ i, ∂ᵈ[i] f η i := by - exact distDiv_apply_eq_sum_fderivD f η + (∇ᵈ ⬝ f) η = ∑ i, ∂ᵈ[i] f η i := distDiv_apply_eq_sum_fderivD f η /-! diff --git a/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean b/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean index fba2c8715..ecda75e79 100644 --- a/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean +++ b/Physlib/SpaceAndTime/Space/Derivatives/Iterated.lean @@ -124,8 +124,7 @@ lemma iteratedDeriv_contDiff (I : MultiIndex d) {f : Space d → ℝ} /-- The topological support of a spatial derivative is contained in that of the original function. -/ lemma tsupport_deriv_subset (i : Fin d) {f : Space d → ℝ} : - tsupport (deriv i f) ⊆ tsupport f := by - simpa [deriv_eq_fderiv_fun] using + tsupport (deriv i f) ⊆ tsupport f := by simpa [deriv_eq_fderiv_fun] using (tsupport_fderiv_apply_subset (𝕜 := ℝ) (f := fun x => f x) (v := basis i)) private lemma iteratedDerivList_commute_deriv (L : List (Fin d)) (i : Fin d) diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index 60197119f..2fbf2e029 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -1156,8 +1156,7 @@ lemma distDiv_norm_zpow_smul_repr_self_eq_smul (IsDistBounded.pow q (by omega))) := by ext η let p : ℕ := Int.toNat (q + (d : ℤ)) - have hp_int : (p : ℤ) = q + (d : ℤ) := by - simpa [p] using Int.toNat_of_nonneg (le_of_lt hq) + have hp_int : (p : ℤ) = q + (d : ℤ) := by simpa [p] using Int.toNat_of_nonneg (le_of_lt hq) have hp_pos : 0 < p := by have : (0 : ℤ) < (p : ℤ) := by simpa [hp_int] using hq exact_mod_cast this From 734bd0364ccea502101e77ad10ba9f8964e53fff Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:14:20 -0700 Subject: [PATCH 448/498] refactor: golf tensor and mechanics one-line proofs Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean | 3 +-- .../Lagrangian/TotalDerivativeEquivalence.lean | 3 +-- Physlib/Relativity/Tensors/Basic.lean | 3 +-- Physlib/Relativity/Tensors/UnitTensor.lean | 3 +-- Physlib/Units/UnitDependent.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index b692fc569..b078f2593 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -419,8 +419,7 @@ lemma gradient_const_mul_inner_self (c : ℝ) (x : EuclideanSpace ℝ (Fin 1)) : simp only [gradient, map_smul] _ = c • ((2 : ℝ) • x) := by rw [gradient_inner_self] - _ = (2 * c) • x := by - rw [smul_smul, mul_comm] + _ = (2 * c) • x := by rw [smul_smul, mul_comm] /-! diff --git a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean index 348cad220..17a5c1a63 100644 --- a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean +++ b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean @@ -258,8 +258,7 @@ lemma isTotalTimeDerivativeVelocity [CompleteSpace X] (E := X) (x := v) (y := φ)] calc δL v = φ v := hφ v - _ = ⟪(InnerProductSpace.toDual ℝ (X)).symm φ, v⟫_ℝ := by - rw [hinner.symm] + _ = ⟪(InnerProductSpace.toDual ℝ (X)).symm φ, v⟫_ℝ := by rw [hinner.symm] end Lagrangian diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index c36acf78a..a9ef2524b 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -518,8 +518,7 @@ lemma actionT_smul {g : G} {r : k} {t : S.Tensor c} : lemma actionT_zero {g : G} : g • (0 : S.Tensor c) = 0 := by simp [actionT_eq] lemma actionT_neg {g : G} {t : S.Tensor c} : - g • (-t) = -(g • t) := by - simp [actionT_eq] + g • (-t) = -(g • t) := by simp [actionT_eq] noncomputable instance : DistribMulAction G (S.Tensor c) where smul_zero g := by simp [actionT_zero] diff --git a/Physlib/Relativity/Tensors/UnitTensor.lean b/Physlib/Relativity/Tensors/UnitTensor.lean index 3da2d5c01..7d7e10233 100644 --- a/Physlib/Relativity/Tensors/UnitTensor.lean +++ b/Physlib/Relativity/Tensors/UnitTensor.lean @@ -103,7 +103,6 @@ lemma contrT_unitTensor_dual_single {c : C} (x : Tensor S ![S.τ c]) : @[simp] lemma unitTensor_invariant {c : C} (g : G) : - g • S.unitTensor c = S.unitTensor c := by - rw [unitTensor, actionT_fromConstPair] + g • S.unitTensor c = S.unitTensor c := by rw [unitTensor, actionT_fromConstPair] end TensorSpecies diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 26dca53ca..3ba345278 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -84,8 +84,7 @@ class ContinuousLinearUnitDependent (M : Type) [AddCommMonoid M] [Module ℝ M] @[simp] lemma UnitDependent.scaleUnit_symm_apply {M : Type} [UnitDependent M] (u1 u2 : UnitChoices) (m : M) : - scaleUnit u2 u1 (scaleUnit u1 u2 m) = m := by - rw [scaleUnit_trans, scaleUnit_id] + scaleUnit u2 u1 (scaleUnit u1 u2 m) = m := by rw [scaleUnit_trans, scaleUnit_id] @[simp] lemma UnitDependent.scaleUnit_injective {M : Type} [UnitDependent M] From 4b67a43f8d1b54a0c9d8c3ab2464df2771965a53 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:16:01 -0700 Subject: [PATCH 449/498] refactor: golf divergence and trace proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/Divergence.lean | 12 ++++-------- .../Mathematics/DataStructures/Matrix/LieTrace.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Calculus/Divergence.lean b/Physlib/Mathematics/Calculus/Divergence.lean index 525524212..c7b410ac6 100644 --- a/Physlib/Mathematics/Calculus/Divergence.lean +++ b/Physlib/Mathematics/Calculus/Divergence.lean @@ -105,26 +105,22 @@ lemma divergence_add {f g : E → E} {x : E} (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : divergence 𝕜 (fun x => f x + g x) x = - divergence 𝕜 f x + divergence 𝕜 g x := by - simp [divergence, fderiv_fun_add hf hg] + divergence 𝕜 f x + divergence 𝕜 g x := by simp [divergence, fderiv_fun_add hf hg] lemma divergence_neg {f : E → E} {x : E} : - divergence 𝕜 (fun x => -f x) x = -divergence 𝕜 f x := by - simp [divergence] + divergence 𝕜 (fun x => -f x) x = -divergence 𝕜 f x := by simp [divergence] lemma divergence_sub {f g : E → E} {x : E} (hf : DifferentiableAt 𝕜 f x) (hg : DifferentiableAt 𝕜 g x) : divergence 𝕜 (fun x => f x - g x) x = - divergence 𝕜 f x - divergence 𝕜 g x := by - simp [divergence, fderiv_fun_sub hf hg] + divergence 𝕜 f x - divergence 𝕜 g x := by simp [divergence, fderiv_fun_sub hf hg] lemma divergence_const_smul {f : E → E} {x : E} {c : 𝕜} (hf : DifferentiableAt 𝕜 f x) : divergence 𝕜 (fun x => c • f x) x = - c * divergence 𝕜 f x := by - simp [divergence, fderiv_fun_const_smul hf] + c * divergence 𝕜 f x := by simp [divergence, fderiv_fun_const_smul hf] open InnerProductSpace' in lemma divergence_smul [InnerProductSpace' 𝕜 E] {f : E → 𝕜} {g : E → E} {x : E} diff --git a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean index f395ea3b9..6e16b9100 100644 --- a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean +++ b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean @@ -187,8 +187,7 @@ lemma exp_unitary_conj (A : Matrix m m 𝕂) (U : unitaryGroup m 𝕂) : lemma det_exp_unitary_conj (A : Matrix m m 𝕂) (U : unitaryGroup m 𝕂) : (NormedSpace.exp ((U : Matrix m m 𝕂) * A * star (U : Matrix m m 𝕂))).det = - (NormedSpace.exp A).det := by - rw [exp_unitary_conj, det_unitary_conj] + (NormedSpace.exp A).det := by rw [exp_unitary_conj, det_unitary_conj] /-- The determinant of the exponential of a matrix is the exponential of its trace. This is also known as **Lie's trace formula**. -/ From 3da87e5aa4ff4374aeb35d096fde3dbf0101e102 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:17:08 -0700 Subject: [PATCH 450/498] refactor: golf real tensor action proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/RealTensor/CoVector/Representation.lean | 3 +-- .../Relativity/Tensors/RealTensor/CoVector/Tensorial.lean | 6 ++---- Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean index a79c5cbc6..094fa9566 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Representation.lean @@ -52,8 +52,7 @@ lemma rep_apply_eq_sum (d : ℕ) (Λ : LorentzGroup d) (v : CoVector d) (k : Fin rep Λ v k = ∑ j, (Λ⁻¹).1 j k • v j := rfl lemma rep_apply_eq_sum_coe (d : ℕ) (Λ : LorentzGroup d) (v : CoVector d) (k : Fin 1 ⊕ Fin d) : - rep Λ v k = ∑ j, Λ.1⁻¹ j k • v j := by - rw [rep_apply_eq_sum, LorentzGroup.coe_inv] + rep Λ v k = ∑ j, Λ.1⁻¹ j k • v j := by rw [rep_apply_eq_sum, LorentzGroup.coe_inv] lemma rep_apply_basis {d} (μ : Fin 1 ⊕ Fin d) (Λ : LorentzGroup d) : rep Λ (basis μ) = ∑ j, Λ.1⁻¹ μ j • basis j := by diff --git a/Physlib/Relativity/Tensors/RealTensor/CoVector/Tensorial.lean b/Physlib/Relativity/Tensors/RealTensor/CoVector/Tensorial.lean index 5a5c6537f..9d3241f95 100644 --- a/Physlib/Relativity/Tensors/RealTensor/CoVector/Tensorial.lean +++ b/Physlib/Relativity/Tensors/RealTensor/CoVector/Tensorial.lean @@ -173,13 +173,11 @@ lemma smul_sub {d : ℕ} (Λ : LorentzGroup d) (p q : CoVector d) : set_option backward.isDefEq.respectTransparency false in lemma smul_zero {d : ℕ} (Λ : LorentzGroup d) : - Λ • (0 : CoVector d) = 0 := by - rw [smul_eq_mulVec, Matrix.mulVec_zero] + Λ • (0 : CoVector d) = 0 := by rw [smul_eq_mulVec, Matrix.mulVec_zero] set_option backward.isDefEq.respectTransparency false in lemma smul_neg {d : ℕ} (Λ : LorentzGroup d) (p : CoVector d) : - Λ • (-p) = - (Λ • p) := by - rw [smul_eq_mulVec, smul_eq_mulVec, Matrix.mulVec_neg] + Λ • (-p) = - (Λ • p) := by rw [smul_eq_mulVec, smul_eq_mulVec, Matrix.mulVec_neg] /-- The Lorentz action on vectors as a continuous linear map. -/ def actionCLM {d : ℕ} (Λ : LorentzGroup d) : diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean index 0eb8fdaac..bc57d3676 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Tensorial.lean @@ -168,13 +168,11 @@ lemma smul_sub {d : ℕ} (Λ : LorentzGroup d) (p q : Vector d) : set_option backward.isDefEq.respectTransparency false in lemma smul_zero {d : ℕ} (Λ : LorentzGroup d) : - Λ • (0 : Vector d) = 0 := by - rw [smul_eq_mulVec, Matrix.mulVec_zero] + Λ • (0 : Vector d) = 0 := by rw [smul_eq_mulVec, Matrix.mulVec_zero] set_option backward.isDefEq.respectTransparency false in lemma smul_neg {d : ℕ} (Λ : LorentzGroup d) (p : Vector d) : - Λ • (-p) = - (Λ • p) := by - rw [smul_eq_mulVec, smul_eq_mulVec, Matrix.mulVec_neg] + Λ • (-p) = - (Λ • p) := by rw [smul_eq_mulVec, smul_eq_mulVec, Matrix.mulVec_neg] lemma neg_smul {d} (Λ : LorentzGroup d) (p : Vector d) : (-Λ) • p = - (Λ • p) := by From fa3d3ba63a2b55008d2f5778c3831580f392201d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:18:25 -0700 Subject: [PATCH 451/498] refactor: golf ddim quantum operator proofs Co-authored-by: Claude Opus 4.8 --- Physlib/QuantumMechanics/DDimensions/Basic.lean | 3 +-- .../DDimensions/Operators/Multiplication.lean | 3 +-- .../QuantumMechanics/DDimensions/Operators/Position.lean | 6 ++---- .../Operators/StateObservables/ExpectedValue.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QuantumMechanics/DDimensions/Basic.lean b/Physlib/QuantumMechanics/DDimensions/Basic.lean index b1fbd1ff2..711dfae5b 100644 --- a/Physlib/QuantumMechanics/DDimensions/Basic.lean +++ b/Physlib/QuantumMechanics/DDimensions/Basic.lean @@ -114,8 +114,7 @@ lemma potentialCLM_apply (h_HTG : Q.potential.HasTemperateGrowth) (ψ : 𝓢(Spa @[simp] lemma potentialCLM_apply_apply (h_HTG : Q.potential.HasTemperateGrowth) (ψ : 𝓢(Space Q.d, ℂ)) (x : Space Q.d) : - Q.potentialCLM ψ x = Q.potential x • ψ x := by - rw [potentialCLM_apply h_HTG] + Q.potentialCLM ψ x = Q.potential x • ψ x := by rw [potentialCLM_apply h_HTG] /-- The potential operator as a self-adjoint, unbounded multiplication operator with domain `{ψ ∈ Q.HS | Q.potential • ψ ∈ Q.HS}`. -/ diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean index 090a9a5ab..99b52a0cd 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Multiplication.lean @@ -297,8 +297,7 @@ lemma mulOperator_adjoint_eq_conj {f : Space d → ℂ} (hf : AEStronglyMeasurab lemma mulOperator_isSelfAdjoint_ofReal {f : Space d → ℂ} (hf : AEStronglyMeasurable f) (hf' : conj ∘ f = f) : - IsSelfAdjoint (𝓜 f) := by - rw [isSelfAdjoint_def, mulOperator_adjoint_eq_conj hf, hf'] + IsSelfAdjoint (𝓜 f) := by rw [isSelfAdjoint_def, mulOperator_adjoint_eq_conj hf, hf'] /-! ## D. Closable & unbounded diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean index ede732380..9c859b9cc 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Position.lean @@ -115,8 +115,7 @@ lemma radiusRegPowCLM_apply_fun {d : ℕ} (ε : ℝˣ) (s : ℝ) (ψ : 𝓢(Spac @[simp] lemma radiusRegPowCLM_apply {d : ℕ} (ε : ℝˣ) (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (x : Space d) : - 𝐫₀ ε s ψ x = (‖x‖ ^ 2 + ε ^ 2) ^ (s / 2) • ψ x := by - rw [radiusRegPowCLM_apply_fun] + 𝐫₀ ε s ψ x = (‖x‖ ^ 2 + ε ^ 2) ^ (s / 2) • ψ x := by rw [radiusRegPowCLM_apply_fun] @[simp] lemma radiusRegPowCLM_comp_eq {d : ℕ} (ε : ℝˣ) (s t : ℝ) : @@ -157,8 +156,7 @@ lemma radiusPowLM_apply_fun {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) : @[simp] lemma radiusPowLM_apply {d : ℕ} (s : ℝ) (ψ : 𝓢(Space d, ℂ)) (x : Space d) : - 𝐫 s ψ x = ‖x‖ ^ s • ψ x := by - rw [radiusPowLM_apply_fun] + 𝐫 s ψ x = ‖x‖ ^ s • ψ x := by rw [radiusPowLM_apply_fun] /-- `x ↦ ‖x‖ˢψ(x)` is smooth away from `x = 0`. -/ @[fun_prop] diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean index 250c088fa..e1f4e8459 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/StateObservables/ExpectedValue.lean @@ -76,8 +76,7 @@ lemma centered_eq (T : H →ₗ.[ℂ] H) (ψ : T.domain) : /-- A centered vector vanishes exactly when `Tψ = ⟨T⟩_ψ ψ`. -/ lemma centered_eq_zero_iff (T : H →ₗ.[ℂ] H) (ψ : T.domain) : - centered T ψ = 0 ↔ T ψ = (expectedValue T ψ : ℂ) • (ψ : H) := by - rw [centered_eq, sub_eq_zero] + centered T ψ = 0 ↔ T ψ = (expectedValue T ψ : ℂ) • (ψ : H) := by rw [centered_eq, sub_eq_zero] /-- For a unit vector and symmetric `T`, the centered vector is orthogonal to the state. -/ lemma inner_state_centered_eq_zero (T : H →ₗ.[ℂ] H) (hT : T.IsSymmetric) From dbfc2d52f5fc233b79fb4b1b5c7d14c8e7a9ea49 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:23:07 -0700 Subject: [PATCH 452/498] refactor: golf relativity and metric one-step proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Electromagnetism/Dynamics/Basic.lean | 3 +-- Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean | 3 +-- Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean | 3 +-- Physlib/Relativity/Tensors/MetricTensor.lean | 3 +-- .../Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Electromagnetism/Dynamics/Basic.lean b/Physlib/Electromagnetism/Dynamics/Basic.lean index 513934f8d..056ddb8b1 100644 --- a/Physlib/Electromagnetism/Dynamics/Basic.lean +++ b/Physlib/Electromagnetism/Dynamics/Basic.lean @@ -102,8 +102,7 @@ lemma c_sq : (𝓕.c : ℝ) ^ 2 = 1 / (𝓕.ε₀ * 𝓕.μ₀) := by · positivity @[simp] -lemma c_abs : abs (𝓕.c : ℝ) = 𝓕.c := by - rw [abs_of_pos (SpeedOfLight.val_pos 𝓕.c)] +lemma c_abs : abs (𝓕.c : ℝ) = 𝓕.c := by rw [abs_of_pos (SpeedOfLight.val_pos 𝓕.c)] end FreeSpace diff --git a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean index d4b0c9673..0d88c7f14 100644 --- a/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean +++ b/Physlib/Mathematics/Geometry/Metric/PseudoRiemannian/Defs.lean @@ -513,8 +513,7 @@ noncomputable def cotangentMetricVal (g : PseudoRiemannianMetric E H M n I) (x : @[simp] lemma cotangentMetricVal_eq_apply_sharp (g : PseudoRiemannianMetric E H M n I) (x : M) (ω₁ ω₂ : TangentSpace I x →L[ℝ] ℝ) : - cotangentMetricVal g x ω₁ ω₂ = ω₁ (g.sharpL x ω₂) := by - rw [cotangentMetricVal, apply_sharp_sharp] + cotangentMetricVal g x ω₁ ω₂ = ω₁ (g.sharpL x ω₂) := by rw [cotangentMetricVal, apply_sharp_sharp] lemma cotangentMetricVal_symm (g : PseudoRiemannianMetric E H M n I) (x : M) (ω₁ ω₂ : TangentSpace I x →L[ℝ] ℝ) : diff --git a/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean b/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean index a602bdba3..ccb40069f 100644 --- a/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean +++ b/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean @@ -167,8 +167,7 @@ lemma succSuccAbove_symm (i j : Fin (n + 1 + 1)) : set_option warning.simp.varHead false in @[simp, nolint simpVarHead] lemma apply_succSuccAbove_symm {c : Fin (n + 1 + 1) → C} (i j : Fin (n + 1 + 1)) - (k : Fin n) : c (succSuccAbove i j k) = c (succSuccAbove j i k) := by - rw [succSuccAbove_symm] + (k : Fin n) : c (succSuccAbove i j k) = c (succSuccAbove j i k) := by rw [succSuccAbove_symm] lemma succSuccAbove_apply_eq_orderIsoOfFin {i j : Fin (n + 1 + 1)} (hij : i ≠ j) (m : Fin n) : (succSuccAbove i j) m = (Finset.orderIsoOfFin {i, j}ᶜ diff --git a/Physlib/Relativity/Tensors/MetricTensor.lean b/Physlib/Relativity/Tensors/MetricTensor.lean index 93f636ed0..f395ad1b1 100644 --- a/Physlib/Relativity/Tensors/MetricTensor.lean +++ b/Physlib/Relativity/Tensors/MetricTensor.lean @@ -36,8 +36,7 @@ lemma metricTensor_congr {c c1 : C} (h : c = c1) : @[simp] lemma metricTensor_invariant {c : C} (g : G) : - g • S.metricTensor c = metricTensor c := by - rw [metricTensor, actionT_fromConstPair] + g • S.metricTensor c = metricTensor c := by rw [metricTensor, actionT_fromConstPair] lemma permT_fromPairTContr_metric_metric {c : C} : permT ![1, 0] (And.intro (by decide) (fun i => by fin_cases i <;> rfl)) diff --git a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean index 57b6cac79..d4ca48adf 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Vector/Pre/Contraction.lean @@ -219,8 +219,7 @@ lemma dual_mulVec_right : ⟪x, dual Λ *ᵥ y⟫ₘ = ⟪Λ *ᵥ x, y⟫ₘ := simp only [dual, ← mul_assoc, minkowskiMatrix.sq, one_mul] rw [← mulVec_mulVec, dotProduct_mulVec, vecMul_transpose] -lemma dual_mulVec_left : ⟪dual Λ *ᵥ x, y⟫ₘ = ⟪x, Λ *ᵥ y⟫ₘ := by - rw [symm, dual_mulVec_right, symm] +lemma dual_mulVec_left : ⟪dual Λ *ᵥ x, y⟫ₘ = ⟪x, Λ *ᵥ y⟫ₘ := by rw [symm, dual_mulVec_right, symm] lemma right_parity : ⟪x, (Contr d).ρ LorentzGroup.parity y⟫ₘ = ∑ i, x.val i * y.val i := by rw [as_sum] From a9d0883dc9c98c35b7346be286935d07286bc7e7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:26:02 -0700 Subject: [PATCH 453/498] refactor: golf field statistics and anomaly wrappers Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean | 6 ++---- .../AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean | 3 +-- Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean | 3 +-- .../PerturbationTheory/FieldStatistics/ExchangeSign.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean index 098e15395..8ae9b4658 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean @@ -51,8 +51,7 @@ lemma BL_add_α₁_α₂_cube (S : (PlusU1 n).QuadSols) : ring lemma BL_add_α₁_α₂_AF (S : (PlusU1 n).Sols) : - BL.addQuad S.1 (α₁ S.1) (α₂ S.1) = (α₁ S.1) • S.1 := by - rw [α₂_AF, BL.addQuad_zero] + BL.addQuad S.1 (α₁ S.1) (α₂ S.1) = (α₁ S.1) • S.1 := by rw [α₂_AF, BL.addQuad_zero] /-- The construction of a `Sol` from a `QuadSol` in the generic case. -/ def generic (S : (PlusU1 n).QuadSols) : (PlusU1 n).Sols := @@ -64,8 +63,7 @@ lemma generic_on_AF (S : (PlusU1 n).Sols) : generic S.1 = (α₁ S.1) • S := b exact congrArg (fun Q : (PlusU1 n).QuadSols => Q.val) (BL_add_α₁_α₂_AF S) lemma generic_on_AF_α₁_ne_zero (S : (PlusU1 n).Sols) (h : α₁ S.1 ≠ 0) : - (α₁ S.1)⁻¹ • generic S.1 = S := by - rw [generic_on_AF, smul_smul, inv_mul_cancel₀ h, one_smul] + (α₁ S.1)⁻¹ • generic S.1 = S := by rw [generic_on_AF, smul_smul, inv_mul_cancel₀ h, one_smul] /-- The construction of a `Sol` from a `QuadSol` in the case when `α₁ S = 0` and `α₂ S = 0`. -/ def special (S : (PlusU1 n).QuadSols) (a b : ℚ) (h1 : α₁ S = 0) (h2 : α₂ S = 0) : diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean index fbd895a82..9d36dbf14 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/PlaneWithY3B3.lean @@ -41,8 +41,7 @@ lemma planeY₃B₃_smul (R : MSSMACC.AnomalyFreePerp) (a b c d : ℚ) : rw [smul_smul, smul_smul, smul_smul] lemma planeY₃B₃_eq (R : MSSMACC.AnomalyFreePerp) (a b c : ℚ) (h : a = a' ∧ b = b' ∧ c = c') : - (planeY₃B₃ R a b c) = (planeY₃B₃ R a' b' c') := by - rw [h.1, h.2.1, h.2.2] + (planeY₃B₃ R a b c) = (planeY₃B₃ R a' b' c') := by rw [h.1, h.2.1, h.2.2] set_option backward.isDefEq.respectTransparency false in lemma planeY₃B₃_val_eq' (R : MSSMACC.AnomalyFreePerp) (a b c : ℚ) (hR' : R.val ≠ 0) diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean index 63981c10a..6284299c7 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/Basic.lean @@ -243,8 +243,7 @@ lemma ofList_map_eq_finset_prod (s : 𝓕 → FieldStatistic) : exact hl.2 lemma ofList_pair (s : 𝓕 → FieldStatistic) (φ1 φ2 : 𝓕) : - ofList s [φ1, φ2] = s φ1 * s φ2 := by - rw [ofList_cons_eq_mul, ofList_singleton] + ofList s [φ1, φ2] = s φ1 * s φ2 := by rw [ofList_cons_eq_mul, ofList_singleton] /-! diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean index 64be719ac..bc0ce6c1c 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/ExchangeSign.lean @@ -97,8 +97,7 @@ lemma exchangeSign_mul_self_swap (a b : FieldStatistic) : 𝓢(a, b) * 𝓢(b, a lemma exchangeSign_ofList_cons (a : FieldStatistic) (s : 𝓕 → FieldStatistic) (φ : 𝓕) (φs : List 𝓕) : - 𝓢(a, ofList s (φ :: φs)) = 𝓢(a, s φ) * 𝓢(a, ofList s φs) := by - rw [ofList_cons_eq_mul, map_mul] + 𝓢(a, ofList s (φ :: φs)) = 𝓢(a, s φ) * 𝓢(a, ofList s φs) := by rw [ofList_cons_eq_mul, map_mul] /-- The exchange sign is a cocycle. -/ lemma exchangeSign_cocycle (a b c : FieldStatistic) : From 93ccb2d31fb3f6c6f6011b6751faa17b1c2b02b6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:29:36 -0700 Subject: [PATCH 454/498] refactor: golf space and time one-step proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Space/Integrals/NormPow.lean | 6 ++---- Physlib/SpaceAndTime/Time/TimeTransMan.lean | 3 +-- Physlib/SpaceAndTime/TimeAndSpace/Basic.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/SpaceAndTime/Space/Integrals/NormPow.lean b/Physlib/SpaceAndTime/Space/Integrals/NormPow.lean index 20c0fb61e..d53edf9bd 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/NormPow.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/NormPow.lean @@ -64,8 +64,7 @@ lemma radial_jacobian_zpow_mul_self rw [← zpow_add₀ hz q 1, ← zpow_add₀ hz (d - 1: ℤ) (q + 1)] _ = r ^ (p : ℤ) := by congr 1; omega - _ = r ^ p := by - rw [zpow_natCast] + _ = r ^ p := by rw [zpow_natCast] private lemma radial_jacobian_zpow {d p : ℕ} [NeZero d] {q : ℤ} (hp_int : (p : ℤ) = q + (d : ℤ)) @@ -78,8 +77,7 @@ private lemma radial_jacobian_zpow rw [← Nat.cast_pred (Nat.pos_of_neZero d), ← zpow_natCast, ← zpow_add₀ hz] _ = r ^ ((p - 1 : ℕ) : ℤ) := by congr 1; omega - _ = r ^ (p - 1) := by - rw [zpow_natCast] + _ = r ^ (p - 1) := by rw [zpow_natCast] lemma radial_norm_power_spherical_integral_eq_space_integral {d p : ℕ} [NeZero d] {q : ℤ} (hp_int : (p : ℤ) = q + (d : ℤ)) diff --git a/Physlib/SpaceAndTime/Time/TimeTransMan.lean b/Physlib/SpaceAndTime/Time/TimeTransMan.lean index 72f6c8983..1d9d5a054 100644 --- a/Physlib/SpaceAndTime/Time/TimeTransMan.lean +++ b/Physlib/SpaceAndTime/Time/TimeTransMan.lean @@ -287,8 +287,7 @@ lemma addTime_eq_val (x : TimeUnit) (r : ℝ) (t : TimeTransMan) : simp [diff_eq_val] lemma addTime_val (x : TimeUnit) (r : ℝ) (t : TimeTransMan) : - (addTime x r t).val = x.1 * r + t.val := by - rw [addTime_eq_val] + (addTime x r t).val = x.1 * r + t.val := by rw [addTime_eq_val] /-! diff --git a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean index 605a6910b..c5084a40e 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean @@ -388,8 +388,7 @@ lemma distTimeDeriv_apply' {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : (distTimeDeriv f) ε = -f (SchwartzMap.evalCLM ℝ (Time × Space d) ℝ (1, 0) - ((fderivCLM ℝ (Time × Space d) ℝ) ε)) := by - rw [distTimeDeriv_apply, fderivD_apply] + ((fderivCLM ℝ (Time × Space d) ℝ) ε)) := by rw [distTimeDeriv_apply, fderivD_apply] lemma apply_fderiv_eq_distTimeDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : @@ -435,8 +434,7 @@ lemma distSpaceDeriv_apply' {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (i : Fin d) (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : (distSpaceDeriv i f) ε = - f ((SchwartzMap.evalCLM ℝ (Time × Space d) ℝ (0, basis i)) - ((fderivCLM ℝ (Time × Space d) ℝ) ε)) := by - rw [distSpaceDeriv_apply, fderivD_apply] + ((fderivCLM ℝ (Time × Space d) ℝ) ε)) := by rw [distSpaceDeriv_apply, fderivD_apply] lemma apply_fderiv_eq_distSpaceDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (i : Fin d) (f : (Time × Space d) →d[ℝ] M) (ε : 𝓢(Time × Space d, ℝ)) : From 18c3271c05354c6e35854ed534e7d1064b927471 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:32:08 -0700 Subject: [PATCH 455/498] refactor: golf nonsingular hermitian wrappers Co-authored-by: Claude Opus 4.8 --- .../ForMathlib/HermitianMat/NonSingular.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean index d8213a60f..175ed0757 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/NonSingular.lean @@ -161,22 +161,17 @@ theorem nonSingular_empty [IsEmpty n] : NonSingular A := by variable [NonSingular A] [NonSingular B] -theorem nonSingular_det_ne_zero : A.mat.det ≠ 0 := by - rwa [← nonSingular_iff_det_ne_zero] +theorem nonSingular_det_ne_zero : A.mat.det ≠ 0 := by rwa [← nonSingular_iff_det_ne_zero] @[simp] -theorem nonSingular_ker_bot : A.ker = ⊥ := by - rwa [← nonSingular_iff_ker_bot] +theorem nonSingular_ker_bot : A.ker = ⊥ := by rwa [← nonSingular_iff_ker_bot] @[simp] -theorem nonSingular_support_top : A.support = ⊤ := by - rwa [← nonSingular_iff_support_top] +theorem nonSingular_support_top : A.support = ⊤ := by rwa [← nonSingular_iff_support_top] -instance nonSingular_neg : NonSingular (-A) := by - rwa [nonSingular_iff_neg] +instance nonSingular_neg : NonSingular (-A) := by rwa [nonSingular_iff_neg] -instance nonSingular_inv : NonSingular (A⁻¹) := by - rwa [nonSingular_iff_inv] +instance nonSingular_inv : NonSingular (A⁻¹) := by rwa [nonSingular_iff_inv] instance nonSingular_kron [Nonempty n] [Nonempty m] : NonSingular (A ⊗ₖ B) := nonSingular_iff_kronecker.mpr ⟨inferInstance, inferInstance⟩ From 6f927a4b86fad718b39dced87535dba8168869f6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:34:30 -0700 Subject: [PATCH 456/498] refactor: golf unitary and hermitian wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/Inner.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean | 3 +-- QuantumInfo/ForMathlib/Unitary.lean | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean index 0374563dc..d30f0d640 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Inner.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Inner.lean @@ -133,8 +133,7 @@ theorem inner_eq_trace_mul : algebraMap R α ⟪A, B⟫_R = (A.mat * B.mat).trac rw [Finset.sum_comm] congr! <;> apply congrFun₂ (H _) -theorem inner_comm : ⟪A, B⟫_R = ⟪B, A⟫_R := by - rw [inner_def, inner_def, Matrix.trace_mul_comm] +theorem inner_comm : ⟪A, B⟫_R = ⟪B, A⟫_R := by rw [inner_def, inner_def, Matrix.trace_mul_comm] end commring diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 88799af92..907001349 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -34,8 +34,7 @@ omit [Fintype n] in theorem le_iff : A ≤ B ↔ (B - A).mat.PosSemidef := Iff.rfl omit [Fintype n] in -theorem zero_le_iff : 0 ≤ A ↔ A.mat.PosSemidef := by - rw [le_iff, sub_zero] +theorem zero_le_iff : 0 ≤ A ↔ A.mat.PosSemidef := by rw [le_iff, sub_zero] theorem le_iff_mulVec_le : A ≤ B ↔ ∀ x, star x ⬝ᵥ A.mat *ᵥ x ≤ star x ⬝ᵥ B.mat *ᵥ x := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean b/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean index 5200976b4..776d0d4ea 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Sqrt.lean @@ -29,8 +29,7 @@ theorem sqrt_sq_eq_proj (A : HermitianMat d 𝕜) : grind [Pi.mul_apply, Real.mul_self_sqrt, Real.sqrt_eq_zero'] theorem sqrt_sq (hA : 0 ≤ A) : - A.sqrt.mat * A.sqrt.mat = A := by - rw [sqrt_sq_eq_proj, posPart_eq_self hA] + A.sqrt.mat * A.sqrt.mat = A := by rw [sqrt_sq_eq_proj, posPart_eq_self hA] @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem commute_sqrt_left (hAB : Commute A.mat B.mat) : diff --git a/QuantumInfo/ForMathlib/Unitary.lean b/QuantumInfo/ForMathlib/Unitary.lean index 5b09a3d5b..58e3f84bd 100644 --- a/QuantumInfo/ForMathlib/Unitary.lean +++ b/QuantumInfo/ForMathlib/Unitary.lean @@ -25,13 +25,11 @@ open Module.End @[simp] theorem unitary_star_apply_eq (U : unitary (E →ₗ[𝕜] E)) (v : E) : - (star U.val) (U.val v) = v := by - rw [← mul_apply, (Unitary.mem_iff.mp U.prop).left, one_apply] + (star U.val) (U.val v) = v := by rw [← mul_apply, (Unitary.mem_iff.mp U.prop).left, one_apply] @[simp] theorem unitary_apply_star_eq (U : unitary (E →ₗ[𝕜] E)) (v : E) : - U.val ((star U.val) v) = v := by - rw [← mul_apply, (Unitary.mem_iff.mp U.prop).right, one_apply] + U.val ((star U.val) v) = v := by rw [← mul_apply, (Unitary.mem_iff.mp U.prop).right, one_apply] /-- Conjugating a linear map by a unitary operator gives a map whose μ-eigenspace is isomorphic (same dimension) as those of the original linear map. -/ From f256ca8a001263a2cdfff0cd4814c6d6dd7fc26c Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:37:13 -0700 Subject: [PATCH 457/498] refactor: golf hermitian power helpers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 12 ++++-------- QuantumInfo/ForMathlib/HermitianMat/Schatten.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 51f60edf9..c75b4d5ae 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -191,8 +191,7 @@ lemma rpow_inv_eq_neg_rpow (hA : A.mat.PosDef) (p : ℝ) : (A ^ p)⁻¹ = A ^ (- rw [ h_inv, cfc_const ] ; norm_num; exact h_inv; -- By definition of matrix inverse, if $(A^p) * (A^{-p}) = 1$, then $(A^{-p})$ is the inverse of $(A^p)$. - have h_inv_def : (A ^ p).mat⁻¹ = (A ^ (-p)).mat := by - exact Matrix.inv_eq_right_inv h_inv; + have h_inv_def : (A ^ p).mat⁻¹ = (A ^ (-p)).mat := Matrix.inv_eq_right_inv h_inv convert! congr_fun ( congr_fun h_inv_def i ) j using 1 open ComplexOrder in @@ -226,8 +225,7 @@ lemma isUnit_rpow_toMat (hA : A.mat.PosDef) (p : ℝ) : IsUnit (A ^ p).mat := by exact IsUnit.of_mul_eq_one _ hA_inv -- Since $(A^{-p}) (A^p) = 1$, we have that $(A^p)$ is the inverse of $(A^{-p})$. have hA_inv : (A ^ p).mat = (A ^ (-p)).mat⁻¹ := by - have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := by - exact rpow_neg_mul_rpow_self hA p; + have hA_inv : (A ^ (-p)).mat * (A ^ p).mat = 1 := rpow_neg_mul_rpow_self hA p exact Eq.symm (Matrix.inv_eq_right_inv hA_inv); aesop @@ -600,8 +598,7 @@ theorem rpow_le_rpow_of_posDef (hA : A.mat.PosDef) (hAB : A ≤ B) convert le_of_tendsto_of_tendsto ( tendsto_rpowApprox hA hq ( lt_of_le_of_ne hq1 hq_eq_one ) ) ( tendsto_rpowApprox ( posDef_of_posDef_le hA hAB ) hq ( lt_of_le_of_ne hq1 hq_eq_one ) ) _ using 1 generalize_proofs at *; ( filter_upwards [ Filter.eventually_gt_atTop 0 ] with T hT using rpowApprox_mono hA ( posDef_of_posDef_le hA hAB ) hAB hq.le T hT |> le_trans <| by aesop;); - have h_rpow_pos : 0 < rpowConst q := by - exact rpowConst_pos hq ( lt_of_le_of_ne hq1 hq_eq_one ); + have h_rpow_pos : 0 < rpowConst q := rpowConst_pos hq ( lt_of_le_of_ne hq1 hq_eq_one ) simp_all open ComplexOrder Filter in @@ -631,8 +628,7 @@ theorem rpow_le_rpow_of_le (hA : 0 ≤ A) (hAB : A ≤ B) have h_pos_def_Bε : (Bε ε).mat.PosDef := by convert posDef_of_posDef_le h_pos_def_Aε _ using 1 exact add_le_add_left hAB _ |> le_trans ( by simp [ Aε ] ) ; - have h_le_Aε_Bε : Aε ε ≤ Bε ε := by - exact add_le_add_left hAB _ |> le_trans <| by simp [ Bε ] ; + have h_le_Aε_Bε : Aε ε ≤ Bε ε := add_le_add_left hAB _ |> le_trans <| by simp [ Bε ] exact ⟨h_pos_def_Aε, h_pos_def_Bε, h_le_Aε_Bε⟩ -- By the continuity of the function $M \mapsto M^q$, we have $(Aε ε)^q \to A^q$ and $(Bε ε)^q \to B^q$ as $\epsilon \to 0^+$. have h_cont : Filter.Tendsto (fun ε => (Aε ε) ^ q) (nhdsWithin 0 (Set.Ioi 0)) (nhds (A ^ q)) ∧ Filter.Tendsto (fun ε => (Bε ε) ^ q) (nhdsWithin 0 (Set.Ioi 0)) (nhds (B ^ q)) := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean index 678d6198f..18be6542d 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Schatten.lean @@ -61,8 +61,7 @@ lemma schattenNorm_pow_eq · rw [ mul_comm, ← HermitianMat.rpow_mul ]; exact hA; · -- Since $A$ is positive, $A^{k*p}$ is also positive, and the trace of a positive matrix is non-negative. - have h_pos : 0 ≤ A ^ (k * p) := by - exact HermitianMat.rpow_nonneg hA; + have h_pos : 0 ≤ A ^ (k * p) := HermitianMat.rpow_nonneg hA exact HermitianMat.trace_nonneg h_pos; · exact HermitianMat.rpow_nonneg hA From 50a49e0e0f9ef3c8c85b6fee8dc42527454ef1c9 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:39:06 -0700 Subject: [PATCH 458/498] refactor: golf hermitian cfc helpers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 12 ++++-------- QuantumInfo/ForMathlib/HermitianMat/Proj.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index 7b6572067..de2e08357 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -376,8 +376,7 @@ theorem Matrix.PosDef.spectrum_subset_Ioi {d 𝕜 : Type*} [Fintype d] [Decidabl {A : Matrix d d 𝕜} (hA : A.PosDef) : spectrum ℝ A ⊆ Set.Ioi 0 := by intro x hx; -- Since $A$ is positive definite, all its eigenvalues are positive. - have h_eigenvalues_pos : ∀ i : d, 0 < hA.1.eigenvalues i := by - exact hA.eigenvalues_pos; + have h_eigenvalues_pos : ∀ i : d, 0 < hA.1.eigenvalues i := hA.eigenvalues_pos have h_spectrum_eq_range : spectrum ℝ A = Set.range (hA.1.eigenvalues) := by exact Matrix.IsHermitian.spectrum_real_eq_range_eigenvalues hA.left; aesop @@ -448,8 +447,7 @@ lemma norm_cfc_sub_cfc_le_sqrt_card {A : HermitianMat d ℂ} {f g : ℝ → ℝ} · intro x hx apply le_csSup; · -- The supremum of a finite set of real numbers is finite. - have h_finite : Set.Finite (spectrum ℝ A.mat) := by - exact Set.toFinite _; + have h_finite : Set.Finite (spectrum ℝ A.mat) := Set.toFinite _ obtain ⟨ M, hM ⟩ := h_finite.exists_finset_coe; refine' ⟨ ∑ x ∈ M, ‖f x - g x‖, Set.forall_mem_range.2 fun x => _ ⟩; rw [ ← hM ]; @@ -1223,8 +1221,7 @@ theorem inv_ge_one_of_le_one (hA : A.mat.PosDef) (h : A ≤ 1) : 1 ≤ A⁻¹ := have h_cfc_nonneg : ∀ i, 0 ≤ (A.H.eigenvalues i)⁻¹ - 1 := by have h_pos : ∀ i, 0 < A.H.eigenvalues i ∧ A.H.eigenvalues i ≤ 1 := by -- Since $A$ is positive definite, all its eigenvalues are positive. - have h_pos : ∀ i, 0 < A.H.eigenvalues i := by - exact fun i => Matrix.PosDef.eigenvalues_pos hA i; + have h_pos : ∀ i, 0 < A.H.eigenvalues i := fun i => Matrix.PosDef.eigenvalues_pos hA i -- Since $A \leq 1$, for any eigenvalue $\lambda_i$ of $A$, we have $\lambda_i \leq 1$. have h_le_one : ∀ i, A.H.eigenvalues i ≤ 1 := by have h_le_one : ∀ i, A.H.eigenvalues i ≤ 1 := by @@ -1382,8 +1379,7 @@ lemma ker_le_ker_cfc_on_set (hs : spectrum ℝ A.mat ⊆ s) (h : ∀ i ∈ s, i intro x hx have h_inner_zero : ∀ i, A.H.eigenvalues i ≠ 0 → inner ℂ (A.H.eigenvectorBasis i) x = 0 := by intro i hi - have h_inner_zero : A.mat.mulVec x = 0 := by - exact (mem_ker_iff_mulVec_zero A x).mp hx; + have h_inner_zero : A.mat.mulVec x = 0 := (mem_ker_iff_mulVec_zero A x).mp hx have := mulVec_eq_zero_iff_inner_eigenvector_zero A x; aesop; have h_mulVec_zero : (A.cfc f).mat.mulVec x = ∑ i, (f (A.H.eigenvalues i) : ℂ) • inner ℂ (A.H.eigenvectorBasis i) x • A.H.eigenvectorBasis i := by convert cfc_mulVec_expansion A f x using 1; diff --git a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean index 03a3d2388..08a367255 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Proj.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Proj.lean @@ -441,8 +441,7 @@ theorem negPart_Continuous : Continuous (·⁻ : HermitianMat n ℂ → _) := by -- variable {d : Type*} [Fintype d] [DecidableEq d] (A B : HermitianMat d ℂ) -theorem one_sub_projLT : 1 - {B ≤ₚ A} = {A <ₚ B} := by - rw [sub_eq_iff_eq_add, proj_le_add_lt] +theorem one_sub_projLT : 1 - {B ≤ₚ A} = {A <ₚ B} := by rw [sub_eq_iff_eq_add, proj_le_add_lt] open MatrixOrder ComplexOrder in theorem projLT_mul_nonneg : 0 ≤ {A <ₚ B}.mat * (B - A).mat := by From a2da45f12e7acc89c1c4653fcfa38f56596d5f5e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:43:33 -0700 Subject: [PATCH 459/498] refactor: golf finite and norm helper proofs Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean | 3 +-- QuantumInfo/ForMathlib/LimSupInf.lean | 3 +-- QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean | 3 +-- QuantumInfo/ForMathlib/Misc.lean | 6 ++---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean index 9a6bbbe6c..6cc9c6a49 100644 --- a/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean +++ b/QuantumInfo/ForMathlib/ComplexLaplaceTransform.lean @@ -139,8 +139,7 @@ theorem measurable_complexLaplaceIntegrand have hUntop : y.untop hy = e := by apply WithTop.coe_inj.mp rw [WithTop.coe_untop, ← he] - have hUntopD : y.untopD 0 = e := by - exact he ▸ rfl + have hUntopD : y.untopD 0 = e := he ▸ rfl rw [hUntop, hUntopD]] exact Measurable.ite (hE (measurableSet_singleton (⊤ : WithTop ℝ))) measurable_const (Complex.continuous_exp.measurable.comp (by fun_prop : diff --git a/QuantumInfo/ForMathlib/LimSupInf.lean b/QuantumInfo/ForMathlib/LimSupInf.lean index 265e3555b..b0efa1f9d 100644 --- a/QuantumInfo/ForMathlib/LimSupInf.lean +++ b/QuantumInfo/ForMathlib/LimSupInf.lean @@ -397,8 +397,7 @@ lemma exists_liminf_zero_of_forall_liminf_limsup_le_with_UB (y₁ y₂ : ℝ≥0 · aesop · aesop obtain ⟨N0, hN0⟩ : ∃ N0 : ℕ → ℕ, ∀ k, ∀ n ≥ N0 k, f₂ (x k) n ≤ y₂ + (k + 1 : ℝ≥0)⁻¹ := by - have h_limsup : ∀ k, Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := by - exact fun k => hf₂ _ ( hx.1 k ); + have h_limsup : ∀ k, Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := fun k => hf₂ _ ( hx.1 k ) have h_limsup_le : ∀ k, ∀ ε > 0, ∃ N, ∀ n ≥ N, f₂ (x k) n ≤ y₂ + ε := by intro k ε hε_pos have h_limsup_le : Filter.limsup (f₂ (x k)) Filter.atTop ≤ y₂ := h_limsup k; diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index 18ffea7d0..476801f0e 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -324,8 +324,7 @@ theorem traceNorm_mul_le_opNorm_traceNorm [DecidableEq n] (A B : Matrix n n ℂ) exact mul_le_mul_of_nonneg_right (hA_bound i) (singularValuesSorted_nonneg B i) _ = ‖A‖ * ∑ i : Fin (Fintype.card n), singularValuesSorted B i := by rw [Finset.mul_sum] - _ = ‖A‖ * B.traceNorm := by - rw [traceNorm_eq_sum_singularValuesSorted] + _ = ‖A‖ * B.traceNorm := by rw [traceNorm_eq_sum_singularValuesSorted] omit [DecidableEq n] in /-- The trace norm is invariant under conjugate transpose. -/ diff --git a/QuantumInfo/ForMathlib/Misc.lean b/QuantumInfo/ForMathlib/Misc.lean index 0e6dd5b76..4faae5a2c 100644 --- a/QuantumInfo/ForMathlib/Misc.lean +++ b/QuantumInfo/ForMathlib/Misc.lean @@ -169,8 +169,7 @@ lemma exists_equiv_of_multiset_map_eq {α β γ : Type*} [Fintype α] [Fintype ∃ e : α ≃ β, f = g ∘ e := by -- Since the multisets of values are equal, the cardinalities of the domains must be equal (as the multiset size is the cardinality of the domain). Thus there exists a bijection `σ : α ≃ β`. obtain ⟨σ, hσ⟩ : ∃ σ : α ≃ β, Multiset.map f Finset.univ.val = Multiset.map (g ∘ σ) Finset.univ.val := by - have h_card : Fintype.card α = Fintype.card β := by - simpa using congr_arg Multiset.card h; + have h_card : Fintype.card α = Fintype.card β := by simpa using congr_arg Multiset.card h obtain σ := Fintype.equivOfCardEq h_card use σ have h_multiset_eq : Multiset.map g Finset.univ.val = Multiset.map (g ∘ σ) Finset.univ.val := by @@ -178,6 +177,5 @@ lemma exists_equiv_of_multiset_map_eq {α β γ : Type*} [Fintype α] [Fintype rw [ Multiset.map_map ] exact h.trans h_multiset_eq; -- By `Multiset.map_univ_eq_iff`, there exists `e' : α ≃ α` such that `f = (g ∘ σ) ∘ e'`. - obtain ⟨e', he'⟩ : ∃ e' : α ≃ α, f = (g ∘ σ) ∘ e' := by - exact (Multiset.map_univ_eq_iff f (g ∘ ⇑σ)).mp hσ; + obtain ⟨e', he'⟩ : ∃ e' : α ≃ α, f = (g ∘ σ) ∘ e' := (Multiset.map_univ_eq_iff f (g ∘ ⇑σ)).mp hσ exact ⟨ e'.trans σ, by simp_all [ Function.comp ]; grind⟩ From 892c0862171972561758fa221c7d988f5a666739 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:46:54 -0700 Subject: [PATCH 460/498] refactor: golf short proof wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean | 3 +-- Physlib/Mathematics/Calculus/Wirtinger/Basic.lean | 3 +-- .../QuantumMechanics/DDimensions/Operators/Uncertainty.lean | 6 ++---- Physlib/Relativity/SL2C/SelfAdjoint.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index b078f2593..6ee5ee999 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -417,8 +417,7 @@ lemma gradient_const_mul_inner_self (c : ℝ) (x : EuclideanSpace ℝ (Fin 1)) : rw [fderiv_const_mul]; fun_prop _ = c • gradient (fun y : EuclideanSpace ℝ (Fin 1) => ⟪y, y⟫_ℝ) x := by simp only [gradient, map_smul] - _ = c • ((2 : ℝ) • x) := by - rw [gradient_inner_self] + _ = c • ((2 : ℝ) • x) := by rw [gradient_inner_self] _ = (2 * c) • x := by rw [smul_smul, mul_comm] /-! diff --git a/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean b/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean index d6dbfaaef..5ba498cf9 100644 --- a/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean +++ b/Physlib/Mathematics/Calculus/Wirtinger/Basic.lean @@ -394,8 +394,7 @@ lemma realLinear_apply_eq_wirtinger (L : ℂ →L[ℝ] ℂ) (w : ℂ) : calc L w = L ((w.re : ℝ) • (1 : ℂ) + (w.im : ℝ) • Complex.I) := by congr 1; apply Complex.ext <;> simp - _ = (w.re : ℝ) • L 1 + (w.im : ℝ) • L Complex.I := by - rw [map_add, map_smul, map_smul] + _ = (w.re : ℝ) • L 1 + (w.im : ℝ) • L Complex.I := by rw [map_add, map_smul, map_smul] _ = ((1 / 2 : ℂ) * (L 1 - Complex.I * L Complex.I)) * w + ((1 / 2 : ℂ) * (L 1 + Complex.I * L Complex.I)) * star w := by apply Complex.ext <;> diff --git a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean index 090c4f3f3..aad85eae0 100644 --- a/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean +++ b/Physlib/QuantumMechanics/DDimensions/Operators/Uncertainty.lean @@ -121,10 +121,8 @@ lemma raw_commutator_eq_of_symmetric calc ⟪A ψ, B ⟨ψ, hψB⟩⟫_ℂ - ⟪B ⟨ψ, hψB⟩, A ψ⟫_ℂ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩⟫_ℂ - - ⟪(ψ : H), B ⟨A ψ, hBA⟩⟫_ℂ := by - rw [ha_pairing, hb_pairing] - _ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩ - B ⟨A ψ, hBA⟩⟫_ℂ := by - rw [inner_sub_right] + ⟪(ψ : H), B ⟨A ψ, hBA⟩⟫_ℂ := by rw [ha_pairing, hb_pairing] + _ = ⟪(ψ : H), A ⟨B ⟨ψ, hψB⟩, hAB⟩ - B ⟨A ψ, hBA⟩⟫_ℂ := by rw [inner_sub_right] _ = Complex.I * c := h_raw /-- The scalar commutator of the centered vectors of `A` and `B` in the state `ψ`. -/ diff --git a/Physlib/Relativity/SL2C/SelfAdjoint.lean b/Physlib/Relativity/SL2C/SelfAdjoint.lean index d8e873171..1290658d7 100644 --- a/Physlib/Relativity/SL2C/SelfAdjoint.lean +++ b/Physlib/Relativity/SL2C/SelfAdjoint.lean @@ -122,8 +122,7 @@ lemma toSelfAdjointMap_det_one' {M : ℂ²ˣ²} (hM : M.IsUpperTriangular) (detM have he' : Mᴴ = !![conj x, 0; _, conj y] := Matrix.ext fun | 0, 0 | 1, 0 | 1, 1 => rfl | 0, 1 => by simp [hM10] have hxy : x * y = 1 := by rw [show x * y = M.det by rw [he]; simp, detM] - have detA_one : normSq x * normSq y = 1 := by - rw [← Complex.normSq_mul, hxy, Complex.normSq_one] + have detA_one : normSq x * normSq y = 1 := by rw [← Complex.normSq_mul, hxy, Complex.normSq_one] have detD_one : D.det = 1 := let z := x * conj y have k₀ : (M * E₂ * Mᴴ) 0 1 = z := by rw [he', he]; simp [E₂, z] From 0ee67b724e3ad993ea1a76aec11d3105256983df Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:52:39 -0700 Subject: [PATCH 461/498] refactor: golf oscillator and ensemble wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean | 6 ++---- Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean | 6 ++---- Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index 9658d400a..49b3271ca 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -998,8 +998,7 @@ lemma trajectory_velocity_eq_zero_iff_exists_int (IC : InitialConditions) linarith calc (t : ℝ) = (S.ω * t) / S.ω := by field_simp [hω] - _ = ((AmplitudePhase.fromInitialConditions S IC).φ + n * π) / S.ω := by - rw [ht] + _ = ((AmplitudePhase.fromInitialConditions S IC).φ + n * π) / S.ω := by rw [ht] · intro h obtain ⟨n, hn⟩ := h rw [Real.sin_eq_zero_iff] @@ -1115,8 +1114,7 @@ lemma trajectory_eq_zero_iff_exists_int (IC : InitialConditions) linarith calc (t : ℝ) = (S.ω * t) / S.ω := by field_simp [hω] - _ = ((AmplitudePhase.fromInitialConditions S IC).φ + (2 * n + 1) * π / 2) / S.ω := by - rw [ht] + _ = ((AmplitudePhase.fromInitialConditions S IC).φ + (2 * n + 1) * π / 2) / S.ω := by rw [ht] · intro h obtain ⟨n, hn⟩ := h rw [Real.cos_eq_zero_iff] diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 7892bf305..19772337d 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -858,8 +858,7 @@ lemma helmholtzFreeEnergy_add calc (𝓒 + 𝓒1).helmholtzFreeEnergy T = -kB * T.val * Real.log ((𝓒 + 𝓒1).partitionFunction T) := rfl - _ = -kB * T.val * Real.log (𝓒.partitionFunction T * 𝓒1.partitionFunction T) := by - rw [hPF] + _ = -kB * T.val * Real.log (𝓒.partitionFunction T * 𝓒1.partitionFunction T) := by rw [hPF] _ = -kB * T.val * (Real.log (𝓒.partitionFunction T) + Real.log (𝓒1.partitionFunction T)) := by rw [Real.log_mul hpf₁.ne' hpf₂.ne'] @@ -881,8 +880,7 @@ lemma helmholtzFreeEnergy_nsmul calc (nsmul n 𝓒).helmholtzFreeEnergy T = -kB * T.val * Real.log ((nsmul n 𝓒).partitionFunction T) := rfl - _ = -kB * T.val * ((n : ℝ) * Real.log (𝓒.partitionFunction T)) := by - rw [hlog] + _ = -kB * T.val * ((n : ℝ) * Real.log (𝓒.partitionFunction T)) := by rw [hlog] _ = (n : ℝ) * (-kB * T.val * Real.log (𝓒.partitionFunction T)) := by ring _ = n * 𝓒.helmholtzFreeEnergy T := by simp [helmholtzFreeEnergy, mul_comm, mul_left_comm, mul_assoc] diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index 81e163e82..649da8926 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -246,8 +246,7 @@ theorem helmholtzFreeEnergy_eq_meanEnergy_sub_temp_mul_thermodynamicEntropy have hZpos := 𝓒.mathematicalPartitionFunction_pos T have hhpos : 0 < 𝓒.phaseSpaceunit ^ 𝓒.dof := pow_pos 𝓒.hPos _ have hTne : (T.val : ℝ) ≠ 0 := by exact_mod_cast hT.ne' - have hkβT : T.val * (kB * (T.β : ℝ)) = 1 := by - rw [kB_mul_beta T hT, mul_one_div, div_self hTne] + have hkβT : T.val * (kB * (T.β : ℝ)) = 1 := by rw [kB_mul_beta T hT, mul_one_div, div_self hTne] rw [helmholtzFreeEnergy_def, partitionFunction_def, Real.log_div hZpos.ne' hhpos.ne', Real.log_pow, 𝓒.thermodynamicEntropy_eq_differentialEntropy_sub_correction (T := T) hE, 𝓒.differentialEntropy_eq_kB_beta_meanEnergy_add_kB_log_mathZ (T := T) hE] From 0ffe7ee71ba89dd1142237059db6129c72432a35 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:54:38 -0700 Subject: [PATCH 462/498] refactor: golf space and matrix wrappers Co-authored-by: Claude Opus 4.8 --- .../Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean | 3 +-- .../CKMMatrix/StandardParameterization/StandardParameters.lean | 3 +-- Physlib/SpaceAndTime/Space/Integrals/NormPow.lean | 3 +-- Physlib/SpaceAndTime/Space/Norm/Basic.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean b/Physlib/Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean index f6ac0b23a..6623c009b 100644 --- a/Physlib/Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean +++ b/Physlib/Particles/BeyondTheStandardModel/TwoHDM/GramMatrix.lean @@ -181,8 +181,7 @@ lemma mem_orbit_gaugeGroupI_iff_gramMatrix (H1 H2 : TwoHiggsDoublet) : obtain ⟨g1, H1_Φ1, H1_Φ2⟩ := gaugeGroupI_exists_fst_eq_snd_eq (H := H1) Φ1_zero have Φ2_nezero : H2.Φ1 ≠ 0 := by intro hzero - have hnorm : ‖H1.Φ1‖ = ‖H2.Φ1‖ := by - rw [← eq_fst_norm_of_eq_gramMatrix h] + have hnorm : ‖H1.Φ1‖ = ‖H2.Φ1‖ := by rw [← eq_fst_norm_of_eq_gramMatrix h] simp [hzero] at hnorm simp [hnorm] at Φ1_zero obtain ⟨g2, H2_Φ1, H2_Φ2⟩ := gaugeGroupI_exists_fst_eq_snd_eq (H := H2) Φ2_nezero diff --git a/Physlib/Particles/FlavorPhysics/CKMMatrix/StandardParameterization/StandardParameters.lean b/Physlib/Particles/FlavorPhysics/CKMMatrix/StandardParameterization/StandardParameters.lean index deda0b3cc..6f7d04085 100644 --- a/Physlib/Particles/FlavorPhysics/CKMMatrix/StandardParameterization/StandardParameters.lean +++ b/Physlib/Particles/FlavorPhysics/CKMMatrix/StandardParameterization/StandardParameters.lean @@ -537,8 +537,7 @@ lemma eq_standParam_of_ubOnePhaseCond {V : CKMMatrix} (hV : ubOnePhaseCond V) : rw [C₁₂_eq_ℂcos_θ₁₂ ⟦V⟧, C₁₂_of_Vub_one h1] rw [S₁₃_eq_ℂsin_θ₁₃ ⟦V⟧, S₁₃_of_Vub_one h1] simp only [Fin.isValue, ofReal_one, one_mul, ofReal_zero, mul_one, VcdAbs, zero_mul, sub_zero] - have h3 : (Real.cos (θ₂₃ ⟦V⟧) : ℂ) = √(1 - S₂₃ ⟦V⟧ ^ 2) := by - rw [θ₂₃, Real.cos_arcsin] + have h3 : (Real.cos (θ₂₃ ⟦V⟧) : ℂ) = √(1 - S₂₃ ⟦V⟧ ^ 2) := by rw [θ₂₃, Real.cos_arcsin] simp only [ofReal_cos] at h3 rw [h3, S₂₃_of_Vub_eq_one h1, hV.2.2.2.2.2.2] · simp only [cRow, Fin.isValue, Fin.reduceFinMk, cons_val_two, Nat.succ_eq_add_one, diff --git a/Physlib/SpaceAndTime/Space/Integrals/NormPow.lean b/Physlib/SpaceAndTime/Space/Integrals/NormPow.lean index d53edf9bd..7fa4215f5 100644 --- a/Physlib/SpaceAndTime/Space/Integrals/NormPow.lean +++ b/Physlib/SpaceAndTime/Space/Integrals/NormPow.lean @@ -60,8 +60,7 @@ lemma radial_jacobian_zpow_mul_self r ^ (d - 1) * (r ^ q * r) = r ^ (d - 1: ℤ) * (r ^ q * r ^ (1 : ℤ)) := by rw [← zpow_natCast, zpow_one, ← Nat.cast_pred (Nat.pos_of_neZero d)] - _ = r ^ ((d - 1: ℤ) + (q + 1)) := by - rw [← zpow_add₀ hz q 1, ← zpow_add₀ hz (d - 1: ℤ) (q + 1)] + _ = r ^ ((d - 1: ℤ) + (q + 1)) := by rw [← zpow_add₀ hz q 1, ← zpow_add₀ hz (d - 1: ℤ) (q + 1)] _ = r ^ (p : ℤ) := by congr 1; omega _ = r ^ p := by rw [zpow_natCast] diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index 2fbf2e029..c0a5aa8a2 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -1112,8 +1112,7 @@ private lemma distDiv_norm_zpow_smul_repr_self_apply_eq_radial_deriv calc (∇ᵈ ⬝ (distOfFunction (fun x : Space d => ‖x‖ ^ q • basis.repr x) (IsDistBounded.zpow_smul_repr_self q (by omega)))) η - = - ∫ x, F x := by - rw [distDiv_ofFunction] + = - ∫ x, F x := by rw [distDiv_ofFunction] _ = - ∫ r, F (r.2.1 • r.1.1) ∂(volume (α := Space d).toSphere.prod (Measure.volumeIoiPow (Module.finrank ℝ (Space d) - 1))) := by diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index c75b4d5ae..6b3af2b89 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -875,8 +875,7 @@ private lemma compound_top_singular_le_posDef c ^ (2 * r) = c ^ (r + r) := by ring_nf _ = c ^ r * c ^ r := by rw [Real.rpow_add hc_pos] _ = (c ^ r) ^ 2 := by ring - have hinv : (c⁻¹) ^ r = (c ^ r)⁻¹ := by - rw [Real.inv_rpow hc_nonneg] + have hinv : (c⁻¹) ^ r = (c ^ r)⁻¹ := by rw [Real.inv_rpow hc_nonneg] calc c ^ (2 * r) * ((c⁻¹) ^ r) ^ 2 = (c ^ r) ^ 2 * ((c ^ r)⁻¹) ^ 2 := by rw [hpow, hinv] From aee2afde8dfc11290db7ca61ee6a4f8126fec7b5 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 13:56:30 -0700 Subject: [PATCH 463/498] refactor: golf hermitian norm wrappers Co-authored-by: Claude Opus 4.8 --- QuantumInfo/ForMathlib/HermitianMat/Order.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 9 +++------ QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/QuantumInfo/ForMathlib/HermitianMat/Order.lean b/QuantumInfo/ForMathlib/HermitianMat/Order.lean index 907001349..12e1d4a03 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Order.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Order.lean @@ -130,8 +130,7 @@ theorem kronecker_self_mono (hA : 0 ≤ A) (hB : 0 ≤ B) (hAB : A ≤ B) : (HermitianMat.kronecker_add (A := A) (B := B) (C := -A)).symm have hEq : B ⊗ₖ B - A ⊗ₖ A = A ⊗ₖ (B - A) + (B - A) ⊗ₖ B := by calc - B ⊗ₖ B - A ⊗ₖ A = (A + (B - A)) ⊗ₖ B - A ⊗ₖ A := by - rw [show A + (B - A) = B by abel] + B ⊗ₖ B - A ⊗ₖ A = (A + (B - A)) ⊗ₖ B - A ⊗ₖ A := by rw [show A + (B - A) = B by abel] _ = (A ⊗ₖ B + (B - A) ⊗ₖ B) - A ⊗ₖ A := by rw [HermitianMat.add_kronecker] _ = (A ⊗ₖ B + -(A ⊗ₖ A)) + (B - A) ⊗ₖ B := by abel _ = A ⊗ₖ (B - A) + (B - A) ⊗ₖ B := by rw [hAC] diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 6b3af2b89..277a6c48e 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -164,8 +164,7 @@ theorem sandwich_self (hB : B.mat.PosDef) : have hB_inv_sqrt : (B ^ (-1 / 2 : ℝ)).mat * (B ^ (-1 / 2 : ℝ)).mat = (B ^ (-1 : ℝ)).mat := by rw [ ← mat_rpow_add ] <;> norm_num simpa [zero_le_iff] using hB.posSemidef - have hB_inv : (B ^ (-1 : ℝ)).mat = B.mat⁻¹ := by - rw [← inv_eq_rpow_neg_one hB, mat_inv] + have hB_inv : (B ^ (-1 : ℝ)).mat = B.mat⁻¹ := by rw [← inv_eq_rpow_neg_one hB, mat_inv] rw [ hB_inv ] at hB_inv_sqrt; ext1 simp [mul_assoc]; @@ -863,8 +862,7 @@ private lemma compound_top_singular_le_posDef apply HermitianMat.cfc_congr_of_nonneg (zero_le_iff.mpr hBk.posSemidef) intro x hx rw [Function.comp_apply, Real.mul_rpow (inv_nonneg.mpr hc_nonneg) hx] - _ = (c⁻¹) ^ r • (Bk ^ r) := by - rw [HermitianMat.cfc_const_mul, HermitianMat.rpow_eq_cfc] + _ = (c⁻¹) ^ r • (Bk ^ r) := by rw [HermitianMat.cfc_const_mul, HermitianMat.rpow_eq_cfc] rwa [hBk_scale, conj_smul_right] at hpow have hNk_le : ((Ak ^ r).conj (Bk ^ r).mat) ≤ c ^ (2 * r) • 1 := by have hmul := smul_le_smul_of_nonneg_left hpow' (show 0 ≤ c ^ (2 * r) by positivity) @@ -877,8 +875,7 @@ private lemma compound_top_singular_le_posDef _ = (c ^ r) ^ 2 := by ring have hinv : (c⁻¹) ^ r = (c ^ r)⁻¹ := by rw [Real.inv_rpow hc_nonneg] calc - c ^ (2 * r) * ((c⁻¹) ^ r) ^ 2 = (c ^ r) ^ 2 * ((c ^ r)⁻¹) ^ 2 := by - rw [hpow, hinv] + c ^ (2 * r) * ((c⁻¹) ^ r) ^ 2 = (c ^ r) ^ 2 * ((c ^ r)⁻¹) ^ 2 := by rw [hpow, hinv] _ = 1 := by field_simp [pow_two, hcr_pos.ne'] rwa [smul_smul, hs, one_smul] at hmul diff --git a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean index 476801f0e..14d942279 100644 --- a/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean +++ b/QuantumInfo/ForMathlib/MatrixNorm/TraceNorm.lean @@ -322,8 +322,7 @@ theorem traceNorm_mul_le_opNorm_traceNorm [DecidableEq n] (A B : Matrix n n ℂ) refine Finset.sum_le_sum ?_ intro i hi exact mul_le_mul_of_nonneg_right (hA_bound i) (singularValuesSorted_nonneg B i) - _ = ‖A‖ * ∑ i : Fin (Fintype.card n), singularValuesSorted B i := by - rw [Finset.mul_sum] + _ = ‖A‖ * ∑ i : Fin (Fintype.card n), singularValuesSorted B i := by rw [Finset.mul_sum] _ = ‖A‖ * B.traceNorm := by rw [traceNorm_eq_sum_singularValuesSorted] omit [DecidableEq n] in From aabdb5476f65971705d776536832bdf32115d363 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:03:44 -0700 Subject: [PATCH 464/498] refactor: golf oscillator and anomaly wrappers Co-authored-by: Claude Opus 4.8 --- .../DampedHarmonicOscillator/Basic.lean | 9 +++------ .../QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 3 +-- QuantumInfo/ForMathlib/HermitianMat/Rpow.lean | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index cfe399866..87525281a 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -276,13 +276,11 @@ lemma isUnderdamped_of_gamma_eq_zero (hγ : S.γ = 0) : S.IsUnderdamped := by /-- An underdamped system has decay rate less than the natural frequency. -/ lemma isUnderdamped_decayRate (hS : S.IsUnderdamped) : S.decayRate < S.ω := by - rw [IsUnderdamped] at hS - rw [discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq] at hS + rw [IsUnderdamped, discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq] at hS have hm_sq_pos : 0 < 4 * S.m^2 := by have hsq : 0 < S.m^2 := sq_pos_of_pos S.m_pos nlinarith - have hsq : S.decayRate^2 < S.ω^2 := by - nlinarith + have hsq : S.decayRate^2 < S.ω^2 := by nlinarith nlinarith [S.decayRate_nonneg, S.ω_pos] /-- A critically damped system has decay rate equal to the natural frequency. -/ @@ -324,8 +322,7 @@ lemma isOverdamped_decayRate (hS : S.IsOverdamped) : S.ω < S.decayRate := by have hm_sq_pos : 0 < 4 * S.m^2 := by have hsq : 0 < S.m^2 := sq_pos_of_pos S.m_pos nlinarith - have hsq : S.ω^2 < S.decayRate^2 := by - nlinarith + have hsq : S.ω^2 < S.decayRate^2 := by nlinarith nlinarith [S.decayRate_nonneg, S.ω_pos] /-- In the underdamped regime, the selected frequency uses the oscillation frequency. -/ diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index ecae20095..a0ea79510 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -152,8 +152,7 @@ lemma sum_even (S : Fin (2 * n.succ) → ℚ) : -/ -lemma n_cond₂ (n : ℕ) : 1 + ((n + n) + 1) = 2 * n.succ := by - linarith +lemma n_cond₂ (n : ℕ) : 1 + ((n + n) + 1) = 2 * n.succ := by linarith /-- The inclusion of `Fin n` into `Fin (1 + (n + n + 1))` via the first `n`, casted into `Fin (2 * n.succ)`. -/ diff --git a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean index 277a6c48e..69b3c1179 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Rpow.lean @@ -876,8 +876,7 @@ private lemma compound_top_singular_le_posDef have hinv : (c⁻¹) ^ r = (c ^ r)⁻¹ := by rw [Real.inv_rpow hc_nonneg] calc c ^ (2 * r) * ((c⁻¹) ^ r) ^ 2 = (c ^ r) ^ 2 * ((c ^ r)⁻¹) ^ 2 := by rw [hpow, hinv] - _ = 1 := by - field_simp [pow_two, hcr_pos.ne'] + _ = 1 := by field_simp [pow_two, hcr_pos.ne'] rwa [smul_smul, hs, one_smul] at hmul have htop : singularValuesSorted Nk (compoundZero k hk) ≤ Real.sqrt (c ^ (2 * r)) := top_singular_le_of_self_mul_le_smul_one Nk From ba437dc316ff1ebfabddef3e3e5b04c4800320ec Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:06:05 -0700 Subject: [PATCH 465/498] refactor: golf damped oscillator rewrites Co-authored-by: Claude Opus 4.8 --- .../DampedHarmonicOscillator/Basic.lean | 9 +++------ .../DampedHarmonicOscillator/Solution.lean | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean index 87525281a..ab3513da1 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Basic.lean @@ -269,8 +269,7 @@ lemma decayRate_nonneg : 0 ≤ S.decayRate := by /-- An undamped oscillator lies in the underdamped regime. -/ lemma isUnderdamped_of_gamma_eq_zero (hγ : S.γ = 0) : S.IsUnderdamped := by - rw [IsUnderdamped, discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq S, decayRate] - rw [hγ] + rw [IsUnderdamped, discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq S, decayRate, hγ] ring_nf nlinarith [sq_pos_of_pos S.m_pos, sq_pos_of_pos S.ω_pos] @@ -285,8 +284,7 @@ lemma isUnderdamped_decayRate (hS : S.IsUnderdamped) : S.decayRate < S.ω := by /-- A critically damped system has decay rate equal to the natural frequency. -/ lemma isCriticallyDamped_decayRate (hS : S.IsCriticallyDamped) : S.ω = S.decayRate := by - rw [IsCriticallyDamped] at hS - rw [discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq] at hS + rw [IsCriticallyDamped, discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq] at hS have hm_sq_ne_zero : 4 * S.m^2 ≠ 0 := by have hm_sq_pos : 0 < 4 * S.m^2 := by have hsq : 0 < S.m^2 := sq_pos_of_pos S.m_pos @@ -317,8 +315,7 @@ lemma k_eq_m_mul_decayRate_sq_of_criticallyDamped (hS : S.IsCriticallyDamped) : /-- An overdamped system has decay rate greater than the natural frequency. -/ lemma isOverdamped_decayRate (hS : S.IsOverdamped) : S.ω < S.decayRate := by - rw [IsOverdamped] at hS - rw [discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq] at hS + rw [IsOverdamped, discriminant_eq_four_mul_m_sq_mul_decayRate_sq_sub_ω_sq] at hS have hm_sq_pos : 0 < 4 * S.m^2 := by have hsq : 0 < S.m^2 := sq_pos_of_pos S.m_pos nlinarith diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean index 96fbaccb1..fced048fb 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean @@ -178,8 +178,7 @@ private lemma exp_decay_smul_velocity ∂ₜ (fun t : Time => exp (-a * t.val) • y t) = fun t : Time => exp (-a * t.val) • (∂ₜ y t - a • y t) := by funext t - rw [Time.deriv] - rw [fderiv_fun_smul (by fun_prop) (hy t)] + rw [Time.deriv, fderiv_fun_smul (by fun_prop) (hy t)] rw [fderiv_exp (by fun_prop), fderiv_fun_mul (by fun_prop) (by fun_prop)] simp only [add_apply, ContinuousLinearMap.smulRight_apply, fderiv_fun_neg, fderiv_fun_const, Pi.zero_apply, Time.fderiv_val, @@ -197,8 +196,7 @@ private lemma exp_decay_smul_acceleration (μ • y t - (2 * a) • ∂ₜ y t + a^2 • y t) := by rw [exp_decay_smul_velocity a y hy] funext t - rw [Time.deriv] - rw [fderiv_fun_smul (by fun_prop) (by fun_prop)] + rw [Time.deriv, fderiv_fun_smul (by fun_prop) (by fun_prop)] rw [fderiv_exp (by fun_prop), fderiv_fun_mul (by fun_prop) (by fun_prop)] rw [fderiv_fun_sub (hdy t) (by fun_prop)] rw [fderiv_fun_const_smul (hy t)] From e69ae84a45920757af52fd6dc936e7224b999fd7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:07:45 -0700 Subject: [PATCH 466/498] refactor: golf oscillator derivative rewrites Co-authored-by: Claude Opus 4.8 --- .../DampedHarmonicOscillator/Solution.lean | 6 ++---- Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean index fced048fb..272254312 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean @@ -198,8 +198,7 @@ private lemma exp_decay_smul_acceleration funext t rw [Time.deriv, fderiv_fun_smul (by fun_prop) (by fun_prop)] rw [fderiv_exp (by fun_prop), fderiv_fun_mul (by fun_prop) (by fun_prop)] - rw [fderiv_fun_sub (hdy t) (by fun_prop)] - rw [fderiv_fun_const_smul (hy t)] + rw [fderiv_fun_sub (hdy t) (by fun_prop), fderiv_fun_const_smul (hy t)] have hy''_t := congrFun hy'' t rw [Time.deriv] at hy''_t simp only [add_apply, _root_.sub_apply, @@ -217,8 +216,7 @@ private lemma exp_decay_smul_equationOfMotion (hγ : S.γ = 2 * S.m * a) (hk : S.k = S.m * (a^2 - μ)) : S.EquationOfMotion (fun t : Time => exp (-a * t.val) • y t) := by intro t - rw [exp_decay_smul_acceleration a μ y hy hdy hy''] - rw [exp_decay_smul_velocity a y hy] + rw [exp_decay_smul_acceleration a μ y hy hdy hy'', exp_decay_smul_velocity a y hy] rw [hγ, hk] simp [smul_add, smul_sub, smul_smul] module diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index 6ee5ee999..5a122403a 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -262,8 +262,7 @@ lemma kineticEnergy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : Con unfold kineticEnergy conv_lhs => simp only [Time.deriv, one_div, ringHom_apply] change (fderiv ℝ ((fun x => 2⁻¹ * S.m * ⟪x, x⟫_ℝ) ∘ (fun t => ∂ₜ xₜ t)) t) 1 = _ - rw [fderiv_comp] - rw [fderiv_const_mul (by fun_prop)] + rw [fderiv_comp, fderiv_const_mul (by fun_prop)] simp only [ContinuousLinearMap.smul_comp, FunLike.coe_smul, ContinuousLinearMap.coe_comp, Pi.smul_apply, Function.comp_apply, smul_eq_mul] rw [fderiv_inner_apply] @@ -280,8 +279,7 @@ lemma potentialEnergy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : C unfold potentialEnergy conv_lhs => simp only [Time.deriv, one_div, smul_eq_mul] change (fderiv ℝ ((fun x => 2⁻¹ * (S.k * ⟪x, x⟫_ℝ)) ∘ (fun t => xₜ t)) t) 1 = _ - rw [fderiv_comp] - rw [fderiv_const_mul (by fun_prop), fderiv_const_mul (by fun_prop)] + rw [fderiv_comp, fderiv_const_mul (by fun_prop), fderiv_const_mul (by fun_prop)] simp only [ContinuousLinearMap.smul_comp, FunLike.coe_smul, ContinuousLinearMap.coe_comp, Pi.smul_apply, Function.comp_apply, smul_eq_mul] rw [fderiv_inner_apply] @@ -304,8 +302,7 @@ lemma energy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff rw [Time.deriv_eq] rw [fderiv_fun_add (by fun_prop) (by apply S.potentialEnergy_differentiable xₜ hx)] simp only [_root_.add_apply] - rw [← Time.deriv_eq, ← Time.deriv_eq] - rw [potentialEnergy_deriv, kineticEnergy_deriv] + rw [← Time.deriv_eq, ← Time.deriv_eq, potentialEnergy_deriv, kineticEnergy_deriv] simp only rw [← inner_add_right] fun_prop From 80ab7f400f061925d667c33a4ec631ebca92d43f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:09:33 -0700 Subject: [PATCH 467/498] refactor: golf classical rewrite sequences Co-authored-by: Claude Opus 4.8 --- .../ClassicalMechanics/DampedHarmonicOscillator/Solution.lean | 3 +-- Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean | 3 +-- Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean | 3 +-- Physlib/ClassicalMechanics/WaveEquation/Basic.lean | 3 +-- Physlib/ClassicalMechanics/WaveEquation/HarmonicWave.lean | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean index 272254312..31581a804 100644 --- a/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/DampedHarmonicOscillator/Solution.lean @@ -216,8 +216,7 @@ private lemma exp_decay_smul_equationOfMotion (hγ : S.γ = 2 * S.m * a) (hk : S.k = S.m * (a^2 - μ)) : S.EquationOfMotion (fun t : Time => exp (-a * t.val) • y t) := by intro t - rw [exp_decay_smul_acceleration a μ y hy hdy hy'', exp_decay_smul_velocity a y hy] - rw [hγ, hk] + rw [exp_decay_smul_acceleration a μ y hy hdy hy'', exp_decay_smul_velocity a y hy, hγ, hk] simp [smul_add, smul_sub, smul_smul] module diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean index 5a122403a..b4dc0d179 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Basic.lean @@ -299,8 +299,7 @@ lemma energy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ∂ₜ (energy S xₜ) = fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ := by unfold energy funext t - rw [Time.deriv_eq] - rw [fderiv_fun_add (by fun_prop) (by apply S.potentialEnergy_differentiable xₜ hx)] + rw [Time.deriv_eq, fderiv_fun_add (by fun_prop) (by apply S.potentialEnergy_differentiable xₜ hx)] simp only [_root_.add_apply] rw [← Time.deriv_eq, ← Time.deriv_eq, potentialEnergy_deriv, kineticEnergy_deriv] simp only diff --git a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean index 49b3271ca..ceded4b46 100644 --- a/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean +++ b/Physlib/ClassicalMechanics/HarmonicOscillator/Solution.lean @@ -1036,8 +1036,7 @@ lemma trajectory_velocity_eq_zero_iff_norm_eq_amplitude (IC : InitialConditions) ext i fin_cases i simp [hA] - rw [trajectory_velocity_eq_zero_iff_sin_eq_zero S IC hA t] - rw [trajectory_eq_cos] + rw [trajectory_velocity_eq_zero_iff_sin_eq_zero S IC hA t, trajectory_eq_cos] set A := (AmplitudePhase.fromInitialConditions S IC).A set θ := S.ω * t.val - (AmplitudePhase.fromInitialConditions S IC).φ show sin θ = 0 ↔ ‖EuclideanSpace.single 0 (A * cos θ)‖ = A diff --git a/Physlib/ClassicalMechanics/WaveEquation/Basic.lean b/Physlib/ClassicalMechanics/WaveEquation/Basic.lean index 38a2663ab..e58867685 100644 --- a/Physlib/ClassicalMechanics/WaveEquation/Basic.lean +++ b/Physlib/ClassicalMechanics/WaveEquation/Basic.lean @@ -179,8 +179,7 @@ lemma planeWave_space_deriv {d f₀ c} {s : Direction d} rw [fderiv_comp] simp only [ContinuousLinearMap.coe_comp, Function.comp_apply, fderiv_eq_smul_deriv, PiLp.smul_apply, smul_eq_mul, one_smul, Pi.smul_apply] - rw [fderiv_sub_const] - rw [fderiv_inner_apply] + rw [fderiv_sub_const, fderiv_inner_apply] simp only [fderiv_fun_const, Pi.zero_apply, _root_.zero_apply, inner_zero_right, fderiv_fun_id, ContinuousLinearMap.coe_id', id_eq, basis_inner, zero_add, mul_eq_mul_left_iff] left diff --git a/Physlib/ClassicalMechanics/WaveEquation/HarmonicWave.lean b/Physlib/ClassicalMechanics/WaveEquation/HarmonicWave.lean index 96b9f2719..faaa61b72 100644 --- a/Physlib/ClassicalMechanics/WaveEquation/HarmonicWave.lean +++ b/Physlib/ClassicalMechanics/WaveEquation/HarmonicWave.lean @@ -69,8 +69,7 @@ lemma transverseHarmonicPlaneWave_eq_planeWave {c : ℝ} {k : WaveVector} {f₀x have normk: ‖k‖ = ω/c := by rw [hk] simp [← abs_div, hc_ge_zero, hω_ge_zero, le_of_lt] - rw [normk] - rw [mul_sub, inner_smul_right, real_inner_comm, ← mul_assoc] + rw [normk, mul_sub, inner_smul_right, real_inner_comm, ← mul_assoc] ring_nf simp [ne_of_gt, hc_ge_zero, hω_ge_zero, mul_comm ω, mul_assoc, basis_repr_inner_eq] From 7ec0f2c5854ab9f01840ca2092573106b270659e Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:11:29 -0700 Subject: [PATCH 468/498] refactor: golf calculus rewrite sequences Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/Divergence.lean | 3 +-- Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean | 6 ++---- Physlib/Mathematics/FDerivCurry.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Calculus/Divergence.lean b/Physlib/Mathematics/Calculus/Divergence.lean index c7b410ac6..9c18cf0ee 100644 --- a/Physlib/Mathematics/Calculus/Divergence.lean +++ b/Physlib/Mathematics/Calculus/Divergence.lean @@ -77,8 +77,7 @@ lemma divergence_eq_space_div {d} (f : Space d → Space d) ext j simp only [Function.comp_apply] rw [Space.coordCLM_apply, Space.coord_apply] - rw [h1] - rw [fderiv_comp] + rw [h1, fderiv_comp] simp [Space.coordCLM_apply, Space.coord_apply] · fun_prop · exact h x diff --git a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean index 6e16b9100..9c8362545 100644 --- a/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean +++ b/Physlib/Mathematics/DataStructures/Matrix/LieTrace.lean @@ -143,8 +143,7 @@ theorem diag_exp_of_blockTriangular_id funext i rw [NormedSpace.exp_eq_tsum 𝕂, diag_apply] simp_rw [matrix_tsum_apply (NormedSpace.expSeries_summable' A) i i] - rw [matrix_exp_series_diag_eq_scalar_series hA i] - rw [NormedSpace.exp_eq_tsum 𝕂] + rw [matrix_exp_series_diag_eq_scalar_series hA i, NormedSpace.exp_eq_tsum 𝕂] /-- Lie's trace formula for upper triangular matrices. -/ lemma det_exp_of_blockTriangular_id {A : Matrix m m 𝕂} (hA : BlockTriangular A id) : @@ -265,8 +264,7 @@ theorem det_exp_real {n : Type*} [Fintype n] [LinearOrder n] have h_det_comm : (algebraMap ℝ ℂ) ((NormedSpace.exp A).det) = (NormedSpace.exp A_ℂ).det := by rw [@RingHom.map_det] rw [← NormedSpace.exp_map_algebraMap]; rfl - rw [← h_det_comm] at h_complex - rw [h_trace_comm] at h_complex + rw [← h_det_comm, h_trace_comm] at h_complex have h_exp_comm : Complex.exp ((algebraMap ℝ ℂ) A.trace) = (algebraMap ℝ ℂ) (Real.exp A.trace) := by rw [Complex.coe_algebraMap, ← Complex.ofReal_exp] diff --git a/Physlib/Mathematics/FDerivCurry.lean b/Physlib/Mathematics/FDerivCurry.lean index 225ca965b..60919c7fa 100644 --- a/Physlib/Mathematics/FDerivCurry.lean +++ b/Physlib/Mathematics/FDerivCurry.lean @@ -123,8 +123,7 @@ lemma fderiv_curry_comp_fst (f : X → Y → Z) (x dx : X) (y : Y) = (fderiv 𝕜 (↿f) ((·, y) x)) ((fderiv 𝕜 (·, y) x) dx) := by have hl (y : Y) : (fun x' => f x' y) = ↿f ∘ (·, y) := rfl - rw [hl] - rw [fderiv_comp] + rw [hl, fderiv_comp] simp only [ContinuousLinearMap.coe_comp, Function.comp_apply] · fun_prop · fun_prop @@ -135,8 +134,7 @@ lemma fderiv_curry_comp_snd (f : X → Y → Z) (x : X) (y dy : Y) = (fderiv 𝕜 (↿f) ((x, ·) y)) ((fderiv 𝕜 (x, ·) y) dy) := by have hl (x : X) : (fun y' => f x y') = ↿f ∘ (x, ·) := rfl - rw [hl] - rw [fderiv_comp] + rw [hl, fderiv_comp] simp only [ContinuousLinearMap.coe_comp, Function.comp_apply] · fun_prop · fun_prop From 7c133605413b27d28848afda0a835b324f6ddf7a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:13:45 -0700 Subject: [PATCH 469/498] refactor: golf insertion sort rewrites Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/List/InsertionSort.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/List/InsertionSort.lean b/Physlib/Mathematics/List/InsertionSort.lean index b19b778dc..85485eebd 100644 --- a/Physlib/Mathematics/List/InsertionSort.lean +++ b/Physlib/Mathematics/List/InsertionSort.lean @@ -350,11 +350,9 @@ lemma orderedInsert_filter_of_pos {α : Type} (r : α → α → Prop) [Decidabl by_cases hpb : p b <;> by_cases hab : r a b · simp only [hab, ↓reduceIte, hpb, decide_true, List.filter_cons_of_pos, List.orderedInsert.eq_2] - rw [List.filter_cons_of_pos (by simp [h])] - rw [List.filter_cons_of_pos (by simp [hpb])] + rw [List.filter_cons_of_pos (by simp [h]), List.filter_cons_of_pos (by simp [hpb])] · simp only [hab, ↓reduceIte] - rw [List.filter_cons_of_pos (by simp [hpb])] - rw [List.filter_cons_of_pos (by simp [hpb])] + rw [List.filter_cons_of_pos (by simp [hpb]), List.filter_cons_of_pos (by simp [hpb])] simp only [List.orderedInsert, hab, ↓reduceIte, List.cons.injEq, true_and] simp only [List.pairwise_cons] at hl exact orderedInsert_filter_of_pos r a p h l hl.2 @@ -383,8 +381,7 @@ lemma orderedInsert_filter_of_pos {α : Type} (r : α → α → Prop) [Decidabl rw [hl] simp · simp only [hab, ↓reduceIte] - rw [List.filter_cons_of_neg (by simp [hpb])] - rw [List.filter_cons_of_neg (by simp [hpb])] + rw [List.filter_cons_of_neg (by simp [hpb]), List.filter_cons_of_neg (by simp [hpb])] simp only [List.pairwise_cons] at hl exact orderedInsert_filter_of_pos r a p h l hl.2 @@ -393,8 +390,7 @@ lemma orderedInsert_filter_of_neg {α : Type} (r : α → α → Prop) [Decidabl List.filter p (List.orderedInsert r a l) = (List.filter p l) := by rw [List.orderedInsert_eq_take_drop] simp only [decide_not, List.filter_append] - rw [List.filter_cons_of_neg] - rw [← List.filter_append] + rw [List.filter_cons_of_neg, ← List.filter_append] congr exact List.takeWhile_append_dropWhile simp [h] @@ -412,8 +408,7 @@ lemma insertionSort_filter {α : Type} (r : α → α → Prop) [DecidableRel r] simp only [List.insertionSort_cons] rw [insertionSort_filter] · rw [orderedInsert_filter_of_neg r a p h] - rw [List.filter_cons_of_neg (by simpa using h)] - rw [insertionSort_filter] + rw [List.filter_cons_of_neg (by simpa using h), insertionSort_filter] lemma takeWhile_sorted_eq_filter {α : Type} (r : α → α → Prop) [DecidableRel r] [IsTrans α r] (a : α) : (l : List α) → (hl : l.Pairwise r) → From d74be9850042538f9b5ec2b88c935a8c3dcb246f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:15:22 -0700 Subject: [PATCH 470/498] refactor: golf trigonometry and variational rewrites Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Trigonometry/Tanh.lean | 6 ++---- .../Mathematics/VariationalCalculus/HasVarAdjoint.lean | 9 +++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/Trigonometry/Tanh.lean b/Physlib/Mathematics/Trigonometry/Tanh.lean index 733cc18cb..377484ac2 100644 --- a/Physlib/Mathematics/Trigonometry/Tanh.lean +++ b/Physlib/Mathematics/Trigonometry/Tanh.lean @@ -143,10 +143,8 @@ lemma tanh_hasTemperateGrowth : Function.HasTemperateGrowth Real.tanh := by use C intro x have h_equiv : ‖iteratedFDeriv ℝ n Real.tanh x‖ = |iteratedDeriv n Real.tanh x| := by - rw [← iteratedFDerivWithin_univ] - rw [← iteratedDerivWithin_univ] - rw [← norm_eq_abs] - rw [norm_iteratedFDerivWithin_eq_norm_iteratedDerivWithin] + rw [← iteratedFDerivWithin_univ, ← iteratedDerivWithin_univ] + rw [← norm_eq_abs, norm_iteratedFDerivWithin_eq_norm_iteratedDerivWithin] rw [h_equiv] simp only [pow_zero, mul_one] exact hC x diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean index d9d9e2ee3..ab984557b 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjoint.lean @@ -121,8 +121,7 @@ lemma unique_on_test_functions {F : (X → U) → (Y → V)} {F' G' : (Y → V) obtain ⟨F_preserve_test, F'_preserve_test, F'_adjoint⟩ := hF' obtain ⟨F_preserve_test, G'_preserve_test, G'_adjoint⟩ := hG' intro φ hφ - rw [← zero_add (G' φ)] - rw [← sub_eq_iff_eq_add] + rw [← zero_add (G' φ), ← sub_eq_iff_eq_add] change (F' - G') φ = 0 apply fundamental_theorem_of_variational_calculus (@volume X _) · simp @@ -444,14 +443,12 @@ lemma fderiv_apply {dx} apply IsLocalizedFunctionTransform.neg apply IsLocalizedFunctionTransform.fderiv adjoint φ ψ hφ hψ := by - rw [← sub_eq_zero] - rw [← integral_sub] + rw [← sub_eq_zero, ← integral_sub] · trans ∫ (a : X), fderiv ℝ (fun a => ⟪φ a, ψ a⟫_ℝ) a dx · congr funext a simp only [inner_neg_right', sub_neg_eq_add] - rw [fderiv_inner_apply'] - rw [add_comm] + rw [fderiv_inner_apply', add_comm] · exact hφ.differentiable a · exact hψ.differentiable a · have h1 := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable (f := fun a => 1) From 4fcf712f3d22d3989f3171cc3a8f9c537b3ace6b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:17:08 -0700 Subject: [PATCH 471/498] refactor: golf variational derivative rewrites Co-authored-by: Claude Opus 4.8 --- .../VariationalCalculus/HasVarAdjDeriv.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean index 3d8dbd900..9671fdf30 100644 --- a/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean +++ b/Physlib/Mathematics/VariationalCalculus/HasVarAdjDeriv.lean @@ -601,8 +601,7 @@ lemma mul · apply hG.diff; assumption linearize := by intro φ hφ x - rw [deriv_fun_mul, deriv_fun_mul] - rw [hF.linearize _ hφ, hG.linearize _ hφ] + rw [deriv_fun_mul, deriv_fun_mul, hF.linearize _ hφ, hG.linearize _ hφ] · simp · exact hF.differentiable_linear hφ x 0 · exact hG.differentiable_linear hφ x 0 @@ -679,8 +678,7 @@ protected lemma fderiv (u : X → U) (dx : X) (hu : ContDiff ℝ ∞ u) simp only [FunLike.coe_smul, Pi.smul_apply] exact (hφ.differentiable (by simp)).differentiableAt · intro φ hφ x - rw [← fderiv_apply_one_eq_deriv] - rw [fderiv_swap] + rw [← fderiv_apply_one_eq_deriv, fderiv_swap] simp only [fderiv_eq_smul_deriv, one_smul] · exact hφ.of_le ENat.LEInfty.out · exact hu @@ -707,14 +705,12 @@ protected lemma gradient {d} (u : Space d → ℝ) (hu : ContDiff ℝ ∞ u) : simp only [Space.deriv] fun_prop · intro φ1 φ2 h1 h2 - rw [Space.gradient_eq_grad] - rw [Space.grad_add, Space.grad_eq_gradient, Space.grad_eq_gradient] + rw [Space.gradient_eq_grad, Space.grad_add, Space.grad_eq_gradient, Space.grad_eq_gradient] rfl · exact h1.differentiable (by simp) · exact h2.differentiable (by simp) · intro c φ hφ - rw [Space.gradient_eq_grad] - rw [Space.grad_smul, Space.grad_eq_gradient] + rw [Space.gradient_eq_grad, Space.grad_smul, Space.grad_eq_gradient] rfl exact hφ.differentiable (by simp) · intro φ hφ x @@ -726,8 +722,7 @@ protected lemma gradient {d} (u : Space d → ℝ) (hu : ContDiff ℝ ∞ u) : rw [deriv_smul_const] congr simp [Space.deriv] - rw [← fderiv_apply_one_eq_deriv] - rw [fderiv_swap] + rw [← fderiv_apply_one_eq_deriv, fderiv_swap] simp only [fderiv_eq_smul_deriv, smul_eq_mul, one_mul] · exact hφ.of_le ENat.LEInfty.out · simp [Space.deriv] From 9164b1414e10d709e6f42ba652bcfa29ac0f6a0b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:18:31 -0700 Subject: [PATCH 472/498] refactor: golf qft section rewrites Co-authored-by: Claude Opus 4.8 --- .../FieldSpecification/CrAnSection.lean | 12 ++++-------- .../QFT/PerturbationTheory/Koszul/KoszulSign.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index f006367fe..0bf15a65e 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -166,20 +166,17 @@ lemma card_eq_mul : {φs : List 𝓕.FieldOp} → Fintype.card (CrAnSection φs) simp | FieldOp.position _ :: φs => by simp only [statesIsPosition, List.countP_cons_of_pos] - rw [card_cons_eq] - rw [card_eq_mul] + rw [card_cons_eq, card_eq_mul] simp only [fieldOpToCrAnType] erw [CreateAnnihilate.CreateAnnihilate_card_eq_two] ring | FieldOp.inAsymp x_ :: φs => by simp only [statesIsPosition, Bool.false_eq_true, not_false_eq_true, List.countP_cons_of_neg] - rw [card_cons_eq] - rw [card_eq_mul] + rw [card_cons_eq, card_eq_mul] simp [fieldOpToCrAnType] | FieldOp.outAsymp _ :: φs => by simp only [statesIsPosition, Bool.false_eq_true, not_false_eq_true, List.countP_cons_of_neg] - rw [card_cons_eq] - rw [card_eq_mul] + rw [card_cons_eq, card_eq_mul] simp [fieldOpToCrAnType] lemma card_perm_eq {φs φs' : List 𝓕.FieldOp} (h : φs.Perm φs') : @@ -413,8 +410,7 @@ lemma sum_eraseIdxEquiv (n : ℕ) (φs : List 𝓕.FieldOp) (hn : n < φs.length (f : CrAnSection φs → M) [AddCommMonoid M] : ∑ (s : CrAnSection φs), f s = ∑ (a : 𝓕.fieldOpToCrAnType φs[n]), ∑ (s : CrAnSection (φs.eraseIdx n)), f ((eraseIdxEquiv n φs hn).symm ⟨a, s⟩) := by - rw [← (eraseIdxEquiv n φs hn).symm.sum_comp] - rw [Fintype.sum_prod_type] + rw [← (eraseIdxEquiv n φs hn).symm.sum_comp, Fintype.sum_prod_type] end CrAnSection diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index 95c43fcb8..86b62eb06 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -118,8 +118,7 @@ lemma koszulSign_insertIdx [Std.Total le] [IsTrans 𝓕 le] (φ : 𝓕) : simp | φ1 :: φs, n + 1, h => by conv_lhs => - rw [List.insertIdx_succ_cons] - rw [koszulSign] + rw [List.insertIdx_succ_cons, koszulSign] rw [koszulSign_insertIdx _ _ _ (Nat.le_of_lt_succ h)] conv_rhs => rhs From 7966900e59746bf4d3541733808688a0c845e682 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:20:05 -0700 Subject: [PATCH 473/498] refactor: golf wick grading rewrites Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/WickAlgebra/Grading.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean index 97a7f729b..2a9935f20 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean @@ -124,8 +124,7 @@ def bosonicProj : 𝓕.WickAlgebra →ₗ[ℂ] statSubmodule (𝓕 := 𝓕) boso obtain ⟨x, hx⟩ := ι_surjective x obtain ⟨y, hy⟩ := ι_surjective y subst hx hy - rw [← map_add, ι_apply, ι_apply, ι_apply] - rw [Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] + rw [← map_add, ι_apply, ι_apply, ι_apply, Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] simp map_smul' c y := by obtain ⟨y, hy⟩ := ι_surjective y @@ -170,8 +169,7 @@ def fermionicProj : 𝓕.WickAlgebra →ₗ[ℂ] statSubmodule (𝓕 := 𝓕) fe obtain ⟨x, hx⟩ := ι_surjective x obtain ⟨y, hy⟩ := ι_surjective y subst hx hy - rw [← map_add, ι_apply, ι_apply, ι_apply] - rw [Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] + rw [← map_add, ι_apply, ι_apply, ι_apply, Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] simp map_smul' c y := by obtain ⟨y, hy⟩ := ι_surjective y @@ -207,10 +205,8 @@ lemma bosonicProj_mem_bosonic (a : 𝓕.WickAlgebra) (ha : a ∈ statSubmodule . simp only [p] apply Subtype.ext simp only - rw [ofCrAnList] - rw [bosonicProj_eq_bosonicProjFree] - rw [bosonicProjFree_eq_ι_bosonicProjF] - rw [bosonicProjF_of_mem_bosonic] + rw [ofCrAnList, bosonicProj_eq_bosonicProjFree] + rw [bosonicProjFree_eq_ι_bosonicProjF, bosonicProjF_of_mem_bosonic] exact ofCrAnListF_mem_statisticSubmodule_of _ _ h · simp only [map_zero, p] rfl @@ -231,8 +227,7 @@ lemma fermionicProj_mem_fermionic (a : 𝓕.WickAlgebra) (ha : a ∈ statSubmodu simp only [p] apply Subtype.ext simp only - rw [ofCrAnList] - rw [fermionicProj_eq_fermionicProjFree] + rw [ofCrAnList, fermionicProj_eq_fermionicProjFree] rw [fermionicProjFree_eq_ι_fermionicProjF] rw [fermionicProjF_of_mem_fermionic] exact ofCrAnListF_mem_statisticSubmodule_of _ _ h From 3f2c1b518c40970e83162174219d1ae8ccce6dd2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:22:08 -0700 Subject: [PATCH 474/498] refactor: golf wick normal-order rewrites Co-authored-by: Claude Opus 4.8 --- .../QFT/PerturbationTheory/WickAlgebra/Grading.lean | 3 +-- .../WickAlgebra/NormalOrder/Basic.lean | 12 ++++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean index 2a9935f20..de43bef79 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/Grading.lean @@ -227,8 +227,7 @@ lemma fermionicProj_mem_fermionic (a : 𝓕.WickAlgebra) (ha : a ∈ statSubmodu simp only [p] apply Subtype.ext simp only - rw [ofCrAnList, fermionicProj_eq_fermionicProjFree] - rw [fermionicProjFree_eq_ι_fermionicProjF] + rw [ofCrAnList, fermionicProj_eq_fermionicProjFree, fermionicProjFree_eq_ι_fermionicProjF] rw [fermionicProjF_of_mem_fermionic] exact ofCrAnListF_mem_statisticSubmodule_of _ _ h · simp only [map_zero, p] diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean index eb79f0b45..7fe976cbb 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean @@ -91,12 +91,10 @@ lemma ι_normalOrderF_superCommuteF_ofCrAnOpF_ofCrAnListF_eq_zero_mul (φa : (φs : List 𝓕.CrAnFieldOp) (a b : 𝓕.FieldOpFreeAlgebra) : ι 𝓝ᶠ(a * [ofCrAnOpF φa, ofCrAnListF φs]ₛF * b) = 0 := by rw [← ofCrAnListF_singleton, superCommuteF_ofCrAnListF_ofCrAnListF_eq_sum] - rw [Finset.mul_sum, Finset.sum_mul] - rw [map_sum, map_sum] + rw [Finset.mul_sum, Finset.sum_mul, map_sum, map_sum] apply Fintype.sum_eq_zero intro n - rw [← mul_assoc, ← mul_assoc] - rw [mul_assoc _ _ b, ofCrAnListF_singleton] + rw [← mul_assoc, ← mul_assoc, mul_assoc _ _ b, ofCrAnListF_singleton] rw [ι_normalOrderF_superCommuteF_ofCrAnOpF_eq_zero_mul] lemma ι_normalOrderF_superCommuteF_ofCrAnListF_ofCrAnOpF_eq_zero_mul (φa : 𝓕.CrAnFieldOp) @@ -115,8 +113,7 @@ lemma ι_normalOrderF_superCommuteF_ofCrAnListF_ofCrAnListF_eq_zero_mul rw [map_sum, map_sum] apply Fintype.sum_eq_zero intro n - rw [← mul_assoc, ← mul_assoc] - rw [mul_assoc _ _ b] + rw [← mul_assoc, ← mul_assoc, mul_assoc _ _ b] rw [ι_normalOrderF_superCommuteF_ofCrAnListF_ofCrAnOpF_eq_zero_mul] lemma ι_normalOrderF_superCommuteF_ofCrAnListF_eq_zero_mul @@ -231,8 +228,7 @@ noncomputable def normalOrder : WickAlgebra 𝓕 →ₗ[ℂ] WickAlgebra 𝓕 wh map_add' x y := by obtain ⟨x, rfl⟩ := ι_surjective x obtain ⟨y, rfl⟩ := ι_surjective y - rw [← map_add, ι_apply, ι_apply, ι_apply] - rw [Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] + rw [← map_add, ι_apply, ι_apply, ι_apply, Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] simp map_smul' c y := by obtain ⟨y, rfl⟩ := ι_surjective y From 519a517234507ecd433eca90883b1576b32a828b Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:26:24 -0700 Subject: [PATCH 475/498] refactor: golf wick super-commute rewrites Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/WickAlgebra/SuperCommute.lean | 12 ++++-------- .../WickAlgebra/TimeContraction.lean | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean index 14f522673..171a599ee 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/SuperCommute.lean @@ -59,8 +59,7 @@ noncomputable def superCommuteRight (a : 𝓕.FieldOpFreeAlgebra) : obtain ⟨x, hx⟩ := ι_surjective x obtain ⟨y, hy⟩ := ι_surjective y subst hx hy - rw [← map_add, ι_apply, ι_apply, ι_apply] - rw [Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] + rw [← map_add, ι_apply, ι_apply, ι_apply, Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] simp map_smul' c y := by obtain ⟨y, hy⟩ := ι_surjective y @@ -155,13 +154,11 @@ lemma superCommute_annihilate_annihilate {φ φ' : 𝓕.CrAnFieldOp} lemma superCommute_diff_statistic {φ φ' : 𝓕.CrAnFieldOp} (h : (𝓕 |>ₛ φ) ≠ 𝓕 |>ₛ φ') : [ofCrAnOp φ, ofCrAnOp φ']ₛ = 0 := by - rw [ofCrAnOp, ofCrAnOp] - rw [superCommute_eq_ι_superCommuteF, ι_superCommuteF_of_diff_statistic h] + rw [ofCrAnOp, ofCrAnOp, superCommute_eq_ι_superCommuteF, ι_superCommuteF_of_diff_statistic h] lemma superCommute_ofCrAnOp_ofFieldOp_diff_stat_zero (φ : 𝓕.CrAnFieldOp) (ψ : 𝓕.FieldOp) (h : (𝓕 |>ₛ φ) ≠ (𝓕 |>ₛ ψ)) : [ofCrAnOp φ, ofFieldOp ψ]ₛ = 0 := by - rw [ofFieldOp_eq_sum, map_sum] - rw [Finset.sum_eq_zero] + rw [ofFieldOp_eq_sum, map_sum, Finset.sum_eq_zero] intro x hx apply superCommute_diff_statistic simpa [crAnStatistics] using h @@ -444,8 +441,7 @@ lemma superCommute_ofCrAnOp_ofCrAnList_eq_sum (φ : 𝓕.CrAnFieldOp) funext n simp only [ofList_singleton, List.get_eq_getElem, Algebra.smul_mul_assoc] congr 1 - rw [ofCrAnList_singleton, superCommute_ofCrAnOp_ofCrAnOp_commute] - rw [mul_assoc, ← ofCrAnList_append] + rw [ofCrAnList_singleton, superCommute_ofCrAnOp_ofCrAnOp_commute, mul_assoc, ← ofCrAnList_append] congr exact Eq.symm (List.eraseIdx_eq_take_drop_succ φs' ↑n) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean index 6e44c75ed..571e33eb7 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeContraction.lean @@ -45,8 +45,7 @@ lemma timeContract_of_timeOrderRel (φ ψ : 𝓕.FieldOp) (h : timeOrderRel φ rw [ofFieldOp_eq_crPart_add_anPart] rw [map_add, superCommute_anPart_anPart, superCommute_anPart_crPart] simp only [timeContract, Algebra.smul_mul_assoc, add_zero] - rw [timeOrder_ofFieldOp_ofFieldOp_ordered h] - rw [normalOrder_ofFieldOp_mul_ofFieldOp] + rw [timeOrder_ofFieldOp_ofFieldOp_ordered h, normalOrder_ofFieldOp_mul_ofFieldOp] rw [ofFieldOp_eq_crPart_add_anPart, ofFieldOp_eq_crPart_add_anPart] simp only [mul_add, add_mul] abel_nf From 6cea4c5cf24cc5bca999f097ae8c834c4d2c5a7f Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:30:31 -0700 Subject: [PATCH 476/498] refactor: golf anomaly cancellation rewrites Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean | 4 +--- .../QFT/QED/AnomalyCancellation/Even/Parameterization.lean | 3 +-- Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean | 6 ++---- .../QFT/QED/AnomalyCancellation/Odd/Parameterization.lean | 4 +--- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean index 7e9157988..ba277ced6 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/BasisLinear.lean @@ -50,8 +50,7 @@ def asLinSols (j : Fin n) : (PureU1 n.succ).LinSols := | ⟨0, _⟩=> simp only [PureU1_linearACCs, accGrav, LinearMap.coe_mk, AddHom.coe_mk] - rw [Fin.sum_univ_castSucc] - rw [Finset.sum_eq_single j] + rw [Fin.sum_univ_castSucc, Finset.sum_eq_single j] · simp only [asCharges, ↓reduceIte] have hn : ¬ (Fin.last n = Fin.castSucc j) := Fin.ne_of_gt j.prop split diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean index a0ea79510..45965bc82 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/BasisLinear.lean @@ -939,9 +939,7 @@ lemma Pa'_eq (f f' : (Fin n.succ) ⊕ (Fin n) → ℚ) : Pa' f = Pa' f' ↔ f = · rw [Pa', Pa'] at h have h1 : ∑ i : Fin (succ n) ⊕ Fin n, (f i + (- f' i)) • basisa i = 0 := by simp only [add_smul, neg_smul] - rw [Finset.sum_add_distrib] - rw [h] - rw [← Finset.sum_add_distrib] + rw [Finset.sum_add_distrib, h, ← Finset.sum_add_distrib] simp have h2 : ∀ i, (f i + (- f' i)) = 0 := by exact Fintype.linearIndependent_iff.mp (@basisa_linear_independent n) diff --git a/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean b/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean index fe88aa1ca..db61c4261 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Even/Parameterization.lean @@ -120,8 +120,7 @@ theorem generic_case {S : (PureU1 (2 * n.succ)).Sols} (h : GenericCase S) : rw [parameterization] apply ACCSystem.Sols.ext rw [parameterizationAsLinear_val] - rw [anomalyFree_param _ _ hS] - rw [neg_neg, ← smul_add, smul_smul, inv_mul_cancel₀, one_smul] + rw [anomalyFree_param _ _ hS, neg_neg, ← smul_add, smul_smul, inv_mul_cancel₀, one_smul] · exact hS · have h := h g f hS rw [anomalyFree_param _ _ hS] at h diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean index 86b22e429..2323ae1d6 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/BasisLinear.lean @@ -130,12 +130,10 @@ lemma sum_odd (S : Fin (2 * n + 1) → ℚ) : · intro i simp only [mem_univ, Fin.symm_castOrderIso, RelIso.coe_fn_toEquiv] · exact fun _ _ => rfl - rw [h1] - rw [Fin.sum_univ_add, Fin.sum_univ_add] + rw [h1, Fin.sum_univ_add, Fin.sum_univ_add] simp only [univ_unique, Fin.default_eq_zero, Fin.isValue, sum_singleton, Function.comp_apply] nth_rewrite 2 [add_comm] - rw [add_assoc] - rw [Finset.sum_add_distrib] + rw [add_assoc, Finset.sum_add_distrib] rfl /-! diff --git a/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean b/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean index 9741bbcba..38489f821 100644 --- a/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean +++ b/Physlib/QFT/QED/AnomalyCancellation/Odd/Parameterization.lean @@ -46,9 +46,7 @@ set_option backward.isDefEq.respectTransparency false in lemma parameterizationCharge_cube (g f : Fin n → ℚ) (a : ℚ) : accCube (2 * n + 1) (parameterizationAsLinear g f a).val = 0 := by change accCubeTriLinSymm.toCubic _ = 0 - rw [parameterizationAsLinear_val] - rw [HomogeneousCubic.map_smul] - rw [TriLinearSymm.toCubic_add] + rw [parameterizationAsLinear_val, HomogeneousCubic.map_smul, TriLinearSymm.toCubic_add] rw [HomogeneousCubic.map_smul, HomogeneousCubic.map_smul] erw [P_accCube g, P!_accCube f] rw [accCubeTriLinSymm.map_smul₁, accCubeTriLinSymm.map_smul₂, From 43b96639468bc1c81f748ebe19fe061fcaaa8f89 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:32:48 -0700 Subject: [PATCH 477/498] refactor: golf wick contraction time rewrites Co-authored-by: Claude Opus 4.8 --- .../WickContraction/TimeCond.lean | 21 +++++++------------ .../WickContraction/TimeContract.lean | 3 +-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean index ebbcaf446..42fe58d92 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeCond.lean @@ -174,8 +174,7 @@ lemma timeOrder_timeContract_mul_of_eqTimeOnly_mid_induction {φs : List 𝓕.Fi | Nat.succ n, hn => by obtain ⟨i, j, hij, φsucΛ, rfl, h2, h3, h4⟩ := exists_join_singleton_of_card_ge_zero φsΛ (by simp [hn]) hl - rw [join_timeContract] - rw [singleton_timeContract] + rw [join_timeContract, singleton_timeContract] simp only [Fin.getElem_fin, MulMemClass.coe_mul] trans timeOrder (a * WickAlgebra.timeContract φs[↑i] φs[↑j] * (φsucΛ.timeContract.1 * b)) simp only [mul_assoc, Fin.getElem_fin] @@ -235,11 +234,9 @@ lemma timeOrder_timeContract_of_not_eqTimeOnly {φs : List 𝓕.FieldOp} (φsΛ : WickContraction φs.length) (hl : ¬ φsΛ.EqTimeOnly) : 𝓣(φsΛ.timeContract.1) = 0 := by obtain ⟨i, j, hij, φsucΛ, rfl, hr⟩ := exists_join_singleton_of_not_eqTimeOnly φsΛ hl - rw [join_timeContract] - rw [singleton_timeContract] + rw [join_timeContract, singleton_timeContract] simp only [Fin.getElem_fin, MulMemClass.coe_mul] - rw [timeOrder_timeOrder_left] - rw [timeOrder_timeContract_ne_time] + rw [timeOrder_timeOrder_left, timeOrder_timeContract_ne_time] simp only [zero_mul, map_zero] simp_all only [Fin.getElem_fin, not_and] intro h @@ -253,8 +250,7 @@ lemma timeOrder_staticContract_of_not_mem {φs : List 𝓕.FieldOp} (φsΛ : Wic obtain ⟨i, j, hij, φsucΛ, rfl, hr⟩ := exists_join_singleton_of_not_eqTimeOnly φsΛ hl rw [join_staticContract] simp only [MulMemClass.coe_mul] - rw [singleton_staticContract] - rw [timeOrder_timeOrder_left] + rw [singleton_staticContract, timeOrder_timeOrder_left] rw [timeOrder_superCommute_anPart_ofFieldOp_ne_time] simp only [zero_mul, map_zero] intro h @@ -527,8 +523,7 @@ def hasEqTimeEquiv (φs : List 𝓕.FieldOp) : apply Subtype.ext ext a simp only [subContraction] - rw [join_eqTimeContractSet] - rw [eqTimeContractSet_of_not_haveEqTime h2] + rw [join_eqTimeContractSet, eqTimeContractSet_of_not_haveEqTime h2] simp only [Finset.le_eq_subset, ne_eq, Finset.map_empty, Finset.union_empty] rw [eqTimeContractSet_of_mem_eqTimeOnly h1.1] refine hasEqTimeEquiv_ext_sigma ?_ ?_ @@ -538,11 +533,9 @@ def hasEqTimeEquiv (φs : List 𝓕.FieldOp) : apply Subtype.ext ext a simp only [quotContraction, Finset.mem_filter, Finset.mem_univ, true_and] - rw [mem_congr_iff] - rw [mem_join_right_iff] + rw [mem_congr_iff, mem_join_right_iff] simp only [ne_eq] - rw [uncontractedListEmd_congr hs] - rw [Finset.map_map] + rw [uncontractedListEmd_congr hs, Finset.map_map] lemma sum_haveEqTime (φs : List 𝓕.FieldOp) (f : WickContraction φs.length → M) [AddCommMonoid M]: diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean b/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean index e36a584dc..a34f80727 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/TimeContract.lean @@ -120,8 +120,7 @@ lemma timeContract_insert_some_of_lt congr rw [← List.map_take] congr - rw [take_uncontractedIndexEquiv_symm] - rw [filter_uncontractedList] + rw [take_uncontractedIndexEquiv_symm, filter_uncontractedList] rw [h1] simp only [exchangeSign_mul_self] · exact ht From d0511e0ca822480365281619461785ca90c09bf6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:34:34 -0700 Subject: [PATCH 478/498] refactor: golf wick time-order rewrites Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/TimeOrder.lean | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean index 7f5a272fc..6dbd24ff9 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/TimeOrder.lean @@ -127,8 +127,7 @@ lemma ι_timeOrderF_superCommuteF_superCommuteF_eq_time_ofCrAnListF {φ1 φ2 φ3 ι [ofCrAnOpF φ1, [ofCrAnOpF φ2, ofCrAnOpF φ3]ₛF]ₛF * ι (ofCrAnListF l2)); swap · simp - rw [mul_assoc] - rw [← ofCrAnListF_singleton, ← ofCrAnListF_singleton, ← ofCrAnListF_singleton] + rw [mul_assoc, ← ofCrAnListF_singleton, ← ofCrAnListF_singleton, ← ofCrAnListF_singleton] rw [superCommuteF_ofCrAnListF_ofCrAnListF] simp only [List.singleton_append, ofList_singleton, map_sub, map_smul] rw [superCommuteF_ofCrAnListF_ofCrAnListF, superCommuteF_ofCrAnListF_ofCrAnListF] @@ -300,14 +299,12 @@ lemma ι_timeOrderF_superCommuteF_eq_time {φ ψ : 𝓕.CrAnFieldOp} rw [← ofCrAnListF_append, ← ofCrAnListF_append, ← ofCrAnListF_append] have h1 := insertionSort_of_takeWhile_filter 𝓕.crAnTimeOrderRel φ φs' φs simp [decide_not, Bool.decide_and, List.append_assoc, List.cons_append] at h1 ⊢ - rw [← h1] - rw [← crAnTimeOrderList] + rw [← h1, ← crAnTimeOrderList] by_cases hq : (𝓕 |>ₛ φ) ≠ (𝓕 |>ₛ ψ) · rw [ι_superCommuteF_of_diff_statistic hq] simp · rw [crAnTimeOrderSign, Wick.koszulSign_eq_rel_eq_stat _ _, ← crAnTimeOrderSign] - rw [← ofCrAnListF_append] - rw [timeOrderF_ofCrAnListF] + rw [← ofCrAnListF_append, timeOrderF_ofCrAnListF] simp only [map_smul, Algebra.mul_smul_comm] exact hφψ exact hψφ @@ -426,8 +423,7 @@ noncomputable def timeOrder : WickAlgebra 𝓕 →ₗ[ℂ] WickAlgebra 𝓕 wher obtain ⟨x, hx⟩ := ι_surjective x obtain ⟨y, hy⟩ := ι_surjective y subst hx hy - rw [← map_add, ι_apply, ι_apply, ι_apply] - rw [Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] + rw [← map_add, ι_apply, ι_apply, ι_apply, Quotient.lift_mk, Quotient.lift_mk, Quotient.lift_mk] simp map_smul' c y := by obtain ⟨y, hy⟩ := ι_surjective y @@ -492,12 +488,10 @@ lemma timeOrder_superCommute_eq_time_mid {φ ψ : 𝓕.CrAnFieldOp} (hφψ : crAnTimeOrderRel φ ψ) (hψφ : crAnTimeOrderRel ψ φ) (a b : 𝓕.WickAlgebra) : 𝓣(a * [ofCrAnOp φ, ofCrAnOp ψ]ₛ * b) = [ofCrAnOp φ, ofCrAnOp ψ]ₛ * 𝓣(a * b) := by - rw [ofCrAnOp, ofCrAnOp] - rw [superCommute_eq_ι_superCommuteF] + rw [ofCrAnOp, ofCrAnOp, superCommute_eq_ι_superCommuteF] obtain ⟨a, rfl⟩ := ι_surjective a obtain ⟨b, rfl⟩ := ι_surjective b - rw [← map_mul, ← map_mul, timeOrder_eq_ι_timeOrderF] - rw [ι_timeOrderF_superCommuteF_eq_time] + rw [← map_mul, ← map_mul, timeOrder_eq_ι_timeOrderF, ι_timeOrderF_superCommuteF_eq_time] rfl · simp_all · simp_all @@ -514,9 +508,7 @@ lemma timeOrder_superCommute_eq_time_left {φ ψ : 𝓕.CrAnFieldOp} lemma timeOrder_superCommute_ne_time {φ ψ : 𝓕.CrAnFieldOp} (hφψ : ¬ (crAnTimeOrderRel φ ψ ∧ crAnTimeOrderRel ψ φ)) : 𝓣([ofCrAnOp φ, ofCrAnOp ψ]ₛ) = 0 := by - rw [ofCrAnOp, ofCrAnOp] - rw [superCommute_eq_ι_superCommuteF] - rw [timeOrder_eq_ι_timeOrderF] + rw [ofCrAnOp, ofCrAnOp, superCommute_eq_ι_superCommuteF, timeOrder_eq_ι_timeOrderF] trans ι (timeOrderF (1 * (superCommuteF (ofCrAnOpF φ)) (ofCrAnOpF ψ) * 1)) simp only [one_mul, mul_one] rw [ι_timeOrderF_superCommuteF_ne_time] From fc32ddfdc9090344f2285298c77a501515466baf Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:41:58 -0700 Subject: [PATCH 479/498] refactor: golf qft ordering and sign proofs Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/FieldSpecification/CrAnSection.lean | 6 ++---- .../QFT/PerturbationTheory/FieldStatistics/OfFinset.lean | 3 +-- Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean | 3 +-- Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean | 3 +-- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 0bf15a65e..6798aac4b 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -151,14 +151,12 @@ instance fintype : (φs : List 𝓕.FieldOp) → Fintype (CrAnSection φs) @[simp] lemma card_nil_eq : Fintype.card (CrAnSection (𝓕 := 𝓕) []) = 1 := by - rw [Fintype.ofEquiv_card nilEquiv.symm] - simp + simpa using Fintype.ofEquiv_card nilEquiv.symm lemma card_cons_eq {φ : 𝓕.FieldOp} {φs : List 𝓕.FieldOp} : Fintype.card (CrAnSection (φ :: φs)) = Fintype.card (𝓕.fieldOpToCrAnType φ) * Fintype.card (CrAnSection φs) := by - rw [Fintype.ofEquiv_card consEquiv.symm] - simp + simpa using Fintype.ofEquiv_card consEquiv.symm lemma card_eq_mul : {φs : List 𝓕.FieldOp} → Fintype.card (CrAnSection φs) = 2 ^ (List.countP 𝓕.statesIsPosition φs) diff --git a/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean b/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean index 62a10a098..85f2f0f4d 100644 --- a/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean +++ b/Physlib/QFT/PerturbationTheory/FieldStatistics/OfFinset.lean @@ -103,8 +103,7 @@ lemma ofFinset_union (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a b : Fins lemma ofFinset_union_disjoint (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a b : Finset (Fin φs.length)) (h : Disjoint a b) : ofFinset q φs.get a * ofFinset q φs.get b = ofFinset q φs.get (a ∪ b) := by - rw [ofFinset_union, Finset.disjoint_iff_inter_eq_empty.mp h] - simp + simpa [Finset.disjoint_iff_inter_eq_empty.mp h] using ofFinset_union q φs a b lemma ofFinset_filter_mul_neg (q : 𝓕 → FieldStatistic) (φs : List 𝓕) (a : Finset (Fin φs.length)) (p : Fin φs.length → Prop) [DecidablePred p] : diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index 86b62eb06..1d9aed40d 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -346,8 +346,7 @@ lemma koszulSign_of_append_eq_insertionSort_left [Std.Total le] [IsTrans 𝓕 le congr 3 · have h2 : (List.insertionSort le φs ++ φ :: φs') = List.insertIdx (List.insertionSort le φs ++ φs') φs.length φ := by - rw [← insertIdx_length_fst_append] - simp + simp [← insertIdx_length_fst_append] rw [insertionSortEquiv_congr _ _ h2.symm] simp only [Equiv.trans_apply, RelIso.coe_fn_toEquiv, Fin.castOrderIso_apply, Fin.cast_mk, Fin.val_cast] diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean index 30e54e66e..7cf6a5af4 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSignInsert.lean @@ -165,8 +165,7 @@ lemma koszulSignInsert_eq_exchangeSign_take [Std.Total le] [IsTrans 𝓕 le] (φ (List.insertionSort le φs))) = if FieldStatistic.ofList q [φ] = fermionic ∧ FieldStatistic.ofList q (List.take (↑(orderedInsertPos le (List.insertionSort le φs) φ)) (List.insertionSort le φs)) = fermionic then - 1 else 1 := by - rw [exchangeSign_eq_if] - simp + simp [exchangeSign_eq_if] rw [hx] congr simp only [List.filter_filter, Bool.and_self] From 3218eeab90a0de64cf2133ae8eda1dc1f3e5cc54 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:44:17 -0700 Subject: [PATCH 480/498] refactor: golf koszul time-order simplifications Co-authored-by: Claude Opus 4.8 --- .../FieldOpFreeAlgebra/TimeOrder.lean | 3 +-- .../QFT/PerturbationTheory/Koszul/KoszulSign.lean | 12 +++--------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean index 6123a105d..0b4d44a7f 100644 --- a/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean +++ b/Physlib/QFT/PerturbationTheory/FieldOpFreeAlgebra/TimeOrder.lean @@ -136,8 +136,7 @@ lemma timeOrderF_ofFieldOpF_ofFieldOpF_ordered {φ ψ : 𝓕.FieldOp} (h : timeO rw [← ofFieldOpListF_singleton, ← ofFieldOpListF_singleton, ← ofFieldOpListF_append, timeOrderF_ofFieldOpListF] simp only [List.singleton_append] - rw [timeOrderSign_pair_ordered h, timeOrderList_pair_ordered h] - simp + simp [timeOrderSign_pair_ordered h, timeOrderList_pair_ordered h] lemma timeOrderF_ofFieldOpF_ofFieldOpF_not_ordered {φ ψ : 𝓕.FieldOp} (h : ¬ timeOrderRel φ ψ) : 𝓣ᶠ(ofFieldOpF φ * ofFieldOpF ψ) = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ ψ) • ofFieldOpF ψ * ofFieldOpF φ := by diff --git a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean index 1d9aed40d..c5e27524c 100644 --- a/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean +++ b/Physlib/QFT/PerturbationTheory/Koszul/KoszulSign.lean @@ -114,7 +114,6 @@ lemma koszulSign_insertIdx [Std.Total le] [IsTrans 𝓕 le] (φ : 𝓕) : change 𝓢(q φ, ofList q ((List.insertionSort le (φ1 :: φs)).take (↑(orderedInsertPos le ((List.insertionSort le (φ1 :: φs))) φ)))) rw [← koszulSignInsert_eq_exchangeSign_take q le] - rw [ofList_take_zero] simp | φ1 :: φs, n + 1, h => by conv_lhs => @@ -235,10 +234,7 @@ lemma koszulSign_eraseIdx [Std.Total le] [IsTrans 𝓕 le] (φs : List 𝓕) (n rhs rw [exchangeSign_mul_self] simp only [Fin.getElem_fin, mul_one] - conv_rhs => - rhs - rw [ofList_take_eraseIdx, exchangeSign_mul_self] - simp + simp [ofList_take_eraseIdx, exchangeSign_mul_self] lemma koszulSign_eraseIdx_insertionSortMinPos [Std.Total le] [IsTrans 𝓕 le] (φ : 𝓕) (φs : List 𝓕) : koszulSign q le ((φ :: φs).eraseIdx (insertionSortMinPos le φ φs)) = koszulSign q le (φ :: φs) @@ -285,8 +281,7 @@ lemma koszulSign_eq_rel_eq_stat_append {ψ φ : 𝓕} [IsTrans 𝓕 le] congr simp only [koszulSignInsert, ite_mul, neg_mul] simp_all only [and_self, ite_true] - rw [koszulSignInsert_eq_rel_eq_stat q le h1 h2 hq] - simp + simp [koszulSignInsert_eq_rel_eq_stat q le h1 h2 hq] lemma koszulSign_eq_rel_eq_stat {ψ φ : 𝓕} [IsTrans 𝓕 le] (h1 : le φ ψ) (h2 : le ψ φ) (hq : q ψ = q φ) : (φs' φs : List 𝓕) → @@ -352,8 +347,7 @@ lemma koszulSign_of_append_eq_insertionSort_left [Std.Total le] [IsTrans 𝓕 le Fin.val_cast] rw [insertionSortEquiv_insertionSort_append] simp only [finCongr_apply, Fin.val_cast] - rw [insertionSortEquiv_congr _ _ h1.symm] - simp + simp [insertionSortEquiv_congr _ _ h1.symm] · rw [insertIdx_length_fst_append] rw [show φs.length = (List.insertionSort le φs).length by simp] rw [insertIdx_length_fst_append] From a88b241005eca98430ef24492d993e9968714adc Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:47:53 -0700 Subject: [PATCH 481/498] refactor: golf wick normal-order simplifications Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/NormalOrder/Lemmas.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean index dc013a6e0..d33355862 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Lemmas.lean @@ -102,8 +102,7 @@ lemma normalOrder_superCommute_eq_zero (a b : 𝓕.WickAlgebra) : 𝓝([a, b]ₛ) = 0 := by obtain ⟨a, rfl⟩ := ι_surjective a obtain ⟨b, rfl⟩ := ι_surjective b - rw [superCommute_eq_ι_superCommuteF, normalOrder_eq_ι_normalOrderF] - simp + simp [superCommute_eq_ι_superCommuteF, normalOrder_eq_ι_normalOrderF] @[simp] lemma normalOrder_superCommute_left_eq_zero (a b c: 𝓕.WickAlgebra) : @@ -111,8 +110,7 @@ lemma normalOrder_superCommute_left_eq_zero (a b c: 𝓕.WickAlgebra) : obtain ⟨a, rfl⟩ := ι_surjective a obtain ⟨b, rfl⟩ := ι_surjective b obtain ⟨c, rfl⟩ := ι_surjective c - rw [superCommute_eq_ι_superCommuteF, ← map_mul, normalOrder_eq_ι_normalOrderF] - simp + simp [superCommute_eq_ι_superCommuteF, ← map_mul, normalOrder_eq_ι_normalOrderF] @[simp] lemma normalOrder_superCommute_right_eq_zero (a b c: 𝓕.WickAlgebra) : @@ -120,8 +118,7 @@ lemma normalOrder_superCommute_right_eq_zero (a b c: 𝓕.WickAlgebra) : obtain ⟨a, rfl⟩ := ι_surjective a obtain ⟨b, rfl⟩ := ι_surjective b obtain ⟨c, rfl⟩ := ι_surjective c - rw [superCommute_eq_ι_superCommuteF, ← map_mul, normalOrder_eq_ι_normalOrderF] - simp + simp [superCommute_eq_ι_superCommuteF, ← map_mul, normalOrder_eq_ι_normalOrderF] @[simp] lemma normalOrder_superCommute_mid_eq_zero (a b c d : 𝓕.WickAlgebra) : @@ -130,8 +127,7 @@ lemma normalOrder_superCommute_mid_eq_zero (a b c d : 𝓕.WickAlgebra) : obtain ⟨b, rfl⟩ := ι_surjective b obtain ⟨c, rfl⟩ := ι_surjective c obtain ⟨d, rfl⟩ := ι_surjective d - rw [superCommute_eq_ι_superCommuteF, ← map_mul, ← map_mul, normalOrder_eq_ι_normalOrderF] - simp + simp [superCommute_eq_ι_superCommuteF, ← map_mul, ← map_mul, normalOrder_eq_ι_normalOrderF] /-! @@ -403,8 +399,7 @@ lemma normalOrder_crPart_mul_anPart (φ φ' : 𝓕.FieldOp) : @[simp] lemma normalOrder_anPart_mul_crPart (φ φ' : 𝓕.FieldOp) : 𝓝(anPart φ * crPart φ') = 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • crPart φ' * anPart φ := by - rw [anPart, crPart, ← map_mul, normalOrder_eq_ι_normalOrderF, normalOrderF_anPartF_mul_crPartF] - simp + simp [anPart, crPart, ← map_mul, normalOrder_eq_ι_normalOrderF, normalOrderF_anPartF_mul_crPartF] lemma normalOrder_ofFieldOp_mul_ofFieldOp (φ φ' : 𝓕.FieldOp) : 𝓝(ofFieldOp φ * ofFieldOp φ') = crPart φ * crPart φ' + 𝓢(𝓕 |>ₛ φ, 𝓕 |>ₛ φ') • (crPart φ' * anPart φ) + From 1adcf39593f86f321fa3be4a0e9eb4355d16095a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:50:21 -0700 Subject: [PATCH 482/498] refactor: golf wick normal-order zero proofs Co-authored-by: Claude Opus 4.8 --- .../WickAlgebra/NormalOrder/Basic.lean | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean index 7fe976cbb..70229a01b 100644 --- a/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean +++ b/Physlib/QFT/PerturbationTheory/WickAlgebra/NormalOrder/Basic.lean @@ -67,8 +67,7 @@ lemma ι_normalOrderF_superCommuteF_ofCrAnListF_eq_zero exact ι_normalOrderF_superCommuteF_ofCrAnListF_ofCrAnListF_eq_zero φa φa' φs l change (ι.toLinearMap ∘ₗ normalOrderF ∘ₗ mulLinearMap ((ofCrAnListF φs * [ofCrAnOpF φa, ofCrAnOpF φa']ₛF))) a = 0 - rw [hf] - simp + simp [hf] lemma ι_normalOrderF_superCommuteF_ofCrAnOpF_eq_zero_mul (φa φa' : 𝓕.CrAnFieldOp) (a b : 𝓕.FieldOpFreeAlgebra) : @@ -84,8 +83,7 @@ lemma ι_normalOrderF_superCommuteF_ofCrAnOpF_eq_zero_mul (φa φa' : 𝓕.CrAnF Function.comp_apply, LinearMap.flip_apply, LinearMap.coe_mk, AddHom.coe_mk, AlgHom.toLinearMap_apply, LinearMap.zero_apply] simpa [← mul_assoc] using ι_normalOrderF_superCommuteF_ofCrAnListF_eq_zero φa φa' _ _ - rw [hf] - simp + simp [hf] lemma ι_normalOrderF_superCommuteF_ofCrAnOpF_ofCrAnListF_eq_zero_mul (φa : 𝓕.CrAnFieldOp) (φs : List 𝓕.CrAnFieldOp) (a b : 𝓕.FieldOpFreeAlgebra) : @@ -103,8 +101,7 @@ lemma ι_normalOrderF_superCommuteF_ofCrAnListF_ofCrAnOpF_eq_zero_mul (φa : rw [← ofCrAnListF_singleton, superCommuteF_ofCrAnListF_ofCrAnListF_symm, ofCrAnListF_singleton] simp only [ofList_singleton, Algebra.mul_smul_comm, Algebra.smul_mul_assoc, map_smul] - rw [ι_normalOrderF_superCommuteF_ofCrAnOpF_ofCrAnListF_eq_zero_mul] - simp + simp [ι_normalOrderF_superCommuteF_ofCrAnOpF_ofCrAnListF_eq_zero_mul] lemma ι_normalOrderF_superCommuteF_ofCrAnListF_ofCrAnListF_eq_zero_mul (φs φs' : List 𝓕.CrAnFieldOp) (a b : 𝓕.FieldOpFreeAlgebra) : @@ -130,8 +127,7 @@ lemma ι_normalOrderF_superCommuteF_ofCrAnListF_eq_zero_mul LinearMap.coe_comp, Function.comp_apply, LinearMap.flip_apply, AlgHom.toLinearMap_apply, LinearMap.zero_apply] rw [ι_normalOrderF_superCommuteF_ofCrAnListF_ofCrAnListF_eq_zero_mul] - rw [hf] - simp + simp [hf] @[simp] lemma ι_normalOrderF_superCommuteF_eq_zero_mul @@ -146,8 +142,7 @@ lemma ι_normalOrderF_superCommuteF_eq_zero_mul LinearMap.coe_comp, Function.comp_apply, LinearMap.flip_apply, AlgHom.toLinearMap_apply, LinearMap.zero_apply] rw [ι_normalOrderF_superCommuteF_ofCrAnListF_eq_zero_mul] - rw [hf] - simp + simp [hf] @[simp] lemma ι_normalOrder_superCommuteF_eq_zero_mul_right (b c d : 𝓕.FieldOpFreeAlgebra) : @@ -166,8 +161,7 @@ lemma ι_normalOrderF_superCommuteF_eq_zero_mul_mul_right (a b1 b2 c d: 𝓕.Fie @[simp] lemma ι_normalOrderF_superCommuteF_eq_zero (c d : 𝓕.FieldOpFreeAlgebra) : ι 𝓝ᶠ([d, c]ₛF) = 0 := by - rw [← ι_normalOrderF_superCommuteF_eq_zero_mul 1 1 c d] - simp + simpa using ι_normalOrderF_superCommuteF_eq_zero_mul (1 : 𝓕.FieldOpFreeAlgebra) 1 c d /-! From 7187399bf34a231d3ed2b966559de13317b5a634 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:53:52 -0700 Subject: [PATCH 483/498] refactor: golf wick insertion finite-set proofs Co-authored-by: Claude Opus 4.8 --- .../WickContraction/InsertAndContractNat.lean | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean index 668a85b6e..e6a45f574 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/InsertAndContractNat.lean @@ -76,8 +76,7 @@ def insertAndContractNat (c : WickContraction n) (i : Fin n.succ) (j : Option (c simp_all only [Finset.mem_insert, Nat.succ_eq_add_one] match ha, hb with | Or.inl ha, Or.inl hb => - rw [ha, hb] - simp + simp [ha, hb] | Or.inl ha, Or.inr hb => apply Or.inr subst ha @@ -343,8 +342,7 @@ lemma insertAndContractNat_none_getDual?_isNone (c : WickContraction n) (i : Fin ((insertAndContractNat c i none).getDual? i).isNone := by have hi : i ∈ (insertAndContractNat c i none).uncontracted := by simp simp only [Nat.succ_eq_add_one, uncontracted, Finset.mem_filter, Finset.mem_univ, true_and] at hi - rw [hi] - simp + simp [hi] set_option backward.isDefEq.respectTransparency false in @[simp] @@ -498,8 +496,7 @@ lemma insertAndContractNat_erase (c : WickContraction n) (i : Fin n.succ) intro x exact fun a => Fin.succAbove_ne i x refine False.elim (hin ?_) - rw [ha] - simp + simp [ha] · obtain ⟨a', ha', ha''⟩ := ha rw [Finset.mapEmbedding_apply] at ha'' simp only [Finset.map_inj] at ha'' @@ -700,8 +697,7 @@ lemma insertLiftSome_injective {c : WickContraction n} (i : Fin n.succ) (j : c.u simp only [Finset.map_insert, Fin.succAboveEmb_apply, Finset.map_singleton] at hab have hi : i ∈ ({i.succAbove (c.fstFieldOfContract a), i.succAbove (c.sndFieldOfContract a)} : Finset (Fin (n + 1))) := by - rw [← hab] - simp + simp [← hab] simp only [Nat.succ_eq_add_one, Finset.mem_insert, Finset.mem_singleton] at hi rcases hi with hi | hi · exact False.elim (Fin.ne_succAbove _ _ hi) @@ -712,8 +708,7 @@ lemma insertLiftSome_injective {c : WickContraction n} (i : Fin n.succ) (j : c.u simp only [Finset.map_insert, Fin.succAboveEmb_apply, Finset.map_singleton] at hab have hi : i ∈ ({i.succAbove (c.fstFieldOfContract a), i.succAbove (c.sndFieldOfContract a)} : Finset (Fin (n + 1))) := by - rw [hab] - simp + simp [hab] simp only [Nat.succ_eq_add_one, Finset.mem_insert, Finset.mem_singleton] at hi rcases hi with hi | hi · exact False.elim (Fin.ne_succAbove _ _ hi) From 361581fc6aac6f29fa3edf591a77a6e3866c7137 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 14:56:37 -0700 Subject: [PATCH 484/498] refactor: golf wick uncontracted finite-set proofs Co-authored-by: Claude Opus 4.8 --- .../PerturbationTheory/WickContraction/Card.lean | 3 +-- .../WickContraction/UncontractedList.lean | 15 +++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean b/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean index a2bce41e0..fc5fffdcb 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/Card.lean @@ -53,8 +53,7 @@ lemma wickContraction_zero_some_eq_sum : ext · simp [c.2.2.2] · rfl} - rw [Fintype.card_congr e1] - simp + simpa using Fintype.card_congr e1 lemma finset_succAbove_succ_disjoint (a : Finset (Fin n)) (i : Fin n.succ) : Disjoint ((Finset.map (Fin.succEmb (n + 1))) ((Finset.map i.succAboveEmb) a)) {0, i.succ} := by diff --git a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean index 3ab88ab1b..2613a8574 100644 --- a/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean +++ b/Physlib/QFT/PerturbationTheory/WickContraction/UncontractedList.lean @@ -246,8 +246,7 @@ lemma filter_uncontractedList (c : WickContraction n) (p : Fin n → Prop) [Deci ext a simp only [List.toFinset_filter, decide_eq_true_eq, Finset.mem_filter, List.mem_toFinset, and_congr_left_iff] - rw [uncontractedList_mem_iff] - simp + simp [uncontractedList_mem_iff] have hx := (List.toFinset_sort (· ≤ ·) h2).mpr h1 rw [← hx, h3] @@ -293,8 +292,7 @@ lemma take_uncontractedIndexEquiv_symm (k : c.uncontracted) : conv_lhs => rhs rw [hl] - rw [uncontractedIndexEquiv_symm_eq_filter_length] - simp + simp [uncontractedIndexEquiv_symm_eq_filter_length] /-! ## Uncontracted List get @@ -463,8 +461,7 @@ lemma uncontractedList_succAbove_orderedInsert_toFinset (c : WickContraction n) ext a simp only [Nat.succ_eq_add_one, Fin.coe_succAboveEmb, List.mem_toFinset, List.mem_orderedInsert, List.mem_map, Finset.mem_insert, Finset.mem_map, Fin.succAboveEmb_apply] - rw [← uncontractedList_toFinset] - simp + simp [← uncontractedList_toFinset] lemma uncontractedList_succAbove_orderedInsert_eq_sort (c : WickContraction n) (i : Fin n.succ) : (List.orderedInsert (· ≤ ·) i (List.map i.succAboveEmb c.uncontractedList)) = @@ -553,8 +550,7 @@ lemma uncontractedList_succAboveEmb_toFinset (c : WickContraction n) (i : Fin n. ext a simp only [Fin.coe_succAboveEmb, List.mem_toFinset, List.mem_map, Finset.mem_map, Fin.succAboveEmb_apply] - rw [← c.uncontractedList_toFinset] - simp + simp [← c.uncontractedList_toFinset] /-! @@ -593,8 +589,7 @@ lemma take_uncontractedListOrderPos_eq_filter_sort (c : WickContraction n) (i : List.Nodup.filter _ (uncontractedList_nodup c) have h3 : (c.uncontractedList.filter (fun x => x.1 < i.1)).toFinset = (c.uncontracted.filter (fun x => x.1 < i.1)) := by - rw [uncontractedList_eq_sort] - simp + simp [uncontractedList_eq_sort] simpa [← h3] using ((List.toFinset_sort (α := Fin n) (· ≤ ·) h2).mpr h1).symm lemma orderedInsert_succAboveEmb_uncontractedList_eq_insertIdx (c : WickContraction n) From b7058a87be7a419bea7b6a50ad8c10bc0cb979b6 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:00:02 -0700 Subject: [PATCH 485/498] refactor: golf complex tensor metric apply-one proofs Co-authored-by: Claude Opus 4.8 --- .../Tensors/ComplexTensor/Metrics/Pre.lean | 6 ++---- .../Tensors/ComplexTensor/Weyl/Metric.lean | 12 ++++-------- .../Relativity/Tensors/ComplexTensor/Weyl/Unit.lean | 12 ++++-------- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean index 8758e0e7b..2e496505d 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean @@ -68,8 +68,7 @@ def contrMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap simp only [LorentzGroup.toComplex_mul_minkowskiMatrix_mul_transpose] lemma contrMetric_apply_one : contrMetric (1 : ℂ) = contrMetricVal := by - change (1 : ℂ) • contrMetricVal = contrMetricVal - simp only [one_smul] + simp [contrMetric] /-- The metric `ηᵢᵢ` as an element of `(complexCo ⊗ complexCo).V`. -/ def coMetricVal : (CoℂModule ⊗[ℂ] CoℂModule) := @@ -118,8 +117,7 @@ def coMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap LorentzGroup.toComplex_transpose_mul_minkowskiMatrix_mul_self] lemma coMetric_apply_one : coMetric (1 : ℂ) = coMetricVal := by - change (1 : ℂ) • coMetricVal = coMetricVal - simp only [one_smul] + simp [coMetric] /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean index 4e842a7cd..eacb75088 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean @@ -107,8 +107,7 @@ def leftMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap not_false_eq_true, mul_nonsing_inv, transpose_one, mul_one] lemma leftMetric_apply_one : leftMetric (1 : ℂ) = leftMetricVal := by - change (1 : ℂ) • leftMetricVal = leftMetricVal - simp only [one_smul] + simp [leftMetric] /-- The metric `εₐₐ` as an element of `(dualLeftHanded ⊗ dualLeftHanded).V`. -/ def dualLeftMetricVal : (DualLeftHandedWeyl ⊗[ℂ] DualLeftHandedWeyl) := @@ -148,8 +147,7 @@ def dualLeftMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap not_false_eq_true, mul_nonsing_inv, mul_one] lemma dualLeftMetric_apply_one : dualLeftMetric (1 : ℂ) = dualLeftMetricVal := by - change (1 : ℂ) • dualLeftMetricVal = dualLeftMetricVal - simp only [one_smul] + simp [dualLeftMetric] /-- The metric `ε^{dot a}^{dot a}` as an element of `(rightHanded ⊗ rightHanded).V`. -/ def rightMetricVal : (RightHandedWeyl ⊗[ℂ] RightHandedWeyl) := @@ -200,8 +198,7 @@ def rightMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap · rw [← rightRightToMatrix_ρ_symm metricRaw M] lemma rightMetric_apply_one : rightMetric (1 : ℂ) = rightMetricVal := by - change (1 : ℂ) • rightMetricVal = rightMetricVal - simp only [one_smul] + simp [rightMetric] /-- The metric `ε_{dot a}_{dot a}` as an element of `(dualRightHanded ⊗ dualRightHanded).V`. -/ def dualRightMetricVal : DualRightHandedWeyl ⊗[ℂ] DualRightHandedWeyl := @@ -251,8 +248,7 @@ def dualRightMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap rfl lemma dualRightMetric_apply_one : dualRightMetric (1 : ℂ) = dualRightMetricVal := by - change (1 : ℂ) • dualRightMetricVal = dualRightMetricVal - simp only [one_smul] + simp [dualRightMetric] /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean index c396f1d47..7390a73c3 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Unit.lean @@ -60,8 +60,7 @@ def leftDualLeftUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMa simp lemma leftDualLeftUnit_apply_one : leftDualLeftUnit (1 : ℂ) = leftDualLeftUnitVal := by - change (1 : ℂ) • leftDualLeftUnitVal = leftDualLeftUnitVal - simp only [one_smul] + simp [leftDualLeftUnit] /-- The dual-left-left unit `δₐᵃ` as an element of `(dualLeftHanded ⊗ leftHanded).V`. -/ def dualLeftLeftUnitVal : (DualLeftHandedWeyl ⊗[ℂ] LeftHandedWeyl) := @@ -100,8 +99,7 @@ def dualLeftLeftUnit : /-- Applying the morphism `dualLeftLeftUnit` to `1` returns `dualLeftLeftUnitVal`. -/ lemma dualLeftLeftUnit_apply_one : dualLeftLeftUnit (1 : ℂ) = dualLeftLeftUnitVal := by - change (1 : ℂ) • dualLeftLeftUnitVal = dualLeftLeftUnitVal - simp only [one_smul] + simp [dualLeftLeftUnit] /-- The right-dual-right unit `δ^{dot a}_{dot a}` as an element of `(rightHanded ⊗ dualRightHanded).V`. -/ @@ -145,8 +143,7 @@ def rightDualRightUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).Intertwining simp lemma rightDualRightUnit_apply_one : rightDualRightUnit (1 : ℂ) = rightDualRightUnitVal := by - change (1 : ℂ) • rightDualRightUnitVal = rightDualRightUnitVal - simp only [one_smul] + simp [rightDualRightUnit] /-- The dual-right-right unit `δ_{dot a}^{dot a}` as an element of `(rightHanded ⊗ dualRightHanded).V`. -/ @@ -188,8 +185,7 @@ def dualRightRightUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).Intertwining simp lemma dualRightRightUnit_apply_one : dualRightRightUnit (1 : ℂ) = dualRightRightUnitVal := by - change (1 : ℂ) • dualRightRightUnitVal = dualRightRightUnitVal - simp only [one_smul] + simp [dualRightRightUnit] /-! From da68366a90139f474d446f182f600605739f2f9d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:01:41 -0700 Subject: [PATCH 486/498] refactor: golf tensor unit apply-one proofs Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/PauliMatrices/AsTensor.lean | 3 +-- Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean | 6 ++---- Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean | 6 ++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Physlib/Relativity/PauliMatrices/AsTensor.lean b/Physlib/Relativity/PauliMatrices/AsTensor.lean index 9234420b1..36204c4a7 100644 --- a/Physlib/Relativity/PauliMatrices/AsTensor.lean +++ b/Physlib/Relativity/PauliMatrices/AsTensor.lean @@ -172,8 +172,7 @@ def asConsTensor : /-- The map `𝟙_ (Rep ℂ SL(2,ℂ)) ⟶ complexContr ⊗ leftHanded ⊗ rightHanded` corresponding to Pauli matrices, when evaluated on `1` corresponds to the tensor `PauliMatrix.asTensor`. -/ lemma asConsTensor_apply_one : asConsTensor (1 : ℂ) = asTensor := by - change (1 : ℂ) • asTensor = asTensor - simp only [one_smul] + simp [asConsTensor] end end PauliMatrix diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean index f257126b5..bd741f3f3 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean @@ -70,8 +70,7 @@ def contrCoUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap simp lemma contrCoUnit_apply_one : contrCoUnit (1 : ℂ) = contrCoUnitVal := by - change (1 : ℂ) • contrCoUnitVal = contrCoUnitVal - rw [one_smul] + simp [contrCoUnit] /-- The co-contra unit for complex lorentz vectors. Usually denoted `δᵢⁱ`. -/ def coContrUnitVal : CoℂModule ⊗[ℂ] ContrℂModule := @@ -121,8 +120,7 @@ def coContrUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap simp lemma coContrUnit_apply_one : coContrUnit (1 : ℂ) = coContrUnitVal := by - change (1 : ℂ) • coContrUnitVal = coContrUnitVal - rw [one_smul] + simp [coContrUnit] /-! diff --git a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean index fc51bb941..3954f1ff8 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Units/Pre.lean @@ -67,8 +67,7 @@ def preContrCoUnit (d : ℕ := 3) : simp lemma preContrCoUnit_apply_one {d : ℕ} : (preContrCoUnit d) (1 : ℝ) = preContrCoUnitVal d := by - change (1 : ℝ) • preContrCoUnitVal d = preContrCoUnitVal d - rw [one_smul] + simp [preContrCoUnit] /-- The co-contra unit for complex lorentz vectors. Usually denoted `δᵢⁱ`. -/ def preCoContrUnitVal (d : ℕ := 3) : (Co d ⊗ Contr d).V := @@ -118,8 +117,7 @@ def preCoContrUnit (d : ℕ) : (Representation.trivial ℝ (LorentzGroup d) ℝ) simp lemma preCoContrUnit_apply_one {d : ℕ} : (preCoContrUnit d) (1 : ℝ) = preCoContrUnitVal d := by - change (1 : ℝ) • preCoContrUnitVal d = preCoContrUnitVal d - rw [one_smul] + simp [preCoContrUnit] /-! From fa161b8ed009633cae6bc0a25928148fdf5104e3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:12:08 -0700 Subject: [PATCH 487/498] refactor: golf Lorentz reindexing proof endings Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/LorentzGroup/Proper.lean | 14 ++++---------- Physlib/Relativity/Tensors/MetricTensor.lean | 3 +-- Physlib/Relativity/Tensors/Reindexing.lean | 6 ++---- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Physlib/Relativity/LorentzGroup/Proper.lean b/Physlib/Relativity/LorentzGroup/Proper.lean index f013917e8..a2a051ead 100644 --- a/Physlib/Relativity/LorentzGroup/Proper.lean +++ b/Physlib/Relativity/LorentzGroup/Proper.lean @@ -73,8 +73,7 @@ lemma detContinuous_eq_one (Λ : LorentzGroup d) : refine Iff.intro (fun h => ?_) (fun h => ?_) · by_contra hn have h' := h hn - change (1 : Fin 2) = (0 : Fin 2) at h' - simp only [Fin.isValue, one_ne_zero] at h' + exact (show (1 : Fin 2) ≠ 0 by decide) h' · intro h' exact False.elim (h' h) @@ -85,8 +84,7 @@ lemma detContinuous_eq_zero (Λ : LorentzGroup d) : refine Iff.intro (fun h => ?_) (fun h => ?_) · by_contra hn rw [if_pos] at h - · change (0 : Fin 2) = (1 : Fin 2) at h - simp only [Fin.isValue, zero_ne_one] at h + · exact (show (0 : Fin 2) ≠ 1 by decide) h · cases' det_eq_one_or_neg_one Λ with h2 h2 · simp_all only [ite_true] · simp_all only [not_true_eq_false] @@ -108,14 +106,10 @@ lemma detContinuous_eq_iff_det_eq (Λ Λ' : LorentzGroup d) : simp only [Nat.reduceAdd] | .inl h1, .inr h2 => rw [h1, h2, (detContinuous_eq_one Λ).mpr h1, (detContinuous_eq_zero Λ').mpr h2] - change (0 : Fin 2) = (1 : Fin 2) ↔ _ - simp only [zero_ne_one, false_iff] - linarith + exact iff_of_false (by decide) (by linarith) | .inr h1, .inl h2 => rw [h1, h2, (detContinuous_eq_zero Λ).mpr h1, (detContinuous_eq_one Λ').mpr h2] - change (1 : Fin 2) = (0 : Fin 2) ↔ _ - simp only [one_ne_zero, false_iff] - linarith + exact iff_of_false (show (1 : Fin 2) ≠ 0 by decide) (by linarith) /-- The representation taking a Lorentz matrix to its determinant. -/ @[simps!] diff --git a/Physlib/Relativity/Tensors/MetricTensor.lean b/Physlib/Relativity/Tensors/MetricTensor.lean index f395ad1b1..7599e724a 100644 --- a/Physlib/Relativity/Tensors/MetricTensor.lean +++ b/Physlib/Relativity/Tensors/MetricTensor.lean @@ -72,8 +72,7 @@ lemma contrT_metricTensor_metricTensor_eq_dual_unit {c : C} : contrT 2 1 2 (by simp; rfl) (prodT (metricTensor c) (metricTensor (S.τ c))) = permT ![0, 1] (And.intro (by decide) (fun i => by fin_cases i - · change S.τ (S.τ c) = c - simp + · exact S.τ_involution c · rfl)) (unitTensor (S := S) (S.τ c)) := by rw [contrT_metricTensor_metricTensor, unitTensor_eq_permT_dual, permT_permT] diff --git a/Physlib/Relativity/Tensors/Reindexing.lean b/Physlib/Relativity/Tensors/Reindexing.lean index 3a8eaa34d..7ba264b73 100644 --- a/Physlib/Relativity/Tensors/Reindexing.lean +++ b/Physlib/Relativity/Tensors/Reindexing.lean @@ -98,14 +98,12 @@ def toEquiv {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} lemma apply_inv_apply {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} (σ : Fin m → Fin n) (h : IsReindexing c c1 σ) (x : Fin m) : h.inv σ (σ x) = x := by - change h.toEquiv (h.toEquiv.symm x) = x - simp + simpa [inv, toEquiv] using h.toEquiv.apply_symm_apply x lemma inv_apply_apply {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} (σ : Fin m → Fin n) (h : IsReindexing c c1 σ) (x : Fin n) : σ (h.inv σ x) = x := by - change h.toEquiv.symm (h.toEquiv x) = x - simp + simpa [inv, toEquiv] using h.toEquiv.symm_apply_apply x lemma preserve_color {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} {σ : Fin m → Fin n} (h : IsReindexing c c1 σ) : From a95ae6a551f7d647516af6e5468e4b1a74e8a792 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:17:05 -0700 Subject: [PATCH 488/498] refactor: golf tensor and qft exact wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/QFT/AnomalyCancellation/GroupActions.lean | 12 +++--------- Physlib/Relativity/Tensors/Basic.lean | 1 - .../Tensors/Contraction/SuccSuccAbove.lean | 1 - Physlib/Relativity/Tensors/Tensorial.lean | 1 - 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Physlib/QFT/AnomalyCancellation/GroupActions.lean b/Physlib/QFT/AnomalyCancellation/GroupActions.lean index bb1345b20..fb85e12a6 100644 --- a/Physlib/QFT/AnomalyCancellation/GroupActions.lean +++ b/Physlib/QFT/AnomalyCancellation/GroupActions.lean @@ -60,12 +60,10 @@ def linSolRep {χ : ACCSystem} (G : ACCSystemGroupAction χ) : toFun := G.linSolMap map_mul' g1 g2 := by refine LinearMap.ext fun S ↦ ACCSystemLinear.LinSols.ext ?_ - change (G.rep (g1 * g2)) S.val = _ exact LinearMap.congr_fun (G.rep.map_mul g1 g2) S.val map_one' := by refine LinearMap.ext fun S ↦ ACCSystemLinear.LinSols.ext ?_ - change (G.rep.toFun 1) S.val = _ - simp only [G.rep.map_one', Module.End.one_apply] + exact LinearMap.congr_fun G.rep.map_one S.val /-- The representation on the charges and anomaly free solutions commutes with the inclusion. -/ @@ -80,12 +78,10 @@ instance quadSolAction {χ : ACCSystem} (G : ACCSystemGroupAction χ) : smul f S := ⟨G.linSolRep f S.1, by simp [linSolRep_apply_apply_val, G.quadInvariant, S.quadSol]⟩ mul_smul f1 f2 S := by apply ACCSystemQuad.QuadSols.ext - change (G.rep.toFun (f1 * f2)) S.val = _ exact LinearMap.congr_fun (G.rep.map_mul' f1 f2) S.val one_smul S := by apply ACCSystemQuad.QuadSols.ext - change (G.rep.toFun 1) S.val = _ - simp only [G.rep.map_one', Module.End.one_apply] + exact LinearMap.congr_fun G.rep.map_one S.val lemma linSolRep_quadSolAction_commute {χ : ACCSystem} (G : ACCSystemGroupAction χ) (g : G.group) (S : χ.QuadSols) : χ.quadSolsInclLinSols (G.quadSolAction.toFun _ _ S g) = @@ -103,12 +99,10 @@ instance solAction {χ : ACCSystem} (G : ACCSystemGroupAction χ) : MulAction G. rw [G.cubicInvariant, S.cubicSol]⟩ mul_smul f1 f2 S := by apply ACCSystem.Sols.ext - change (G.rep.toFun (f1 * f2)) S.val = _ exact LinearMap.congr_fun (G.rep.map_mul' f1 f2) S.val one_smul S := by apply ACCSystem.Sols.ext - change (G.rep.toFun 1) S.val = _ - simp only [G.rep.map_one', Module.End.one_apply] + exact LinearMap.congr_fun G.rep.map_one S.val lemma quadSolAction_solAction_commute {χ : ACCSystem} (G : ACCSystemGroupAction χ) (g : G.group) (S : χ.Sols) : χ.solsInclQuadSols (G.solAction.toFun _ _ S g) = diff --git a/Physlib/Relativity/Tensors/Basic.lean b/Physlib/Relativity/Tensors/Basic.lean index a9ef2524b..cfea4048c 100644 --- a/Physlib/Relativity/Tensors/Basic.lean +++ b/Physlib/Relativity/Tensors/Basic.lean @@ -251,7 +251,6 @@ noncomputable def componentMap {n : ℕ} (c : Fin n → C) : exact component_update_add p i x y b map_update_smul' p i x y := by ext b - change component (update p i (x • y)) b = x * component (update p i y) b exact component_update_smul p i x y b @[simp] diff --git a/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean b/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean index ccb40069f..5ca0785e2 100644 --- a/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean +++ b/Physlib/Relativity/Tensors/Contraction/SuccSuccAbove.lean @@ -340,7 +340,6 @@ lemma succSuccAbove_comm_apply (i1 j1 : Fin (n + 1 + 1 + 1 + 1)) (i2 j2 : Fin (n succSuccAbove i2' j2' (succSuccAbove i1' j1' m) = succSuccAbove i1 j1 (succSuccAbove i2 j2 m) := by intro i2' j2' hi2j2' i1' j1' - change _ = (succSuccAbove i1 j1 ∘ succSuccAbove i2 j2) m exact (congr_fun (succSuccAbove_comm i1 j1 i2 j2 hij1 hij2) m).symm /-! diff --git a/Physlib/Relativity/Tensors/Tensorial.lean b/Physlib/Relativity/Tensors/Tensorial.lean index 6f1794119..0ea6dc78a 100644 --- a/Physlib/Relativity/Tensors/Tensorial.lean +++ b/Physlib/Relativity/Tensors/Tensorial.lean @@ -388,7 +388,6 @@ def toTensorCLM [IsTopologicalAddGroup M] continuous_toFun := by let e : M →L[k] (S.Tensor c) := LinearMap.toContinuousLinearMap (Tensorial.toTensor (M := M)) - change Continuous e exact ContinuousLinearMap.continuous e continuous_invFun := by apply IsModuleTopology.continuous_of_linearMap From 689a07d230b555a59e09502df369fb901115af0d Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:20:39 -0700 Subject: [PATCH 489/498] refactor: golf unit and finite-sum wrappers Co-authored-by: Claude Opus 4.8 --- .../BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean | 1 - Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean | 1 - .../SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean | 1 - Physlib/Relativity/Tensors/MetricTensor.lean | 1 - Physlib/Units/UnitDependent.lean | 3 +-- Physlib/Units/WithDim/Basic.lean | 1 - 6 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean index f81cc1ad7..138d1cb1b 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean @@ -34,7 +34,6 @@ variable {n : ℕ} lemma sum_one [AddCommMonoid M] (f : Fin (SMνSpecies 1).numberCharges → M) : ∑ i, f i = f ⟨0, by simp⟩ := by - change ∑ (i : Fin 1), f i = _ exact Fin.sum_univ_one f /-- An equivalence between `(SMνCharges n).charges` and `(Fin 6 → Fin n → ℚ)` diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index eb4e78a4d..1acbee206 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -34,7 +34,6 @@ variable {n : ℕ} lemma sum_SMSpecies_numberCharges_one {M} [AddCommMonoid M] (f : Fin (SMSpecies 1).numberCharges → M) : ∑ i, f i = f ⟨0, by simp⟩ := by - change ∑ (i : Fin 1), f i = _ exact Fin.sum_univ_one f /-- An equivalence between the set `(SMCharges n).charges` and the set diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean index c1b3d5f86..5db2b0dfb 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean @@ -32,7 +32,6 @@ namespace MSSMCharges lemma sum_MSSMSpecies_numberCharges_eq_expand [AddCommMonoid M] (f : Fin MSSMSpecies.numberCharges → M) : ∑ i, f i = f ⟨0, by simp⟩ + f ⟨1, by simp⟩ + f ⟨2, by simp⟩ := by - change ∑ (i : Fin 3), f i = f ⟨0, by simp⟩ + f ⟨1, by simp⟩ + f ⟨2, by simp⟩ exact Fin.sum_univ_three f /-- An equivalence between `MSSMCharges.charges` and the space of maps diff --git a/Physlib/Relativity/Tensors/MetricTensor.lean b/Physlib/Relativity/Tensors/MetricTensor.lean index 7599e724a..f8f6159f7 100644 --- a/Physlib/Relativity/Tensors/MetricTensor.lean +++ b/Physlib/Relativity/Tensors/MetricTensor.lean @@ -43,7 +43,6 @@ lemma permT_fromPairTContr_metric_metric {c : C} : (fromPairTContr ((S.metric c) (1 : k)) ((S.metric ((S.τ c))) (1 : k))) = (unitTensor c) := by rw [fromPairTContr, ← fromPairT_comm] - change _ = fromPairT ((S.unit c) (1 : k)) exact congr_arg fromPairT (S.contr_metric c) lemma fromPairTContr_metric_metric_eq_permT_unit {c : C} : diff --git a/Physlib/Units/UnitDependent.lean b/Physlib/Units/UnitDependent.lean index 3ba345278..a90342013 100644 --- a/Physlib/Units/UnitDependent.lean +++ b/Physlib/Units/UnitDependent.lean @@ -274,8 +274,7 @@ noncomputable instance {M : Type} [AddCommMonoid M] [Module ℝ M] conv => enter [1, m] rw [toDimensionful_apply_apply] - change Continuous fun m => (u1.dimScale u2 (dim M)).1 • m - exact Continuous.const_smul continuous_id' _ + exact Continuous.const_smul continuous_id' (u1.dimScale u2 (dim M)).1 /-! diff --git a/Physlib/Units/WithDim/Basic.lean b/Physlib/Units/WithDim/Basic.lean index 63d44b1bf..d9b179f81 100644 --- a/Physlib/Units/WithDim/Basic.lean +++ b/Physlib/Units/WithDim/Basic.lean @@ -120,7 +120,6 @@ instance (d : Dimension) (M : Type) [Preorder M] : le_refl m := le_refl m.val le_trans m1 m2 m3 h12 h23 := le_trans h12 h23 lt_iff_le_not_ge m1 m2 := by - change m1.val < m2.val ↔ m1.val ≤ m2.val ∧ ¬ m2.val ≤ m1.val exact lt_iff_le_not_ge instance (d : Dimension) (M : Type) [PartialOrder M] : From d4447b4071b1628fc0dcf3a51088457657dfba65 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:23:52 -0700 Subject: [PATCH 490/498] refactor: golf particle scalar wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean | 1 - .../MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean | 3 --- Physlib/Relativity/Tensors/RealTensor/ToComplex.lean | 1 - 3 files changed, 5 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean index 8ae9b4658..cf52cc138 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/QuadSolToSol.lean @@ -59,7 +59,6 @@ def generic (S : (PlusU1 n).QuadSols) : (PlusU1 n).Sols := lemma generic_on_AF (S : (PlusU1 n).Sols) : generic S.1 = (α₁ S.1) • S := by apply ACCSystem.Sols.ext - change (BL.addQuad S.1 (α₁ S.1) (α₂ S.1)).val = _ exact congrArg (fun Q : (PlusU1 n).QuadSols => Q.val) (BL_add_α₁_α₂_AF S) lemma generic_on_AF_α₁_ne_zero (S : (PlusU1 n).Sols) (h : α₁ S.1 ≠ 0) : diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean index 6a28f9e20..be63be629 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/OrthogY3B3/ToSols.lean @@ -257,7 +257,6 @@ def inLineEqProj (T : InLineEqSol) : InLineEq × ℚ × ℚ × ℚ := lemma inLineEqTo_smul (R : InLineEq) (c₁ c₂ c₃ d : ℚ) : inLineEqToSol (R, (d * c₁), (d * c₂), (d * c₃)) = d • inLineEqToSol (R, c₁, c₂, c₃) := by apply ACCSystem.Sols.ext - change (lineQuad _ _ _ _).val = _ exact congrArg (fun x => x.val) (lineQuad_smul R.val c₁ c₂ c₃ d) lemma inLineEqToSol_proj (T : InLineEqSol) : inLineEqToSol (inLineEqProj T) = T.val := by @@ -288,7 +287,6 @@ def inQuadToSol : InQuad × ℚ × ℚ × ℚ → MSSMACC.Sols := fun (R, a₁, lemma inQuadToSol_smul (R : InQuad) (c₁ c₂ c₃ d : ℚ) : inQuadToSol (R, (d * c₁), (d * c₂), (d * c₃)) = d • inQuadToSol (R, c₁, c₂, c₃) := by apply ACCSystem.Sols.ext - change (lineCube _ _ _ _).val = _ exact congrArg (fun x => x.val) (lineCube_smul R.val.val c₁ c₂ c₃ d) /-- On elements of `inQuadSol` a right-inverse to `inQuadToSol`. -/ @@ -327,7 +325,6 @@ def inQuadCubeToSol : InQuadCube × ℚ × ℚ × ℚ → MSSMACC.Sols := fun (R lemma inQuadCubeToSol_smul (R : InQuadCube) (c₁ c₂ c₃ d : ℚ) : inQuadCubeToSol (R, (d * c₁), (d * c₂), (d * c₃)) = d • inQuadCubeToSol (R, c₁, c₂, c₃) := by apply ACCSystem.Sols.ext - change (planeY₃B₃ _ _ _ _).val = _ exact congrArg (fun x => x.val) (planeY₃B₃_smul R.val.val.val c₁ c₂ c₃ d) /-- On elements of `inQuadCubeSol` a right-inverse to `inQuadCubeToSol`. -/ diff --git a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean index ee5fab2fa..44e3be6d7 100644 --- a/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean +++ b/Physlib/Relativity/Tensors/RealTensor/ToComplex.lean @@ -503,7 +503,6 @@ lemma toComplex_equivariant {n} {c : Fin n → realLorentzTensor.Color} · rw [actionT_pure, toComplex_pure, actionT_pure, actionP_toComplexPure, toComplex_pure] · simp rw [← h] - change Λ • (r : ℂ) • toComplex t = _ exact actionT_smul (g := Λ) (r := (r : ℂ)) (t := toComplex t) · simp_all From b5640dff9cd470b9d502279c53dea1922eddedcd Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:29:22 -0700 Subject: [PATCH 491/498] refactor: golf time and unit wrapper proofs Co-authored-by: Claude Opus 4.8 --- Physlib/SpaceAndTime/Time/Basic.lean | 3 +-- Physlib/SpaceAndTime/TimeAndSpace/Basic.lean | 2 -- Physlib/Units/Basic.lean | 6 ++---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index e6d5e389d..de09ba2df 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -185,8 +185,7 @@ instance : PartialOrder Time where lemma lt_def (t1 t2 : Time) : t1 < t2 ↔ t1.val < t2.val := by - change t1.val ≤ t2.val ∧ ¬ t2.val ≤ t1.val ↔ t1.val < t2.val - rw [lt_iff_le_not_ge] + exact Iff.symm lt_iff_le_not_ge /-! diff --git a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean index c5084a40e..cae49e6df 100644 --- a/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean +++ b/Physlib/SpaceAndTime/TimeAndSpace/Basic.lean @@ -97,14 +97,12 @@ lemma space_apply (tx : TimeAndSpace d) : /-- The time projection is nonexpanding for the product metric. -/ lemma dist_time_le (tx ty : TimeAndSpace d) : dist (time tx) (time ty) ≤ dist tx ty := by - change dist tx.1 ty.1 ≤ dist tx ty rw [Prod.dist_eq] exact le_max_left (dist tx.1 ty.1) (dist tx.2 ty.2) /-- The spatial projection is nonexpanding for the product metric. -/ lemma dist_space_le (tx ty : TimeAndSpace d) : dist (space tx) (space ty) ≤ dist tx ty := by - change dist tx.2 ty.2 ≤ dist tx ty rw [Prod.dist_eq] exact le_max_right (dist tx.1 ty.1) (dist tx.2 ty.2) diff --git a/Physlib/Units/Basic.lean b/Physlib/Units/Basic.lean index 8ecea386f..aeb71166e 100644 --- a/Physlib/Units/Basic.lean +++ b/Physlib/Units/Basic.lean @@ -326,12 +326,10 @@ instance {M : Type} [CarriesDimension M] : MulAction ℝ≥0 (Dimensionful M) wh rw [smul_comm]⟩ one_smul f := by ext u - change (1 : ℝ≥0) • f.1 u = f.1 u - simp + exact one_smul ℝ≥0 (f.1 u) mul_smul a b f := by ext u - change (a * b) • f.1 u = a • (b • f.1 u) - rw [smul_smul] + exact (smul_smul a b (f.1 u)).symm @[simp] lemma Dimensionful.smul_apply {M : Type} [CarriesDimension M] From a614556d9e6319dfc6de9e42cdfe3ce43a5c75f7 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:33:01 -0700 Subject: [PATCH 492/498] refactor: golf finite-sum and order wrappers Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/Basic.lean | 3 +-- .../Particles/StandardModel/AnomalyCancellation/Basic.lean | 3 +-- .../SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean | 3 +-- Physlib/SpaceAndTime/Time/Basic.lean | 3 +-- Physlib/Units/WithDim/Basic.lean | 5 ++--- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean index 138d1cb1b..ebaea736e 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/Basic.lean @@ -33,8 +33,7 @@ namespace SMνCharges variable {n : ℕ} lemma sum_one [AddCommMonoid M] (f : Fin (SMνSpecies 1).numberCharges → M) : - ∑ i, f i = f ⟨0, by simp⟩ := by - exact Fin.sum_univ_one f + ∑ i, f i = f ⟨0, by simp⟩ := Fin.sum_univ_one f /-- An equivalence between `(SMνCharges n).charges` and `(Fin 6 → Fin n → ℚ)` splitting the charges into species. -/ diff --git a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean index 1acbee206..56b4baa1d 100644 --- a/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/StandardModel/AnomalyCancellation/Basic.lean @@ -33,8 +33,7 @@ variable {n : ℕ} lemma sum_SMSpecies_numberCharges_one {M} [AddCommMonoid M] (f : Fin (SMSpecies 1).numberCharges → M) : - ∑ i, f i = f ⟨0, by simp⟩ := by - exact Fin.sum_univ_one f + ∑ i, f i = f ⟨0, by simp⟩ := Fin.sum_univ_one f /-- An equivalence between the set `(SMCharges n).charges` and the set `(Fin 5 → Fin n → ℚ)`. -/ diff --git a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean index 5db2b0dfb..ce7c618a1 100644 --- a/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean +++ b/Physlib/Particles/SuperSymmetry/MSSMNu/AnomalyCancellation/Basic.lean @@ -31,8 +31,7 @@ namespace MSSMCharges lemma sum_MSSMSpecies_numberCharges_eq_expand [AddCommMonoid M] (f : Fin MSSMSpecies.numberCharges → M) : - ∑ i, f i = f ⟨0, by simp⟩ + f ⟨1, by simp⟩ + f ⟨2, by simp⟩ := by - exact Fin.sum_univ_three f + ∑ i, f i = f ⟨0, by simp⟩ + f ⟨1, by simp⟩ + f ⟨2, by simp⟩ := Fin.sum_univ_three f /-- An equivalence between `MSSMCharges.charges` and the space of maps `(Fin 18 ⊕ Fin 2 → ℚ)`. The first 18 factors corresponds to the SM fermions, while the last two diff --git a/Physlib/SpaceAndTime/Time/Basic.lean b/Physlib/SpaceAndTime/Time/Basic.lean index de09ba2df..d3fe73bfe 100644 --- a/Physlib/SpaceAndTime/Time/Basic.lean +++ b/Physlib/SpaceAndTime/Time/Basic.lean @@ -184,8 +184,7 @@ instance : PartialOrder Time where le_antisymm t1 t2 h1 h2 := by simp_all [le_def]; ext; exact le_antisymm h1 h2 lemma lt_def (t1 t2 : Time) : - t1 < t2 ↔ t1.val < t2.val := by - exact Iff.symm lt_iff_le_not_ge + t1 < t2 ↔ t1.val < t2.val := Iff.symm lt_iff_le_not_ge /-! diff --git a/Physlib/Units/WithDim/Basic.lean b/Physlib/Units/WithDim/Basic.lean index d9b179f81..8ab69e863 100644 --- a/Physlib/Units/WithDim/Basic.lean +++ b/Physlib/Units/WithDim/Basic.lean @@ -118,9 +118,8 @@ lemma lt_def {d : Dimension} {M : Type} [LT M] (m1 m2 : WithDim d M) : instance (d : Dimension) (M : Type) [Preorder M] : Preorder (WithDim d M) where le_refl m := le_refl m.val - le_trans m1 m2 m3 h12 h23 := le_trans h12 h23 - lt_iff_le_not_ge m1 m2 := by - exact lt_iff_le_not_ge + le_trans _ _ _ h12 h23 := le_trans h12 h23 + lt_iff_le_not_ge _ _ := lt_iff_le_not_ge instance (d : Dimension) (M : Type) [PartialOrder M] : PartialOrder (WithDim d M) where From 56b59f59324747cdb3ebacf2a318d8c1dc33f019 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:36:54 -0700 Subject: [PATCH 493/498] refactor: golf curry and reindexing wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/FDerivCurry.lean | 18 ++++++------------ .../FieldSpecification/CrAnSection.lean | 3 +-- Physlib/Relativity/Tensors/Reindexing.lean | 6 ++---- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Physlib/Mathematics/FDerivCurry.lean b/Physlib/Mathematics/FDerivCurry.lean index 60919c7fa..30a09793b 100644 --- a/Physlib/Mathematics/FDerivCurry.lean +++ b/Physlib/Mathematics/FDerivCurry.lean @@ -163,35 +163,29 @@ lemma function_differentiableAt_snd (f : X → Y → Z) (x : X) (y : Y) (hf : Di @[fun_prop] lemma fderiv_uncurry_differentiable_fst (f : X → Y → Z) (y : Y) (hf : ContDiff 𝕜 2 ↿f) : - Differentiable 𝕜 (fderiv 𝕜 fun x' => (↿f) (x', y)) := by - fun_prop + Differentiable 𝕜 (fderiv 𝕜 fun x' => (↿f) (x', y)) := by fun_prop @[fun_prop] lemma fderiv_uncurry_differentiable_snd (f : X → Y → Z) (x : X) (hf : ContDiff 𝕜 2 ↿f) : - Differentiable 𝕜 (fderiv 𝕜 fun y' => (↿f) (x, y')) := by - fun_prop + Differentiable 𝕜 (fderiv 𝕜 fun y' => (↿f) (x, y')) := by fun_prop @[fun_prop] lemma fderiv_uncurry_differentiable_fst_comp_snd (f : X → Y → Z) (x : X) (hf : ContDiff 𝕜 2 ↿f) : - Differentiable 𝕜 (fun y' => fderiv 𝕜 (fun x' => (↿f) (x', y')) x) := by - fun_prop + Differentiable 𝕜 (fun y' => fderiv 𝕜 (fun x' => (↿f) (x', y')) x) := by fun_prop @[fun_prop] lemma fderiv_uncurry_differentiable_fst_comp_snd_apply (f : X → Y → Z) (x δx : X) (hf : ContDiff 𝕜 2 ↿f) : - Differentiable 𝕜 (fun y' => fderiv 𝕜 (fun x' => (↿f) (x', y')) x δx) := by - fun_prop + Differentiable 𝕜 (fun y' => fderiv 𝕜 (fun x' => (↿f) (x', y')) x δx) := by fun_prop @[fun_prop] lemma fderiv_uncurry_differentiable_snd_comp_fst (f : X → Y → Z) (y : Y) (hf : ContDiff 𝕜 2 ↿f) : - Differentiable 𝕜 (fun x' => fderiv 𝕜 (fun y' => (↿f) (x', y')) y) := by - fun_prop + Differentiable 𝕜 (fun x' => fderiv 𝕜 (fun y' => (↿f) (x', y')) y) := by fun_prop @[fun_prop] lemma fderiv_uncurry_differentiable_snd_comp_fst_apply (f : X → Y → Z) (y δy : Y) (hf : ContDiff 𝕜 2 ↿f) : - Differentiable 𝕜 (fun x' => fderiv 𝕜 (fun y' => (↿f) (x', y')) y δy) := by - fun_prop + Differentiable 𝕜 (fun x' => fderiv 𝕜 (fun y' => (↿f) (x', y')) y δy) := by fun_prop @[fun_prop] lemma fderiv_curry_differentiableAt_fst_comp_snd (f : X → Y → Z) (x dx : X) (y : Y) diff --git a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean index 6798aac4b..92235ada7 100644 --- a/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean +++ b/Physlib/QFT/PerturbationTheory/FieldSpecification/CrAnSection.lean @@ -155,8 +155,7 @@ lemma card_nil_eq : Fintype.card (CrAnSection (𝓕 := 𝓕) []) = 1 := by lemma card_cons_eq {φ : 𝓕.FieldOp} {φs : List 𝓕.FieldOp} : Fintype.card (CrAnSection (φ :: φs)) = Fintype.card (𝓕.fieldOpToCrAnType φ) * - Fintype.card (CrAnSection φs) := by - simpa using Fintype.ofEquiv_card consEquiv.symm + Fintype.card (CrAnSection φs) := by simpa using Fintype.ofEquiv_card consEquiv.symm lemma card_eq_mul : {φs : List 𝓕.FieldOp} → Fintype.card (CrAnSection φs) = 2 ^ (List.countP 𝓕.statesIsPosition φs) diff --git a/Physlib/Relativity/Tensors/Reindexing.lean b/Physlib/Relativity/Tensors/Reindexing.lean index 7ba264b73..41e0207ad 100644 --- a/Physlib/Relativity/Tensors/Reindexing.lean +++ b/Physlib/Relativity/Tensors/Reindexing.lean @@ -97,13 +97,11 @@ def toEquiv {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} lemma apply_inv_apply {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} (σ : Fin m → Fin n) (h : IsReindexing c c1 σ) (x : Fin m) : - h.inv σ (σ x) = x := by - simpa [inv, toEquiv] using h.toEquiv.apply_symm_apply x + h.inv σ (σ x) = x := by simpa [inv, toEquiv] using h.toEquiv.apply_symm_apply x lemma inv_apply_apply {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} (σ : Fin m → Fin n) (h : IsReindexing c c1 σ) (x : Fin n) : - σ (h.inv σ x) = x := by - simpa [inv, toEquiv] using h.toEquiv.symm_apply_apply x + σ (h.inv σ x) = x := by simpa [inv, toEquiv] using h.toEquiv.symm_apply_apply x lemma preserve_color {n m : ℕ} {c : Fin n → C} {c1 : Fin m → C} {σ : Fin m → Fin n} (h : IsReindexing c c1 σ) : From d62c75f56d49bfecbc5140f1aa182102e56e098a Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:39:17 -0700 Subject: [PATCH 494/498] refactor: golf fun-prop wrapper proofs Co-authored-by: Claude Opus 4.8 --- .../Lagrangian/TotalDerivativeEquivalence.lean | 3 +-- Physlib/Mathematics/Calculus/AdjFDeriv.lean | 3 +-- .../Mathematics/VariationalCalculus/IsTestFunction.lean | 3 +-- .../Relativity/Tensors/RealTensor/Velocity/Basic.lean | 6 ++---- Physlib/SpaceAndTime/Space/IsDistBounded.lean | 9 +++------ Physlib/SpaceAndTime/Space/Norm/Basic.lean | 4 +--- Physlib/SpaceAndTime/SpaceTime/Basic.lean | 6 ++---- .../StatisticalMechanics/CanonicalEnsemble/Lemmas.lean | 3 +-- 8 files changed, 12 insertions(+), 25 deletions(-) diff --git a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean index 17a5c1a63..697aa5e90 100644 --- a/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean +++ b/Physlib/ClassicalMechanics/Lagrangian/TotalDerivativeEquivalence.lean @@ -96,8 +96,7 @@ lemma isTotalTimeDerivative_explicit {δL : Time → X → X → ℝ} : ∀ t q v, δL t q v = fderiv ℝ ↿F (t, q) ((1 : Time), v)) := by -- Preliminary construction: properties of the function t => (t, q t) let tq := fun (q : Time → X) t => (t, q t) - have h_tq_contDiff : ∀ (q : Time → X), ContDiff ℝ ∞ q -> ContDiff ℝ ∞ (tq q) := by - fun_prop + have h_tq_contDiff : ∀ (q : Time → X), ContDiff ℝ ∞ q -> ContDiff ℝ ∞ (tq q) := by fun_prop have h_tq_der : ∀ (q : Time → X) t, ContDiff ℝ ∞ q -> ∂ₜ (tq q) t = (1, ∂ₜ q t) := by intro q t h_ContDiff_q ext diff --git a/Physlib/Mathematics/Calculus/AdjFDeriv.lean b/Physlib/Mathematics/Calculus/AdjFDeriv.lean index 2c9e2a65e..a8ec72601 100644 --- a/Physlib/Mathematics/Calculus/AdjFDeriv.lean +++ b/Physlib/Mathematics/Calculus/AdjFDeriv.lean @@ -158,8 +158,7 @@ lemma adjFDeriv_const (y : F) : adjFDeriv 𝕜 (fun _ : E => y) = fun _ _ => 0 : lemma HasAdjFDerivAt.comp {f : F → G} {g : E → F} {f' g'} {x : E} (hf : HasAdjFDerivAt 𝕜 f f' (g x)) (hg : HasAdjFDerivAt 𝕜 g g' x) : HasAdjFDerivAt 𝕜 (fun x => f (g x)) (fun dz => g' (f' dz)) x where - differentiableAt := by - fun_prop + differentiableAt := by fun_prop hasAdjoint_fderiv := by simp (disch:=fun_prop) [fderiv_fun_comp] exact hf.hasAdjoint_fderiv.comp hg.hasAdjoint_fderiv diff --git a/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean b/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean index 109616792..748b65919 100644 --- a/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean +++ b/Physlib/Mathematics/VariationalCalculus/IsTestFunction.lean @@ -207,8 +207,7 @@ lemma IsTestFunction.linearMap_comp {f : X → V} (hf : IsTestFunction f) lemma IsTestFunction.family_linearMap_comp {f : X → V} (hf : IsTestFunction f) {g : X → V →L[ℝ] U} (hg : ContDiff ℝ ∞ g) : IsTestFunction (fun x => g x (f x)) where - smooth := by - fun_prop + smooth := by fun_prop supp := by have hf' := hf.supp rw [← exists_compact_iff_hasCompactSupport] at hf' ⊢ diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index 875a95427..6af49798b 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -87,8 +87,7 @@ lemma one_add_minkowskiProduct_ne_zero (u v : Velocity d) : linarith [zero_le_minkowskiProduct u v] lemma minkowskiProduct_continuous_snd (u : Vector d) : - Continuous fun (x : Velocity d) => ⟪u, x.1⟫ₘ := by - fun_prop + Continuous fun (x : Velocity d) => ⟪u, x.1⟫ₘ := by fun_prop @[fun_prop] lemma minkowskiProduct_continuous_fst (u : Vector d) : @@ -150,8 +149,7 @@ noncomputable def pathFromZero (u : Velocity d) : Path zero u where · apply mul_nonneg · exact sq_nonneg _ · exact sq_nonneg _⟩ - continuous_toFun := by - fun_prop + continuous_toFun := by fun_prop source' := by simp target' := by ext1 diff --git a/Physlib/SpaceAndTime/Space/IsDistBounded.lean b/Physlib/SpaceAndTime/Space/IsDistBounded.lean index 72c98dac7..30963783f 100644 --- a/Physlib/SpaceAndTime/Space/IsDistBounded.lean +++ b/Physlib/SpaceAndTime/Space/IsDistBounded.lean @@ -115,14 +115,12 @@ lemma aestronglyMeasurable {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) @[fun_prop] lemma aeStronglyMeasurable_schwartzMap_smul {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) : - AEStronglyMeasurable (fun x => η x • f x) := by - fun_prop + AEStronglyMeasurable (fun x => η x • f x) := by fun_prop @[fun_prop] lemma aeStronglyMeasurable_fderiv_schwartzMap_smul {d : ℕ} {f : Space d → F} (hf : IsDistBounded f) (η : 𝓢(Space d, ℝ)) (y : Space d) : - AEStronglyMeasurable (fun x => fderiv ℝ η x y • f x) := by - fun_prop + AEStronglyMeasurable (fun x => fderiv ℝ η x y • f x) := by fun_prop @[fun_prop] lemma aeStronglyMeasurable_inv_pow {d r : ℕ} {f : Space d → F} @@ -1182,8 +1180,7 @@ lemma component_smul_isDistBounded {d : ℕ} [NormedSpace ℝ F] {f : Space d apply IsDistBounded.mono (f := fun x => ‖x‖ • f x) · fun_prop · apply AEStronglyMeasurable.smul - · have h1 : AEStronglyMeasurable (fun x => Space.coordCLM i x) := by - fun_prop + · have h1 : AEStronglyMeasurable (fun x => Space.coordCLM i x) := by fun_prop convert h1 using 1 funext i simp [coordCLM_apply, coord_apply] diff --git a/Physlib/SpaceAndTime/Space/Norm/Basic.lean b/Physlib/SpaceAndTime/Space/Norm/Basic.lean index c0a5aa8a2..db6c0bd0d 100644 --- a/Physlib/SpaceAndTime/Space/Norm/Basic.lean +++ b/Physlib/SpaceAndTime/Space/Norm/Basic.lean @@ -1065,9 +1065,7 @@ private lemma radial_power_deriv_integral_by_parts ring_nf simp [hη'_apply, mul_assoc]) measurableSet_Ioi - · have hcont : - ContinuousAt (fun x : ℝ => x ^ p * η (x • n.1)) (0 : ℝ) := by - fun_prop + · have hcont : ContinuousAt (fun x : ℝ => x ^ p * η (x • n.1)) (0 : ℝ) := by fun_prop have hlim := tendsto_nhdsWithin_of_tendsto_nhds (s := Set.Ioi (0 : ℝ)) hcont.tendsto simp only [ne_eq, hp.ne', not_false_eq_true, zero_pow, zero_smul, zero_mul] at hlim diff --git a/Physlib/SpaceAndTime/SpaceTime/Basic.lean b/Physlib/SpaceAndTime/SpaceTime/Basic.lean index fd327dbdf..58d321fae 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Basic.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Basic.lean @@ -115,8 +115,7 @@ def coordCLM (μ : Fin 1 ⊕ Fin d) : SpaceTime d →L[ℝ] ℝ where toFun x := x μ map_add' _ _ := rfl map_smul' _ _ := rfl - cont := by - fun_prop + cont := by fun_prop /-! @@ -199,8 +198,7 @@ def space {d : ℕ} : SpaceTime d →L[ℝ] Space d where map_smul' c x := by ext i simp - cont := by - fun_prop + cont := by fun_prop /-! diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean index 649da8926..aa8b9ceaf 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Lemmas.lean @@ -376,8 +376,7 @@ lemma integral_bolt_eq_integral_mul_exp = ∫ x, φ x * Real.exp (-T.β * 𝓒.energy x) ∂ 𝓒.μ := by unfold μBolt set f : ι → ℝ≥0∞ := fun x => ENNReal.ofReal (Real.exp (-T.β * 𝓒.energy x)) - have hf_meas : Measurable f := by - fun_prop + have hf_meas : Measurable f := by fun_prop have hf_lt_top : ∀ᵐ x ∂ 𝓒.μ, f x < ∞ := by simp [f] have h := integral_withDensity_eq_integral_toReal_smul From df1d2ec7eee4783c718559d084324e5ad6cd4cd2 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:41:41 -0700 Subject: [PATCH 495/498] refactor: golf complex tensor metric unit wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean | 6 ++---- Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean | 6 ++---- Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean index 2e496505d..ce8b812b6 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Metrics/Pre.lean @@ -67,8 +67,7 @@ def contrMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap apply congrArg simp only [LorentzGroup.toComplex_mul_minkowskiMatrix_mul_transpose] -lemma contrMetric_apply_one : contrMetric (1 : ℂ) = contrMetricVal := by - simp [contrMetric] +lemma contrMetric_apply_one : contrMetric (1 : ℂ) = contrMetricVal := by simp [contrMetric] /-- The metric `ηᵢᵢ` as an element of `(complexCo ⊗ complexCo).V`. -/ def coMetricVal : (CoℂModule ⊗[ℂ] CoℂModule) := @@ -116,8 +115,7 @@ def coMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap simp only [LorentzGroup.inv_eq_dual, SL2C.toLorentzGroup_apply_coe, LorentzGroup.toComplex_transpose_mul_minkowskiMatrix_mul_self] -lemma coMetric_apply_one : coMetric (1 : ℂ) = coMetricVal := by - simp [coMetric] +lemma coMetric_apply_one : coMetric (1 : ℂ) = coMetricVal := by simp [coMetric] /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean b/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean index bd741f3f3..d0bc3ba8d 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Units/Pre.lean @@ -69,8 +69,7 @@ def contrCoUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap apply congrArg simp -lemma contrCoUnit_apply_one : contrCoUnit (1 : ℂ) = contrCoUnitVal := by - simp [contrCoUnit] +lemma contrCoUnit_apply_one : contrCoUnit (1 : ℂ) = contrCoUnitVal := by simp [contrCoUnit] /-- The co-contra unit for complex lorentz vectors. Usually denoted `δᵢⁱ`. -/ def coContrUnitVal : CoℂModule ⊗[ℂ] ContrℂModule := @@ -119,8 +118,7 @@ def coContrUnit : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap refine transpose_eq_one.mp ?h.h.h.a simp -lemma coContrUnit_apply_one : coContrUnit (1 : ℂ) = coContrUnitVal := by - simp [coContrUnit] +lemma coContrUnit_apply_one : coContrUnit (1 : ℂ) = coContrUnitVal := by simp [coContrUnit] /-! diff --git a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean index eacb75088..216bb7fa2 100644 --- a/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean +++ b/Physlib/Relativity/Tensors/ComplexTensor/Weyl/Metric.lean @@ -106,8 +106,7 @@ def leftMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap simp only [SpecialLinearGroup.det_coe, isUnit_iff_ne_zero, ne_eq, one_ne_zero, not_false_eq_true, mul_nonsing_inv, transpose_one, mul_one] -lemma leftMetric_apply_one : leftMetric (1 : ℂ) = leftMetricVal := by - simp [leftMetric] +lemma leftMetric_apply_one : leftMetric (1 : ℂ) = leftMetricVal := by simp [leftMetric] /-- The metric `εₐₐ` as an element of `(dualLeftHanded ⊗ dualLeftHanded).V`. -/ def dualLeftMetricVal : (DualLeftHandedWeyl ⊗[ℂ] DualLeftHandedWeyl) := @@ -197,8 +196,7 @@ def rightMetric : (Representation.trivial ℂ SL(2,ℂ) ℂ).IntertwiningMap simp · rw [← rightRightToMatrix_ρ_symm metricRaw M] -lemma rightMetric_apply_one : rightMetric (1 : ℂ) = rightMetricVal := by - simp [rightMetric] +lemma rightMetric_apply_one : rightMetric (1 : ℂ) = rightMetricVal := by simp [rightMetric] /-- The metric `ε_{dot a}_{dot a}` as an element of `(dualRightHanded ⊗ dualRightHanded).V`. -/ def dualRightMetricVal : DualRightHandedWeyl ⊗[ℂ] DualRightHandedWeyl := From ef20544ca731a78a9f9f07239320451c2848f920 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:43:49 -0700 Subject: [PATCH 496/498] refactor: golf calculus and tensor wrappers Co-authored-by: Claude Opus 4.8 --- Physlib/Mathematics/Calculus/AdjFDeriv.lean | 6 ++---- Physlib/Mathematics/FDerivCurry.lean | 3 +-- Physlib/Relativity/PauliMatrices/AsTensor.lean | 3 +-- Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean | 3 +-- Physlib/StatisticalMechanics/BoltzmannConstant.lean | 3 +-- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Physlib/Mathematics/Calculus/AdjFDeriv.lean b/Physlib/Mathematics/Calculus/AdjFDeriv.lean index a8ec72601..622fc1936 100644 --- a/Physlib/Mathematics/Calculus/AdjFDeriv.lean +++ b/Physlib/Mathematics/Calculus/AdjFDeriv.lean @@ -136,8 +136,7 @@ attribute [fun_prop] HasAdjFDerivAt.differentiableAt lemma hasAdjFDerivAt_id (x : E) : HasAdjFDerivAt 𝕜 (fun x : E => x) (fun dx => dx) x where differentiableAt := by fun_prop - hasAdjoint_fderiv := by - simp; apply hasAdjoint_id + hasAdjoint_fderiv := by simp; apply hasAdjoint_id lemma adjFDeriv_id : adjFDeriv 𝕜 (fun x : E => x) = fun _ dx => dx := by funext x @@ -148,8 +147,7 @@ lemma adjFDeriv_id' : adjFDeriv 𝕜 (id : E → E) = fun _ dx => dx := adjFDeri lemma hasAdjFDerivAt_const (x : E) (y : F) : HasAdjFDerivAt 𝕜 (fun _ : E => y) (fun _ => 0) x where differentiableAt := by fun_prop - hasAdjoint_fderiv := by - simp; apply hasAdjoint_zero + hasAdjoint_fderiv := by simp; apply hasAdjoint_zero lemma adjFDeriv_const (y : F) : adjFDeriv 𝕜 (fun _ : E => y) = fun _ _ => 0 := by funext x diff --git a/Physlib/Mathematics/FDerivCurry.lean b/Physlib/Mathematics/FDerivCurry.lean index 30a09793b..8c1c15735 100644 --- a/Physlib/Mathematics/FDerivCurry.lean +++ b/Physlib/Mathematics/FDerivCurry.lean @@ -91,8 +91,7 @@ lemma fderiv_wrt_prod_clm_comp (f : X × Y → Z) (hf : Differentiable 𝕜 f) : lemma fderiv_curry_clm_apply (f : X → Y →L[𝕜] Z) (y : Y) (x dx : X) (h : Differentiable 𝕜 f) : fderiv 𝕜 f x dx y = - fderiv 𝕜 (f · y) x dx := by - rw [fderiv_clm_apply] <;> first | simp | fun_prop + fderiv 𝕜 (f · y) x dx := by rw [fderiv_clm_apply] <;> first | simp | fun_prop /- Helper rw lemmas for proving differentiability conditions. -/ lemma fderiv_uncurry_comp_fst (f : X → Y → Z) (y : Y) (hf : Differentiable 𝕜 (↿f)) : diff --git a/Physlib/Relativity/PauliMatrices/AsTensor.lean b/Physlib/Relativity/PauliMatrices/AsTensor.lean index 36204c4a7..7bbfebbe8 100644 --- a/Physlib/Relativity/PauliMatrices/AsTensor.lean +++ b/Physlib/Relativity/PauliMatrices/AsTensor.lean @@ -171,8 +171,7 @@ def asConsTensor : /-- The map `𝟙_ (Rep ℂ SL(2,ℂ)) ⟶ complexContr ⊗ leftHanded ⊗ rightHanded` corresponding to Pauli matrices, when evaluated on `1` corresponds to the tensor `PauliMatrix.asTensor`. -/ -lemma asConsTensor_apply_one : asConsTensor (1 : ℂ) = asTensor := by - simp [asConsTensor] +lemma asConsTensor_apply_one : asConsTensor (1 : ℂ) = asTensor := by simp [asConsTensor] end end PauliMatrix diff --git a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean index 6af49798b..661ca703b 100644 --- a/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean +++ b/Physlib/Relativity/Tensors/RealTensor/Velocity/Basic.lean @@ -83,8 +83,7 @@ lemma zero_le_minkowskiProduct (u v : Velocity d) : · exact real_inner_le_norm u.1.spatialPart v.1.spatialPart lemma one_add_minkowskiProduct_ne_zero (u v : Velocity d) : - 1 + ⟪u.1, v.1⟫ₘ ≠ 0 := by - linarith [zero_le_minkowskiProduct u v] + 1 + ⟪u.1, v.1⟫ₘ ≠ 0 := by linarith [zero_le_minkowskiProduct u v] lemma minkowskiProduct_continuous_snd (u : Vector d) : Continuous fun (x : Velocity d) => ⟪u, x.1⟫ₘ := by fun_prop diff --git a/Physlib/StatisticalMechanics/BoltzmannConstant.lean b/Physlib/StatisticalMechanics/BoltzmannConstant.lean index 9836dfe8b..212eabbb6 100644 --- a/Physlib/StatisticalMechanics/BoltzmannConstant.lean +++ b/Physlib/StatisticalMechanics/BoltzmannConstant.lean @@ -39,7 +39,6 @@ lemma kB_pos : 0 < kB := kBAx.2 lemma kB_nonneg : 0 ≤ kB := le_of_lt kBAx.2 /-- The Boltzmann constant is not equal to zero. -/ -lemma kB_ne_zero : kB ≠ 0 := by - linarith [kB_pos] +lemma kB_ne_zero : kB ≠ 0 := by linarith [kB_pos] end Constants From a6629364d9dc11cb0eab2851e8a7525e737203e3 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Wed, 1 Jul 2026 15:47:28 -0700 Subject: [PATCH 497/498] refactor: golf Hermitian log-exp wrappers Co-authored-by: Claude Opus 4.8 --- .../RHN/AnomalyCancellation/PlusU1/HyperCharge.lean | 3 +-- .../CanonicalEnsemble/Basic.lean | 6 ++---- QuantumInfo/ForMathlib/HermitianMat/LogExp.lean | 12 ++++-------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/HyperCharge.lean b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/HyperCharge.lean index a7be87e52..3e250acee 100644 --- a/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/HyperCharge.lean +++ b/Physlib/Particles/BeyondTheStandardModel/RHN/AnomalyCancellation/PlusU1/HyperCharge.lean @@ -76,8 +76,7 @@ lemma add_AFL_quad (S : (PlusU1 n).LinSols) (a b : ℚ) : simp lemma add_quad (S : (PlusU1 n).QuadSols) (a b : ℚ) : - accQuad (a • S.val + b • (Y n).val) = 0 := by - rw [add_AFL_quad, quadSol S]; simp + accQuad (a • S.val + b • (Y n).val) = 0 := by rw [add_AFL_quad, quadSol S]; simp /-- The `QuadSol` obtained by adding hypercharge to a `QuadSol`. -/ def addQuad (S : (PlusU1 n).QuadSols) (a b : ℚ) : (PlusU1 n).QuadSols := diff --git a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean index 19772337d..4a7f1aead 100644 --- a/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean +++ b/Physlib/StatisticalMechanics/CanonicalEnsemble/Basic.lean @@ -381,12 +381,10 @@ instance (T : Temperature) [NeZero 𝓒.μ] : NeZero (𝓒.μBolt T) := ⟨μBolt_ne_zero_of_μ_ne_zero 𝓒 T (Ne.symm (NeZero.ne' 𝓒.μ))⟩ instance (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] [IsFiniteMeasure (𝓒1.μBolt T)] : - IsFiniteMeasure ((𝓒 + 𝓒1).μBolt T) := by - simp only [μBolt_add]; infer_instance + IsFiniteMeasure ((𝓒 + 𝓒1).μBolt T) := by simp only [μBolt_add]; infer_instance instance (T : Temperature) [IsFiniteMeasure (𝓒.μBolt T)] (n : ℕ) : - IsFiniteMeasure ((nsmul n 𝓒).μBolt T) := by - simp [μBolt_nsmul]; infer_instance + IsFiniteMeasure ((nsmul n 𝓒).μBolt T) := by simp [μBolt_nsmul]; infer_instance /-! diff --git a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean index 832ed950f..6d5e0e6a0 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/LogExp.lean @@ -48,14 +48,12 @@ def exp (A : HermitianMat d 𝕜) : HermitianMat d 𝕜 := /-- Primed because `Commute.exp_left` refers to `NormedSpace.exp` instead of `HermitianMat.exp`. -/ @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.exp_left' (hAB : Commute A.mat B.mat) : - Commute (A.exp).mat B.mat := by - rw [exp]; commutes + Commute (A.exp).mat B.mat := by rw [exp]; commutes /-- Primed because `Commute.exp_right` refers to `NormedSpace.exp` instead of `HermitianMat.exp`. -/ @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.exp_right' (hAB : Commute A.mat B.mat) : - Commute A.mat (B.exp).mat := by - rw [exp]; commutes + Commute A.mat (B.exp).mat := by rw [exp]; commutes @[simp] theorem reindex_exp (e : d ≃ d₂) : (A.reindex e).exp = A.exp.reindex e := @@ -102,13 +100,11 @@ def log (A : HermitianMat d 𝕜) : HermitianMat d 𝕜 := @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.log_left (hAB : Commute A.mat B.mat) : - Commute (A.log).mat B.mat := by - rw [log]; commutes + Commute (A.log).mat B.mat := by rw [log]; commutes @[aesop unsafe apply 50% (rule_sets := [Commutes])] theorem _root_.Commute.log_right (hAB : Commute A.mat B.mat) : - Commute A.mat (B.log).mat := by - rw [log]; commutes + Commute A.mat (B.log).mat := by rw [log]; commutes @[simp] theorem reindex_log (e : d ≃ d₂) : (A.reindex e).log = A.log.reindex e := From 4e3d67f031152a3155a393f191f69f19a571bf16 Mon Sep 17 00:00:00 2001 From: Vasily Ilin Date: Thu, 2 Jul 2026 09:24:16 -0700 Subject: [PATCH 498/498] fix: repair over-golfed proofs so CI builds green MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The automated golf over-shortened many proofs, breaking compilation. Each fix is surgical: restore only the broken proof/step from master while preserving all other golf in the file. Key root-cause fix: several @[simp] coercion lemmas (HermitianMat.val_eq_coe, mat_smul, mat_cfc, MState.mat_M) were golfed from `:= by rfl` to `:= rfl`, which makes them eligible for `dsimp` definitional rewriting. That caused `dsimp` calls in downstream proofs (Pinching, SteinsLemma) to over-normalize goals — unfolding `↑(c • A)`, `↑A`, `↑(A.cfc f)` — so subsequent `rw`s no longer matched, and produced dsimp recursion-depth loops. Reverting those specific lemmas to `by rfl` restores the intended non-dsimp semantics. All CI steps pass locally: lake build -KCI (Physlib + QuantumInfo), check_file_imports, check_dup_tags, sorry_lint, runPhyslibLinters, PhyslibAlpha build + runPhyslibAlphaLinters, lint-style.sh, codespell. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01YRA4h6VJRALwaZK1xeUsg3 --- .../Distributional/Basic.lean | 11 +++++++++- .../Distributional/Dynamics/KineticTerm.lean | 3 ++- .../Distributional/FieldStrength.lean | 3 ++- .../Dynamics/CurrentDensity.lean | 4 +++- .../Dynamics/Hamiltonian.lean | 2 ++ .../Electromagnetism/Dynamics/IsExtrema.lean | 1 + .../Dynamics/KineticTerm.lean | 9 ++++++-- .../Electromagnetism/Kinematics/Boosts.lean | 4 +++- .../Kinematics/EMPotential.lean | 9 ++++++-- .../Kinematics/ElectricField.lean | 5 ++++- .../Kinematics/FieldStrength.lean | 21 ++++++++++++++----- .../Kinematics/MagneticField.lean | 8 ++++++- .../Kinematics/ScalarPotential.lean | 10 ++++++++- Physlib/Electromagnetism/Vacuum/Constant.lean | 9 ++++---- .../Electromagnetism/Vacuum/HarmonicWave.lean | 13 +++++++++--- .../Electromagnetism/Vacuum/IsPlaneWave.lean | 3 ++- .../SpaceAndTime/SpaceTime/Derivatives.lean | 1 + Physlib/Units/Examples.lean | 1 + Physlib/Units/WithDim/Area.lean | 4 ++++ Physlib/Units/WithDim/Speed.lean | 10 ++++++++- QuantumInfo/Channels/Dual.lean | 2 ++ QuantumInfo/Channels/MatrixMap.lean | 1 + QuantumInfo/Channels/Pinching.lean | 21 +++++++++++++------ QuantumInfo/Entropy/DPI.lean | 1 + QuantumInfo/Entropy/Relative.lean | 17 ++++++++++----- QuantumInfo/Entropy/SSA.lean | 3 +++ .../TraceInequality/LiebAndoTrace.lean | 2 ++ .../ForMathlib/HermitianMat/Basic.lean | 6 ++++-- QuantumInfo/ForMathlib/HermitianMat/CFC.lean | 3 ++- QuantumInfo/Measurements/POVM.lean | 5 ++++- QuantumInfo/ResourceTheory/FreeState.lean | 3 ++- .../ResourceTheory/HypothesisTesting.lean | 2 ++ QuantumInfo/ResourceTheory/SteinsLemma.lean | 1 + QuantumInfo/States/Ensemble.lean | 3 ++- QuantumInfo/States/Entanglement.lean | 5 +++++ QuantumInfo/States/Mixed/MState.lean | 16 ++++++++++---- QuantumInfo/States/Pure/Braket.lean | 8 +++++-- 37 files changed, 181 insertions(+), 49 deletions(-) diff --git a/Physlib/Electromagnetism/Distributional/Basic.lean b/Physlib/Electromagnetism/Distributional/Basic.lean index 377f3740f..49c214689 100644 --- a/Physlib/Electromagnetism/Distributional/Basic.lean +++ b/Physlib/Electromagnetism/Distributional/Basic.lean @@ -154,6 +154,8 @@ lemma distTensorDeriv_eq_sum_sum {d} (A : DistElectromagneticPotential d) rw [tmul_sum] congr funext ν + simp + rfl /-! @@ -195,7 +197,14 @@ lemma toTensor_distTensorDeriv_basis_repr_apply {d} (A : DistElectromagneticPote Lorentz.CoVector.indexEquiv.symm).tensorProduct (Lorentz.Vector.basis.reindex Lorentz.Vector.indexEquiv.symm)) = ((Lorentz.CoVector.basis (d := d)).tensorProduct (Lorentz.Vector.basis (d := d))).reindex - (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := rfl + (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by + ext b + match b with + | ⟨i, j⟩ => + simp + rw [hb] + rw [Module.Basis.repr_reindex_apply, distTensorDeriv_basis_repr_apply] + rfl end DistElectromagneticPotential diff --git a/Physlib/Electromagnetism/Distributional/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Distributional/Dynamics/KineticTerm.lean index 344d498cc..e47af046f 100644 --- a/Physlib/Electromagnetism/Distributional/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Distributional/Dynamics/KineticTerm.lean @@ -209,7 +209,8 @@ lemma gradKineticTerm_eq_distTensorDeriv {d} {𝓕 : FreeSpace} (Lorentz.Vector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by ext ⟨i, j⟩ simp - simpa [hb] using Module.Basis.repr_reindex_apply _ _ _ + rw [hb, Module.Basis.repr_reindex_apply] + rfl apply congr · simp rfl diff --git a/Physlib/Electromagnetism/Distributional/FieldStrength.lean b/Physlib/Electromagnetism/Distributional/FieldStrength.lean index e05dc0005..3fbcda8fe 100644 --- a/Physlib/Electromagnetism/Distributional/FieldStrength.lean +++ b/Physlib/Electromagnetism/Distributional/FieldStrength.lean @@ -80,7 +80,8 @@ lemma fieldStrengthAux_eq_add {d} (A : DistElectromagneticPotential d) (ε : rw [sub_eq_add_neg] apply congrArg₂ · rfl - · rfl + · rw [permT_permT] + rfl lemma toTensor_fieldStrengthAux {d} (A : DistElectromagneticPotential d) (ε : 𝓢(SpaceTime d, ℝ)) : diff --git a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean index bd18aba23..616e8187c 100644 --- a/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean +++ b/Physlib/Electromagnetism/Dynamics/CurrentDensity.lean @@ -90,7 +90,9 @@ lemma chargeDensity_eq_timeSlice {d : ℕ} {c : SpeedOfLight} {J : LorentzCurren @[simp] lemma chargeDensity_zero {d : ℕ} {c : SpeedOfLight}: - chargeDensity c (0 : LorentzCurrentDensity d) = 0 := rfl + chargeDensity c (0 : LorentzCurrentDensity d) = 0 := by + simp [chargeDensity_eq_timeSlice, timeSlice] + rfl /-! diff --git a/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean b/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean index ffda4f069..d05778a75 100644 --- a/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean +++ b/Physlib/Electromagnetism/Dynamics/Hamiltonian.lean @@ -207,6 +207,8 @@ lemma hamiltonian_eq_electricField_vectorPotential {d} {𝓕 : FreeSpace} rw [← Time.deriv_euclid] simp [vectorPotential, timeSlice] ring_nf + congr + rw [← Time.deriv_lorentzVector] rfl · exact (hA.differentiable (by simp)).comp (by fun_prop) · exact vectorPotential_differentiable_time A (hA.differentiable (by simp)) x.space diff --git a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean index 7c2820229..dff99ce3f 100644 --- a/Physlib/Electromagnetism/Dynamics/IsExtrema.lean +++ b/Physlib/Electromagnetism/Dynamics/IsExtrema.lean @@ -417,6 +417,7 @@ lemma time_deriv_time_deriv_electricField_of_isExtrema {A : ElectromagneticPoten congr rw [Time.deriv_eq] rw [fderiv_fun_sum fun i _ => (hBt i).differentiableAt] + simp only [FunLike.coe_sum, Finset.sum_apply] rfl _ = 1 / (𝓕.μ₀ * 𝓕.ε₀) * (∑ j, ∂[j] (fun x => ∂ₜ (A.magneticFieldMatrix 𝓕.c · x (j, i)) t)) x - 1 / 𝓕.ε₀ * ∂ₜ (J.currentDensity 𝓕.c · x i) t := by diff --git a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean index 7a1fe1ed7..ab5d6c2ee 100644 --- a/Physlib/Electromagnetism/Dynamics/KineticTerm.lean +++ b/Physlib/Electromagnetism/Dynamics/KineticTerm.lean @@ -758,9 +758,11 @@ lemma gradKineticTerm_eq_fieldStrength {d} {𝓕 : FreeSpace} (A : Electromagnet apply Finset.sum_congr rfl (fun ν _ => ?_) apply Finset.sum_congr rfl (fun μ _ => ?_) congr - · rfl + · rw [SpaceTime.deriv_eq, SpaceTime.deriv_eq, fderiv_const_mul] + rfl fun_prop - · rfl + · rw [SpaceTime.deriv_eq, SpaceTime.deriv_eq, fderiv_const_mul] + rfl fun_prop _ = ∑ (ν : (Fin 1 ⊕ Fin d)), ∑ (μ : (Fin 1 ⊕ Fin d)), ((1/𝓕.μ₀ * η ν ν) * (∂_ μ (fun x' => η μ μ * ∂_ μ A x' ν - @@ -869,6 +871,7 @@ lemma gradKineticTerm_add {d} {𝓕 : FreeSpace} (A1 A2 : ElectromagneticPotenti rw [fieldStrengthMatrix_add _ _ _ (hA1.differentiable (by simp)) (hA2.differentiable (by simp))] simp [Finsupp.coe_add, Pi.add_apply] + rw [fderiv_fun_add] rfl · apply fieldStrengthMatrix_differentiable <| hA1.of_le (ENat.LEInfty.out) · apply fieldStrengthMatrix_differentiable <| hA2.of_le (ENat.LEInfty.out) @@ -899,6 +902,7 @@ lemma gradKineticTerm_smul {d} {𝓕 : FreeSpace} (A : ElectromagneticPotential rw [← SpaceTime.deriv_eq] congr funext x + rw [fieldStrengthMatrix_smul _ _ _] rfl · exact hA.differentiable (by simp) · exact hA @@ -986,6 +990,7 @@ lemma gradKineticTerm_eq_tensorDeriv {d} {𝓕 : FreeSpace} rw [gradKineticTerm_eq_fieldStrength A x hA] simp [Lorentz.Vector.apply_sum] ring_nf + rfl end ElectromagneticPotential diff --git a/Physlib/Electromagnetism/Kinematics/Boosts.lean b/Physlib/Electromagnetism/Kinematics/Boosts.lean index c902e270e..e8359f484 100644 --- a/Physlib/Electromagnetism/Kinematics/Boosts.lean +++ b/Physlib/Electromagnetism/Kinematics/Boosts.lean @@ -190,7 +190,9 @@ lemma magneticFieldMatrix_apply_x_boost_succ_succ {d : ℕ} {c : SpeedOfLight} ( rw [magneticFieldMatrix_eq] simp only rw [fieldStrengthMatrix_equivariant _ _ hA] - simpa [Fintype.sum_sum_type, boost_zero_inr_succ_inr_succ, Fin.sum_univ_succ] + simp [Fintype.sum_sum_type, boost_zero_inr_succ_inr_succ, Fin.sum_univ_succ] + rw [SpaceTime.boost_zero_apply_time_space] + rfl end ElectromagneticPotential end Electromagnetism diff --git a/Physlib/Electromagnetism/Kinematics/EMPotential.lean b/Physlib/Electromagnetism/Kinematics/EMPotential.lean index 1875182ac..522271a1a 100644 --- a/Physlib/Electromagnetism/Kinematics/EMPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/EMPotential.lean @@ -280,7 +280,7 @@ noncomputable instance {d} : simp smul_add Λ A B := by ext x μ - simp [Lorentz.Vector.smul_add] + simp /-! @@ -484,6 +484,7 @@ lemma hasVarAdjDerivAt_component {d : ℕ} (μ : Fin 1 ⊕ Fin d) (A : SpaceTime intro u v simp [f, f', inner_smul_left, Lorentz.Vector.basis_inner] ring_nf + rfl /-! @@ -626,7 +627,11 @@ lemma toTensor_deriv_basis_repr_apply {d} (A : ElectromagneticPotential d) Lorentz.CoVector.indexEquiv.symm).tensorProduct (Lorentz.Vector.basis.reindex Lorentz.Vector.indexEquiv.symm)) = ((Lorentz.CoVector.basis (d := d)).tensorProduct (Lorentz.Vector.basis (d := d))).reindex - (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := rfl + (Lorentz.CoVector.indexEquiv.symm.prodCongr Lorentz.Vector.indexEquiv.symm) := by + ext ⟨i, j⟩ + simp + rw [hb] + rw [Module.Basis.repr_reindex_apply, deriv_basis_repr_apply] rfl end ElectromagneticPotential diff --git a/Physlib/Electromagnetism/Kinematics/ElectricField.lean b/Physlib/Electromagnetism/Kinematics/ElectricField.lean index ae0b79dbc..8e4bcc04a 100644 --- a/Physlib/Electromagnetism/Kinematics/ElectricField.lean +++ b/Physlib/Electromagnetism/Kinematics/ElectricField.lean @@ -292,7 +292,10 @@ lemma time_deriv_comp_vectorPotential_eq_electricField {d} {A : ElectromagneticP (t : Time) (x : Space d) (i : Fin d) : ∂ₜ (fun t => A.vectorPotential c t x i) t = - A.electricField c t x i - ∂[i] (A.scalarPotential c t) x := by - exact time_deriv_vectorPotential_eq_electricField A hA c t x i + rw [Time.deriv_euclid, time_deriv_vectorPotential_eq_electricField] + simp + rfl + apply vectorPotential_differentiable_time A hA x /-! diff --git a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean index a0f0db80f..d6c84b18d 100644 --- a/Physlib/Electromagnetism/Kinematics/FieldStrength.lean +++ b/Physlib/Electromagnetism/Kinematics/FieldStrength.lean @@ -118,14 +118,17 @@ lemma toFieldStrength_eq_add {d} (A : ElectromagneticPotential d) (x : SpaceTime rw [sub_eq_add_neg] apply congrArg₂ · rfl - · rfl + · rw [permT_permT] + rfl lemma toFieldStrength_eq_sub_tensorDeriv {d} {A : ElectromagneticPotential d} (hA : Differentiable ℝ A) (x : SpaceTime d) : toFieldStrength A x = Tensorial.toTensor.symm (permT id IsReindexing.auto {η d | μ μ' ⊗ tensorDeriv A x | μ' ν}ᵀ) - Tensorial.toTensor.symm (permT ![1, 0] IsReindexing.auto - {η d | μ μ' ⊗ tensorDeriv A x | μ' ν}ᵀ) := rfl + {η d | μ μ' ⊗ tensorDeriv A x | μ' ν}ᵀ) := by + simp only [toFieldStrength_eq_tensorDeriv hA, map_add, map_neg, sub_eq_add_neg, permT_permT] + rfl lemma toTensor_toFieldStrength {d} (A : ElectromagneticPotential d) (x : SpaceTime d) : Tensorial.toTensor (toFieldStrength A x) = @@ -335,7 +338,11 @@ lemma toFieldStrength_basis_repr_apply {d} {μν : (Fin 1 ⊕ Fin d) × (Fin 1 ∑ κ, ((η μν.1 κ * ∂_ κ A x μν.2) - η μν.2 κ * ∂_ κ A x μν.1) := by match μν with | (μ, ν) => - simpa using toTensor_toFieldStrength_basis_repr A x μ ν + trans (Tensor.basis _).repr (Tensorial.toTensor (toFieldStrength A x)) + (fun | 0 => μ | 1 => ν); swap + · rw [toTensor_toFieldStrength_basis_repr] + rw [toFieldStrength_tensor_basis_eq_basis] + rfl lemma toFieldStrength_basis_repr_apply_eq_single {d} {μν : (Fin 1 ⊕ Fin d) × (Fin 1 ⊕ Fin d)} (A : ElectromagneticPotential d) (x : SpaceTime d) : @@ -426,7 +433,9 @@ lemma fieldStrengthMatrix_eq_tensor_basis_repr {d} (A : ElectromagneticPotential (x : SpaceTime d) (μ ν : (Fin 1 ⊕ Fin d)) : A.fieldStrengthMatrix x (μ, ν) = (Tensor.basis _).repr (Tensorial.toTensor (toFieldStrength A x)) - (fun | 0 => μ | 1 => ν) := rfl + (fun | 0 => μ | 1 => ν) := by + rw [toFieldStrength_tensor_basis_eq_basis] + rfl lemma toFieldStrength_eq_fieldStrengthMatrix {d} (A : ElectromagneticPotential d) : toFieldStrength A = fun x => ∑ μ, ∑ ν, @@ -437,7 +446,8 @@ lemma toFieldStrength_eq_fieldStrengthMatrix {d} (A : ElectromagneticPotential d ext κ match κ with | (μ', ν') => - simpa [Finsupp.single_apply] + simp [Finsupp.single_apply] + rfl /-! @@ -525,6 +535,7 @@ lemma toFieldStrength_antisymmetric {d} (A : ElectromagneticPotential d) (x : Sp rw [toTensor_toFieldStrength_basis_repr] rw [← Finset.sum_neg_distrib] apply Finset.sum_congr rfl (fun κ _ => ?_) + simp only [Fin.isValue, neg_sub] rfl lemma fieldStrengthMatrix_antisymm {d} (A : ElectromagneticPotential d) (x : SpaceTime d) diff --git a/Physlib/Electromagnetism/Kinematics/MagneticField.lean b/Physlib/Electromagnetism/Kinematics/MagneticField.lean index faf91c126..dfeeb0f5f 100644 --- a/Physlib/Electromagnetism/Kinematics/MagneticField.lean +++ b/Physlib/Electromagnetism/Kinematics/MagneticField.lean @@ -100,6 +100,8 @@ lemma magneticField_coord_eq_fieldStrengthMatrix {i : Fin 3} {c : SpeedOfLight} congr all_goals · rw [SpaceTime.deriv_sum_inr c _ hA] + simp only [Fin.isValue, ContinuousLinearEquiv.apply_symm_apply] + rw [Space.deriv_eq, Space.deriv_eq, Lorentz.Vector.fderiv_apply] rfl · fun_prop @@ -149,6 +151,7 @@ lemma ofElectromagneticField_magneticField {c : SpeedOfLight} (u • basis.repr x) ⨯ₑ₃ B t (u • x) suffices h : ContDiff ℝ 1 (fun x => C x i) by convert! h using 1 + simp [C] rfl fin_cases i all_goals @@ -303,7 +306,8 @@ lemma magneticFieldMatrix_eq_vectorPotential {c : SpeedOfLight} (A : Electromagn rw [add_comm] congr all_goals - · rfl + · rw [← Space.deriv_lorentz_vector] + rfl fun_prop /-! @@ -392,6 +396,7 @@ lemma time_deriv_magneticFieldMatrix {d : ℕ} {c : SpeedOfLight} (A : Electroma conv_lhs => enter [1, t] rw [magneticFieldMatrix_eq_vectorPotential _ (hA.differentiable (by simp))] + rw [Time.deriv, fderiv_fun_sub] rfl all_goals · apply Differentiable.differentiableAt @@ -469,6 +474,7 @@ lemma curl_magneticFieldMatrix_eq_electricField_fieldStrengthMatrix {d : ℕ} {c field_simp · funext j rw [SpaceTime.deriv_sum_inr c] + simp rfl · apply fieldStrengthMatrix_differentiable hA diff --git a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean index 0c0fe07ff..945a1f6c6 100644 --- a/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean +++ b/Physlib/Electromagnetism/Kinematics/ScalarPotential.lean @@ -85,7 +85,9 @@ lemma ofStaticScalarPotential_scalarPotential {d} (c : SpeedOfLight) @[simp] lemma ofVectorPotential_scalarPotential {d} (c : SpeedOfLight) (A : Time → Space d → EuclideanSpace ℝ (Fin d)) : - (ofVectorPotential c A).scalarPotential = 0 := rfl + (ofVectorPotential c A).scalarPotential = 0 := by + simp only [scalarPotential, SpeedOfLight.val_one, ofVectorPotential, Fin.isValue, mul_zero] + rfl @[simp] lemma ofStaticVectorPotential_scalarPotential {d} (c : SpeedOfLight) @@ -140,6 +142,9 @@ lemma scalarPotential_contDiff {n} {d} (c : SpeedOfLight) (A : ElectromagneticPo (hA : ContDiff ℝ n A) : ContDiff ℝ n ↿(A.scalarPotential c) := by simp [scalarPotential] apply timeSlice_contDiff + have h1 : ∀ i, ContDiff ℝ n (fun x => A x i) := by + rw [SpaceTime.contDiff_vector] + exact hA apply ContDiff.mul · fun_prop exact h1 (Sum.inl 0) @@ -174,6 +179,9 @@ lemma scalarPotential_differentiable {d} (c : SpeedOfLight) (A : Electromagnetic (hA : Differentiable ℝ A) : Differentiable ℝ ↿(A.scalarPotential c) := by simp [scalarPotential] apply timeSlice_differentiable + have h1 : ∀ i, Differentiable ℝ (fun x => A x i) := by + rw [SpaceTime.differentiable_vector] + exact hA apply Differentiable.mul · fun_prop exact h1 (Sum.inl 0) diff --git a/Physlib/Electromagnetism/Vacuum/Constant.lean b/Physlib/Electromagnetism/Vacuum/Constant.lean index be1431c8e..1f4dc9cdd 100644 --- a/Physlib/Electromagnetism/Vacuum/Constant.lean +++ b/Physlib/Electromagnetism/Vacuum/Constant.lean @@ -85,10 +85,11 @@ The potential is smooth. lemma constantEB_smooth {c : SpeedOfLight} {E₀ : EuclideanSpace ℝ (Fin d)} {B₀ : Fin d × Fin d → ℝ} {B₀_antisymm : ∀ i j, B₀ (i, j) = - B₀ (j, i)} : - ContDiff ℝ ∞ (constantEB c E₀ B₀ B₀_antisymm) := - (Lorentz.Vector.contDiff_apply _).mp (fun μ => by - match μ with - | Sum.inl _ => + ContDiff ℝ ∞ (constantEB c E₀ B₀ B₀_antisymm) := by + rw [← Lorentz.Vector.contDiff_apply] + intro μ + match μ with + | Sum.inl _ => simp [constantEB] apply ContDiff.neg apply ContDiff.mul diff --git a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean index a2dc73cb4..255a29080 100644 --- a/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean +++ b/Physlib/Electromagnetism/Vacuum/HarmonicWave.lean @@ -141,7 +141,10 @@ The scalar potential of the harmonic wave is zero. @[simp] lemma harmonicWaveX_scalarPotential_eq_zero {d} (𝓕 : FreeSpace) (k : ℝ) (E₀ : Fin d → ℝ) (φ : Fin d → ℝ) : - (harmonicWaveX 𝓕 k E₀ φ).scalarPotential 𝓕.c = 0 := rfl + (harmonicWaveX 𝓕 k E₀ φ).scalarPotential 𝓕.c = 0 := by + ext x + simp [harmonicWaveX, scalarPotential] + rfl /-! @@ -511,7 +514,9 @@ lemma harmonicWaveX_isPlaneWave {d} (𝓕 : FreeSpace) (k : ℝ) (hk : k ≠ 0) | ⟨Nat.succ i, h⟩ => E₀ ⟨i, by grind⟩ * cos (-k * u + φ ⟨i, by grind⟩) ext t x i match i with - | 0 => rfl + | 0 => + simp [harmonicWaveX_electricField_zero, planeWave] + rfl | ⟨Nat.succ i, h⟩ => simp only [Nat.succ_eq_add_one, neg_mul] rw [← Fin.succ_mk _ _ (by grind)] @@ -531,7 +536,9 @@ lemma harmonicWaveX_isPlaneWave {d} (𝓕 : FreeSpace) (k : ℝ) (hk : k ≠ 0) intro t x ext ij match ij with - | (0, 0) => rfl + | (0, 0) => + simp only [Nat.succ_eq_add_one, magneticFieldMatrix_diag_eq_zero, inner_basis, neg_mul] + rfl | (⟨0, h0⟩, ⟨Nat.succ j, hj⟩) => simp only [Nat.succ_eq_add_one, Fin.zero_eta, inner_basis, neg_mul] rw [← Fin.succ_mk _ _ (by grind)] diff --git a/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean b/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean index 3cb20dafd..761811058 100644 --- a/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean +++ b/Physlib/Electromagnetism/Vacuum/IsPlaneWave.lean @@ -152,7 +152,8 @@ lemma electricFunction_unique {d : ℕ} {𝓕 : FreeSpace} funext x obtain ⟨t, rfl⟩ : ∃ t, x = ⟪0, s.unit⟫_ℝ - 𝓕.c * t := by use (- x/𝓕.c); field_simp; simp trans A.electricField 𝓕.c t (0 : Space d) - · exact congrFun hE₁ _ + · rw [hE₁] + rfl · rw [P.electricField_eq_electricFunction] /-! diff --git a/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean b/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean index 28eb65a7c..3e88e2bd0 100644 --- a/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean +++ b/Physlib/SpaceAndTime/SpaceTime/Derivatives.lean @@ -378,6 +378,7 @@ noncomputable def distDeriv {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] ev.comp (Distribution.fderivD ℝ f) map_add' f1 f2 := by simp + map_smul' a f := by simp lemma distDeriv_apply {M d} [NormedAddCommGroup M] [NormedSpace ℝ M] (μ : Fin 1 ⊕ Fin d) (f : (SpaceTime d) →d[ℝ] M) (ε : 𝓢(SpaceTime d, ℝ)) : diff --git a/Physlib/Units/Examples.lean b/Physlib/Units/Examples.lean index 8a2877403..6d05e321d 100644 --- a/Physlib/Units/Examples.lean +++ b/Physlib/Units/Examples.lean @@ -33,6 +33,7 @@ noncomputable def meters400 : Dimensionful (WithDim L𝓭 ℝ) := toDimensionful /-- Changing that length to miles. 400 meters is very almost a quarter of a mile. -/ example : meters400 {SI with length := LengthUnit.miles} = ⟨1/4 - 73/50292⟩ := by + simp [meters400, toDimensionful_apply_apply, dimScale, LengthUnit.miles] ext show (1609.344 : ℝ)⁻¹ * 400 = _ norm_num diff --git a/Physlib/Units/WithDim/Area.lean b/Physlib/Units/WithDim/Area.lean index 1bb15f0d6..ca58d950c 100644 --- a/Physlib/Units/WithDim/Area.lean +++ b/Physlib/Units/WithDim/Area.lean @@ -68,6 +68,7 @@ lemma squareMeter_in_SI : squareMeter.1 SI = ⟨1⟩ := by @[simp] lemma squareFoot_in_SI : squareFoot.1 SI = ⟨0.09290304⟩ := by + simp [squareFoot, dimScale, LengthUnit.feet, toDimensionful_apply_apply,] ext simp [NNReal.coe_ofScientific] rw [toReal] @@ -75,6 +76,7 @@ lemma squareFoot_in_SI : squareFoot.1 SI = ⟨0.09290304⟩ := by @[simp] lemma squareMile_in_SI : squareMile.1 SI = ⟨2589988.110336⟩ := by + simp [squareMile, dimScale, LengthUnit.miles, toDimensionful_apply_apply] ext simp [NNReal.coe_ofScientific] rw [toReal] @@ -90,6 +92,7 @@ lemma hectare_in_SI : hectare.1 SI = ⟨10000⟩ := by @[simp] lemma acre_in_SI : acre.1 SI = ⟨4046.8564224⟩ := by + simp [acre, dimScale, LengthUnit.miles, toDimensionful_apply_apply] ext simp [NNReal.coe_ofScientific] rw [toReal] @@ -104,6 +107,7 @@ lemma acre_in_SI : acre.1 SI = ⟨4046.8564224⟩ := by /-- One acre is exactly `43560` square feet. -/ lemma acre_eq_mul_squareFeet : acre = (43560 : ℝ≥0) • squareFoot := by apply (toDimensionful SI).symm.injective + simp [toDimensionful] ext norm_num diff --git a/Physlib/Units/WithDim/Speed.lean b/Physlib/Units/WithDim/Speed.lean index efd69a55e..aa76ce536 100644 --- a/Physlib/Units/WithDim/Speed.lean +++ b/Physlib/Units/WithDim/Speed.lean @@ -65,6 +65,7 @@ lemma oneMeterPerSecond_in_SI : oneMeterPerSecond SI = ⟨1⟩ := by @[simp] lemma oneMilePerHour_in_SI : oneMilePerHour SI = ⟨0.44704⟩ := by + simp [oneMilePerHour, dimScale, LengthUnit.miles, TimeUnit.hours, toDimensionful_apply_apply] ext simp [NNReal.coe_ofScientific] rw [toReal] @@ -73,6 +74,8 @@ lemma oneMilePerHour_in_SI : oneMilePerHour SI = ⟨0.44704⟩ := by @[simp] lemma oneKilometerPerHour_in_SI : oneKilometerPerHour SI = ⟨5/18⟩ := by + simp [oneKilometerPerHour, dimScale, + LengthUnit.kilometers, TimeUnit.hours, toDimensionful_apply_apply] ext simp only [WithDim.smul_val, smul_eq_mul, mul_one, NNReal.coe_mul, coe_rpow, NNReal.coe_div, NNReal.coe_ofNat] @@ -81,8 +84,10 @@ lemma oneKilometerPerHour_in_SI : @[simp] lemma oneKnot_in_SI : oneKnot SI = ⟨463/900⟩ := by + simp [oneKnot, dimScale, LengthUnit.nauticalMiles, TimeUnit.hours, toDimensionful_apply_apply] ext - norm_num [oneKnot, dimScale, LengthUnit.nauticalMiles, TimeUnit.hours, toDimensionful_apply_apply] + simp only [WithDim.smul_val, smul_eq_mul, mul_one, NNReal.coe_mul, coe_rpow, NNReal.coe_div, + NNReal.coe_ofNat] rw [toReal] norm_num @@ -99,18 +104,21 @@ lemma speedOfLight_in_SI : speedOfLight SI = ⟨299792458⟩ := by lemma oneKnot_eq_mul_oneKilometerPerHour : oneKnot = (1.852 : ℝ≥0) • oneKilometerPerHour := by apply (toDimensionful SI).symm.injective + simp [toDimensionful] ext norm_num lemma oneKilometerPerHour_eq_mul_oneKnot: oneKilometerPerHour = (250/463 : ℝ≥0) • oneKnot := by apply (toDimensionful SI).symm.injective + simp [toDimensionful] ext norm_num lemma oneMeterPerSecond_eq_mul_oneMilePerHour : oneMeterPerSecond = (3125/1397 : ℝ≥0) • oneMilePerHour := by apply (toDimensionful SI).symm.injective + simp [toDimensionful] ext norm_num diff --git a/QuantumInfo/Channels/Dual.lean b/QuantumInfo/Channels/Dual.lean index f697ef5d0..acb18f0ba 100644 --- a/QuantumInfo/Channels/Dual.lean +++ b/QuantumInfo/Channels/Dual.lean @@ -259,6 +259,8 @@ lemma dual_kron {A B C D : Type*} [Fintype A] [Fintype B] [Fintype C] [Fintype D -- see Lemma 3.1 of https://www.math.uwaterloo.ca/~krdavids/Preprints/CDPRpositivereal.pdf theorem IsCompletelyPositive.dual {M : MatrixMap dIn dOut ℂ} (h : M.IsCompletelyPositive) : M.dual.IsCompletelyPositive := by intro n + have h_dual_pos : (MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ)).IsPositive := by + exact IsPositive.dual (h n); -- By definition of complete positivity, we know that $(M ⊗ₖₘ id) dually map = M.dual ⊗ₖₘ id.dual$. have h_dual_kron : (MatrixMap.dual (M ⊗ₖₘ MatrixMap.id (Fin n) ℂ)) = (MatrixMap.dual M) ⊗ₖₘ (MatrixMap.dual (MatrixMap.id (Fin n) ℂ)) := by convert dual_kron M ( MatrixMap.id ( Fin n ) ℂ ) using 1; diff --git a/QuantumInfo/Channels/MatrixMap.lean b/QuantumInfo/Channels/MatrixMap.lean index acaf43ef2..ba94eb425 100644 --- a/QuantumInfo/Channels/MatrixMap.lean +++ b/QuantumInfo/Channels/MatrixMap.lean @@ -233,6 +233,7 @@ theorem kron_def [CommSemiring R] (M₁ : MatrixMap A B R) (M₂ : MatrixMap C D rw [Finset.sum_eq_single a₁, Finset.sum_eq_single a₂, Finset.sum_eq_single c₁, Finset.sum_eq_single c₂] <;> simp +contextual nth_rw 1 [h_expand] + simp only [map_sum, LinearMap.map_smulₛₗ] rfl rw [h_expand] clear h_expand diff --git a/QuantumInfo/Channels/Pinching.lean b/QuantumInfo/Channels/Pinching.lean index 2074bc8f0..07b5d2dc1 100644 --- a/QuantumInfo/Channels/Pinching.lean +++ b/QuantumInfo/Channels/Pinching.lean @@ -146,7 +146,13 @@ theorem pinching_self (ρ : MState d) : pinching_map ρ ρ = ρ := by simp only [HermitianMat.conjTranspose_mat, MState.mat_M, LinearMap.coe_sum, LinearMap.coe_mk, AddHom.coe_mk, Finset.sum_apply] simp_rw [(pinching_kraus_commutes ρ _).eq, mul_assoc, ← sq] - simp_rw [pinching_sq_eq_self] + conv_lhs => + enter [1, 2, x, 2] + change (pinching_kraus ρ x ^ 2).mat + rw [pinching_sq_eq_self] + simp_rw [← Finset.mul_sum, ← HermitianMat.mat_finset_sum] + simp only [pinching_sum, HermitianMat.mat_one, mul_one] + rfl set_option backward.isDefEq.respectTransparency false in /-- Lemma 3.10 of Hayashi's book "Quantum Information Theory - Mathematical Foundations". @@ -184,7 +190,7 @@ theorem pinching_bound (ρ σ : MState d) : ρ.M ≤ (↑(Fintype.card (spectrum simp only [HermitianMat.mat_finset_sum] simp only [Matrix.mul_sum, Matrix.sum_mul, Matrix.sum_mulVec, dotProduct_sum] simp only [MState.pure] - dsimp [MState.m] + dsimp only [MState.m] --This out to be Cauchy-Schwarz. have hschwarz := inner_mul_inner_self_le (𝕜 := ℂ) (E := EuclideanSpace ℂ (↑(spectrum ℝ σ.m))) (x := .toLp 2 fun i ↦ 1) (y := .toLp 2 fun k ↦ ( @@ -217,7 +223,8 @@ theorem pinching_bound (ρ σ : MState d) : ρ.M ≤ (↑(Fintype.card (spectrum rw [Complex.mul_conj, Complex.norm_real, Real.norm_of_nonneg (Complex.normSq_nonneg _)] simp_rw [← Complex.mul_conj, map_sum, Finset.mul_sum, Finset.sum_mul] congr! with x _ y _ - simpa [← Matrix.mul_assoc] using h_mul x y + rw [← Matrix.mul_assoc] + exact h_mul x y · simp · have hc (c d : ℂ) : d = starRingEnd ℂ d → c = d → c = d.re := by rintro h rfl; simp [Complex.ext_iff] at h ⊢; linarith @@ -349,8 +356,9 @@ theorem ker_le_ker_pinching_map_ker (ρ σ : MState d) (h : σ.M.ker ≤ ρ.M.ke --TODO Cleanup intro v hv; -- Since $v \in \ker \sigma$, we have $P_k v = 0$ for all $k$ where the eigenvalue of $k$ is non-zero. - have h_proj_zero : ∀ k : spectrum ℝ σ.m, k.val ≠ 0 → (pinching_kraus σ k).mat *ᵥ v = 0 := - fun k hk => pinching_kraus_ker_of_ne_zero σ v congr($hv) k hk + have h_proj_zero : ∀ k : spectrum ℝ σ.m, k.val ≠ 0 → (pinching_kraus σ k).mat *ᵥ v = 0 := by + intro k hk + exact pinching_kraus_ker_of_ne_zero σ v congr($hv) k hk -- Since $v \in \ker \sigma$, we have $P_k v = v$ for all $k$ where the eigenvalue of $k$ is zero. have h_proj_one : ∀ k : spectrum ℝ σ.m, k.val = 0 → (pinching_kraus σ k).mat *ᵥ v = v := by intro k hk @@ -383,7 +391,8 @@ theorem ker_le_ker_pinching_map_ker (ρ σ : MState d) (h : σ.M.ker ≤ ρ.M.ke rw! [← hk_zero] at h_proj_one simp only [Subtype.coe_eta] at h_proj_one simp only [← Matrix.mul_assoc, ← Matrix.mulVec_mulVec, ContinuousLinearMap.coe_coe] - exact h_proj_one + rw [h_proj_one] + rfl · simp · simp [← Matrix.mulVec_mulVec, h_proj_zero _ hk_zero] diff --git a/QuantumInfo/Entropy/DPI.lean b/QuantumInfo/Entropy/DPI.lean index 4a344a49b..de8febf8a 100644 --- a/QuantumInfo/Entropy/DPI.lean +++ b/QuantumInfo/Entropy/DPI.lean @@ -755,6 +755,7 @@ private lemma twirling_identity [Nonempty dB] (X : HermitianMat dB ℂ) : · rename_i a s a_1 a_2 obtain ⟨fst, snd⟩ := a simp only [not_false_eq_true, Finset.sum_insert, *] + rfl · norm_num [Matrix.one_apply] rw [show X.trace = ∑ k, X k k from X.trace_eq_trace] rcases n : Fintype.card dB with (_ | n) diff --git a/QuantumInfo/Entropy/Relative.lean b/QuantumInfo/Entropy/Relative.lean index e25b23bfd..49db5cee4 100644 --- a/QuantumInfo/Entropy/Relative.lean +++ b/QuantumInfo/Entropy/Relative.lean @@ -279,7 +279,7 @@ lemma HermitianMat.supportProj_mul_self (A : HermitianMat d ℂ) : have h_supportProj_mul_A : ∀ (v : EuclideanSpace ℂ d), v ∈ LinearMap.range A.val.toEuclideanLin → (A.supportProj.val.toEuclideanLin v) = v := by intro v hv have h_supportProj_mul_A : (A.supportProj.val.toEuclideanLin v) = (Submodule.orthogonalProjectionOnto (LinearMap.range A.val.toEuclideanLin) v) := by - simp only [val_eq_coe, Submodule.coe_orthogonalProjectionOnto_apply] + simp only [val_eq_coe] simp [supportProj, projector] have key : ∀ (f : EuclideanSpace ℂ d →ₗ[ℂ] EuclideanSpace ℂ d), Matrix.toEuclideanLin @@ -290,6 +290,7 @@ lemma HermitianMat.supportProj_mul_self (A : HermitianMat d ℂ) : have hsup : A.support = (Matrix.toEuclideanLin (↑A : Matrix d d ℂ)).range := by simp [HermitianMat.support, HermitianMat.lin] rw [key, LinearMap.comp_apply, Submodule.subtype_apply, hsup] + rfl rw [h_supportProj_mul_A] exact Submodule.eq_starProjection_of_mem_of_inner_eq_zero (by simpa using hv) (by simp) exact congr(WithLp.ofLp $(h_supportProj_mul_A _ h_range)) @@ -461,7 +462,8 @@ private lemma hasDerivAt_trace_rpow_at_one (B : HermitianMat d ℂ) (hB : 0 ≤ simp [pow_one, HermitianMat.log] rw [h_log] exact (B.mat_cfc_mul_apply id Real.log).symm - exact h_trace.trans HermitianMat.trace_eq_trace_rc.symm + rw [h_trace, ← HermitianMat.trace_eq_trace_rc] + rfl simp_all [ HermitianMat.trace_cfc_eq ]; exact_mod_cast h_inner_def.trans h_trace; have h_deriv : ∀ i, HasDerivAt (fun α : ℝ => (B.H.eigenvalues i) ^ α) (B.H.eigenvalues i * Real.log (B.H.eigenvalues i)) 1 := by @@ -1254,6 +1256,7 @@ lemma ker_le_of_ker_kron_le_left (ρ₁ σ₁ : MState d₁) (ρ₂ σ₂ : MSta convert! congr(WithLp.ofLp $(h_top (WithLp.toLp 2 ( Pi.single j 1 )) ) i) using 1 simp simp [ HermitianMat.lin ]; + rfl exact ρ₂.pos.ne' h_contra; have h_union : ∀ (U V : Submodule ℂ (EuclideanSpace ℂ d₂)), U ≠ ⊤ → V ≠ ⊤ → ∃ v : EuclideanSpace ℂ d₂, v ∉ U ∧ v ∉ V := by intros U V hU hV; @@ -1490,6 +1493,7 @@ private theorem sandwichedRelRentropy_additive_alpha_one (ρ₁ σ₁ : MState d <;> by_cases h2 : σ₂.M.ker ≤ ρ₂.M.ker · simp only [SandwichedRelRentropy, ↓reduceIte, ↓reduceDIte, h1, h2] split_ifs <;> simp_all [ ker_prod_le_iff ]; + simp only [sandwichedRelRentropy_additive_alpha_one_aux ρ₁ σ₁ ρ₂ σ₂ h1 h2] rfl · simp only [SandwichedRelRentropy, zero_lt_one, ↓reduceDIte, ↓reduceIte, h1, h2, add_top, dite_eq_right_iff, ENNReal.coe_ne_top, imp_false] @@ -1662,7 +1666,8 @@ private theorem sandwichedRelRentropy.continuousOn_Ioi_1 (ρ σ : MState d) : have hα₀ : 0 < α := by linarith have hα₁ : α ≠ 1 := by linarith simp only [dif_pos hα₀, if_neg hα₁, ENNReal.ofReal] - exact Real.toNNReal_of_nonneg _ + rw [Real.toNNReal_of_nonneg] + rfl · rw [continuousOn_congr (f := fun α ↦ ⊤)] · fun_prop · clear ρ σ hρ; @@ -1707,7 +1712,8 @@ private theorem sandwichedRelRentropy.continuousOn_Ioo_0_1 (ρ σ : MState d) : have hα₁ : α ≠ 1 := ne_of_lt hα.2 split_ifs · norm_cast - · exact Real.toNNReal_of_nonneg _ + · rw [ENNReal.ofReal, Real.toNNReal_of_nonneg] + rfl · rw [continuousOn_congr (f := fun α ↦ ⊤)] · fun_prop · intro x hx @@ -1964,7 +1970,8 @@ private lemma ker_le_iff_eigenWeight_zero (ρ x : MState d) : replace h_eigenvalue := congr(WithLp.toLp 2 $h_eigenvalue) simp only [HermitianMat.val_eq_coe, MState.mat_M, WithLp.ofLp_sum, WithLp.ofLp_smul, WithLp.toLp_sum, WithLp.toLp_smul, WithLp.toLp_ofLp] at h_eigenvalue - exact h_eigenvalue.symm.trans hv.symm + rw [← h_eigenvalue, ← hv] + rfl have h_eigenvalue_zero : ∀ i, (x.M.H.eigenvalues i) • w i = 0 := by intro i have h_eigenvalue_zero : (x.M.H.eigenvalues i) • w i = inner ℂ (x.M.H.eigenvectorBasis i) (∑ j, (x.M.H.eigenvalues j) • w j • x.M.H.eigenvectorBasis j) := by diff --git a/QuantumInfo/Entropy/SSA.lean b/QuantumInfo/Entropy/SSA.lean index 47d6d0b9d..e9011a35d 100644 --- a/QuantumInfo/Entropy/SSA.lean +++ b/QuantumInfo/Entropy/SSA.lean @@ -291,6 +291,8 @@ theorem Matrix.opNorm_conjTranspose_eq_opNorm {m n : Type*} [Fintype m] [Fintype Matrix.opNorm Aᴴ = Matrix.opNorm A := by unfold Matrix.opNorm rw [← ContinuousLinearMap.adjoint.norm_map (toEuclideanLin A).toContinuousLinearMap] + rw [toEuclideanLin_conjTranspose_eq_adjoint] + rfl theorem isometry_mul_conjTranspose_le_one {m n : Type*} [Fintype m] [Fintype n] [DecidableEq m] [DecidableEq n] @@ -867,6 +869,7 @@ private lemma inner_one_kron_eq_inner_traceLeft refine' Finset.sum_bij ( fun x y => ( x.2, x.1 ) ) _ _ _ _ <;> simp [ Matrix.mul_apply ]; intro a b; rw [ ← Equiv.sum_comp ( Equiv.prodComm d₁ d₂ ) ] simp [mul_comm] + rfl open HermitianMat in private lemma hermitianMat_log_inv_eq_neg diff --git a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean index 9caae93ae..5c1d5d07c 100644 --- a/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean +++ b/QuantumInfo/ForMathlib/HayataGroup/TraceInequality/LiebAndoTrace.lean @@ -862,6 +862,8 @@ private lemma pdSet_rpow_of_mem_Icc_zero_one (algebraMap ℝ (L ℋ) r) ^ p = algebraMap ℝ (L ℋ) (r ^ p) := by rw [CFC.rpow_eq_cfc_real (A := L ℋ) (a := algebraMap ℝ (L ℋ) r) (y := p) (ha := hr0)] simp + have hbound : algebraMap ℝ (L ℋ) (r ^ p) ≤ A ^ p := by + simpa [hscalar, hApow] using hmono exact (CFC.exists_pos_algebraMap_le_iff (A := L ℋ) (a := A ^ p) (ha := hApow_sa)).1 ⟨r ^ p, Real.rpow_pos_of_pos hr p, hbound⟩ diff --git a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean index 9b1146256..b8f8e3047 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/Basic.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/Basic.lean @@ -36,7 +36,8 @@ theorem eq_IsHermitian : HermitianMat n α = { m : Matrix n n α // m.IsHermiti instance : Coe (HermitianMat n α) (Matrix n n α) := ⟨mat⟩ @[simp] -theorem val_eq_coe (A : HermitianMat n α) : A.val = A := rfl +theorem val_eq_coe (A : HermitianMat n α) : A.val = A := by + rfl @[simp] theorem mat_mk (x : Matrix n n α) (h) : mat ⟨x, h⟩ = x := rfl @@ -100,7 +101,8 @@ instance : SMul R (HermitianMat n α) := @[simp, norm_cast] theorem mat_smul (c : R) (A : HermitianMat n α) : - (c • A).mat = c • A.mat := rfl + (c • A).mat = c • A.mat := by + rfl @[simp] theorem smul_apply (c : R) (A : HermitianMat n α) (i j : n) : diff --git a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean index de2e08357..e1187b559 100644 --- a/QuantumInfo/ForMathlib/HermitianMat/CFC.lean +++ b/QuantumInfo/ForMathlib/HermitianMat/CFC.lean @@ -50,7 +50,8 @@ protected def cfc : HermitianMat d 𝕜 := theorem cfc_eq : A.cfc f = ⟨cfc f A.mat, cfc_predicate f A.mat⟩ := rfl @[simp] -theorem mat_cfc : (A.cfc f).mat = _root_.cfc f A.mat := rfl +theorem mat_cfc : (A.cfc f).mat = _root_.cfc f A.mat := by + rfl section congr diff --git a/QuantumInfo/Measurements/POVM.lean b/QuantumInfo/Measurements/POVM.lean index d9745cdda..c2c7c32e0 100644 --- a/QuantumInfo/Measurements/POVM.lean +++ b/QuantumInfo/Measurements/POVM.lean @@ -102,7 +102,10 @@ def measurementMap (Λ : POVM X d) : CPTPMap d (d × X) where open Kronecker in theorem measurementMap_apply_matrix (Λ : POVM X d) (m : Matrix d d ℂ) : Λ.measurementMap.map m = ∑ x : X, - ((((Λ.mats x) ^ (1/2:ℝ)).mat * m * ((Λ.mats x)^(1/2:ℝ)).mat) ⊗ₖ Matrix.single x x 1) := rfl + ((((Λ.mats x) ^ (1/2:ℝ)).mat * m * ((Λ.mats x)^(1/2:ℝ)).mat) ⊗ₖ Matrix.single x x 1) := by + dsimp [measurementMap, HPMap.map] + rw [LinearMap.sum_apply] + rfl open HermitianMat in theorem measurementMap_apply_hermitianMat (Λ : POVM X d) (m : HermitianMat d ℂ) : diff --git a/QuantumInfo/ResourceTheory/FreeState.lean b/QuantumInfo/ResourceTheory/FreeState.lean index bc1712a87..d93598b96 100644 --- a/QuantumInfo/ResourceTheory/FreeState.lean +++ b/QuantumInfo/ResourceTheory/FreeState.lean @@ -90,7 +90,8 @@ theorem prodRelabel_assoc (ρ₁ : MState (H i)) (ρ₂ : MState (H j)) (ρ₃ : rw [← MState.relabel_cast]; swap · rw [mul_assoc] rw [MState.kron_relabel, MState.prod_assoc] - simp [MState.relabel_comp] + rw [MState.relabel_comp, MState.relabel_comp, MState.relabel_comp] + rfl /-- A `MState.relabel` can be distributed across a `prodRelabel`, if you have proofs that the factors correspond correctly. -/ diff --git a/QuantumInfo/ResourceTheory/HypothesisTesting.lean b/QuantumInfo/ResourceTheory/HypothesisTesting.lean index f7186f5ff..e6bec24a8 100644 --- a/QuantumInfo/ResourceTheory/HypothesisTesting.lean +++ b/QuantumInfo/ResourceTheory/HypothesisTesting.lean @@ -100,6 +100,7 @@ theorem iInf_IsConvex (ρ : MState d) (ε : Prob) : Convex ℝ { m | ρ.exp_val @[simp] theorem of_empty {ρ : MState d} (ε : Prob) : β_ ε(ρ‖∅) = 0 := by simp [OptimalHypothesisRate] + rfl set_option backward.isDefEq.respectTransparency false in theorem le_sup_exp_val {ρ : MState d} (ε : Prob) {S : Set (MState d)} @@ -304,6 +305,7 @@ theorem Lemma3 {ρ : MState d} (ε : Prob) {S : Set (MState d)} (hS₁ : IsCompa have hi := iSup_range' (ι := S) (fun x ↦ (f x) ↑y) (·) rw [← Set.image_eq_range] at hi rw [← iSup_subtype'', Set.Icc.coe_iSup zero_le_one, hi] + rfl --Maybe should be phrased in terms of `0 < ...` instead? Maybe belongs in another file? It's kiinnnd of specialized.. theorem ker_diagonal_prob_eq_bot {q : Prob} (hq₁ : 0 < q) (hq₂ : q < 1) : diff --git a/QuantumInfo/ResourceTheory/SteinsLemma.lean b/QuantumInfo/ResourceTheory/SteinsLemma.lean index 30ef6d375..b5d4edadd 100644 --- a/QuantumInfo/ResourceTheory/SteinsLemma.lean +++ b/QuantumInfo/ResourceTheory/SteinsLemma.lean @@ -2026,6 +2026,7 @@ theorem GeneralizedQSteinsLemma {i : ι} (ρ : MState (H i)) {ε : Prob} (hε : rw [← add_assoc, σₖ_succ, pow_succ] grw [Lemma7_gap ρ hε hε' (σₖ (m + k)), ih m] ring_nf + rfl replace hσₖ_gap : Filter.atTop.liminf (fun k ↦ R2 ρ (σₖ k)) ≤ R1 ρ ε := by rw [ENNReal.tendsto_sub_const_nhds_zero_iff] at hσₖ_gap diff --git a/QuantumInfo/States/Ensemble.lean b/QuantumInfo/States/Ensemble.lean index 6875b8bdf..ec2a0ae1d 100644 --- a/QuantumInfo/States/Ensemble.lean +++ b/QuantumInfo/States/Ensemble.lean @@ -136,7 +136,8 @@ theorem mix_pEnsemble_pure_iff_pure {e : PEnsemble d α} : refine Finset.sum_congr rfl fun i _ => ?_ by_cases hi : e.distr i = 0 · simp [hi] - · exact h i hi + · rw [← h i hi] + rfl simp [MState.ext_iff, h_sum, ← Finset.sum_smul] /- The theorem below is also false for the same reason as the original `mix_pEnsemble_pure_iff_pure`: diff --git a/QuantumInfo/States/Entanglement.lean b/QuantumInfo/States/Entanglement.lean index 83ff9af20..76667a7b0 100644 --- a/QuantumInfo/States/Entanglement.lean +++ b/QuantumInfo/States/Entanglement.lean @@ -179,6 +179,7 @@ theorem convex_roof_of_pure (ψ : Ket d) : convex_roof g (pure ψ) = g (KetUpToP conv_lhs => enter [1, 1] rw [trivial_pEnsemble_average ψ _ 0] + rfl · apply le_convex_roof intro n hnpos e hmix apply le_of_eq @@ -190,6 +191,7 @@ theorem convex_roof_of_pure (ψ : Ket d) : convex_roof g (pure ψ) = g (KetUpToP congr 1 exact congrArg g (Quotient.sound hab) simp [mix_pEnsemble_pure_average (NNReal.toReal ∘ g ∘ KetUpToPhase.mk) hphase_inv hmix] + rfl omit [Nonempty d] in /-- The mixed convex roof extension of `f : MState d → ℝ≥0` applied to a pure state `ψ` is `f (pure ψ)`. -/ @@ -204,6 +206,7 @@ theorem mixed_convex_roof_of_pure (ψ : Ket d) : mixed_convex_roof f (pure ψ) = conv_lhs => enter [1, 1] rw [trivial_mEnsemble_average _ (pure ψ) 0] + rfl · apply le_mixed_convex_roof intro n hnpos e hmix replace hpure := mix_mEnsemble_pure_iff_pure.mp hmix @@ -212,6 +215,7 @@ theorem mixed_convex_roof_of_pure (ψ : Ket d) : mixed_convex_roof f (pure ψ) = conv_rhs => enter [1, 1] rw [mix_mEnsemble_pure_average (toReal ∘ f) hmix, Function.comp_apply] + rfl /-- Entanglement of Formation of bipartite systems. It is the convex roof extension of the von Neumann entropy of one of the subsystems (here chosen to be the left one, but see `Entropy.Sᵥₙ_of_partial_eq`). @@ -250,6 +254,7 @@ theorem traceRight_pure_MES (d : Type*) [Fintype d] [DecidableEq d] [Nonempty d] coe_ofClassical, ProbDistribution.uniform_def, Finset.card_univ] unfold HermitianMat.diagonal simp_all only [map_inv₀, map_natCast] + rfl /- The von Neumann entropy of a state is equal to the trace of `ρ log ρ` (technically `cfc ρ negMulLog`). diff --git a/QuantumInfo/States/Mixed/MState.lean b/QuantumInfo/States/Mixed/MState.lean index c160dc7cb..ff29ab560 100644 --- a/QuantumInfo/States/Mixed/MState.lean +++ b/QuantumInfo/States/Mixed/MState.lean @@ -83,7 +83,8 @@ attribute [simp] MState.tr def m (ρ : MState d) : Matrix d d ℂ := ρ.M.mat @[simp] -theorem mat_M : ρ.M.mat = ρ.m := rfl +theorem mat_M : ρ.M.mat = ρ.m := by + rfl theorem pos (ρ : MState d) : 0 < ρ.M := by apply ρ.nonneg.lt_of_ne' @@ -407,6 +408,7 @@ theorem pure_of_constant_spectrum (h : ∃ i, ρ.spectrum = ProbDistribution.con rw [if_neg hxnoti, Complex.ofReal_zero] ring simp_rw [←Finset.sum_subset (Finset.subset_univ {i}) hsum, Finset.sum_singleton, reduceIte, Complex.ofReal_one, mul_one] + rfl /-- A state ρ is pure iff its spectrum is (1,0,0,...) i.e. a constant distribution. -/ theorem pure_iff_constant_spectrum : (∃ ψ, ρ = pure ψ) ↔ @@ -475,6 +477,8 @@ theorem spectralDecomposition (ρ : MState d) : congr! simp only [Matrix.mul_diagonal, Matrix.IsHermitian.eigenvectorUnitary_apply, mul_comm, Matrix.star_apply, RCLike.star_def] + simp only [Function.comp_apply, mat_M, mat_apply, HermitianMat.smul_apply, Complex.real_smul] + rw [mul_assoc] rfl end pure @@ -548,7 +552,9 @@ instance instInhabited [Nonempty d] : Inhabited (MState d) where lemma default_eq [Nonempty d] : (default : MState d) = uniform := rfl @[simp] -theorem M_default [Unique d] : (default : MState d).M = 1 := rfl +theorem M_default [Unique d] : (default : MState d).M = 1 := by + simp [default_eq, uniform] + rfl section ptrace @@ -786,7 +792,8 @@ theorem pure_separable_imp_IsProd {d₁ d₂ : Type*} [Fintype d₁] [Fintype d · intro a exact MState.ext_iff.mpr a.symm · intro a - exact MState.ext_iff.mpr a + rw [← a] + rfl -- Since `pure ψ` is pure (`purity = 1`), by `MState.pure_iff_purity_one`, `ρL_k = pure ξ` and `ρR_k = pure φ` for some `ξ, φ`. obtain ⟨ξ, hξ⟩ : ∃ ξ : MState d₁, k.val.1 = ξ ∧ ξ.purity = 1 := by have h_purity : (pure ψ).purity = (k.val.1).purity * (k.val.2).purity := by @@ -1136,7 +1143,8 @@ def spectrum_SWAP (ρ : MState (d₁ × d₂)) : ∃ e, ρ.SWAP.spectrum.relabel (ρ.multiset_spectrum_relabel_eq (Equiv.prodComm _ _).symm ▸ rfl) use w ext x - exact h x + simp_rw [h] + rfl @[simp] theorem SWAP_SWAP (ρ : MState (d₁ × d₂)) : ρ.SWAP.SWAP = ρ := rfl diff --git a/QuantumInfo/States/Pure/Braket.lean b/QuantumInfo/States/Pure/Braket.lean index bd5724515..b74b0ff18 100644 --- a/QuantumInfo/States/Pure/Braket.lean +++ b/QuantumInfo/States/Pure/Braket.lean @@ -107,10 +107,14 @@ theorem Bra.ext {ξ ψ : Bra d} (h : ∀ x, ξ x = ψ x) : ξ = ψ := DFunLike.ext ξ ψ h theorem Ket.normalized (ψ : Ket d) : ∑ x, Complex.normSq (ψ x) = 1 := by - exact ψ.normalized' + convert ψ.normalized' + rw [Complex.normSq_eq_norm_sq] + rfl theorem Bra.normalized (ψ : Bra d) : ∑ x, Complex.normSq (ψ x) = 1 := by - exact ψ.normalized' + convert ψ.normalized' + rw [Complex.normSq_eq_norm_sq] + rfl /-- Any Bra can be turned into a Ket by conjugating the elements. -/ @[coe]