diff --git a/lean-toolchain b/lean-toolchain index f07ca867e..e7e4e1364 100644 --- a/lean-toolchain +++ b/lean-toolchain @@ -1 +1 @@ -leanprover/lean4:nightly-2026-09-06 +leanprover/lean4-pr-releases:pr-release-15066-2214407 diff --git a/mathlib4/Mathlib/Algebra/AddConstMap/Basic.lean b/mathlib4/Mathlib/Algebra/AddConstMap/Basic.lean index 4e52663a0..9350695e4 100644 --- a/mathlib4/Mathlib/Algebra/AddConstMap/Basic.lean +++ b/mathlib4/Mathlib/Algebra/AddConstMap/Basic.lean @@ -292,8 +292,9 @@ theorem monotone_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] theorem antitone_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G] [AddCommGroup H] [PartialOrder H] [IsOrderedAddMonoid H] [AddConstMapClass F G H a b] {f : F} (ha : 0 < a) (l : G) : - Antitone f ↔ AntitoneOn f (Icc l (l + a)) := - monotone_iff_Icc (H := Hᵒᵈ) ha l + Antitone f ↔ AntitoneOn f (Icc l (l + a)) := by + unsealing_newtype OrderDual => + exact monotone_iff_Icc (H := Hᵒᵈ) ha l theorem strictMono_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G] [AddCommGroup H] [PartialOrder H] [IsOrderedAddMonoid H] @@ -304,8 +305,9 @@ theorem strictMono_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid theorem strictAnti_iff_Icc [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] [Archimedean G] [AddCommGroup H] [PartialOrder H] [IsOrderedAddMonoid H] [AddConstMapClass F G H a b] {f : F} (ha : 0 < a) (l : G) : - StrictAnti f ↔ StrictAntiOn f (Icc l (l + a)) := - strictMono_iff_Icc (H := Hᵒᵈ) ha l + StrictAnti f ↔ StrictAntiOn f (Icc l (l + a)) := by + unsealing_newtype OrderDual => + exact strictMono_iff_Icc (H := Hᵒᵈ) ha l end AddConstMapClass diff --git a/mathlib4/Mathlib/Algebra/Field/Basic.lean b/mathlib4/Mathlib/Algebra/Field/Basic.lean index 8bbdcd156..6b4a55afe 100644 --- a/mathlib4/Mathlib/Algebra/Field/Basic.lean +++ b/mathlib4/Mathlib/Algebra/Field/Basic.lean @@ -297,12 +297,30 @@ end Function.Injective namespace OrderDual -instance [RatCast K] : RatCast Kᵒᵈ := inferInstanceAs <| RatCast K -instance [NNRatCast K] : NNRatCast Kᵒᵈ := inferInstanceAs <| NNRatCast K -instance [DivisionSemiring K] : DivisionSemiring Kᵒᵈ := inferInstanceAs <| DivisionSemiring K -instance [DivisionRing K] : DivisionRing Kᵒᵈ := inferInstanceAs <| DivisionRing K -instance [Semifield K] : Semifield Kᵒᵈ := inferInstanceAs <| Semifield K -instance [Field K] : Field Kᵒᵈ := inferInstanceAs <| Field K +instance [RatCast K] : RatCast Kᵒᵈ := ⟨fun q ↦ OrderDual.mk q⟩ +instance [NNRatCast K] : NNRatCast Kᵒᵈ := ⟨fun q ↦ OrderDual.mk q⟩ + +instance [DivisionSemiring K] : DivisionSemiring Kᵒᵈ := + ofDual.injective.divisionSemiring _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + fun _ ↦ rfl + +instance [DivisionRing K] : DivisionRing Kᵒᵈ := + ofDual.injective.divisionRing _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) + fun _ ↦ rfl + +instance [Semifield K] : Semifield Kᵒᵈ := + ofDual.injective.semifield _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + fun _ ↦ rfl + +instance [Field K] : Field Kᵒᵈ := + ofDual.injective.field _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) + fun _ ↦ rfl end OrderDual diff --git a/mathlib4/Mathlib/Algebra/Group/Finsupp.lean b/mathlib4/Mathlib/Algebra/Group/Finsupp.lean index c491e39a0..52f1e99b5 100644 --- a/mathlib4/Mathlib/Algebra/Group/Finsupp.lean +++ b/mathlib4/Mathlib/Algebra/Group/Finsupp.lean @@ -307,8 +307,9 @@ lemma induction_on_max (f : ι →₀ M) (zero : motive 0) The lemma `induction_on_min₂` swaps the argument order in the sum. -/ lemma induction_on_min (f : ι →₀ M) (zero : motive 0) (single_add : ∀ a b (f : ι →₀ M), (∀ c ∈ f.support, a < c) → b ≠ 0 → - motive f → motive (single a b + f)) : motive f := - induction_on_max (ι := ιᵒᵈ) f zero single_add + motive f → motive (single a b + f)) : motive f := by + unsealing_newtype OrderDual => + exact induction_on_max (ι := ιᵒᵈ) f zero single_add /-- A finitely supported function can be built by adding up `single a b` for increasing `a`. @@ -327,8 +328,9 @@ lemma induction_on_max₂ (f : ι →₀ M) (zero : motive 0) The lemma `induction_on_min` swaps the argument order in the sum. -/ lemma induction_on_min₂ (f : ι →₀ M) (zero : motive 0) (add_single : ∀ a b (f : ι →₀ M), (∀ c ∈ f.support, a < c) → b ≠ 0 → - motive f → motive (f + single a b)) : motive f := - induction_on_max₂ (ι := ιᵒᵈ) f zero add_single + motive f → motive (f + single a b)) : motive f := by + unsealing_newtype OrderDual => + exact induction_on_max₂ (ι := ιᵒᵈ) f zero add_single end LinearOrder diff --git a/mathlib4/Mathlib/Algebra/Lie/Nilpotent.lean b/mathlib4/Mathlib/Algebra/Lie/Nilpotent.lean index 66d37b001..b345cb5a6 100644 --- a/mathlib4/Mathlib/Algebra/Lie/Nilpotent.lean +++ b/mathlib4/Mathlib/Algebra/Lie/Nilpotent.lean @@ -181,14 +181,16 @@ theorem antitone_lowerCentralSeries : Antitone <| lowerCentralSeries R L M := by theorem eventually_iInf_lowerCentralSeries_eq [IsArtinian R M] : ∀ᶠ l in Filter.atTop, ⨅ k, lowerCentralSeries R L M k = lowerCentralSeries R L M l := by - have h_wf : WellFoundedGT (LieSubmodule R L M)ᵒᵈ := - LieSubmodule.wellFoundedLT_of_isArtinian R L M - obtain ⟨n, hn : ∀ m, n ≤ m → lowerCentralSeries R L M n = lowerCentralSeries R L M m⟩ := - h_wf.monotone_chain_condition ⟨_, antitone_lowerCentralSeries R L M⟩ - refine Filter.eventually_atTop.mpr ⟨n, fun l hl ↦ le_antisymm (iInf_le _ _) (le_iInf fun m ↦ ?_)⟩ - rcases le_or_gt l m with h | h - · rw [← hn _ hl, ← hn _ (hl.trans h)] - · exact antitone_lowerCentralSeries R L M (le_of_lt h) + unsealing_newtype OrderDual => + have h_wf : WellFoundedGT (LieSubmodule R L M)ᵒᵈ := + LieSubmodule.wellFoundedLT_of_isArtinian R L M + obtain ⟨n, hn : ∀ m, n ≤ m → lowerCentralSeries R L M n = lowerCentralSeries R L M m⟩ := + h_wf.monotone_chain_condition ⟨_, antitone_lowerCentralSeries R L M⟩ + refine Filter.eventually_atTop.mpr + ⟨n, fun l hl ↦ le_antisymm (iInf_le _ _) (le_iInf fun m ↦ ?_)⟩ + rcases le_or_gt l m with h | h + · rw [← hn _ hl, ← hn _ (hl.trans h)] + · exact antitone_lowerCentralSeries R L M (le_of_lt h) theorem trivial_iff_lower_central_eq_bot : IsTrivial L M ↔ lowerCentralSeries R L M 1 = ⊥ := by constructor <;> intro h diff --git a/mathlib4/Mathlib/Algebra/Lie/Submodule.lean b/mathlib4/Mathlib/Algebra/Lie/Submodule.lean index 4026532d8..b3dd20648 100644 --- a/mathlib4/Mathlib/Algebra/Lie/Submodule.lean +++ b/mathlib4/Mathlib/Algebra/Lie/Submodule.lean @@ -519,7 +519,8 @@ variable (R L M) map_rel_iff' := Iff.rfl } instance wellFoundedGT_of_noetherian [IsNoetherian R M] : WellFoundedGT (LieSubmodule R L M) := - RelHomClass.isWellFounded (toSubmodule_orderEmbedding R L M).dual.ltEmbedding + (wellFoundedLT_dual_iff _).1 <| + RelHomClass.isWellFounded (toSubmodule_orderEmbedding R L M).dual.ltEmbedding instance wellFoundedLT_of_isArtinian [IsArtinian R M] : WellFoundedLT (LieSubmodule R L M) := RelHomClass.isWellFounded (toSubmodule_orderEmbedding R L M).ltEmbedding diff --git a/mathlib4/Mathlib/Algebra/Module/Submodule/Range.lean b/mathlib4/Mathlib/Algebra/Module/Submodule/Range.lean index 80f52ef00..9b6821d08 100644 --- a/mathlib4/Mathlib/Algebra/Module/Submodule/Range.lean +++ b/mathlib4/Mathlib/Algebra/Module/Submodule/Range.lean @@ -141,13 +141,14 @@ end -/ @[simps] def iterateRange (f : M →ₗ[R] M) : ℕ →o (Submodule R M)ᵒᵈ where - toFun n := LinearMap.range (f ^ n) + toFun n := OrderDual.toDual (LinearMap.range (f ^ n)) monotone' := monotone_nat_of_le_succ fun | n, _, ⟨x, rfl⟩ => ⟨f x, rfl⟩ -set_option backward.isDefEq.respectTransparency false in lemma iterateRange_succ {f : M →ₗ[R] M} {n : ℕ} : - iterateRange f (n + 1) = (iterateRange f n).map f := by - simp only [iterateRange_coe, range_eq_map, ← map_comp, Module.End.iterate_succ'] + OrderDual.ofDual (iterateRange f (n + 1)) = + (OrderDual.ofDual (iterateRange f n)).map f := by + simp only [iterateRange_coe, OrderDual.ofDual_toDual, range_eq_map, ← map_comp, + Module.End.iterate_succ'] /-- Restrict the codomain of a linear map `f` to `f.range`. diff --git a/mathlib4/Mathlib/Algebra/Module/Torsion/Basic.lean b/mathlib4/Mathlib/Algebra/Module/Torsion/Basic.lean index dfa54a53e..b74d24577 100644 --- a/mathlib4/Mathlib/Algebra/Module/Torsion/Basic.lean +++ b/mathlib4/Mathlib/Algebra/Module/Torsion/Basic.lean @@ -405,7 +405,8 @@ theorem torsionBySet_torsionBySet_eq_top : torsionBySet R (torsionBySet R M s) s variable (R M) theorem torsion_gc : - @GaloisConnection (Submodule R M) (Ideal R)ᵒᵈ _ _ annihilator fun I => + @GaloisConnection (Submodule R M) (Ideal R)ᵒᵈ _ _ + (fun N => OrderDual.toDual (annihilator N)) fun I => torsionBySet R M ↑(OrderDual.ofDual I) := fun _ _ => ⟨fun h x hx => (mem_torsionBySet_iff _ _).mpr fun ⟨_, ha⟩ => mem_annihilator.mp (h ha) x hx, diff --git a/mathlib4/Mathlib/Algebra/MonoidAlgebra/Degree.lean b/mathlib4/Mathlib/Algebra/MonoidAlgebra/Degree.lean index ffc26b012..a123dadbb 100644 --- a/mathlib4/Mathlib/Algebra/MonoidAlgebra/Degree.lean +++ b/mathlib4/Mathlib/Algebra/MonoidAlgebra/Degree.lean @@ -71,6 +71,11 @@ section GeneralResultsAssumingSemilatticeSup variable [SemilatticeSup B] [OrderBot B] [SemilatticeInf T] [OrderTop T] +/-- Transport a finite infimum to the supremum in the order dual. -/ +private lemma toDual_support_inf (s : Finset A) (degt : A → T) : + OrderDual.toDual (s.inf degt) = s.sup fun a ↦ OrderDual.toDual (degt a) := + Finset.toDual_inf s degt + section Semiring variable [Semiring R] @@ -94,8 +99,9 @@ theorem sup_support_coeff_add_le : @[deprecated (since := "2026-06-18")] alias sup_support_add_le := sup_support_coeff_add_le theorem le_inf_support_coeff_add : - f.coeff.support.inf degt ⊓ g.coeff.support.inf degt ≤ (f + g).coeff.support.inf degt := - sup_support_coeff_add_le (fun a : A => OrderDual.toDual (degt a)) f g + f.coeff.support.inf degt ⊓ g.coeff.support.inf degt ≤ (f + g).coeff.support.inf degt := by + unsealing_newtype OrderDual => + exact sup_support_coeff_add_le (fun a : A => OrderDual.toDual (degt a)) f g @[deprecated (since := "2026-06-18")] alias le_inf_support_add := le_inf_support_coeff_add @@ -118,8 +124,10 @@ theorem sup_support_coeff_mul_le {degb : A → B} (degbm : ∀ a b, degb (a + b) theorem le_inf_support_coeff_mul {degt : A → T} (degtm : ∀ a b, degt a + degt b ≤ degt (a + b)) (f g : R[A]) : - f.coeff.support.inf degt + g.coeff.support.inf degt ≤ (f * g).coeff.support.inf degt := - sup_support_coeff_mul_le (B := Tᵒᵈ) degtm f g + f.coeff.support.inf degt + g.coeff.support.inf degt ≤ (f * g).coeff.support.inf degt := by + have h := sup_support_coeff_mul_le (B := Tᵒᵈ) + (degb := fun a ↦ OrderDual.toDual (degt a)) degtm f g + simpa only [← toDual_support_inf, ← toDual_add, OrderDual.toDual_le_toDual] using h @[deprecated (since := "2026-06-18")] alias le_inf_support_mul := le_inf_support_coeff_mul @@ -145,12 +153,13 @@ theorem sup_support_list_prod_le (degb0 : degb 0 ≤ 0) theorem le_inf_support_list_prod (degt0 : 0 ≤ degt 0) (degtm : ∀ a b, degt a + degt b ≤ degt (a + b)) (l : List R[A]) : (l.map fun f : R[A] => f.coeff.support.inf degt).sum ≤ l.prod.coeff.support.inf degt := by - refine OrderDual.ofDual_le_ofDual.mpr ?_ - refine sup_support_list_prod_le ?_ ?_ l - · refine (OrderDual.ofDual_le_ofDual.mp ?_) - exact degt0 - · refine (fun a b => OrderDual.ofDual_le_ofDual.mp ?_) - exact degtm a b + unsealing_newtype OrderDual => + refine OrderDual.ofDual_le_ofDual.mpr ?_ + refine sup_support_list_prod_le ?_ ?_ l + · refine (OrderDual.ofDual_le_ofDual.mp ?_) + exact degt0 + · refine (fun a b => OrderDual.ofDual_le_ofDual.mp ?_) + exact degtm a b theorem sup_support_pow_le (degb0 : degb 0 ≤ 0) (degbm : ∀ a b, degb (a + b) ≤ degb a + degb b) (n : ℕ) (f : R[A]) : (f ^ n).coeff.support.sup degb ≤ n • f.coeff.support.sup degb := by @@ -160,10 +169,12 @@ theorem sup_support_pow_le (degb0 : degb 0 ≤ 0) (degbm : ∀ a b, degb (a + b) theorem le_inf_support_pow (degt0 : 0 ≤ degt 0) (degtm : ∀ a b, degt a + degt b ≤ degt (a + b)) (n : ℕ) (f : R[A]) : n • f.coeff.support.inf degt ≤ (f ^ n).coeff.support.inf degt := by - refine OrderDual.ofDual_le_ofDual.mpr <| sup_support_pow_le (OrderDual.ofDual_le_ofDual.mp ?_) - (fun a b => OrderDual.ofDual_le_ofDual.mp ?_) n f - · exact degt0 - · exact degtm _ _ + unsealing_newtype OrderDual => + refine OrderDual.ofDual_le_ofDual.mpr <| + sup_support_pow_le (B := Tᵒᵈ) (degb := degt) (OrderDual.ofDual_le_ofDual.mp ?_) + (fun a b => OrderDual.ofDual_le_ofDual.mp ?_) n f + · exact degt0 + · exact degtm _ _ end AddMonoids @@ -188,11 +199,12 @@ alias sup_support_multiset_prod_le := sup_support_coeff_multisetProd_le theorem le_inf_support_coeff_multisetProd (degt0 : 0 ≤ degt 0) (degtm : ∀ a b, degt a + degt b ≤ degt (a + b)) (m : Multiset R[A]) : (m.map fun f : R[A] => f.coeff.support.inf degt).sum ≤ m.prod.coeff.support.inf degt := by - refine OrderDual.ofDual_le_ofDual.mpr <| - sup_support_coeff_multisetProd_le (OrderDual.ofDual_le_ofDual.mp ?_) - (fun a b => OrderDual.ofDual_le_ofDual.mp ?_) m - · exact degt0 - · exact degtm _ _ + unsealing_newtype OrderDual => + refine OrderDual.ofDual_le_ofDual.mpr <| + sup_support_coeff_multisetProd_le (B := Tᵒᵈ) (degb := degt) (OrderDual.ofDual_le_ofDual.mp ?_) + (fun a b => OrderDual.ofDual_le_ofDual.mp ?_) m + · exact degt0 + · exact degtm _ _ @[deprecated (since := "2026-06-18")] alias le_inf_support_multiset_prod := le_inf_support_coeff_multisetProd diff --git a/mathlib4/Mathlib/Algebra/Order/Archimedean/Class.lean b/mathlib4/Mathlib/Algebra/Order/Archimedean/Class.lean index 06fbc370b..3eceeeed9 100644 --- a/mathlib4/Mathlib/Algebra/Order/Archimedean/Class.lean +++ b/mathlib4/Mathlib/Algebra/Order/Archimedean/Class.lean @@ -595,12 +595,13 @@ def subsemigroup (s : UpperSet (MulArchimedeanClass M)) : Subsemigroup M where @[to_additive] theorem subsemigroup_strictAnti : StrictAnti (subsemigroup (M := M)) := by - intro s t hst - rw [← SetLike.coe_ssubset_coe] - refine Set.ssubset_iff_subset_ne.mpr ⟨fun _ h ↦ hst.le h, ?_⟩ - contrapose! hst with heq - apply le_of_eq - simpa [MulArchimedeanClass.mk_surjective, MulArchimedeanClass.subsemigroup] using heq + unsealing_newtype OrderDual => + intro s t hst + rw [← SetLike.coe_ssubset_coe] + refine Set.ssubset_iff_subset_ne.mpr ⟨fun _ h ↦ hst.le h, ?_⟩ + contrapose! hst with heq + apply le_of_eq + simpa [MulArchimedeanClass.mk_surjective, MulArchimedeanClass.subsemigroup] using heq /-- Make `MulArchimedeanClass.subsemigroup` a subgroup by assigning s = ⊤ with a junk value ⊥. -/ diff --git a/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/Finset.lean b/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/Finset.lean index e5d1dc73d..97bae16cf 100644 --- a/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/Finset.lean +++ b/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/Finset.lean @@ -179,8 +179,9 @@ alias prod_le_prod_of_subset_of_one_le' := prod_le_prod_of_subset_of_one_le @[to_additive] lemma prod_le_prod_of_subset_of_le_one [MulLeftMono N] (h : s ⊆ t) (hf : ∀ i ∈ t, i ∉ s → f i ≤ 1) : - ∏ i ∈ t, f i ≤ ∏ i ∈ s, f i := - prod_le_prod_of_subset_of_one_le (N := Nᵒᵈ) h hf + ∏ i ∈ t, f i ≤ ∏ i ∈ s, f i := by + unsealing_newtype OrderDual => + exact prod_le_prod_of_subset_of_one_le (N := Nᵒᵈ) h hf @[deprecated (since := "2026-09-01")] alias prod_le_prod_of_subset_of_le_one' := prod_le_prod_of_subset_of_le_one @@ -249,16 +250,18 @@ lemma one_lt_prod_iff_of_one_le {ι : Type u_1} {N : Type u_5} [CommMonoid N] [P @[to_additive] theorem prod_eq_one_iff_of_le_one {ι : Type u_1} {N : Type u_5} [CommMonoid N] [PartialOrder N] {f : ι → N} {s : Finset ι} [MulLeftMono N] : - (∀ i ∈ s, f i ≤ 1) → ((∏ i ∈ s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) := - prod_eq_one_iff_of_one_le (N := Nᵒᵈ) + (∀ i ∈ s, f i ≤ 1) → ((∏ i ∈ s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) := by + unsealing_newtype OrderDual => + exact prod_eq_one_iff_of_one_le (N := Nᵒᵈ) @[deprecated (since := "2026-09-01")] alias prod_eq_one_iff_of_le_one' := prod_eq_one_iff_of_le_one @[to_additive] lemma prod_lt_one_iff_of_le_one {ι : Type u_1} {N : Type u_5} [CommMonoid N] [PartialOrder N] {f : ι → N} {s : Finset ι} [MulLeftMono N] (hf : ∀ x ∈ s, f x ≤ 1) : - ∏ x ∈ s, f x < 1 ↔ ∃ x ∈ s, f x < 1 := - one_lt_prod_iff_of_one_le (N := Nᵒᵈ) hf + ∏ x ∈ s, f x < 1 ↔ ∃ x ∈ s, f x < 1 := by + unsealing_newtype OrderDual => + exact one_lt_prod_iff_of_one_le (N := Nᵒᵈ) hf @[to_additive] theorem single_le_prod [MulLeftMono N] (hf : ∀ i ∈ s, 1 ≤ f i) {a} (h : a ∈ s) : @@ -289,7 +292,9 @@ theorem prod_le_pow_card [MulLeftMono N] (s : Finset ι) (f : ι → N) (n : N) @[to_additive card_nsmul_le_sum] theorem pow_card_le_prod [MulLeftMono N] (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, n ≤ f x) : - n ^ #s ≤ s.prod f := Finset.prod_le_pow_card (N := Nᵒᵈ) _ _ _ h + n ^ #s ≤ s.prod f := by + unsealing_newtype OrderDual => + exact Finset.prod_le_pow_card (N := Nᵒᵈ) _ _ _ h theorem card_biUnion_le_card_mul [DecidableEq β] (s : Finset ι) (f : ι → Finset β) (n : ℕ) (h : ∀ a ∈ s, #(f a) ≤ n) : #(s.biUnion f) ≤ #s * n := @@ -314,8 +319,9 @@ alias prod_fiberwise_le_prod_of_one_le_prod_fiber' := prod_fiberwise_le_prod_of_ @[to_additive] theorem prod_le_prod_fiberwise_of_prod_fiber_le_one [MulLeftMono N] {t : Finset ι'} {g : ι → ι'} {f : ι → N} (h : ∀ y ∉ t, ∏ x ∈ s with g x = y, f x ≤ 1) : - ∏ x ∈ s, f x ≤ ∏ y ∈ t, ∏ x ∈ s with g x = y, f x := - prod_fiberwise_le_prod_of_one_le_prod_fiber (N := Nᵒᵈ) h + ∏ x ∈ s, f x ≤ ∏ y ∈ t, ∏ x ∈ s with g x = y, f x := by + unsealing_newtype OrderDual => + exact prod_fiberwise_le_prod_of_one_le_prod_fiber (N := Nᵒᵈ) h @[deprecated (since := "2026-09-01")] alias prod_le_prod_fiberwise_of_prod_fiber_le_one' := prod_le_prod_fiberwise_of_prod_fiber_le_one @@ -344,8 +350,9 @@ theorem apply_prod_le_sum_apply (h_one : g 1 ≤ 0) (h_mul : ∀ (a b : α), g ( rw [Multiset.map_map, Function.comp_def, Finset.sum_map_val] theorem sum_apply_le_apply_prod (h_one : 0 ≤ g 1) (h_mul : ∀ (a b : α), g a + g b ≤ g (a * b)) : - ∑ x ∈ s, g (f x) ≤ g (∏ x ∈ s, f x) := - s.apply_prod_le_sum_apply (β := βᵒᵈ) g h_one h_mul + ∑ x ∈ s, g (f x) ≤ g (∏ x ∈ s, f x) := by + unsealing_newtype OrderDual => + exact s.apply_prod_le_sum_apply (β := βᵒᵈ) g h_one h_mul end ProdSum @@ -684,8 +691,9 @@ theorem exists_one_lt_of_prod_one_of_exists_ne_one [MulLeftMono M] (f : ι → M @[to_additive exists_neg_of_sum_zero_of_exists_nonzero] theorem exists_lt_one_of_prod_one_of_exists_ne_one [MulLeftMono M] (f : ι → M) - (h₁ : ∏ i ∈ s, f i = 1) (h₂ : ∃ i ∈ s, f i ≠ 1) : ∃ i ∈ s, f i < 1 := - exists_one_lt_of_prod_one_of_exists_ne_one (M := Mᵒᵈ) f h₁ h₂ + (h₁ : ∏ i ∈ s, f i = 1) (h₂ : ∃ i ∈ s, f i ≠ 1) : ∃ i ∈ s, f i < 1 := by + unsealing_newtype OrderDual => + exact exists_one_lt_of_prod_one_of_exists_ne_one (M := Mᵒᵈ) f h₁ h₂ variable [IsOrderedCancelMonoid M] diff --git a/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/List.lean b/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/List.lean index 93e73ab31..17cf2dbba 100644 --- a/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/List.lean +++ b/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/List.lean @@ -110,8 +110,9 @@ alias prod_le_pow_card := prod_le_pow_length @[to_additive length_nsmul_le_sum] lemma pow_length_le_prod [Preorder M] [MulRightMono M] [MulLeftMono M] (l : List M) (n : M) (h : ∀ x ∈ l, n ≤ x) : - n ^ l.length ≤ l.prod := - @prod_le_pow_length Mᵒᵈ _ _ _ _ l n h + n ^ l.length ≤ l.prod := by + unsealing_newtype OrderDual => + exact @prod_le_pow_length Mᵒᵈ _ _ _ _ l n h @[to_additive (attr := deprecated (since := "2026-08-26")) card_nsmul_le_sum] alias pow_card_le_prod := pow_length_le_prod @@ -288,8 +289,9 @@ theorem apply_prod_le_sum_map (h_one : f 1 ≤ 0) (h_mul : ∀ (a b : α), f (a | cons hd tl IH => grw [prod_cons, h_mul, IH]; simp theorem sum_map_le_apply_prod (h_one : 0 ≤ f 1) (h_mul : ∀ (a b : α), f a + f b ≤ f (a * b)) : - (l.map f).sum ≤ f l.prod := - apply_prod_le_sum_map (β := βᵒᵈ) l f h_one h_mul + (l.map f).sum ≤ f l.prod := by + unsealing_newtype OrderDual => + exact apply_prod_le_sum_map (β := βᵒᵈ) l f h_one h_mul end ProdSum diff --git a/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/Multiset.lean b/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/Multiset.lean index c8c2b21f9..779c60639 100644 --- a/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/Multiset.lean +++ b/mathlib4/Mathlib/Algebra/Order/BigOperators/Group/Multiset.lean @@ -70,8 +70,9 @@ lemma prod_map_le_prod [MulLeftMono α] (f : α → α) (h : ∀ x, x ∈ s → @[to_additive] lemma prod_le_prod_map [MulLeftMono α] (f : α → α) (h : ∀ x, x ∈ s → x ≤ f x) : - s.prod ≤ (s.map f).prod := - prod_map_le_prod (α := αᵒᵈ) f h + s.prod ≤ (s.map f).prod := by + unsealing_newtype OrderDual => + exact prod_map_le_prod (α := αᵒᵈ) f h @[to_additive card_nsmul_le_sum] lemma pow_card_le_prod [MulLeftMono α] (h : ∀ x ∈ s, a ≤ x) : a ^ card s ≤ s.prod := by @@ -187,8 +188,9 @@ lemma apply_prod_le_sum_map (h_one : f 1 ≤ 0) (h_mul : ∀ (a b : α), f (a * | h l => simp [l.apply_prod_le_sum_map _ h_one h_mul] lemma sum_map_le_apply_prod (h_one : 0 ≤ f 1) (h_mul : ∀ (a b : α), f a + f b ≤ f (a * b)) : - (m.map f).sum ≤ f m.prod := - m.apply_prod_le_sum_map (β := βᵒᵈ) f h_one h_mul + (m.map f).sum ≤ f m.prod := by + unsealing_newtype OrderDual => + exact m.apply_prod_le_sum_map (β := βᵒᵈ) f h_one h_mul end ProdSum diff --git a/mathlib4/Mathlib/Algebra/Order/Chebyshev.lean b/mathlib4/Mathlib/Algebra/Order/Chebyshev.lean index 92c5c8662..eda12c45c 100644 --- a/mathlib4/Mathlib/Algebra/Order/Chebyshev.lean +++ b/mathlib4/Mathlib/Algebra/Order/Chebyshev.lean @@ -67,8 +67,9 @@ theorem MonovaryOn.sum_smul_sum_le_card_smul_sum (hfg : MonovaryOn f g s) : other is antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem AntivaryOn.card_smul_sum_le_sum_smul_sum (hfg : AntivaryOn f g s) : - #s • ∑ i ∈ s, f i • g i ≤ (∑ i ∈ s, f i) • ∑ i ∈ s, g i := - hfg.dual_right.sum_smul_sum_le_card_smul_sum + #s • ∑ i ∈ s, f i • g i ≤ (∑ i ∈ s, f i) • ∑ i ∈ s, g i := by + unsealing_newtype OrderDual => + exact hfg.dual_right.sum_smul_sum_le_card_smul_sum variable [Fintype ι] @@ -83,8 +84,9 @@ theorem Monovary.sum_smul_sum_le_card_smul_sum (hfg : Monovary f g) : other is antitone), the scalar product of their sum is less than the size of the set times their scalar product. -/ theorem Antivary.card_smul_sum_le_sum_smul_sum (hfg : Antivary f g) : - Fintype.card ι • ∑ i, f i • g i ≤ (∑ i, f i) • ∑ i, g i := - (hfg.dual_right.monovaryOn _).sum_smul_sum_le_card_smul_sum + Fintype.card ι • ∑ i, f i • g i ≤ (∑ i, f i) • ∑ i, g i := by + unsealing_newtype OrderDual => + exact (hfg.dual_right.monovaryOn _).sum_smul_sum_le_card_smul_sum end SMul diff --git a/mathlib4/Mathlib/Algebra/Order/Group/Action/Synonym.lean b/mathlib4/Mathlib/Algebra/Order/Group/Action/Synonym.lean index 038d275cc..4d98118e0 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/Action/Synonym.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/Action/Synonym.lean @@ -23,37 +23,43 @@ public section variable {M N α : Type*} +open OrderDual + namespace OrderDual @[to_additive] -instance [Monoid M] [MulAction M α] : MulAction Mᵒᵈ α := inferInstanceAs <| MulAction M α +instance [Monoid M] [MulAction M α] : MulAction Mᵒᵈ α where + one_smul := one_smul M + mul_smul x y b := mul_smul x.ofDual' y.ofDual' b @[to_additive] -instance [Monoid M] [MulAction M α] : MulAction M αᵒᵈ := inferInstanceAs <| MulAction M α +instance [Monoid M] [MulAction M α] : MulAction M αᵒᵈ where + one_smul a := congrArg OrderDual.mk (one_smul M a.ofDual') + mul_smul x y b := congrArg OrderDual.mk (mul_smul x y b.ofDual') @[to_additive] instance [SMul M α] [SMul N α] [SMulCommClass M N α] : SMulCommClass Mᵒᵈ N α := - ‹SMulCommClass M N α› + ⟨fun m n a ↦ smul_comm m.ofDual' n a⟩ @[to_additive] instance [SMul M α] [SMul N α] [SMulCommClass M N α] : SMulCommClass M Nᵒᵈ α := - ‹SMulCommClass M N α› + ⟨fun m n a ↦ smul_comm m n.ofDual' a⟩ @[to_additive] instance [SMul M α] [SMul N α] [SMulCommClass M N α] : SMulCommClass M N αᵒᵈ := - ‹SMulCommClass M N α› + ⟨fun m n a ↦ congrArg OrderDual.mk (smul_comm m n a.ofDual')⟩ @[to_additive] instance [SMul M N] [SMul M α] [SMul N α] [IsScalarTower M N α] : IsScalarTower Mᵒᵈ N α := - ‹IsScalarTower M N α› + ⟨fun x y z ↦ smul_assoc x.ofDual' y z⟩ @[to_additive] instance [SMul M N] [SMul M α] [SMul N α] [IsScalarTower M N α] : IsScalarTower M Nᵒᵈ α := - ‹IsScalarTower M N α› + ⟨fun x y z ↦ smul_assoc x y.ofDual' z⟩ @[to_additive] instance [SMul M N] [SMul M α] [SMul N α] [IsScalarTower M N α] : IsScalarTower M N αᵒᵈ := - ‹IsScalarTower M N α› + ⟨fun x y z ↦ congrArg OrderDual.mk (smul_assoc x y z.ofDual')⟩ end OrderDual diff --git a/mathlib4/Mathlib/Algebra/Order/Group/DenselyOrdered.lean b/mathlib4/Mathlib/Algebra/Order/Group/DenselyOrdered.lean index 2c2898b7c..b7c88dda6 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/DenselyOrdered.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/DenselyOrdered.lean @@ -27,8 +27,9 @@ variable [MulLeftMono α] variable [DenselyOrdered α] {a b : α} @[to_additive] -theorem le_of_forall_lt_one_mul_le (h : ∀ ε < 1, a * ε ≤ b) : a ≤ b := - le_of_forall_one_lt_le_mul (α := αᵒᵈ) h +theorem le_of_forall_lt_one_mul_le (h : ∀ ε < 1, a * ε ≤ b) : a ≤ b := by + unsealing_newtype OrderDual => + exact le_of_forall_one_lt_le_mul (α := αᵒᵈ) h @[to_additive] theorem le_of_forall_one_lt_div_le (h : ∀ ε : α, 1 < ε → a / ε ≤ b) : a ≤ b := @@ -36,8 +37,9 @@ theorem le_of_forall_one_lt_div_le (h : ∀ ε : α, 1 < ε → a / ε ≤ b) : simpa only [div_eq_mul_inv, inv_inv] using h ε⁻¹ (Left.one_lt_inv_iff.2 ε1) @[to_additive] -theorem le_iff_forall_lt_one_mul_le : a ≤ b ↔ ∀ ε < 1, a * ε ≤ b := - le_iff_forall_one_lt_le_mul (α := αᵒᵈ) +theorem le_iff_forall_lt_one_mul_le : a ≤ b ↔ ∀ ε < 1, a * ε ≤ b := by + unsealing_newtype OrderDual => + exact le_iff_forall_one_lt_le_mul (α := αᵒᵈ) end DenselyOrdered diff --git a/mathlib4/Mathlib/Algebra/Order/Group/Indicator.lean b/mathlib4/Mathlib/Algebra/Order/Group/Indicator.lean index b198788f9..fbca32d92 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/Indicator.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/Indicator.lean @@ -56,7 +56,9 @@ lemma mulSupport_iSup [ConditionallyCompleteLattice M] [Nonempty ι] (f : ι → @[to_additive] lemma mulSupport_iInf [ConditionallyCompleteLattice M] [Nonempty ι] (f : ι → α → M) : - mulSupport (fun x ↦ ⨅ i, f i x) ⊆ ⋃ i, mulSupport (f i) := mulSupport_iSup (M := Mᵒᵈ) f + mulSupport (fun x ↦ ⨅ i, f i x) ⊆ ⋃ i, mulSupport (f i) := by + unsealing_newtype OrderDual => + exact mulSupport_iSup (M := Mᵒᵈ) f end Function @@ -78,7 +80,9 @@ lemma mulIndicator_le' (hfg : ∀ a ∈ s, f a ≤ g a) (hg : ∀ a, a ∉ s → @[to_additive] lemma le_mulIndicator_apply (hfg : a ∈ s → y ≤ g a) (hf : a ∉ s → y ≤ 1) : - y ≤ mulIndicator s g a := mulIndicator_apply_le' (M := Mᵒᵈ) hfg hf + y ≤ mulIndicator s g a := by + unsealing_newtype OrderDual => + exact mulIndicator_apply_le' (M := Mᵒᵈ) hfg hf @[to_additive] lemma le_mulIndicator (hfg : ∀ a ∈ s, f a ≤ g a) (hf : ∀ a ∉ s, f a ≤ 1) : @@ -148,8 +152,9 @@ lemma indicator_le_indicator_nonneg (s : Set α) (f : α → M) : exacts [le_rfl, (not_le.1 ‹_›).le, ‹_›, le_rfl] lemma indicator_nonpos_le_indicator (s : Set α) (f : α → M) : - {a | f a ≤ 0}.indicator f ≤ s.indicator f := - indicator_le_indicator_nonneg (M := Mᵒᵈ) _ _ + {a | f a ≤ 0}.indicator f ≤ s.indicator f := by + unsealing_newtype OrderDual => + exact indicator_le_indicator_nonneg (M := Mᵒᵈ) _ _ end LinearOrder diff --git a/mathlib4/Mathlib/Algebra/Order/Group/Lattice.lean b/mathlib4/Mathlib/Algebra/Order/Group/Lattice.lean index 883e9109d..7abd96be3 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/Lattice.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/Lattice.lean @@ -78,15 +78,23 @@ lemma inf_div [MulRightMono α] (a b c : α) : section variable [MulLeftMono α] [MulRightMono α] -@[to_additive] lemma inv_sup (a b : α) : (a ⊔ b)⁻¹ = a⁻¹ ⊓ b⁻¹ := (OrderIso.inv α).map_sup _ _ +@[to_additive] lemma inv_sup (a b : α) : (a ⊔ b)⁻¹ = a⁻¹ ⊓ b⁻¹ := by + unsealing_newtype OrderDual => + exact (OrderIso.inv α).map_sup _ _ -@[to_additive] lemma inv_inf (a b : α) : (a ⊓ b)⁻¹ = a⁻¹ ⊔ b⁻¹ := (OrderIso.inv α).map_inf _ _ +@[to_additive] lemma inv_inf (a b : α) : (a ⊓ b)⁻¹ = a⁻¹ ⊔ b⁻¹ := by + unsealing_newtype OrderDual => + exact (OrderIso.inv α).map_inf _ _ @[to_additive] -lemma div_sup (a b c : α) : c / (a ⊔ b) = c / a ⊓ c / b := (OrderIso.divLeft c).map_sup _ _ +lemma div_sup (a b c : α) : c / (a ⊔ b) = c / a ⊓ c / b := by + unsealing_newtype OrderDual => + exact (OrderIso.divLeft c).map_sup _ _ @[to_additive] -lemma div_inf (a b c : α) : c / (a ⊓ b) = c / a ⊔ c / b := (OrderIso.divLeft c).map_inf _ _ +lemma div_inf (a b c : α) : c / (a ⊓ b) = c / a ⊔ c / b := by + unsealing_newtype OrderDual => + exact (OrderIso.divLeft c).map_inf _ _ -- In fact 0 ≤ n•a implies 0 ≤ a, see L. Fuchs, "Partially ordered algebraic systems" -- Chapter V, 1.E diff --git a/mathlib4/Mathlib/Algebra/Order/Group/MinMax.lean b/mathlib4/Mathlib/Algebra/Order/Group/MinMax.lean index ba69c4b95..794114885 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/MinMax.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/MinMax.lean @@ -46,14 +46,16 @@ section LinearOrderedCommGroup variable {α : Type*} [CommGroup α] [LinearOrder α] [IsOrderedMonoid α] @[to_additive min_neg_neg] -theorem min_inv_inv' (a b : α) : min a⁻¹ b⁻¹ = (max a b)⁻¹ := - Eq.symm <| (@Monotone.map_max α αᵒᵈ _ _ Inv.inv a b) fun _ _ => - inv_le_inv_iff.mpr +theorem min_inv_inv' (a b : α) : min a⁻¹ b⁻¹ = (max a b)⁻¹ := by + unsealing_newtype OrderDual => + exact Eq.symm <| (@Monotone.map_max α αᵒᵈ _ _ Inv.inv a b) fun _ _ => + inv_le_inv_iff.mpr @[to_additive max_neg_neg] -theorem max_inv_inv' (a b : α) : max a⁻¹ b⁻¹ = (min a b)⁻¹ := - Eq.symm <| (@Monotone.map_min α αᵒᵈ _ _ Inv.inv a b) fun _ _ => - inv_le_inv_iff.mpr +theorem max_inv_inv' (a b : α) : max a⁻¹ b⁻¹ = (min a b)⁻¹ := by + unsealing_newtype OrderDual => + exact Eq.symm <| (@Monotone.map_min α αᵒᵈ _ _ Inv.inv a b) fun _ _ => + inv_le_inv_iff.mpr @[to_additive min_sub_sub_right] theorem min_div_div_right' (a b c : α) : min (a / c) (b / c) = min a b / c := by diff --git a/mathlib4/Mathlib/Algebra/Order/Group/PiLex.lean b/mathlib4/Mathlib/Algebra/Order/Group/PiLex.lean index dc77c4a59..91759413b 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/PiLex.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/PiLex.lean @@ -34,3 +34,15 @@ instance isOrderedCancelMonoid [∀ i, CommMonoid (α i)] [∀ i, PartialOrder ( Or.inr ⟨i, fun j hj => (mul_left_cancel <| hi.1 j hj), lt_of_mul_lt_mul_left' hi.2⟩ end Pi.Lex + +namespace Pi.Colex +variable {ι : Type*} {α : ι → Type*} [LinearOrder ι] + +@[to_additive] +instance isOrderedCancelMonoid [∀ i, CommMonoid (α i)] [∀ i, PartialOrder (α i)] + [∀ i, IsOrderedCancelMonoid (α i)] : + IsOrderedCancelMonoid (Colex (∀ i, α i)) := by + unsealing_newtype OrderDual => + exact @Pi.Lex.isOrderedCancelMonoid ιᵒᵈ α _ ‹_› ‹_› ‹_› + +end Pi.Colex diff --git a/mathlib4/Mathlib/Algebra/Order/Group/Pointwise/Bounds.lean b/mathlib4/Mathlib/Algebra/Order/Group/Pointwise/Bounds.lean index a465892cb..698fb2daa 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/Pointwise/Bounds.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/Pointwise/Bounds.lean @@ -20,7 +20,7 @@ In this file we prove a few facts like “`-s` is bounded above iff `s` is bound public section -open Function Set +open Function OrderDual Set open scoped Pointwise variable {ι G M : Type*} @@ -39,11 +39,15 @@ lemma subset_upperBounds_mul (s t : Set M) : upperBounds s * upperBounds t ⊆ u @[to_additive] lemma mul_mem_lowerBounds_mul (ha : a ∈ lowerBounds s) (hb : b ∈ lowerBounds t) : - a * b ∈ lowerBounds (s * t) := mul_mem_upperBounds_mul (M := Mᵒᵈ) ha hb + a * b ∈ lowerBounds (s * t) := by + unsealing_newtype OrderDual => + exact mul_mem_upperBounds_mul (M := Mᵒᵈ) ha hb @[to_additive] -lemma subset_lowerBounds_mul (s t : Set M) : lowerBounds s * lowerBounds t ⊆ lowerBounds (s * t) := - subset_upperBounds_mul (M := Mᵒᵈ) _ _ +lemma subset_lowerBounds_mul (s t : Set M) : + lowerBounds s * lowerBounds t ⊆ lowerBounds (s * t) := by + unsealing_newtype OrderDual => + exact subset_upperBounds_mul (M := Mᵒᵈ) _ _ @[to_additive] lemma BddAbove.mul (hs : BddAbove s) (ht : BddAbove t) : BddAbove (s * t) := @@ -63,7 +67,9 @@ lemma BddAbove.range_mul (hf : BddAbove (range f)) (hg : BddAbove (range g)) : @[to_additive] lemma BddBelow.range_mul (hf : BddBelow (range f)) (hg : BddBelow (range g)) : - BddBelow (range fun i ↦ f i * g i) := BddAbove.range_mul (M := Mᵒᵈ) hf hg + BddBelow (range fun i ↦ f i * g i) := by + unsealing_newtype OrderDual => + exact BddAbove.range_mul (M := Mᵒᵈ) hf hg end Mul @@ -72,12 +78,14 @@ variable [Group G] [Preorder G] [MulLeftMono G] [MulRightMono G] {s t : Set G} {a b : G} @[to_additive (attr := simp)] -theorem bddAbove_inv : BddAbove s⁻¹ ↔ BddBelow s := - (OrderIso.inv G).bddAbove_preimage +theorem bddAbove_inv : BddAbove s⁻¹ ↔ BddBelow s := by + unsealing_newtype OrderDual => + exact ((OrderIso.inv G).bddAbove_preimage (s := ofDual ⁻¹' s)) @[to_additive (attr := simp)] -theorem bddBelow_inv : BddBelow s⁻¹ ↔ BddAbove s := - (OrderIso.inv G).bddBelow_preimage +theorem bddBelow_inv : BddBelow s⁻¹ ↔ BddAbove s := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).bddBelow_preimage @[to_additive] theorem BddAbove.inv (h : BddAbove s) : BddBelow s⁻¹ := @@ -88,24 +96,28 @@ theorem BddBelow.inv (h : BddBelow s) : BddAbove s⁻¹ := bddAbove_inv.2 h @[to_additive (attr := simp)] -theorem isLUB_inv : IsLUB s⁻¹ a ↔ IsGLB s a⁻¹ := - (OrderIso.inv G).isLUB_preimage +theorem isLUB_inv : IsLUB s⁻¹ a ↔ IsGLB s a⁻¹ := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).isLUB_preimage @[to_additive] -theorem isLUB_inv' : IsLUB s⁻¹ a⁻¹ ↔ IsGLB s a := - (OrderIso.inv G).isLUB_preimage' +theorem isLUB_inv' : IsLUB s⁻¹ a⁻¹ ↔ IsGLB s a := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).isLUB_preimage' @[to_additive] theorem IsGLB.inv (h : IsGLB s a) : IsLUB s⁻¹ a⁻¹ := isLUB_inv'.2 h @[to_additive (attr := simp)] -theorem isGLB_inv : IsGLB s⁻¹ a ↔ IsLUB s a⁻¹ := - (OrderIso.inv G).isGLB_preimage +theorem isGLB_inv : IsGLB s⁻¹ a ↔ IsLUB s a⁻¹ := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).isGLB_preimage @[to_additive] -theorem isGLB_inv' : IsGLB s⁻¹ a⁻¹ ↔ IsLUB s a := - (OrderIso.inv G).isGLB_preimage' +theorem isGLB_inv' : IsGLB s⁻¹ a⁻¹ ↔ IsLUB s a := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).isGLB_preimage' @[to_additive] theorem IsLUB.inv (h : IsLUB s a) : IsGLB s⁻¹ a⁻¹ := @@ -113,13 +125,15 @@ theorem IsLUB.inv (h : IsLUB s a) : IsGLB s⁻¹ a⁻¹ := @[to_additive] lemma BddBelow.range_inv {α : Type*} {f : α → G} (hf : BddBelow (range f)) : - BddAbove (range (fun x => (f x)⁻¹)) := - hf.range_comp_left (OrderIso.inv G).monotone + BddAbove (range (fun x => (f x)⁻¹)) := by + unsealing_newtype OrderDual => + exact hf.range_comp_left (OrderIso.inv G).monotone @[to_additive] lemma BddAbove.range_inv {α : Type*} {f : α → G} (hf : BddAbove (range f)) : - BddBelow (range (fun x => (f x)⁻¹)) := - BddBelow.range_inv (G := Gᵒᵈ) hf + BddBelow (range (fun x => (f x)⁻¹)) := by + unsealing_newtype OrderDual => + exact BddBelow.range_inv (G := Gᵒᵈ) hf @[to_additive] lemma IsLUB.mul (hs : IsLUB s a) (ht : IsLUB t b) : @@ -129,8 +143,9 @@ lemma IsLUB.mul (hs : IsLUB s a) (ht : IsLUB t b) : @[to_additive] lemma IsGLB.mul (hs : IsGLB s a) (ht : IsGLB t b) : - IsGLB (s * t) (a * b) := - IsLUB.mul (G := Gᵒᵈ) hs ht + IsGLB (s * t) (a * b) := by + unsealing_newtype OrderDual => + exact IsLUB.mul (G := Gᵒᵈ) hs ht @[to_additive] lemma IsLUB.div (hs : IsLUB s a) (ht : IsGLB t b) : @@ -140,7 +155,8 @@ lemma IsLUB.div (hs : IsLUB s a) (ht : IsGLB t b) : @[to_additive] lemma IsGLB.div (hs : IsGLB s a) (ht : IsLUB t b) : - IsGLB (s / t) (a / b) := - IsLUB.div (G := Gᵒᵈ) hs ht + IsGLB (s / t) (a / b) := by + unsealing_newtype OrderDual => + exact IsLUB.div (G := Gᵒᵈ) hs ht end Group diff --git a/mathlib4/Mathlib/Algebra/Order/Group/Pointwise/CompleteLattice.lean b/mathlib4/Mathlib/Algebra/Order/Group/Pointwise/CompleteLattice.lean index 358097b43..a56135777 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/Pointwise/CompleteLattice.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/Pointwise/CompleteLattice.lean @@ -42,14 +42,12 @@ variable [Group M] [MulLeftMono M] [MulRightMono M] {s t : Set M} @[to_additive] -lemma csSup_inv (hs₀ : s.Nonempty) (hs₁ : BddBelow s) : sSup s⁻¹ = (sInf s)⁻¹ := by - rw [← image_inv_eq_inv] - exact ((OrderIso.inv _).map_csInf' hs₀ hs₁).symm +lemma csSup_inv (hs₀ : s.Nonempty) (hs₁ : BddBelow s) : sSup s⁻¹ = (sInf s)⁻¹ := + (isLUB_inv'.2 (isGLB_csInf hs₀ hs₁)).csSup_eq hs₀.inv @[to_additive] -lemma csInf_inv (hs₀ : s.Nonempty) (hs₁ : BddAbove s) : sInf s⁻¹ = (sSup s)⁻¹ := by - rw [← image_inv_eq_inv] - exact ((OrderIso.inv _).map_csSup' hs₀ hs₁).symm +lemma csInf_inv (hs₀ : s.Nonempty) (hs₁ : BddAbove s) : sInf s⁻¹ = (sSup s)⁻¹ := + (isGLB_inv'.2 (isLUB_csSup hs₀ hs₁)).csInf_eq hs₀.inv @[to_additive] lemma csSup_mul (hs₀ : s.Nonempty) (hs₁ : BddAbove s) (ht₀ : t.Nonempty) (ht₁ : BddAbove t) : @@ -92,14 +90,12 @@ variable [Group M] [MulLeftMono M] [MulRightMono M] (s t : Set M) @[to_additive] -lemma sSup_inv (s : Set M) : sSup s⁻¹ = (sInf s)⁻¹ := by - rw [← image_inv_eq_inv, sSup_image] - exact ((OrderIso.inv M).map_sInf _).symm +lemma sSup_inv (s : Set M) : sSup s⁻¹ = (sInf s)⁻¹ := + (isLUB_inv'.2 (isGLB_sInf s)).sSup_eq @[to_additive] -lemma sInf_inv (s : Set M) : sInf s⁻¹ = (sSup s)⁻¹ := by - rw [← image_inv_eq_inv, sInf_image] - exact ((OrderIso.inv M).map_sSup _).symm +lemma sInf_inv (s : Set M) : sInf s⁻¹ = (sSup s)⁻¹ := + (isGLB_inv'.2 (isLUB_sSup s)).sInf_eq @[to_additive] lemma sSup_mul : sSup (s * t) = sSup s * sSup t := diff --git a/mathlib4/Mathlib/Algebra/Order/Group/Synonym.lean b/mathlib4/Mathlib/Algebra/Order/Group/Synonym.lean index f99283394..eade77d69 100644 --- a/mathlib4/Mathlib/Algebra/Order/Group/Synonym.lean +++ b/mathlib4/Mathlib/Algebra/Order/Group/Synonym.lean @@ -6,6 +6,7 @@ Authors: Yury Kudryashov, Yaël Dillies module public import Mathlib.Algebra.Group.Defs +public import Mathlib.Algebra.Group.InjSurj public import Mathlib.Algebra.Notation.Defs public import Mathlib.Order.Lex public import Mathlib.Order.OrderDual @@ -27,37 +28,33 @@ variable {α β : Type*} namespace OrderDual -set_option backward.inferInstanceAs.wrap.instances false in -@[to_additive] instance [One α] : One αᵒᵈ := inferInstanceAs <| One α +@[to_additive] instance [One α] : One αᵒᵈ := ⟨OrderDual.mk 1⟩ -set_option backward.inferInstanceAs.wrap.instances false in -@[to_additive] instance [Mul α] : Mul αᵒᵈ := inferInstanceAs <| Mul α +@[to_additive] instance [Mul α] : Mul αᵒᵈ := ⟨fun a b ↦ OrderDual.mk (a.ofDual' * b.ofDual')⟩ -set_option backward.inferInstanceAs.wrap.instances false in -@[to_additive] instance [Inv α] : Inv αᵒᵈ := inferInstanceAs <| Inv α +@[to_additive] instance [Inv α] : Inv αᵒᵈ := ⟨fun a ↦ OrderDual.mk a.ofDual'⁻¹⟩ -set_option backward.inferInstanceAs.wrap.instances false in -@[to_additive] instance [Div α] : Div αᵒᵈ := inferInstanceAs <| Div α +@[to_additive] instance [Div α] : Div αᵒᵈ := ⟨fun a b ↦ OrderDual.mk (a.ofDual' / b.ofDual')⟩ -set_option backward.inferInstanceAs.wrap.instances false in @[to_additive (attr := to_additive) (reorder := 1 2) OrderDual.instSMul] -instance [Pow α β] : Pow αᵒᵈ β := inferInstanceAs <| Pow α β +instance [Pow α β] : Pow αᵒᵈ β := ⟨fun a b ↦ OrderDual.mk (a.ofDual' ^ b)⟩ -set_option backward.inferInstanceAs.wrap.instances false in @[to_additive (attr := to_additive) (reorder := 1 2) OrderDual.instSMul'] -instance [Pow α β] : Pow α βᵒᵈ := inferInstanceAs <| Pow α β +instance [Pow α β] : Pow α βᵒᵈ := ⟨fun a b ↦ a ^ b.ofDual'⟩ -@[to_additive] instance [Semigroup α] : Semigroup αᵒᵈ := inferInstanceAs <| Semigroup α +@[to_additive] instance [Semigroup α] : Semigroup αᵒᵈ := + ofDual.injective.semigroup _ fun _ _ ↦ rfl -@[to_additive] instance [CommSemigroup α] : CommSemigroup αᵒᵈ := inferInstanceAs <| CommSemigroup α +@[to_additive] instance [CommSemigroup α] : CommSemigroup αᵒᵈ := + ofDual.injective.commSemigroup _ fun _ _ ↦ rfl @[to_additive] instance [Mul α] [IsLeftCancelMul α] : IsLeftCancelMul αᵒᵈ := - inferInstanceAs <| IsLeftCancelMul α + ofDual.injective.isLeftCancelMul _ fun _ _ ↦ rfl @[to_additive] instance [Mul α] [IsRightCancelMul α] : IsRightCancelMul αᵒᵈ := - inferInstanceAs <| IsRightCancelMul α + ofDual.injective.isRightCancelMul _ fun _ _ ↦ rfl @[to_additive] instance [Mul α] [IsCancelMul α] : IsCancelMul αᵒᵈ where @@ -69,44 +66,61 @@ instance [LeftCancelSemigroup α] : LeftCancelSemigroup αᵒᵈ where instance [RightCancelSemigroup α] : RightCancelSemigroup αᵒᵈ where @[to_additive] -instance [MulOneClass α] : MulOneClass αᵒᵈ := inferInstanceAs <| MulOneClass α +instance [MulOneClass α] : MulOneClass αᵒᵈ := + ofDual.injective.mulOneClass _ rfl fun _ _ ↦ rfl @[to_additive] -instance [Monoid α] : Monoid αᵒᵈ := inferInstanceAs <| Monoid α +instance [Monoid α] : Monoid αᵒᵈ := + ofDual.injective.monoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [CommMonoid α] : CommMonoid αᵒᵈ := inferInstanceAs <| CommMonoid α +instance [CommMonoid α] : CommMonoid αᵒᵈ := + ofDual.injective.commMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [LeftCancelMonoid α] : LeftCancelMonoid αᵒᵈ := inferInstanceAs <| LeftCancelMonoid α +instance [LeftCancelMonoid α] : LeftCancelMonoid αᵒᵈ := + ofDual.injective.leftCancelMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [RightCancelMonoid α] : RightCancelMonoid αᵒᵈ := inferInstanceAs <| RightCancelMonoid α +instance [RightCancelMonoid α] : RightCancelMonoid αᵒᵈ := + ofDual.injective.rightCancelMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [CancelMonoid α] : CancelMonoid αᵒᵈ := inferInstanceAs <| CancelMonoid α +instance [CancelMonoid α] : CancelMonoid αᵒᵈ := + ofDual.injective.cancelMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [CancelCommMonoid α] : CancelCommMonoid αᵒᵈ := inferInstanceAs <| CancelCommMonoid α +instance [CancelCommMonoid α] : CancelCommMonoid αᵒᵈ := + ofDual.injective.cancelCommMonoid _ rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [InvolutiveInv α] : InvolutiveInv αᵒᵈ := inferInstanceAs <| InvolutiveInv α +instance [InvolutiveInv α] : InvolutiveInv αᵒᵈ := + ofDual.injective.involutiveInv _ fun _ ↦ rfl @[to_additive] -instance [DivInvMonoid α] : DivInvMonoid αᵒᵈ := inferInstanceAs <| DivInvMonoid α +instance [DivInvMonoid α] : DivInvMonoid αᵒᵈ := + ofDual.injective.divInvMonoid _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [DivisionMonoid α] : DivisionMonoid αᵒᵈ := inferInstanceAs <| DivisionMonoid α +instance [DivisionMonoid α] : DivisionMonoid αᵒᵈ := + ofDual.injective.divisionMonoid _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] instance [DivisionCommMonoid α] : DivisionCommMonoid αᵒᵈ := - inferInstanceAs <| DivisionCommMonoid α + ofDual.injective.divisionCommMonoid _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [Group α] : Group αᵒᵈ := inferInstanceAs <| Group α +instance [Group α] : Group αᵒᵈ := + ofDual.injective.group _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ _ ↦ rfl @[to_additive] -instance [CommGroup α] : CommGroup αᵒᵈ := inferInstanceAs <| CommGroup α +instance [CommGroup α] : CommGroup αᵒᵈ := + ofDual.injective.commGroup _ rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ _ ↦ rfl end OrderDual @@ -116,8 +130,11 @@ theorem toDual_one [One α] : toDual (1 : α) = 1 := rfl @[to_additive (attr := simp)] theorem ofDual_one [One α] : (ofDual 1 : α) = 1 := rfl -@[to_additive (attr := simp)] lemma toDual_eq_one [One α] {a : α} : toDual a = 1 ↔ a = 1 := .rfl -@[to_additive (attr := simp)] lemma ofDual_eq_one [One α] {a : αᵒᵈ} : ofDual a = 1 ↔ a = 1 := .rfl +@[to_additive (attr := simp)] +lemma toDual_eq_one [One α] {a : α} : toDual a = 1 ↔ a = 1 := toDual_inj +@[to_additive (attr := simp)] +lemma ofDual_eq_one [One α] {a : αᵒᵈ} : ofDual a = 1 ↔ a = 1 := by + unsealing_newtype OrderDual => rfl @[to_additive (attr := simp)] theorem toDual_mul [Mul α] (a b : α) : toDual (a * b) = toDual a * toDual b := rfl @@ -153,22 +170,28 @@ section Monoid variable [Monoid α] @[to_additive (attr := simp)] -lemma isLeftRegular_toDual {a : α} : IsLeftRegular (toDual a) ↔ IsLeftRegular a := .rfl +lemma isLeftRegular_toDual {a : α} : IsLeftRegular (toDual a) ↔ IsLeftRegular a := by + unsealing_newtype OrderDual => rfl @[to_additive (attr := simp)] -lemma isLeftRegular_ofDual {a : αᵒᵈ} : IsLeftRegular (ofDual a) ↔ IsLeftRegular a := .rfl +lemma isLeftRegular_ofDual {a : αᵒᵈ} : IsLeftRegular (ofDual a) ↔ IsLeftRegular a := by + unsealing_newtype OrderDual => rfl @[to_additive (attr := simp)] -lemma isRightRegular_toDual {a : α} : IsRightRegular (toDual a) ↔ IsRightRegular a := .rfl +lemma isRightRegular_toDual {a : α} : IsRightRegular (toDual a) ↔ IsRightRegular a := by + unsealing_newtype OrderDual => rfl @[to_additive (attr := simp)] -lemma isRightRegular_ofDual {a : αᵒᵈ} : IsRightRegular (ofDual a) ↔ IsRightRegular a := .rfl +lemma isRightRegular_ofDual {a : αᵒᵈ} : IsRightRegular (ofDual a) ↔ IsRightRegular a := by + unsealing_newtype OrderDual => rfl @[to_additive (attr := simp)] -lemma isRegular_toDual {a : α} : IsRegular (toDual a) ↔ IsRegular a := .rfl +lemma isRegular_toDual {a : α} : IsRegular (toDual a) ↔ IsRegular a := by + unsealing_newtype OrderDual => rfl @[to_additive (attr := simp)] -lemma isRegular_ofDual {a : αᵒᵈ} : IsRegular (ofDual a) ↔ IsRegular a := .rfl +lemma isRegular_ofDual {a : αᵒᵈ} : IsRegular (ofDual a) ↔ IsRegular a := by + unsealing_newtype OrderDual => rfl end Monoid diff --git a/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Action/Synonym.lean b/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Action/Synonym.lean index 06f782bd9..c61cca1b5 100644 --- a/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Action/Synonym.lean +++ b/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Action/Synonym.lean @@ -28,35 +28,41 @@ variable {G₀ M₀ : Type*} namespace OrderDual -instance [Zero M₀] [SMulZeroClass G₀ M₀] : SMulZeroClass G₀ᵒᵈ M₀ := - inferInstanceAs <| SMulZeroClass G₀ M₀ +instance [Zero M₀] [SMulZeroClass G₀ M₀] : SMulZeroClass G₀ᵒᵈ M₀ where + smul_zero a := smul_zero a.ofDual' -instance [Zero M₀] [SMulZeroClass G₀ M₀] : SMulZeroClass G₀ M₀ᵒᵈ := - inferInstanceAs <| SMulZeroClass G₀ M₀ +instance [Zero M₀] [SMulZeroClass G₀ M₀] : SMulZeroClass G₀ M₀ᵒᵈ where + smul_zero a := congrArg OrderDual.mk (smul_zero a) -instance [Zero G₀] [Zero M₀] [SMulWithZero G₀ M₀] : SMulWithZero G₀ᵒᵈ M₀ := - inferInstanceAs <| SMulWithZero G₀ M₀ +instance [Zero G₀] [Zero M₀] [SMulWithZero G₀ M₀] : SMulWithZero G₀ᵒᵈ M₀ where + zero_smul m := zero_smul G₀ m -instance [Zero G₀] [Zero M₀] [SMulWithZero G₀ M₀] : SMulWithZero G₀ M₀ᵒᵈ := - inferInstanceAs <| SMulWithZero G₀ M₀ +instance [Zero G₀] [Zero M₀] [SMulWithZero G₀ M₀] : SMulWithZero G₀ M₀ᵒᵈ where + zero_smul m := congrArg OrderDual.mk (zero_smul G₀ m.ofDual') -instance [AddZeroClass M₀] [DistribSMul G₀ M₀] : DistribSMul G₀ᵒᵈ M₀ := - inferInstanceAs <| DistribSMul G₀ M₀ +instance [AddZeroClass M₀] [DistribSMul G₀ M₀] : DistribSMul G₀ᵒᵈ M₀ where + smul_add a := smul_add a.ofDual' -instance [AddZeroClass M₀] [DistribSMul G₀ M₀] : DistribSMul G₀ M₀ᵒᵈ := - inferInstanceAs <| DistribSMul G₀ M₀ +instance [AddZeroClass M₀] [DistribSMul G₀ M₀] : DistribSMul G₀ M₀ᵒᵈ where + smul_add a b c := congrArg OrderDual.mk (smul_add a b.ofDual' c.ofDual') -instance [Monoid G₀] [AddMonoid M₀] [DistribMulAction G₀ M₀] : DistribMulAction G₀ᵒᵈ M₀ := - inferInstanceAs <| DistribMulAction G₀ M₀ +instance [Monoid G₀] [AddMonoid M₀] [DistribMulAction G₀ M₀] : DistribMulAction G₀ᵒᵈ M₀ where + smul_zero a := smul_zero a.ofDual' + smul_add a := smul_add a.ofDual' -instance [Monoid G₀] [AddMonoid M₀] [DistribMulAction G₀ M₀] : DistribMulAction G₀ M₀ᵒᵈ := - inferInstanceAs <| DistribMulAction G₀ M₀ +instance [Monoid G₀] [AddMonoid M₀] [DistribMulAction G₀ M₀] : DistribMulAction G₀ M₀ᵒᵈ where + smul_zero a := congrArg OrderDual.mk (smul_zero a) + smul_add a b c := congrArg OrderDual.mk (smul_add a b.ofDual' c.ofDual') instance [MonoidWithZero G₀] [AddMonoid M₀] [MulActionWithZero G₀ M₀] : - MulActionWithZero G₀ᵒᵈ M₀ := inferInstanceAs <| MulActionWithZero G₀ M₀ + MulActionWithZero G₀ᵒᵈ M₀ where + smul_zero a := smul_zero a.ofDual' + zero_smul m := zero_smul G₀ m instance [MonoidWithZero G₀] [AddMonoid M₀] [MulActionWithZero G₀ M₀] : - MulActionWithZero G₀ M₀ᵒᵈ := inferInstanceAs <| MulActionWithZero G₀ M₀ + MulActionWithZero G₀ M₀ᵒᵈ where + smul_zero a := congrArg OrderDual.mk (smul_zero a) + zero_smul m := congrArg OrderDual.mk (zero_smul G₀ m.ofDual') end OrderDual diff --git a/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean b/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean index faa48da85..4f3acdbb0 100644 --- a/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean +++ b/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Canonical.lean @@ -184,12 +184,11 @@ instance instLinearOrderedCommMonoidWithZeroMultiplicativeOrderDual [LinearOrderedAddCommMonoidWithTop α] : LinearOrderedCommMonoidWithZero (Multiplicative αᵒᵈ) where zero := .ofAdd <| .toDual ⊤ - zero_mul := @top_add _ (_) - mul_zero := @add_top _ (_) + zero_mul a := congrArg OrderDual.mk (top_add (OrderDual.ofDual' a.toAdd)) + mul_zero a := congrArg OrderDual.mk (add_top (OrderDual.ofDual' a.toAdd)) isBot_zero _ := (le_top : _ ≤ ⊤) - mul_lt_mul_of_pos_left := by - simpa [← ofAdd_add, ← toDual_add] - using! fun a ha b c hbc ↦ add_right_strictMono_of_ne_top (by simpa using! ha.ne') hbc + mul_lt_mul_of_pos_left := @fun _ ha _ _ hbc ↦ + add_right_strictMono_of_ne_top (fun h ↦ ha.ne' (congrArg OrderDual.mk h)) hbc @[simp] theorem ofDual_toAdd_zero [LinearOrderedAddCommMonoidWithTop α] : @@ -197,8 +196,10 @@ theorem ofDual_toAdd_zero [LinearOrderedAddCommMonoidWithTop α] : instance [LinearOrderedAddCommGroupWithTop α] : LinearOrderedCommGroupWithZero (Multiplicative αᵒᵈ) where - inv_zero := LinearOrderedAddCommGroupWithTop.neg_top (α := α) - mul_inv_cancel := LinearOrderedAddCommGroupWithTop.add_neg_cancel_of_ne_top (α := α) + inv_zero := congrArg OrderDual.mk (LinearOrderedAddCommGroupWithTop.neg_top (α := α)) + mul_inv_cancel _ ha := congrArg OrderDual.mk + (LinearOrderedAddCommGroupWithTop.add_neg_cancel_of_ne_top + (fun h ↦ ha (congrArg OrderDual.mk h))) namespace WithZero diff --git a/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Synonym.lean b/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Synonym.lean index 6af1f0af6..02485db82 100644 --- a/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Synonym.lean +++ b/mathlib4/Mathlib/Algebra/Order/GroupWithZero/Synonym.lean @@ -6,6 +6,7 @@ Authors: Johan Commelin module public import Mathlib.Algebra.GroupWithZero.Defs +public import Mathlib.Algebra.GroupWithZero.InjSurj public import Mathlib.Algebra.Order.Group.Synonym /-! @@ -24,30 +25,39 @@ variable {α : Type*} namespace OrderDual -instance [MulZeroClass α] : MulZeroClass αᵒᵈ := inferInstanceAs <| MulZeroClass α +instance [MulZeroClass α] : MulZeroClass αᵒᵈ := + ofDual.injective.mulZeroClass _ rfl fun _ _ ↦ rfl -instance [MulZeroOneClass α] : MulZeroOneClass αᵒᵈ := inferInstanceAs <| MulZeroOneClass α +instance [MulZeroOneClass α] : MulZeroOneClass αᵒᵈ := + ofDual.injective.mulZeroOneClass _ rfl rfl fun _ _ ↦ rfl instance [Mul α] [Zero α] [NoZeroDivisors α] : NoZeroDivisors αᵒᵈ := - inferInstanceAs <| NoZeroDivisors α + ofDual.injective.noZeroDivisors _ rfl fun _ _ ↦ rfl -instance [SemigroupWithZero α] : SemigroupWithZero αᵒᵈ := inferInstanceAs <| SemigroupWithZero α +instance [SemigroupWithZero α] : SemigroupWithZero αᵒᵈ := + ofDual.injective.semigroupWithZero _ rfl fun _ _ ↦ rfl -instance [MonoidWithZero α] : MonoidWithZero αᵒᵈ := inferInstanceAs <| MonoidWithZero α +instance [MonoidWithZero α] : MonoidWithZero αᵒᵈ := + ofDual.injective.monoidWithZero _ rfl rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance [Mul α] [Zero α] [IsLeftCancelMulZero α] : IsLeftCancelMulZero αᵒᵈ := - inferInstanceAs <| IsLeftCancelMulZero α + ofDual.injective.isLeftCancelMulZero _ rfl fun _ _ ↦ rfl instance [Mul α] [Zero α] [IsRightCancelMulZero α] : IsRightCancelMulZero αᵒᵈ := - inferInstanceAs <| IsRightCancelMulZero α + ofDual.injective.isRightCancelMulZero _ rfl fun _ _ ↦ rfl instance [Mul α] [Zero α] [IsCancelMulZero α] : IsCancelMulZero αᵒᵈ where -instance [CommMonoidWithZero α] : CommMonoidWithZero αᵒᵈ := inferInstanceAs <| CommMonoidWithZero α +instance [CommMonoidWithZero α] : CommMonoidWithZero αᵒᵈ := + ofDual.injective.commMonoidWithZero _ rfl rfl (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [GroupWithZero α] : GroupWithZero αᵒᵈ := inferInstanceAs <| GroupWithZero α +instance [GroupWithZero α] : GroupWithZero αᵒᵈ := + ofDual.injective.groupWithZero _ rfl rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [CommGroupWithZero α] : CommGroupWithZero αᵒᵈ := inferInstanceAs <| CommGroupWithZero α +instance [CommGroupWithZero α] : CommGroupWithZero αᵒᵈ := + ofDual.injective.commGroupWithZero _ rfl rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ _ ↦ rfl end OrderDual diff --git a/mathlib4/Mathlib/Algebra/Order/Hom/Monoid.lean b/mathlib4/Mathlib/Algebra/Order/Hom/Monoid.lean index d0cb45efb..6fdb103ff 100644 --- a/mathlib4/Mathlib/Algebra/Order/Hom/Monoid.lean +++ b/mathlib4/Mathlib/Algebra/Order/Hom/Monoid.lean @@ -232,14 +232,32 @@ theorem monotone_iff_map_nonneg [iamhc : AddMonoidHomClass F α β] : variable [iamhc : AddMonoidHomClass F α β] -theorem antitone_iff_map_nonpos : Antitone (f : α → β) ↔ ∀ a, 0 ≤ a → f a ≤ 0 := - monotone_toDual_comp_iff.symm.trans <| monotone_iff_map_nonneg (β := βᵒᵈ) (iamhc := iamhc) _ - -theorem monotone_iff_map_nonpos : Monotone (f : α → β) ↔ ∀ a ≤ 0, f a ≤ 0 := - antitone_comp_ofDual_iff.symm.trans <| antitone_iff_map_nonpos (α := αᵒᵈ) (iamhc := iamhc) _ - -theorem antitone_iff_map_nonneg : Antitone (f : α → β) ↔ ∀ a ≤ 0, 0 ≤ f a := - monotone_comp_ofDual_iff.symm.trans <| monotone_iff_map_nonneg (α := αᵒᵈ) (iamhc := iamhc) _ +/-- `OrderDual.toDual` as an additive monoid hom. -/ +private def toDualAddHom {γ : Type*} [AddZeroClass γ] : γ →+ γᵒᵈ where + toFun := OrderDual.mk + map_zero' := rfl + map_add' _ _ := rfl + +/-- `OrderDual.ofDual` as an additive monoid hom. -/ +private def ofDualAddHom {γ : Type*} [AddZeroClass γ] : γᵒᵈ →+ γ where + toFun := OrderDual.ofDual' + map_zero' := rfl + map_add' _ _ := rfl + +theorem antitone_iff_map_nonpos : Antitone (f : α → β) ↔ ∀ a, 0 ≤ a → f a ≤ 0 := by + unsealing_newtype OrderDual => + exact monotone_toDual_comp_iff.symm.trans <| + monotone_iff_map_nonneg (β := βᵒᵈ) (iamhc := iamhc) _ + +theorem monotone_iff_map_nonpos : Monotone (f : α → β) ↔ ∀ a ≤ 0, f a ≤ 0 := by + unsealing_newtype OrderDual => + exact antitone_comp_ofDual_iff.symm.trans <| + antitone_iff_map_nonpos (α := αᵒᵈ) (iamhc := iamhc) _ + +theorem antitone_iff_map_nonneg : Antitone (f : α → β) ↔ ∀ a ≤ 0, 0 ≤ f a := by + unsealing_newtype OrderDual => + exact monotone_comp_ofDual_iff.symm.trans <| + monotone_iff_map_nonneg (α := αᵒᵈ) (iamhc := iamhc) _ theorem strictMono_iff_map_pos : StrictMono (f : α → β) ↔ ∀ a, 0 < a → 0 < f a := by @@ -249,14 +267,20 @@ theorem strictMono_iff_map_pos : · rw [← sub_add_cancel b a, map_add f] exact lt_add_of_pos_left _ (h _ <| sub_pos.2 hl) -theorem strictAnti_iff_map_neg : StrictAnti (f : α → β) ↔ ∀ a, 0 < a → f a < 0 := - strictMono_toDual_comp_iff.symm.trans <| strictMono_iff_map_pos (β := βᵒᵈ) (iamhc := iamhc) _ +theorem strictAnti_iff_map_neg : StrictAnti (f : α → β) ↔ ∀ a, 0 < a → f a < 0 := by + unsealing_newtype OrderDual => + exact strictMono_toDual_comp_iff.symm.trans <| + strictMono_iff_map_pos (β := βᵒᵈ) (iamhc := iamhc) _ -theorem strictMono_iff_map_neg : StrictMono (f : α → β) ↔ ∀ a < 0, f a < 0 := - strictAnti_comp_ofDual_iff.symm.trans <| strictAnti_iff_map_neg (α := αᵒᵈ) (iamhc := iamhc) _ +theorem strictMono_iff_map_neg : StrictMono (f : α → β) ↔ ∀ a < 0, f a < 0 := by + unsealing_newtype OrderDual => + exact strictAnti_comp_ofDual_iff.symm.trans <| + strictAnti_iff_map_neg (α := αᵒᵈ) (iamhc := iamhc) _ -theorem strictAnti_iff_map_pos : StrictAnti (f : α → β) ↔ ∀ a < 0, 0 < f a := - strictMono_comp_ofDual_iff.symm.trans <| strictMono_iff_map_pos (α := αᵒᵈ) (iamhc := iamhc) _ +theorem strictAnti_iff_map_pos : StrictAnti (f : α → β) ↔ ∀ a < 0, 0 < f a := by + unsealing_newtype OrderDual => + exact strictMono_comp_ofDual_iff.symm.trans <| + strictMono_iff_map_pos (α := αᵒᵈ) (iamhc := iamhc) _ end OrderedAddCommGroup diff --git a/mathlib4/Mathlib/Algebra/Order/Module/Pointwise.lean b/mathlib4/Mathlib/Algebra/Order/Module/Pointwise.lean index 4a3bc5d72..6a6d7dd2b 100644 --- a/mathlib4/Mathlib/Algebra/Order/Module/Pointwise.lean +++ b/mathlib4/Mathlib/Algebra/Order/Module/Pointwise.lean @@ -88,16 +88,31 @@ variable [Field α] [LinearOrder α] [IsStrictOrderedRing α] [Module α β] [PosSMulMono α β] {s : Set β} {a : α} -@[simp] lemma lowerBounds_smul_of_neg (ha : a < 0) : lowerBounds (a • s) = a • upperBounds s := - (OrderIso.smulRightDual β ha).upperBounds_image - -@[simp] lemma upperBounds_smul_of_neg (ha : a < 0) : upperBounds (a • s) = a • lowerBounds s := - (OrderIso.smulRightDual β ha).lowerBounds_image - -@[simp] lemma bddBelow_smul_iff_of_neg (ha : a < 0) : BddBelow (a • s) ↔ BddAbove s := - (OrderIso.smulRightDual β ha).bddAbove_image - -@[simp] lemma bddAbove_smul_iff_of_neg (ha : a < 0) : BddAbove (a • s) ↔ BddBelow s := - (OrderIso.smulRightDual β ha).bddBelow_image +/-- The image of `t` under `OrderIso.smulRightDual`, as a set of `βᵒᵈ`, is the dual copy of the +pointwise scalar multiple `a • t`. -/ +lemma image_smulRightDual (ha : a < 0) (t : Set β) : + OrderIso.smulRightDual β ha '' t = ⇑OrderDual.ofDual ⁻¹' (a • t) := by + ext x + constructor + · rintro ⟨y, hy, rfl⟩ + exact ⟨y, hy, rfl⟩ + · rintro ⟨y, hy, hxy⟩ + exact ⟨y, hy, congrArg OrderDual.toDual hxy⟩ + +@[simp] lemma lowerBounds_smul_of_neg (ha : a < 0) : lowerBounds (a • s) = a • upperBounds s := by + unsealing_newtype OrderDual => + exact (OrderIso.smulRightDual β ha).upperBounds_image + +@[simp] lemma upperBounds_smul_of_neg (ha : a < 0) : upperBounds (a • s) = a • lowerBounds s := by + unsealing_newtype OrderDual => + exact (OrderIso.smulRightDual β ha).lowerBounds_image + +@[simp] lemma bddBelow_smul_iff_of_neg (ha : a < 0) : BddBelow (a • s) ↔ BddAbove s := by + unsealing_newtype OrderDual => + exact (OrderIso.smulRightDual β ha).bddAbove_image + +@[simp] lemma bddAbove_smul_iff_of_neg (ha : a < 0) : BddAbove (a • s) ↔ BddBelow s := by + unsealing_newtype OrderDual => + exact (OrderIso.smulRightDual β ha).bddBelow_image end LinearOrderedField diff --git a/mathlib4/Mathlib/Algebra/Order/Module/Synonym.lean b/mathlib4/Mathlib/Algebra/Order/Module/Synonym.lean index cb86b6a1f..e2491f0c4 100644 --- a/mathlib4/Mathlib/Algebra/Order/Module/Synonym.lean +++ b/mathlib4/Mathlib/Algebra/Order/Module/Synonym.lean @@ -29,12 +29,12 @@ variable {α β : Type*} namespace OrderDual instance instModule [Semiring α] [AddCommMonoid β] [Module α β] : Module αᵒᵈ β where - add_smul := add_smul (R := α) - zero_smul := zero_smul _ + add_smul r s x := add_smul r.ofDual' s.ofDual' x + zero_smul x := zero_smul α x instance instModule' [Semiring α] [AddCommMonoid β] [Module α β] : Module α βᵒᵈ where - add_smul := add_smul (M := β) - zero_smul := zero_smul _ + add_smul r s x := congrArg OrderDual.mk (add_smul r s x.ofDual') + zero_smul x := congrArg OrderDual.mk (zero_smul α x.ofDual') end OrderDual diff --git a/mathlib4/Mathlib/Algebra/Order/Monoid/Unbundled/OrderDual.lean b/mathlib4/Mathlib/Algebra/Order/Monoid/Unbundled/OrderDual.lean index 34b2e2e2a..740208d5e 100644 --- a/mathlib4/Mathlib/Algebra/Order/Monoid/Unbundled/OrderDual.lean +++ b/mathlib4/Mathlib/Algebra/Order/Monoid/Unbundled/OrderDual.lean @@ -27,7 +27,7 @@ instance mulLeftReflectLE [LE α] [Mul α] [MulLeftReflectLE α] : MulLeftReflec @[to_additive] instance mulLeftMono [LE α] [Mul α] [c : MulLeftMono α] : MulLeftMono αᵒᵈ := - ⟨c.1.flip⟩ + ⟨fun a _ _ h ↦ c.elim a.ofDual' h⟩ @[to_additive] instance mulRightReflectLE [LE α] [Mul α] [MulRightReflectLE α] : MulRightReflectLE αᵒᵈ where @@ -36,22 +36,22 @@ instance mulRightReflectLE [LE α] [Mul α] [MulRightReflectLE α] : MulRightRef @[to_additive] instance mulRightMono [LE α] [Mul α] [c : MulRightMono α] : MulRightMono αᵒᵈ := - ⟨c.1.flip⟩ + ⟨fun a _ _ h ↦ c.elim a.ofDual' h⟩ @[to_additive] instance mulLeftReflectLT [LT α] [Mul α] [c : MulLeftReflectLT α] : MulLeftReflectLT αᵒᵈ := - ⟨c.1.flip⟩ + ⟨fun a _ _ h ↦ c.elim a.ofDual' h⟩ @[to_additive] instance mulLeftStrictMono [LT α] [Mul α] [c : MulLeftStrictMono α] : MulLeftStrictMono αᵒᵈ := - ⟨c.1.flip⟩ + ⟨fun a _ _ h ↦ c.elim a.ofDual' h⟩ @[to_additive] instance mulRightReflectLT [LT α] [Mul α] [c : MulRightReflectLT α] : MulRightReflectLT αᵒᵈ := - ⟨c.1.flip⟩ + ⟨fun a _ _ h ↦ c.elim a.ofDual' h⟩ @[to_additive] instance mulRightStrictMono [LT α] [Mul α] [c : MulRightStrictMono α] : MulRightStrictMono αᵒᵈ := - ⟨c.1.flip⟩ + ⟨fun a _ _ h ↦ c.elim a.ofDual' h⟩ end OrderDual diff --git a/mathlib4/Mathlib/Algebra/Order/Rearrangement.lean b/mathlib4/Mathlib/Algebra/Order/Rearrangement.lean index bde64c883..b9cbff7c2 100644 --- a/mathlib4/Mathlib/Algebra/Order/Rearrangement.lean +++ b/mathlib4/Mathlib/Algebra/Order/Rearrangement.lean @@ -114,8 +114,9 @@ theorem MonovaryOn.sum_smul_comp_perm_le_sum_smul (hfg : MonovaryOn f g s) /-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is minimized when `f` and `g` antivary together on `s`. Stated by permuting the entries of `g`. -/ theorem AntivaryOn.sum_smul_le_sum_smul_comp_perm (hfg : AntivaryOn f g s) - (hσ : {x | σ x ≠ x} ⊆ s) : ∑ i ∈ s, f i • g i ≤ ∑ i ∈ s, f i • g (σ i) := - hfg.dual_right.sum_smul_comp_perm_le_sum_smul hσ + (hσ : {x | σ x ≠ x} ⊆ s) : ∑ i ∈ s, f i • g i ≤ ∑ i ∈ s, f i • g (σ i) := by + unsealing_newtype OrderDual => + exact hfg.dual_right.sum_smul_comp_perm_le_sum_smul hσ /-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is maximized when `f` and `g` monovary together on `s`. Stated by permuting the entries of `f`. -/ @@ -129,8 +130,9 @@ theorem MonovaryOn.sum_comp_perm_smul_le_sum_smul (hfg : MonovaryOn f g s) /-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is minimized when `f` and `g` antivary together on `s`. Stated by permuting the entries of `f`. -/ theorem AntivaryOn.sum_smul_le_sum_comp_perm_smul (hfg : AntivaryOn f g s) - (hσ : {x | σ x ≠ x} ⊆ s) : ∑ i ∈ s, f i • g i ≤ ∑ i ∈ s, f (σ i) • g i := - hfg.dual_right.sum_comp_perm_smul_le_sum_smul hσ + (hσ : {x | σ x ≠ x} ⊆ s) : ∑ i ∈ s, f i • g i ≤ ∑ i ∈ s, f (σ i) • g i := by + unsealing_newtype OrderDual => + exact hfg.dual_right.sum_comp_perm_smul_le_sum_smul hσ variable [Fintype ι] @@ -197,8 +199,9 @@ theorem MonovaryOn.sum_smul_comp_perm_eq_sum_smul_iff (hfg : MonovaryOn f g s) antivary together on `s`. Stated by permuting the entries of `g`. -/ theorem AntivaryOn.sum_smul_comp_perm_eq_sum_smul_iff (hfg : AntivaryOn f g s) (hσ : {x | σ x ≠ x} ⊆ s) : - ∑ i ∈ s, f i • g (σ i) = ∑ i ∈ s, f i • g i ↔ AntivaryOn f (g ∘ σ) s := - (hfg.dual_right.sum_smul_comp_perm_eq_sum_smul_iff hσ).trans monovaryOn_toDual_right + ∑ i ∈ s, f i • g (σ i) = ∑ i ∈ s, f i • g i ↔ AntivaryOn f (g ∘ σ) s := by + unsealing_newtype OrderDual => + exact (hfg.dual_right.sum_smul_comp_perm_eq_sum_smul_iff hσ).trans monovaryOn_toDual_right /-- **Equality case of the Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g`, which monovary together on `s`, is unchanged by a permutation if and only if `f ∘ σ` and `g` @@ -225,8 +228,9 @@ theorem MonovaryOn.sum_comp_perm_smul_eq_sum_smul_iff (hfg : MonovaryOn f g s) antivary together on `s`. Stated by permuting the entries of `f`. -/ theorem AntivaryOn.sum_comp_perm_smul_eq_sum_smul_iff (hfg : AntivaryOn f g s) (hσ : {x | σ x ≠ x} ⊆ s) : - ∑ i ∈ s, f (σ i) • g i = ∑ i ∈ s, f i • g i ↔ AntivaryOn (f ∘ σ) g s := - (hfg.dual_right.sum_comp_perm_smul_eq_sum_smul_iff hσ).trans monovaryOn_toDual_right + ∑ i ∈ s, f (σ i) • g i = ∑ i ∈ s, f i • g i ↔ AntivaryOn (f ∘ σ) g s := by + unsealing_newtype OrderDual => + exact (hfg.dual_right.sum_comp_perm_smul_eq_sum_smul_iff hσ).trans monovaryOn_toDual_right variable [Fintype ι] diff --git a/mathlib4/Mathlib/Algebra/Order/Ring/Synonym.lean b/mathlib4/Mathlib/Algebra/Order/Ring/Synonym.lean index 7608b6530..da8724467 100644 --- a/mathlib4/Mathlib/Algebra/Order/Ring/Synonym.lean +++ b/mathlib4/Mathlib/Algebra/Order/Ring/Synonym.lean @@ -7,6 +7,7 @@ module public import Mathlib.Algebra.Order.Group.Synonym public import Mathlib.Algebra.Ring.Defs +public import Mathlib.Algebra.Ring.InjSurj /-! # Ring structure on the order type synonyms @@ -23,58 +24,83 @@ variable {R : Type*} namespace OrderDual -instance [Distrib R] : Distrib Rᵒᵈ := inferInstanceAs <| Distrib R +instance [Distrib R] : Distrib Rᵒᵈ := + ofDual.injective.distrib _ (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance [Mul R] [Add R] [LeftDistribClass R] : LeftDistribClass Rᵒᵈ := - inferInstanceAs <| LeftDistribClass R + ofDual.injective.leftDistribClass _ (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance [Mul R] [Add R] [RightDistribClass R] : RightDistribClass Rᵒᵈ := - inferInstanceAs <| RightDistribClass R + ofDual.injective.rightDistribClass _ (fun _ _ ↦ rfl) fun _ _ ↦ rfl instance [NonUnitalNonAssocSemiring R] : NonUnitalNonAssocSemiring Rᵒᵈ := - inferInstanceAs <| NonUnitalNonAssocSemiring R + ofDual.injective.nonUnitalNonAssocSemiring _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [NatCast R] : NatCast Rᵒᵈ := inferInstanceAs <| NatCast R +instance [NatCast R] : NatCast Rᵒᵈ := ⟨fun n ↦ OrderDual.mk n⟩ -instance [IntCast R] : IntCast Rᵒᵈ := inferInstanceAs <| IntCast R +instance [IntCast R] : IntCast Rᵒᵈ := ⟨fun n ↦ OrderDual.mk n⟩ -instance [AddMonoidWithOne R] : AddMonoidWithOne Rᵒᵈ := inferInstanceAs <| AddMonoidWithOne R +instance [AddMonoidWithOne R] : AddMonoidWithOne Rᵒᵈ := + ofDual.injective.addMonoidWithOne _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ ↦ rfl instance [AddCommMonoidWithOne R] : AddCommMonoidWithOne Rᵒᵈ := - inferInstanceAs <| AddCommMonoidWithOne R + ofDual.injective.addCommMonoidWithOne _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ ↦ rfl -instance [AddGroupWithOne R] : AddGroupWithOne Rᵒᵈ := inferInstanceAs <| AddGroupWithOne R +instance [AddGroupWithOne R] : AddGroupWithOne Rᵒᵈ := + ofDual.injective.addGroupWithOne _ rfl rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) fun _ ↦ rfl instance [AddCommGroupWithOne R] : AddCommGroupWithOne Rᵒᵈ := - inferInstanceAs <| AddCommGroupWithOne R + ofDual.injective.addCommGroupWithOne _ rfl rfl (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) fun _ ↦ rfl -instance [NonUnitalSemiring R] : NonUnitalSemiring Rᵒᵈ := inferInstanceAs <| NonUnitalSemiring R +instance [NonUnitalSemiring R] : NonUnitalSemiring Rᵒᵈ := + ofDual.injective.nonUnitalSemiring _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [NonAssocSemiring R] : NonAssocSemiring Rᵒᵈ := inferInstanceAs <| NonAssocSemiring R +instance [NonAssocSemiring R] : NonAssocSemiring Rᵒᵈ := + ofDual.injective.nonAssocSemiring _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + fun _ ↦ rfl -instance [Semiring R] : Semiring Rᵒᵈ := inferInstanceAs <| Semiring R +instance [Semiring R] : Semiring Rᵒᵈ := + ofDual.injective.semiring _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ ↦ rfl instance [NonUnitalCommSemiring R] : NonUnitalCommSemiring Rᵒᵈ := - inferInstanceAs <| NonUnitalCommSemiring R + ofDual.injective.nonUnitalCommSemiring _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [CommSemiring R] : CommSemiring Rᵒᵈ := inferInstanceAs <| CommSemiring R +instance [CommSemiring R] : CommSemiring Rᵒᵈ := + ofDual.injective.commSemiring _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) fun _ ↦ rfl -instance [Mul R] [HasDistribNeg R] : HasDistribNeg Rᵒᵈ := inferInstanceAs <| HasDistribNeg R +instance [Mul R] [HasDistribNeg R] : HasDistribNeg Rᵒᵈ := + ofDual.injective.hasDistribNeg _ (fun _ ↦ rfl) fun _ _ ↦ rfl instance [NonUnitalNonAssocRing R] : NonUnitalNonAssocRing Rᵒᵈ := - inferInstanceAs <| NonUnitalNonAssocRing R + ofDual.injective.nonUnitalNonAssocRing _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [NonUnitalRing R] : NonUnitalRing Rᵒᵈ := inferInstanceAs <| NonUnitalRing R +instance [NonUnitalRing R] : NonUnitalRing Rᵒᵈ := + ofDual.injective.nonUnitalRing _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [NonAssocRing R] : NonAssocRing Rᵒᵈ := inferInstanceAs <| NonAssocRing R +instance [NonAssocRing R] : NonAssocRing Rᵒᵈ := + ofDual.injective.nonAssocRing _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) fun _ ↦ rfl -instance [Ring R] : Ring Rᵒᵈ := inferInstanceAs <| Ring R +instance [Ring R] : Ring Rᵒᵈ := + ofDual.injective.ring _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) fun _ ↦ rfl -instance [NonUnitalCommRing R] : NonUnitalCommRing Rᵒᵈ := inferInstanceAs <| NonUnitalCommRing R +instance [NonUnitalCommRing R] : NonUnitalCommRing Rᵒᵈ := + ofDual.injective.nonUnitalCommRing _ rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [CommRing R] : CommRing Rᵒᵈ := inferInstanceAs <| CommRing R +instance [CommRing R] : CommRing Rᵒᵈ := + ofDual.injective.commRing _ rfl rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) fun _ ↦ rfl -instance [Ring R] [IsDomain R] : IsDomain Rᵒᵈ := inferInstanceAs <| IsDomain R +instance [Ring R] [IsDomain R] : IsDomain Rᵒᵈ where + __ := ofDual.injective.isCancelMulZero _ rfl fun _ _ ↦ rfl end OrderDual diff --git a/mathlib4/Mathlib/Algebra/Order/UpperLower.lean b/mathlib4/Mathlib/Algebra/Order/UpperLower.lean index 73864388c..51846e596 100644 --- a/mathlib4/Mathlib/Algebra/Order/UpperLower.lean +++ b/mathlib4/Mathlib/Algebra/Order/UpperLower.lean @@ -63,10 +63,14 @@ theorem IsUpperSet.mul_right (hs : IsUpperSet s) : IsUpperSet (s * t) := by exact hs.mul_left @[to_additive] -theorem IsLowerSet.mul_left (ht : IsLowerSet t) : IsLowerSet (s * t) := ht.toDual.mul_left +theorem IsLowerSet.mul_left (ht : IsLowerSet t) : IsLowerSet (s * t) := by + unsealing_newtype OrderDual => + exact ht.toDual.mul_left @[to_additive] -theorem IsLowerSet.mul_right (hs : IsLowerSet s) : IsLowerSet (s * t) := hs.toDual.mul_right +theorem IsLowerSet.mul_right (hs : IsLowerSet s) : IsLowerSet (s * t) := by + unsealing_newtype OrderDual => + exact hs.toDual.mul_right @[to_additive] theorem IsUpperSet.inv {α : Type*} [CommGroup α] [PartialOrder α] [IsOrderedMonoid α] @@ -89,10 +93,14 @@ theorem IsUpperSet.div_right (hs : IsUpperSet s) : IsUpperSet (s / t) := by @[to_additive] theorem IsLowerSet.div_left {α : Type*} [CommGroup α] [PartialOrder α] [IsOrderedMonoid α] - {s t : Set α} (ht : IsLowerSet t) : IsUpperSet (s / t) := ht.toDual.div_left + {s t : Set α} (ht : IsLowerSet t) : IsUpperSet (s / t) := by + unsealing_newtype OrderDual => + exact ht.toDual.div_left @[to_additive] -theorem IsLowerSet.div_right (hs : IsLowerSet s) : IsLowerSet (s / t) := hs.toDual.div_right +theorem IsLowerSet.div_right (hs : IsLowerSet s) : IsLowerSet (s / t) := by + unsealing_newtype OrderDual => + exact hs.toDual.div_right namespace UpperSet diff --git a/mathlib4/Mathlib/Algebra/Tropical/Basic.lean b/mathlib4/Mathlib/Algebra/Tropical/Basic.lean index 4f3e19c1d..8540055a0 100644 --- a/mathlib4/Mathlib/Algebra/Tropical/Basic.lean +++ b/mathlib4/Mathlib/Algebra/Tropical/Basic.lean @@ -403,6 +403,9 @@ theorem trop_mul_def [Add R] (x y : MinTropical R) : x * y = trop (untrop x + un def equivMaxTropical [LinearOrder R] [Add R] : MinTropical R ≃+* MaxTropical Rᵒᵈ where toFun a := .trop (OrderDual.toDual a.untrop) invFun a := .trop (OrderDual.ofDual a.untrop) + left_inv _ := rfl + right_inv a := by + simpa only [untrop_trop, OrderDual.toDual_ofDual] using MaxTropical.trop_untrop a map_add' a b := by simp map_mul' a b := by simp diff --git a/mathlib4/Mathlib/AlgebraicGeometry/AffineSpace.lean b/mathlib4/Mathlib/AlgebraicGeometry/AffineSpace.lean index 7a67d2476..19f28ada6 100644 --- a/mathlib4/Mathlib/AlgebraicGeometry/AffineSpace.lean +++ b/mathlib4/Mathlib/AlgebraicGeometry/AffineSpace.lean @@ -483,10 +483,14 @@ lemma spec_le_iff (R : CommRingCat) (p q : Spec R) : p ≤ q ↔ q.asIdeal ≤ p /-- One should bear this equality in mind when breaking the `Spec R/ PrimeSpectrum R` abstraction -boundary, since these instances are not definitionally equal. +boundary, since these instances are not definitionally equal. Note that `(PrimeSpectrum R)ᵒᵈ` is +a different type from `Spec R`, so the two preorders are compared by transporting the dual one +along `OrderDual.toDual`. -/ example (R : CommRingCat) : - inferInstance (α := Preorder (Spec R)) = inferInstance (α := Preorder (PrimeSpectrum R)ᵒᵈ) := by + inferInstance (α := Preorder (Spec R)) = + Preorder.lift fun p : Spec R ↦ OrderDual.toDual (show PrimeSpectrum R from p) := by + refine Preorder.ext fun p q ↦ ?_ aesop (add simp spec_le_iff) end instances diff --git a/mathlib4/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean b/mathlib4/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean index f8b70f468..0d721c11f 100644 --- a/mathlib4/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean +++ b/mathlib4/Mathlib/AlgebraicGeometry/IdealSheaf/Basic.lean @@ -623,11 +623,14 @@ lemma le_support_iff_le_vanishingIdeal {I : X.IdealSheafData} {Z : Closeds X} : /-- `support` and `vanishingIdeal` forms a Galois connection. This is the global version of `PrimeSpectrum.gc`. -/ -lemma gc : @GaloisConnection X.IdealSheafData (Closeds X)ᵒᵈ _ _ (support ·) (vanishingIdeal ·) := +lemma gc : @GaloisConnection X.IdealSheafData (Closeds X)ᵒᵈ _ _ + (fun I ↦ OrderDual.toDual I.support) (fun Z ↦ vanishingIdeal (OrderDual.ofDual Z)) := fun _ _ ↦ le_support_iff_le_vanishingIdeal -lemma vanishingIdeal_antimono {S T : Closeds X} (h : S ≤ T) : vanishingIdeal T ≤ vanishingIdeal S := - gc.monotone_u h +lemma vanishingIdeal_antimono {S T : Closeds X} (h : S ≤ T) : + vanishingIdeal T ≤ vanishingIdeal S := by + unsealing_newtype OrderDual => + exact gc.monotone_u h set_option backward.defeqAttrib.useBackward true in set_option backward.isDefEq.respectTransparency false in @@ -647,22 +650,32 @@ lemma vanishingIdeal_support {I : IdealSheafData X} : rw [← support_bot, vanishingIdeal_support, nilradical] @[simp] lemma vanishingIdeal_iSup {ι : Sort*} (Z : ι → Closeds X) : - vanishingIdeal (iSup Z) = ⨅ i, vanishingIdeal (Z i) := gc.u_iInf + vanishingIdeal (iSup Z) = ⨅ i, vanishingIdeal (Z i) := by + unsealing_newtype OrderDual => + exact gc.u_iInf @[simp] lemma vanishingIdeal_sSup (Z : Set (Closeds X)) : - vanishingIdeal (sSup Z) = ⨅ z ∈ Z, vanishingIdeal z := gc.u_sInf + vanishingIdeal (sSup Z) = ⨅ z ∈ Z, vanishingIdeal z := by + unsealing_newtype OrderDual => + exact gc.u_sInf @[simp] lemma vanishingIdeal_sup (Z Z' : TopologicalSpace.Closeds X) : vanishingIdeal (Z ⊔ Z') = vanishingIdeal Z ⊓ vanishingIdeal Z' := gc.u_inf @[simp] lemma support_sup (I J : X.IdealSheafData) : - (I ⊔ J).support = I.support ⊓ J.support := gc.l_sup + (I ⊔ J).support = I.support ⊓ J.support := by + unsealing_newtype OrderDual => + exact gc.l_sup @[simp] lemma support_iSup {ι : Sort*} (I : ι → X.IdealSheafData) : - (iSup I).support = ⨅ i, (I i).support := gc.l_iSup + (iSup I).support = ⨅ i, (I i).support := by + unsealing_newtype OrderDual => + exact gc.l_iSup @[simp] lemma support_sSup (I : Set X.IdealSheafData) : - (sSup I).support = ⨅ i ∈ I, i.support := gc.l_sSup + (sSup I).support = ⨅ i ∈ I, i.support := by + unsealing_newtype OrderDual => + exact gc.l_sSup end ofIsClosed diff --git a/mathlib4/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean b/mathlib4/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean index e34b25769..6ab1424e5 100644 --- a/mathlib4/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean +++ b/mathlib4/Mathlib/AlgebraicGeometry/ProjectiveSpectrum/Topology.lean @@ -123,27 +123,33 @@ variable (𝒜) /-- `zeroLocus` and `vanishingIdeal` form a Galois connection. -/ theorem gc_ideal : @GaloisConnection (Ideal A) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _ - (fun I => zeroLocus 𝒜 I) fun t => (vanishingIdeal t).toIdeal := - fun I t => subset_zeroLocus_iff_le_vanishingIdeal t I + (fun I => OrderDual.toDual (zeroLocus 𝒜 I)) fun t => + (vanishingIdeal (OrderDual.ofDual t)).toIdeal := by + unsealing_newtype OrderDual => + exact fun I t => subset_zeroLocus_iff_le_vanishingIdeal t I set_option backward.isDefEq.respectTransparency.types false in /-- `zeroLocus` and `vanishingIdeal` form a Galois connection. -/ theorem gc_set : @GaloisConnection (Set A) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _ - (fun s => zeroLocus 𝒜 s) fun t => vanishingIdeal t := by + (fun s => OrderDual.toDual (zeroLocus 𝒜 s)) fun t => + vanishingIdeal (OrderDual.ofDual t) := by have ideal_gc : GaloisConnection Ideal.span _ := (Submodule.gi A _).gc simpa [zeroLocus_span, Function.comp_def] using GaloisConnection.compose ideal_gc (gc_ideal 𝒜) theorem gc_homogeneousIdeal : @GaloisConnection (HomogeneousIdeal 𝒜) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _ - (fun I => zeroLocus 𝒜 I) fun t => vanishingIdeal t := - fun I t => by - simpa [show I.toIdeal ≤ (vanishingIdeal t).toIdeal ↔ I ≤ vanishingIdeal t from Iff.rfl] using! - subset_zeroLocus_iff_le_vanishingIdeal t I.toIdeal + (fun I => OrderDual.toDual (zeroLocus 𝒜 I)) fun t => + vanishingIdeal (OrderDual.ofDual t) := by + unsealing_newtype OrderDual => + exact fun I t => by + simpa [show I.toIdeal ≤ (vanishingIdeal t).toIdeal ↔ I ≤ vanishingIdeal t from Iff.rfl] using! + subset_zeroLocus_iff_le_vanishingIdeal t I.toIdeal theorem subset_zeroLocus_iff_subset_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) (s : Set A) : - t ⊆ zeroLocus 𝒜 s ↔ s ⊆ vanishingIdeal t := - (gc_set _) s t + t ⊆ zeroLocus 𝒜 s ↔ s ⊆ vanishingIdeal t := by + unsealing_newtype OrderDual => + exact (gc_set _) s t theorem subset_vanishingIdeal_zeroLocus (s : Set A) : s ⊆ vanishingIdeal (zeroLocus 𝒜 s) := (gc_set _).le_u_l s @@ -157,8 +163,9 @@ theorem homogeneousIdeal_le_vanishingIdeal_zeroLocus (I : HomogeneousIdeal 𝒜) (gc_homogeneousIdeal _).le_u_l I theorem subset_zeroLocus_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) : - t ⊆ zeroLocus 𝒜 (vanishingIdeal t) := - (gc_ideal _).l_u_le t + t ⊆ zeroLocus 𝒜 (vanishingIdeal t) := by + unsealing_newtype OrderDual => + exact (gc_ideal _).l_u_le t theorem zeroLocus_anti_mono {s t : Set A} (h : s ⊆ t) : zeroLocus 𝒜 t ⊆ zeroLocus 𝒜 s := (gc_set _).monotone_l h @@ -175,16 +182,18 @@ theorem vanishingIdeal_anti_mono {s t : Set (ProjectiveSpectrum 𝒜)} (h : s vanishingIdeal t ≤ vanishingIdeal s := (gc_ideal _).monotone_u h -theorem zeroLocus_bot : zeroLocus 𝒜 ((⊥ : Ideal A) : Set A) = Set.univ := - (gc_ideal 𝒜).l_bot +theorem zeroLocus_bot : zeroLocus 𝒜 ((⊥ : Ideal A) : Set A) = Set.univ := by + unsealing_newtype OrderDual => + exact (gc_ideal 𝒜).l_bot @[simp] theorem zeroLocus_singleton_zero : zeroLocus 𝒜 ({0} : Set A) = Set.univ := zeroLocus_bot _ @[simp] -theorem zeroLocus_empty : zeroLocus 𝒜 (∅ : Set A) = Set.univ := - (gc_set 𝒜).l_bot +theorem zeroLocus_empty : zeroLocus 𝒜 (∅ : Set A) = Set.univ := by + unsealing_newtype OrderDual => + exact (gc_set 𝒜).l_bot @[simp] theorem vanishingIdeal_univ : vanishingIdeal (∅ : Set (ProjectiveSpectrum 𝒜)) = ⊤ := by @@ -204,40 +213,48 @@ theorem zeroLocus_univ : zeroLocus 𝒜 (Set.univ : Set A) = ∅ := zeroLocus_empty_of_one_mem _ (Set.mem_univ 1) theorem zeroLocus_sup_ideal (I J : Ideal A) : - zeroLocus 𝒜 ((I ⊔ J : Ideal A) : Set A) = zeroLocus _ I ∩ zeroLocus _ J := - (gc_ideal 𝒜).l_sup + zeroLocus 𝒜 ((I ⊔ J : Ideal A) : Set A) = zeroLocus _ I ∩ zeroLocus _ J := by + unsealing_newtype OrderDual => + exact (gc_ideal 𝒜).l_sup theorem zeroLocus_sup_homogeneousIdeal (I J : HomogeneousIdeal 𝒜) : - zeroLocus 𝒜 ((I ⊔ J : HomogeneousIdeal 𝒜) : Set A) = zeroLocus _ I ∩ zeroLocus _ J := - (gc_homogeneousIdeal 𝒜).l_sup + zeroLocus 𝒜 ((I ⊔ J : HomogeneousIdeal 𝒜) : Set A) = zeroLocus _ I ∩ zeroLocus _ J := by + unsealing_newtype OrderDual => + exact (gc_homogeneousIdeal 𝒜).l_sup -theorem zeroLocus_union (s s' : Set A) : zeroLocus 𝒜 (s ∪ s') = zeroLocus _ s ∩ zeroLocus _ s' := - (gc_set 𝒜).l_sup +theorem zeroLocus_union (s s' : Set A) : zeroLocus 𝒜 (s ∪ s') = zeroLocus _ s ∩ zeroLocus _ s' := by + unsealing_newtype OrderDual => + exact (gc_set 𝒜).l_sup theorem vanishingIdeal_union (t t' : Set (ProjectiveSpectrum 𝒜)) : vanishingIdeal (t ∪ t') = vanishingIdeal t ⊓ vanishingIdeal t' := by - ext1; exact (gc_ideal 𝒜).u_inf + unsealing_newtype OrderDual => + ext1; exact (gc_ideal 𝒜).u_inf theorem zeroLocus_iSup_ideal {γ : Sort*} (I : γ → Ideal A) : - zeroLocus _ ((⨆ i, I i : Ideal A) : Set A) = ⋂ i, zeroLocus 𝒜 (I i) := - (gc_ideal 𝒜).l_iSup + zeroLocus _ ((⨆ i, I i : Ideal A) : Set A) = ⋂ i, zeroLocus 𝒜 (I i) := by + unsealing_newtype OrderDual => + exact (gc_ideal 𝒜).l_iSup theorem zeroLocus_iSup_homogeneousIdeal {γ : Sort*} (I : γ → HomogeneousIdeal 𝒜) : - zeroLocus _ ((⨆ i, I i : HomogeneousIdeal 𝒜) : Set A) = ⋂ i, zeroLocus 𝒜 (I i) := - (gc_homogeneousIdeal 𝒜).l_iSup + zeroLocus _ ((⨆ i, I i : HomogeneousIdeal 𝒜) : Set A) = ⋂ i, zeroLocus 𝒜 (I i) := by + unsealing_newtype OrderDual => + exact (gc_homogeneousIdeal 𝒜).l_iSup theorem zeroLocus_iUnion {γ : Sort*} (s : γ → Set A) : - zeroLocus 𝒜 (⋃ i, s i) = ⋂ i, zeroLocus 𝒜 (s i) := - (gc_set 𝒜).l_iSup + zeroLocus 𝒜 (⋃ i, s i) = ⋂ i, zeroLocus 𝒜 (s i) := by + unsealing_newtype OrderDual => + exact (gc_set 𝒜).l_iSup theorem zeroLocus_bUnion (s : Set (Set A)) : zeroLocus 𝒜 (⋃ s' ∈ s, s' : Set A) = ⋂ s' ∈ s, zeroLocus 𝒜 s' := by simp only [zeroLocus_iUnion] theorem vanishingIdeal_iUnion {γ : Sort*} (t : γ → Set (ProjectiveSpectrum 𝒜)) : - vanishingIdeal (⋃ i, t i) = ⨅ i, vanishingIdeal (t i) := - HomogeneousIdeal.toIdeal_injective <| by - convert! (gc_ideal 𝒜).u_iInf; exact HomogeneousIdeal.toIdeal_iInf _ + vanishingIdeal (⋃ i, t i) = ⨅ i, vanishingIdeal (t i) := by + unsealing_newtype OrderDual => + exact HomogeneousIdeal.toIdeal_injective <| by + convert! (gc_ideal 𝒜).u_iInf; exact HomogeneousIdeal.toIdeal_iInf _ theorem zeroLocus_inf (I J : Ideal A) : zeroLocus 𝒜 ((I ⊓ J : Ideal A) : Set A) = zeroLocus 𝒜 I ∪ zeroLocus 𝒜 J := @@ -321,10 +338,12 @@ theorem zeroLocus_vanishingIdeal_eq_closure (t : Set (ProjectiveSpectrum 𝒜)) theorem vanishingIdeal_closure (t : Set (ProjectiveSpectrum 𝒜)) : vanishingIdeal (closure t) = vanishingIdeal t := by - have : (vanishingIdeal (zeroLocus 𝒜 (vanishingIdeal t))).toIdeal = _ := (gc_ideal 𝒜).u_l_u_eq_u t - ext1 - rw [zeroLocus_vanishingIdeal_eq_closure 𝒜 t] at this - exact this + unsealing_newtype OrderDual => + have : (vanishingIdeal (zeroLocus 𝒜 (vanishingIdeal t))).toIdeal = _ := + (gc_ideal 𝒜).u_l_u_eq_u t + ext1 + rw [zeroLocus_vanishingIdeal_eq_closure 𝒜 t] at this + exact this section BasicOpen diff --git a/mathlib4/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Rank.lean b/mathlib4/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Rank.lean index 99440f0f9..29f10109d 100644 --- a/mathlib4/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Rank.lean +++ b/mathlib4/Mathlib/AlgebraicTopology/SimplicialSet/AnodyneExtensions/Rank.lean @@ -81,17 +81,18 @@ include f set_option backward.isDefEq.respectTransparency.types false in lemma wf_ancestralRel : WellFounded P.AncestralRel := by - rw [wellFounded_iff_isEmpty_descending_chain] - refine ⟨fun ⟨g, hg⟩ ↦ ?_⟩ - obtain ⟨n₀, hn₀⟩ := - (wellFoundedGT_iff_monotone_chain_condition (α := ℕᵒᵈ)).1 - inferInstance ⟨fun n ↦ (g n).1.dim, - monotone_nat_of_le_succ (fun n ↦ (hg n).dim_le)⟩ - dsimp at hn₀ - refine not_strictAnti_of_wellFoundedLT (fun n ↦ f.rank (g (n₀ + n))) - (strictAnti_nat_of_succ_lt (fun n ↦ ?_)) - rw [← add_assoc] - exact f.lt (hg _) (by rw [← hn₀ (n₀ + n + 1) (by lia), ← hn₀ (n₀ + n) (by lia)]) + unsealing_newtype OrderDual => + rw [wellFounded_iff_isEmpty_descending_chain] + refine ⟨fun ⟨g, hg⟩ ↦ ?_⟩ + obtain ⟨n₀, hn₀⟩ := + (wellFoundedGT_iff_monotone_chain_condition (α := ℕᵒᵈ)).1 + inferInstance ⟨fun n ↦ (g n).1.dim, + monotone_nat_of_le_succ (fun n ↦ (hg n).dim_le)⟩ + dsimp at hn₀ + refine not_strictAnti_of_wellFoundedLT (fun n ↦ f.rank (g (n₀ + n))) + (strictAnti_nat_of_succ_lt (fun n ↦ ?_)) + rw [← add_assoc] + exact f.lt (hg _) (by rw [← hn₀ (n₀ + n + 1) (by lia), ← hn₀ (n₀ + n) (by lia)]) lemma isRegular : P.IsRegular where wf := f.wf_ancestralRel diff --git a/mathlib4/Mathlib/Analysis/Convex/Basic.lean b/mathlib4/Mathlib/Analysis/Convex/Basic.lean index 74588106f..d9a04fd51 100644 --- a/mathlib4/Mathlib/Analysis/Convex/Basic.lean +++ b/mathlib4/Mathlib/Analysis/Convex/Basic.lean @@ -250,8 +250,9 @@ theorem convex_Iic (r : β) : Convex 𝕜 (Iic r) := fun x hx y hy a b ha hb hab add_le_add (smul_le_smul_of_nonneg_left hx ha) (smul_le_smul_of_nonneg_left hy hb) _ = r := Convex.combo_self hab _ -theorem convex_Ici (r : β) : Convex 𝕜 (Ici r) := - convex_Iic (β := βᵒᵈ) r +theorem convex_Ici (r : β) : Convex 𝕜 (Ici r) := by + unsealing_newtype OrderDual => + exact convex_Iic (β := βᵒᵈ) r theorem convex_Icc (r s : β) : Convex 𝕜 (Icc r s) := Ici_inter_Iic.subst ((convex_Ici r).inter <| convex_Iic s) @@ -282,8 +283,9 @@ theorem convex_Iio (r : β) : Convex 𝕜 (Iio r) := by (smul_lt_smul_of_pos_left hx ha') (smul_le_smul_of_nonneg_left hy.le hb) _ = r := Convex.combo_self hab _ -theorem convex_Ioi (r : β) : Convex 𝕜 (Ioi r) := - convex_Iio (β := βᵒᵈ) r +theorem convex_Ioi (r : β) : Convex 𝕜 (Ioi r) := by + unsealing_newtype OrderDual => + exact convex_Iio (β := βᵒᵈ) r theorem convex_Ioo (r s : β) : Convex 𝕜 (Ioo r s) := Ioi_inter_Iio.subst ((convex_Ioi r).inter <| convex_Iio s) @@ -349,28 +351,34 @@ theorem MonotoneOn.convex_lt (hf : MonotoneOn f s) (hs : Convex 𝕜 s) (r : β) (max_rec' (f · < r) hx.2 hy.2)⟩ theorem MonotoneOn.convex_ge (hf : MonotoneOn f s) (hs : Convex 𝕜 s) (r : β) : - Convex 𝕜 ({ x ∈ s | r ≤ f x }) := - MonotoneOn.convex_le (E := Eᵒᵈ) (β := βᵒᵈ) hf.dual (by exact hs) r + Convex 𝕜 ({ x ∈ s | r ≤ f x }) := by + unsealing_newtype OrderDual => + exact MonotoneOn.convex_le (E := Eᵒᵈ) (β := βᵒᵈ) hf.dual (by exact hs) r theorem MonotoneOn.convex_gt (hf : MonotoneOn f s) (hs : Convex 𝕜 s) (r : β) : - Convex 𝕜 ({ x ∈ s | r < f x }) := - MonotoneOn.convex_lt (E := Eᵒᵈ) (β := βᵒᵈ) hf.dual (by exact hs) r + Convex 𝕜 ({ x ∈ s | r < f x }) := by + unsealing_newtype OrderDual => + exact MonotoneOn.convex_lt (E := Eᵒᵈ) (β := βᵒᵈ) hf.dual (by exact hs) r theorem AntitoneOn.convex_le (hf : AntitoneOn f s) (hs : Convex 𝕜 s) (r : β) : - Convex 𝕜 ({ x ∈ s | f x ≤ r }) := - MonotoneOn.convex_ge (β := βᵒᵈ) hf hs r + Convex 𝕜 ({ x ∈ s | f x ≤ r }) := by + unsealing_newtype OrderDual => + exact MonotoneOn.convex_ge (β := βᵒᵈ) hf hs r theorem AntitoneOn.convex_lt (hf : AntitoneOn f s) (hs : Convex 𝕜 s) (r : β) : - Convex 𝕜 ({ x ∈ s | f x < r }) := - MonotoneOn.convex_gt (β := βᵒᵈ) hf hs r + Convex 𝕜 ({ x ∈ s | f x < r }) := by + unsealing_newtype OrderDual => + exact MonotoneOn.convex_gt (β := βᵒᵈ) hf hs r theorem AntitoneOn.convex_ge (hf : AntitoneOn f s) (hs : Convex 𝕜 s) (r : β) : - Convex 𝕜 ({ x ∈ s | r ≤ f x }) := - MonotoneOn.convex_le (β := βᵒᵈ) hf hs r + Convex 𝕜 ({ x ∈ s | r ≤ f x }) := by + unsealing_newtype OrderDual => + exact MonotoneOn.convex_le (β := βᵒᵈ) hf hs r theorem AntitoneOn.convex_gt (hf : AntitoneOn f s) (hs : Convex 𝕜 s) (r : β) : - Convex 𝕜 ({ x ∈ s | r < f x }) := - MonotoneOn.convex_lt (β := βᵒᵈ) hf hs r + Convex 𝕜 ({ x ∈ s | r < f x }) := by + unsealing_newtype OrderDual => + exact MonotoneOn.convex_lt (β := βᵒᵈ) hf hs r theorem Monotone.convex_le (hf : Monotone f) (r : β) : Convex 𝕜 { x | f x ≤ r } := Set.sep_univ.subst ((hf.monotoneOn univ).convex_le convex_univ r) diff --git a/mathlib4/Mathlib/Analysis/Convex/Combination.lean b/mathlib4/Mathlib/Analysis/Convex/Combination.lean index a7508e810..ef573ef1b 100644 --- a/mathlib4/Mathlib/Analysis/Convex/Combination.lean +++ b/mathlib4/Mathlib/Analysis/Convex/Combination.lean @@ -143,8 +143,9 @@ theorem centerMass_le_sup {s : Finset ι} {f : ι → α} {w : ι → R} (hw₀ theorem inf_le_centerMass {s : Finset ι} {f : ι → α} {w : ι → R} (hw₀ : ∀ i ∈ s, 0 ≤ w i) (hw₁ : 0 < ∑ i ∈ s, w i) : - s.inf' (nonempty_of_ne_empty <| by rintro rfl; simp at hw₁) f ≤ s.centerMass w f := - centerMass_le_sup (α := αᵒᵈ) hw₀ hw₁ + s.inf' (nonempty_of_ne_empty <| by rintro rfl; simp at hw₁) f ≤ s.centerMass w f := by + unsealing_newtype OrderDual => + exact centerMass_le_sup (α := αᵒᵈ) hw₀ hw₁ end Finset diff --git a/mathlib4/Mathlib/Analysis/Convex/Function.lean b/mathlib4/Mathlib/Analysis/Convex/Function.lean index 245e37c93..2b4f1c656 100644 --- a/mathlib4/Mathlib/Analysis/Convex/Function.lean +++ b/mathlib4/Mathlib/Analysis/Convex/Function.lean @@ -172,8 +172,9 @@ theorem StrictConcaveOn.comp_strictConvexOn (hg : StrictConcaveOn 𝕜 (f '' s) hg.dual.comp hf hg' hf' theorem StrictConcaveOn.comp (hg : StrictConcaveOn 𝕜 (f '' s) g) (hf : StrictConcaveOn 𝕜 s f) - (hg' : StrictMonoOn g (f '' s)) (hf' : s.InjOn f) : StrictConcaveOn 𝕜 s (g ∘ f) := - hg.comp_strictConvexOn (β := βᵒᵈ) hf hg'.dual hf' + (hg' : StrictMonoOn g (f '' s)) (hf' : s.InjOn f) : StrictConcaveOn 𝕜 s (g ∘ f) := by + unsealing_newtype OrderDual => + exact hg.comp_strictConvexOn (β := βᵒᵈ) hf hg'.dual hf' theorem StrictConvexOn.comp_strictConcaveOn (hg : StrictConvexOn 𝕜 (f '' s) g) (hf : StrictConcaveOn 𝕜 s f) (hg' : StrictAntiOn g (f '' s)) (hf' : s.InjOn f) : @@ -192,8 +193,9 @@ theorem ConcaveOn.comp_strictConvexOn (hg : ConcaveOn 𝕜 (f '' s) g) (hf : Str hg.dual.comp_strictConvexOn hf hg' theorem ConcaveOn.comp_strictConcaveOn (hg : ConcaveOn 𝕜 (f '' s) g) (hf : StrictConcaveOn 𝕜 s f) - (hg' : StrictMonoOn g (f '' s)) : StrictConcaveOn 𝕜 s (g ∘ f) := - hg.comp_strictConvexOn (β := βᵒᵈ) hf hg'.dual + (hg' : StrictMonoOn g (f '' s)) : StrictConcaveOn 𝕜 s (g ∘ f) := by + unsealing_newtype OrderDual => + exact hg.comp_strictConvexOn (β := βᵒᵈ) hf hg'.dual theorem ConvexOn.comp_strictConcaveOn (hg : ConvexOn 𝕜 (f '' s) g) (hf : StrictConcaveOn 𝕜 s f) (hg' : StrictAntiOn g (f '' s)) : StrictConvexOn 𝕜 s (g ∘ f) := @@ -212,8 +214,9 @@ theorem StrictConcaveOn.comp_convexOn (hg : StrictConcaveOn 𝕜 (f '' s) g) (hf hg.dual.comp_convexOn hf hg' hf' theorem StrictConvexOn.comp_concaveOn (hg : StrictConvexOn 𝕜 (f '' s) g) (hf : ConcaveOn 𝕜 s f) - (hg' : AntitoneOn g (f '' s)) (hf' : s.InjOn f) : StrictConvexOn 𝕜 s (g ∘ f) := - hg.comp_convexOn (β := βᵒᵈ) hf hg'.dual hf' + (hg' : AntitoneOn g (f '' s)) (hf' : s.InjOn f) : StrictConvexOn 𝕜 s (g ∘ f) := by + unsealing_newtype OrderDual => + exact hg.comp_convexOn (β := βᵒᵈ) hf hg'.dual hf' theorem StrictConcaveOn.comp_concaveOn (hg : StrictConcaveOn 𝕜 (f '' s) g) (hf : ConcaveOn 𝕜 s f) (hg' : MonotoneOn g (f '' s)) (hf' : s.InjOn f) : StrictConcaveOn 𝕜 s (g ∘ f) := @@ -262,8 +265,9 @@ theorem convexOn_of_convex_epigraph (h : Convex 𝕜 { p : E × β | p.1 ∈ s fun x hx y hy a b ha hb hab => (@h (x, f x) ⟨hx, le_rfl⟩ (y, f y) ⟨hy, le_rfl⟩ a b ha hb hab).2⟩ theorem concaveOn_of_convex_hypograph (h : Convex 𝕜 { p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1 }) : - ConcaveOn 𝕜 s f := - convexOn_of_convex_epigraph (β := βᵒᵈ) h + ConcaveOn 𝕜 s f := by + unsealing_newtype OrderDual => + exact convexOn_of_convex_epigraph (β := βᵒᵈ) h end Module @@ -283,8 +287,9 @@ theorem ConvexOn.convex_le (hf : ConvexOn 𝕜 s f) (r : β) : Convex 𝕜 ({ x _ = r := Convex.combo_self hab r ⟩ -theorem ConcaveOn.convex_ge (hf : ConcaveOn 𝕜 s f) (r : β) : Convex 𝕜 ({ x ∈ s | r ≤ f x }) := - hf.dual.convex_le r +theorem ConcaveOn.convex_ge (hf : ConcaveOn 𝕜 s f) (r : β) : Convex 𝕜 ({ x ∈ s | r ≤ f x }) := by + unsealing_newtype OrderDual => + exact hf.dual.convex_le r theorem ConvexOn.convex_epigraph (hf : ConvexOn 𝕜 s f) : Convex 𝕜 { p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2 } := by @@ -295,16 +300,18 @@ theorem ConvexOn.convex_epigraph (hf : ConvexOn 𝕜 s f) : _ ≤ a • r + b • t := by gcongr theorem ConcaveOn.convex_hypograph (hf : ConcaveOn 𝕜 s f) : - Convex 𝕜 { p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1 } := - hf.dual.convex_epigraph + Convex 𝕜 { p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1 } := by + unsealing_newtype OrderDual => + exact hf.dual.convex_epigraph theorem convexOn_iff_convex_epigraph : ConvexOn 𝕜 s f ↔ Convex 𝕜 { p : E × β | p.1 ∈ s ∧ f p.1 ≤ p.2 } := ⟨ConvexOn.convex_epigraph, convexOn_of_convex_epigraph⟩ theorem concaveOn_iff_convex_hypograph : - ConcaveOn 𝕜 s f ↔ Convex 𝕜 { p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1 } := - convexOn_iff_convex_epigraph (β := βᵒᵈ) + ConcaveOn 𝕜 s f ↔ Convex 𝕜 { p : E × β | p.1 ∈ s ∧ p.2 ≤ f p.1 } := by + unsealing_newtype OrderDual => + exact convexOn_iff_convex_epigraph (β := βᵒᵈ) end PosSMulMono @@ -419,8 +426,9 @@ theorem StrictConvexOn.convex_lt (hf : StrictConvexOn 𝕜 s f) (r : β) : ⟩ theorem StrictConcaveOn.convex_gt (hf : StrictConcaveOn 𝕜 s f) (r : β) : - Convex 𝕜 ({ x ∈ s | r < f x }) := - hf.dual.convex_lt r + Convex 𝕜 ({ x ∈ s | r < f x }) := by + unsealing_newtype OrderDual => + exact hf.dual.convex_lt r end PosSMulMono @@ -570,8 +578,9 @@ theorem ConvexOn.convex_lt (hf : ConvexOn 𝕜 s f) (r : β) : Convex 𝕜 ({ x (smul_le_smul_of_nonneg_left hy.2.le hb.le)) _ = r := Convex.combo_self hab _⟩ -theorem ConcaveOn.convex_gt (hf : ConcaveOn 𝕜 s f) (r : β) : Convex 𝕜 ({ x ∈ s | r < f x }) := - hf.dual.convex_lt r +theorem ConcaveOn.convex_gt (hf : ConcaveOn 𝕜 s f) (r : β) : Convex 𝕜 ({ x ∈ s | r < f x }) := by + unsealing_newtype OrderDual => + exact hf.dual.convex_lt r theorem ConvexOn.openSegment_subset_strict_epigraph (hf : ConvexOn 𝕜 s f) (p q : E × β) (hp : p.1 ∈ s ∧ f p.1 < p.2) (hq : q.1 ∈ s ∧ f q.1 ≤ q.2) : @@ -585,8 +594,9 @@ theorem ConvexOn.openSegment_subset_strict_epigraph (hf : ConvexOn 𝕜 s f) (p theorem ConcaveOn.openSegment_subset_strict_hypograph (hf : ConcaveOn 𝕜 s f) (p q : E × β) (hp : p.1 ∈ s ∧ p.2 < f p.1) (hq : q.1 ∈ s ∧ q.2 ≤ f q.1) : - openSegment 𝕜 p q ⊆ { p : E × β | p.1 ∈ s ∧ p.2 < f p.1 } := - hf.dual.openSegment_subset_strict_epigraph p q hp hq + openSegment 𝕜 p q ⊆ { p : E × β | p.1 ∈ s ∧ p.2 < f p.1 } := by + unsealing_newtype OrderDual => + exact hf.dual.openSegment_subset_strict_epigraph p q hp hq theorem ConvexOn.convex_strict_epigraph [ZeroLEOneClass 𝕜] (hf : ConvexOn 𝕜 s f) : Convex 𝕜 { p : E × β | p.1 ∈ s ∧ f p.1 < p.2 } := @@ -594,8 +604,9 @@ theorem ConvexOn.convex_strict_epigraph [ZeroLEOneClass 𝕜] (hf : ConvexOn hf.openSegment_subset_strict_epigraph p q hp ⟨hq.1, hq.2.le⟩ theorem ConcaveOn.convex_strict_hypograph [ZeroLEOneClass 𝕜] (hf : ConcaveOn 𝕜 s f) : - Convex 𝕜 { p : E × β | p.1 ∈ s ∧ p.2 < f p.1 } := - hf.dual.convex_strict_epigraph + Convex 𝕜 { p : E × β | p.1 ∈ s ∧ p.2 < f p.1 } := by + unsealing_newtype OrderDual => + exact hf.dual.convex_strict_epigraph end Module diff --git a/mathlib4/Mathlib/Analysis/Convex/FunctionTopology.lean b/mathlib4/Mathlib/Analysis/Convex/FunctionTopology.lean index 52d6e02cd..d1cb07440 100644 --- a/mathlib4/Mathlib/Analysis/Convex/FunctionTopology.lean +++ b/mathlib4/Mathlib/Analysis/Convex/FunctionTopology.lean @@ -41,10 +41,12 @@ public theorem isClosed_setOfPred_convexOn {s : Set α} : @[deprecated (since := "2026-07-09")] public alias isClosed_setOf_convexOn := isClosed_setOfPred_convexOn +set_option backward.isDefEq.respectTransparency false in /-- The set of concave functions on a set `s` is closed. -/ public theorem isClosed_setOfPred_concaveOn {s : Set α} : - IsClosed {f : α → β | ConcaveOn 𝕜 s f} := - isClosed_setOfPred_convexOn (α := α) (β := βᵒᵈ) + IsClosed {f : α → β | ConcaveOn 𝕜 s f} := by + unsealing_newtype OrderDual => + exact isClosed_setOfPred_convexOn (α := α) (β := βᵒᵈ) @[deprecated (since := "2026-07-09")] public alias isClosed_setOf_concaveOn := isClosed_setOfPred_concaveOn diff --git a/mathlib4/Mathlib/Analysis/Convex/Jensen.lean b/mathlib4/Mathlib/Analysis/Convex/Jensen.lean index 25776a442..9ef05658e 100644 --- a/mathlib4/Mathlib/Analysis/Convex/Jensen.lean +++ b/mathlib4/Mathlib/Analysis/Convex/Jensen.lean @@ -60,8 +60,9 @@ theorem ConvexOn.map_centerMass_le (hf : ConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, /-- Concave **Jensen's inequality**, `Finset.centerMass` version. -/ theorem ConcaveOn.le_map_centerMass (hf : ConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : 0 < ∑ i ∈ t, w i) (hmem : ∀ i ∈ t, p i ∈ s) : - t.centerMass w (f ∘ p) ≤ f (t.centerMass w p) := - ConvexOn.map_centerMass_le (β := βᵒᵈ) hf h₀ h₁ hmem + t.centerMass w (f ∘ p) ≤ f (t.centerMass w p) := by + unsealing_newtype OrderDual => + exact (hf.dual.map_centerMass_le h₀ h₁ hmem :) /-- Convex **Jensen's inequality**, `Finset.sum` version. -/ theorem ConvexOn.map_sum_le (hf : ConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : ∑ i ∈ t, w i = 1) @@ -72,8 +73,9 @@ theorem ConvexOn.map_sum_le (hf : ConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ /-- Concave **Jensen's inequality**, `Finset.sum` version. -/ theorem ConcaveOn.le_map_sum (hf : ConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : - (∑ i ∈ t, w i • f (p i)) ≤ f (∑ i ∈ t, w i • p i) := - ConvexOn.map_sum_le (β := βᵒᵈ) hf h₀ h₁ hmem + (∑ i ∈ t, w i • f (p i)) ≤ f (∑ i ∈ t, w i • p i) := by + unsealing_newtype OrderDual => + exact ConvexOn.map_sum_le (β := βᵒᵈ) hf h₀ h₁ hmem /-- Convex **Jensen's inequality** where an element plays a distinguished role. -/ lemma ConvexOn.map_add_sum_le (hf : ConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) @@ -89,8 +91,9 @@ lemma ConvexOn.map_add_sum_le (hf : ConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 /-- Concave **Jensen's inequality** where an element plays a distinguished role. -/ lemma ConcaveOn.map_add_sum_le (hf : ConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : v + ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) (hv : 0 ≤ v) (hq : q ∈ s) : - v • f q + ∑ i ∈ t, w i • f (p i) ≤ f (v • q + ∑ i ∈ t, w i • p i) := - hf.dual.map_add_sum_le h₀ h₁ hmem hv hq + v • f q + ∑ i ∈ t, w i • f (p i) ≤ f (v • q + ∑ i ∈ t, w i • p i) := by + unsealing_newtype OrderDual => + exact hf.dual.map_add_sum_le h₀ h₁ hmem hv hq /-! ### Strict Jensen inequality -/ @@ -146,7 +149,9 @@ points is non-constant, then Jensen's inequality is strict. See also `StrictConcaveOn.map_sum_eq_iff`. -/ lemma StrictConcaveOn.lt_map_sum (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) (hp : ∃ j ∈ t, ∃ k ∈ t, p j ≠ p k) : - ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) := hf.dual.map_sum_lt h₀ h₁ hmem hp + ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_lt h₀ h₁ hmem hp /-! ### Equality case of Jensen's inequality -/ @@ -171,8 +176,9 @@ See also `StrictConcaveOn.map_sum_eq_iff`. -/ lemma StrictConcaveOn.eq_of_map_sum_eq (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) (h_eq : f (∑ i ∈ t, w i • p i) ≤ ∑ i ∈ t, w i • f (p i)) : - ∀ ⦃j⦄, j ∈ t → ∀ ⦃k⦄, k ∈ t → p j = p k := - hf.dual.eq_of_le_map_sum h₀ h₁ hmem h_eq + ∀ ⦃j⦄, j ∈ t → ∀ ⦃k⦄, k ∈ t → p j = p k := by + unsealing_newtype OrderDual => + exact hf.dual.eq_of_le_map_sum h₀ h₁ hmem h_eq /-- A form of the **equality case of Jensen's equality** for the case of strict convex and positive weights. -/ @@ -189,8 +195,9 @@ theorem StrictConvexOn.map_sum_eq_iff_of_pos (hf : StrictConvexOn 𝕜 s f) (h weights. -/ theorem StrictConcaveOn.map_sum_eq_iff_of_pos (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : - f (∑ i ∈ t, w i • p i) = ∑ i ∈ t, w i • f (p i) ↔ ∀ ⦃j⦄, j ∈ t → ∀ ⦃k⦄, k ∈ t → p j = p k := - hf.dual.map_sum_eq_iff_of_pos h₀ h₁ hmem + f (∑ i ∈ t, w i • p i) = ∑ i ∈ t, w i • f (p i) ↔ ∀ ⦃j⦄, j ∈ t → ∀ ⦃k⦄, k ∈ t → p j = p k := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_eq_iff_of_pos h₀ h₁ hmem /-- A form of the **equality case of Jensen's equality** for the case of strict convex and non-negative weights. -/ @@ -210,8 +217,9 @@ non-negative weights. -/ theorem StrictConcaveOn.map_sum_eq_iff_of_nonneg (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : f (∑ i ∈ t, w i • p i) = ∑ i ∈ t, w i • f (p i) ↔ - ∀ ⦃j⦄, j ∈ t → w j ≠ 0 → ∀ ⦃k⦄, k ∈ t → w k ≠ 0 → p j = p k := - hf.dual.map_sum_eq_iff_of_nonneg h₀ h₁ hmem + ∀ ⦃j⦄, j ∈ t → w j ≠ 0 → ∀ ⦃k⦄, k ∈ t → w k ≠ 0 → p j = p k := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_eq_iff_of_nonneg h₀ h₁ hmem theorem StrictConvexOn.map_sum_lt_iff_of_pos (hf : StrictConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : @@ -222,8 +230,9 @@ theorem StrictConvexOn.map_sum_lt_iff_of_pos (hf : StrictConvexOn 𝕜 s f) (h theorem StrictConcaveOn.lt_map_sum_iff_of_pos (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : - ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) ↔ ∃ j ∈ t, ∃ k ∈ t, p j ≠ p k := - hf.dual.map_sum_lt_iff_of_pos h₀ h₁ hmem + ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) ↔ ∃ j ∈ t, ∃ k ∈ t, p j ≠ p k := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_lt_iff_of_pos h₀ h₁ hmem theorem StrictConvexOn.map_sum_lt_iff_of_nonneg (hf : StrictConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : @@ -234,8 +243,9 @@ theorem StrictConvexOn.map_sum_lt_iff_of_nonneg (hf : StrictConvexOn 𝕜 s f) ( theorem StrictConcaveOn.lt_map_sum_iff_of_nonneg (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) ↔ - ∃ j ∈ t, ∃ k ∈ t, w j ≠ 0 ∧ w k ≠ 0 ∧ p j ≠ p k := - hf.dual.map_sum_lt_iff_of_nonneg h₀ h₁ hmem + ∃ j ∈ t, ∃ k ∈ t, w j ≠ 0 ∧ w k ≠ 0 ∧ p j ≠ p k := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_lt_iff_of_nonneg h₀ h₁ hmem /-- Canonical form of the **equality case of Jensen's equality**. @@ -264,8 +274,9 @@ For a strictly concave function `f` and positive weights `w`, we have (and in fact all equal to their center of mass w.r.t. `w`). -/ lemma StrictConcaveOn.map_sum_eq_iff (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : - f (∑ i ∈ t, w i • p i) = ∑ i ∈ t, w i • f (p i) ↔ ∀ j ∈ t, p j = ∑ i ∈ t, w i • p i := - hf.dual.map_sum_eq_iff h₀ h₁ hmem + f (∑ i ∈ t, w i • p i) = ∑ i ∈ t, w i • f (p i) ↔ ∀ j ∈ t, p j = ∑ i ∈ t, w i • p i := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_eq_iff h₀ h₁ hmem /-- Canonical form of the **equality case of Jensen's equality**. @@ -292,7 +303,9 @@ weight are all equal (and in fact all equal to their center of mass w.r.t. `w`). lemma StrictConcaveOn.map_sum_eq_iff' (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : f (∑ i ∈ t, w i • p i) = ∑ i ∈ t, w i • f (p i) ↔ - ∀ j ∈ t, w j ≠ 0 → p j = ∑ i ∈ t, w i • p i := hf.dual.map_sum_eq_iff' h₀ h₁ hmem + ∀ j ∈ t, w j ≠ 0 → p j = ∑ i ∈ t, w i • p i := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_eq_iff' h₀ h₁ hmem /-- Canonical form of the **strict Jensen's inequality**. -/ theorem StrictConvexOn.map_sum_lt_iff_of_pos' (hf : StrictConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i) @@ -305,8 +318,9 @@ theorem StrictConvexOn.map_sum_lt_iff_of_pos' (hf : StrictConvexOn 𝕜 s f) (h /-- Canonical form of the **strict Jensen's inequality**. -/ theorem StrictConcaveOn.lt_map_sum_iff_of_pos' (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 < w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : - ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) ↔ ∃ j ∈ t, p j ≠ ∑ i ∈ t, w i • p i := - hf.dual.map_sum_lt_iff_of_pos' h₀ h₁ hmem + ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) ↔ ∃ j ∈ t, p j ≠ ∑ i ∈ t, w i • p i := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_lt_iff_of_pos' h₀ h₁ hmem /-- Canonical form of the **strict Jensen's inequality**. -/ theorem StrictConvexOn.map_sum_lt_iff_of_nonneg' (hf : StrictConvexOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) @@ -323,8 +337,10 @@ theorem StrictConvexOn.map_sum_lt_iff_of_nonneg' (hf : StrictConvexOn 𝕜 s f) /-- Canonical form of the **strict Jensen's inequality**. -/ theorem StrictConcaveOn.lt_map_sum_iff_of_nonneg' (hf : StrictConcaveOn 𝕜 s f) (h₀ : ∀ i ∈ t, 0 ≤ w i) (h₁ : ∑ i ∈ t, w i = 1) (hmem : ∀ i ∈ t, p i ∈ s) : - ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) ↔ ∃ j ∈ t, w j ≠ 0 ∧ p j ≠ ∑ i ∈ t, w i • p i := - hf.dual.map_sum_lt_iff_of_nonneg' h₀ h₁ hmem + ∑ i ∈ t, w i • f (p i) < f (∑ i ∈ t, w i • p i) ↔ + ∃ j ∈ t, w j ≠ 0 ∧ p j ≠ ∑ i ∈ t, w i • p i := by + unsealing_newtype OrderDual => + exact hf.dual.map_sum_lt_iff_of_nonneg' h₀ h₁ hmem end Jensen @@ -347,8 +363,9 @@ theorem ConvexOn.le_sup_of_mem_convexHull {t : Finset E} (hf : ConvexOn 𝕜 s f theorem ConvexOn.inf_le_of_mem_convexHull {t : Finset E} (hf : ConcaveOn 𝕜 s f) (hts : ↑t ⊆ s) (hx : x ∈ convexHull 𝕜 (t : Set E)) : - t.inf' (coe_nonempty.1 <| convexHull_nonempty_iff.1 ⟨x, hx⟩) f ≤ f x := - hf.dual.le_sup_of_mem_convexHull hts hx + t.inf' (coe_nonempty.1 <| convexHull_nonempty_iff.1 ⟨x, hx⟩) f ≤ f x := by + unsealing_newtype OrderDual => + exact hf.dual.le_sup_of_mem_convexHull hts hx /-- If a function `f` is convex on `s`, then the value it takes at some center of mass of points of `s` is less than the value it takes on one of those points. -/ @@ -419,6 +436,8 @@ lemma ConvexOn.bddAbove_convexHull {s t : Set E} (hst : s ⊆ t) (hf : ConvexOn exact hxy.trans <| hb <| mem_image_of_mem _ hy lemma ConcaveOn.bddBelow_convexHull {s t : Set E} (hst : s ⊆ t) (hf : ConcaveOn 𝕜 t f) : - BddBelow (f '' s) → BddBelow (f '' convexHull 𝕜 s) := hf.dual.bddAbove_convexHull hst + BddBelow (f '' s) → BddBelow (f '' convexHull 𝕜 s) := by + unsealing_newtype OrderDual => + exact hf.dual.bddAbove_convexHull hst end MaximumPrinciple diff --git a/mathlib4/Mathlib/Analysis/Convex/Quasiconvex.lean b/mathlib4/Mathlib/Analysis/Convex/Quasiconvex.lean index 0961faa73..f7085d53c 100644 --- a/mathlib4/Mathlib/Analysis/Convex/Quasiconvex.lean +++ b/mathlib4/Mathlib/Analysis/Convex/Quasiconvex.lean @@ -62,21 +62,23 @@ def QuasilinearOn : Prop := variable {𝕜 s f} -theorem QuasiconvexOn.dual : QuasiconvexOn 𝕜 s f → QuasiconcaveOn 𝕜 s (toDual ∘ f) := - id +theorem QuasiconvexOn.dual : QuasiconvexOn 𝕜 s f → QuasiconcaveOn 𝕜 s (toDual ∘ f) := by + unsealing_newtype OrderDual => + exact id -theorem QuasiconcaveOn.dual : QuasiconcaveOn 𝕜 s f → QuasiconvexOn 𝕜 s (toDual ∘ f) := - id +theorem QuasiconcaveOn.dual : QuasiconcaveOn 𝕜 s f → QuasiconvexOn 𝕜 s (toDual ∘ f) := by + unsealing_newtype OrderDual => + exact id -theorem QuasilinearOn.dual : QuasilinearOn 𝕜 s f → QuasilinearOn 𝕜 s (toDual ∘ f) := - And.symm +theorem QuasilinearOn.dual : QuasilinearOn 𝕜 s f → QuasilinearOn 𝕜 s (toDual ∘ f) := by + unsealing_newtype OrderDual => + exact And.symm theorem Convex.quasiconvexOn_of_convex_le (hs : Convex 𝕜 s) (h : ∀ r, Convex 𝕜 { x | f x ≤ r }) : QuasiconvexOn 𝕜 s f := fun r => hs.inter (h r) theorem Convex.quasiconcaveOn_of_convex_ge (hs : Convex 𝕜 s) (h : ∀ r, Convex 𝕜 { x | r ≤ f x }) : - QuasiconcaveOn 𝕜 s f := - Convex.quasiconvexOn_of_convex_le (β := βᵒᵈ) hs h + QuasiconcaveOn 𝕜 s f := fun r => hs.inter (h r) theorem QuasiconvexOn.convex [IsDirectedOrder β] (hf : QuasiconvexOn 𝕜 s f) : Convex 𝕜 s := fun x hx y hy _ _ ha hb hab => @@ -107,16 +109,19 @@ theorem QuasiconvexOn.monotone_comp exact ⟨hf.1, le_trans (hg hf.2) hy.2⟩ theorem QuasiconvexOn.antitone_comp (hg : Antitone g) (hf : QuasiconvexOn 𝕜 s f) : - QuasiconcaveOn 𝕜 s (g ∘ f) := - hf.monotone_comp (γ := γᵒᵈ) hg + QuasiconcaveOn 𝕜 s (g ∘ f) := by + unsealing_newtype OrderDual => + exact QuasiconvexOn.monotone_comp (γ := γᵒᵈ) (f := f) (g := g) hg hf theorem QuasiconcaveOn.monotone_comp (hg : Monotone g) (hf : QuasiconcaveOn 𝕜 s f) : - QuasiconcaveOn 𝕜 s (g ∘ f) := - QuasiconvexOn.monotone_comp hg.dual hf + QuasiconcaveOn 𝕜 s (g ∘ f) := by + unsealing_newtype OrderDual => + exact QuasiconvexOn.monotone_comp hg.dual hf theorem QuasiconcaveOn.antitone_comp (hg : Antitone g) (hf : QuasiconcaveOn 𝕜 s f) : - QuasiconvexOn 𝕜 s (g ∘ f) := - QuasiconvexOn.monotone_comp (β := βᵒᵈ) hg.dual hf + QuasiconvexOn 𝕜 s (g ∘ f) := by + unsealing_newtype OrderDual => + exact QuasiconvexOn.monotone_comp (β := βᵒᵈ) hg.dual hf theorem QuasilinearOn.monotone_comp (hg : Monotone g) (hf : QuasilinearOn 𝕜 s f) : QuasilinearOn 𝕜 s (g ∘ f) := @@ -170,8 +175,9 @@ theorem QuasiconcaveOn.isPreconnected_preimage_subtype {s : Set E} {t : β} /-- If `f` is quasiconcave, then its under-levels are connected. -/ theorem QuasiconvexOn.isPreconnected_preimage_subtype {s : Set E} {t : β} (hfc : QuasiconvexOn ℝ s f) : - IsPreconnected (s ↓∩ (f ⁻¹' Iic t)) := - QuasiconcaveOn.isPreconnected_preimage_subtype (β := βᵒᵈ) hfc + IsPreconnected (s ↓∩ (f ⁻¹' Iic t)) := by + unsealing_newtype OrderDual => + exact QuasiconcaveOn.isPreconnected_preimage_subtype (β := βᵒᵈ) hfc theorem QuasilinearOn.isPreconnected_preimage_subtype {s : Set E} {t : β} (hfc : QuasilinearOn ℝ s f) : @@ -191,8 +197,9 @@ theorem QuasiconvexOn.sup [SemilatticeSup β] (hf : QuasiconvexOn 𝕜 s f) exact (hf r).inter (hg r) theorem QuasiconcaveOn.inf [SemilatticeInf β] (hf : QuasiconcaveOn 𝕜 s f) - (hg : QuasiconcaveOn 𝕜 s g) : QuasiconcaveOn 𝕜 s (f ⊓ g) := - hf.dual.sup hg + (hg : QuasiconcaveOn 𝕜 s g) : QuasiconcaveOn 𝕜 s (f ⊓ g) := by + unsealing_newtype OrderDual => + exact hf.dual.sup hg end Semilattice_β @@ -209,8 +216,9 @@ theorem quasiconvexOn_iff_le_max : QuasiconvexOn 𝕜 s f ↔ Convex 𝕜 s ∧ ⟨hf.1 hx.1 hy.1 ha hb hab, (hf.2 hx.1 hy.1 ha hb hab).trans <| max_le hx.2 hy.2⟩⟩ theorem quasiconcaveOn_iff_min_le : QuasiconcaveOn 𝕜 s f ↔ Convex 𝕜 s ∧ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, - y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → min (f x) (f y) ≤ f (a • x + b • y) := - quasiconvexOn_iff_le_max (β := βᵒᵈ) + y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → min (f x) (f y) ≤ f (a • x + b • y) := by + unsealing_newtype OrderDual => + exact quasiconvexOn_iff_le_max (β := βᵒᵈ) theorem quasilinearOn_iff_mem_uIcc : QuasilinearOn 𝕜 s f ↔ Convex 𝕜 s ∧ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → f (a • x + b • y) ∈ uIcc (f x) (f y) := by @@ -226,8 +234,9 @@ theorem QuasiconvexOn.convex_lt (hf : QuasiconvexOn 𝕜 s f) (r : β) : exact ⟨h.1, h.2.trans_lt <| max_lt hx.2 hy.2⟩ theorem QuasiconcaveOn.convex_gt (hf : QuasiconcaveOn 𝕜 s f) (r : β) : - Convex 𝕜 ({ x ∈ s | r < f x }) := - hf.dual.convex_lt r + Convex 𝕜 ({ x ∈ s | r < f x }) := by + unsealing_newtype OrderDual => + exact hf.dual.convex_lt r end LinearOrder_β diff --git a/mathlib4/Mathlib/Analysis/Convex/Star.lean b/mathlib4/Mathlib/Analysis/Convex/Star.lean index 268c23f78..f87124ef2 100644 --- a/mathlib4/Mathlib/Analysis/Convex/Star.lean +++ b/mathlib4/Mathlib/Analysis/Convex/Star.lean @@ -376,8 +376,9 @@ lemma starConvex_compl_Iic (h : x < y) : StarConvex 𝕜 y (Iic x)ᶜ := by gcongr /-- If `x < y`, then `(Set.Ici y)ᶜ` is star convex at `x`. -/ -lemma starConvex_compl_Ici (h : x < y) : StarConvex 𝕜 x (Ici y)ᶜ := - starConvex_compl_Iic (E := Eᵒᵈ) h +lemma starConvex_compl_Ici (h : x < y) : StarConvex 𝕜 x (Ici y)ᶜ := by + unsealing_newtype OrderDual => + exact starConvex_compl_Iic (E := Eᵒᵈ) h end OrderedAddCommGroup diff --git a/mathlib4/Mathlib/Analysis/Convex/Topology.lean b/mathlib4/Mathlib/Analysis/Convex/Topology.lean index c3ddde1ba..fff3a9858 100644 --- a/mathlib4/Mathlib/Analysis/Convex/Topology.lean +++ b/mathlib4/Mathlib/Analysis/Convex/Topology.lean @@ -491,6 +491,16 @@ private lemma sdiff_singleton_eventually_mem_nhds_left {s : Set 𝕜} {a : 𝕜} · exact mem_nhdsWithin.2 ⟨Ioi b, isOpen_Ioi, hba, fun _ ⟨h₁, _, h₂⟩ ↦ ⟨h₁, h₂⟩⟩ · exact mem_nhds_iff.2 ⟨Ioo b a, subset_sdiff_singleton this right_notMem_Ioo, isOpen_Ioo, hx⟩ +omit [Field 𝕜] [IsStrictOrderedRing 𝕜] in +private lemma sdiff_singleton_eventually_mem_nhds_right {s : Set 𝕜} {a : 𝕜} + (h : ∀ x ∈ closure s, Ioo a x ⊆ s) : ∀ᶠ (x : 𝕜) in 𝓝[s ∩ Ioi a] a, s \ {a} ∈ 𝓝 x := by + rcases eq_empty_or_nonempty (s ∩ Ioi a) with hs' | ⟨b, hbs, hba⟩ + · simp [hs'] + have : Ioo a b ⊆ s := h b (subset_closure hbs) + apply eventually_of_mem (U := Ioo a b) ?_ fun x hx ↦ ?_ + · exact mem_nhdsWithin.2 ⟨Iio b, isOpen_Iio, hba, fun _ ⟨h₁, _, h₂⟩ ↦ ⟨h₂, h₁⟩⟩ + · exact mem_nhds_iff.2 ⟨Ioo a b, subset_sdiff_singleton this left_notMem_Ioo, isOpen_Ioo, hx⟩ + theorem Convex.sdiff_singleton_eventually_mem_nhds {s : Set 𝕜} (hs : Convex 𝕜 s) (a : 𝕜) : ∀ᶠ x in 𝓝[s \ {a}] a, s \ {a} ∈ 𝓝 x := by rcases eq_or_neBot (𝓝[s \ {a}] a) with h | has @@ -500,8 +510,8 @@ theorem Convex.sdiff_singleton_eventually_mem_nhds {s : Set 𝕜} (hs : Convex conv in 𝓝[s \ {a}] a => rw [sdiff_eq, ← Iio_union_Ioi, inter_union_distrib_left] rw [nhdsWithin_union, eventually_sup] exact ⟨sdiff_singleton_eventually_mem_nhds_left fun x hx ↦ hs.Ioo_subset_of_mem_closure hx has, - sdiff_singleton_eventually_mem_nhds_left (𝕜 := 𝕜ᵒᵈ) fun x hx z hz ↦ - hs.Ioo_subset_of_mem_closure has hx hz.symm⟩ + sdiff_singleton_eventually_mem_nhds_right fun x hx ↦ + hs.Ioo_subset_of_mem_closure has hx⟩ @[deprecated (since := "2026-06-03")] alias Convex.diff_singleton_eventually_mem_nhds := Convex.sdiff_singleton_eventually_mem_nhds diff --git a/mathlib4/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean b/mathlib4/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean index 0f349bcd1..1c0be147b 100644 --- a/mathlib4/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean +++ b/mathlib4/Mathlib/Analysis/InnerProductSpace/Orthogonal.lean @@ -163,7 +163,9 @@ variable (𝕜 E) /-- `orthogonal` gives a `GaloisConnection` between `Submodule 𝕜 E` and its `OrderDual`. -/ theorem orthogonal_gc : - @GaloisConnection (Submodule 𝕜 E) (Submodule 𝕜 E)ᵒᵈ _ _ orthogonal orthogonal := fun _K₁ _K₂ => + @GaloisConnection (Submodule 𝕜 E) (Submodule 𝕜 E)ᵒᵈ _ _ + (fun K ↦ OrderDual.toDual (orthogonal K)) (fun K ↦ orthogonal (OrderDual.ofDual K)) := + fun _K₁ _K₂ => ⟨fun h _v hv _u hu => inner_left_of_mem_orthogonal hv (h hu), fun h _v hv _u hu => inner_left_of_mem_orthogonal hv (h hu)⟩ @@ -185,17 +187,20 @@ theorem le_orthogonal_orthogonal : K ≤ Kᗮᗮ := /-- The inf of two orthogonal subspaces equals the subspace orthogonal to the sup. -/ -theorem inf_orthogonal (K₁ K₂ : Submodule 𝕜 E) : K₁ᗮ ⊓ K₂ᗮ = (K₁ ⊔ K₂)ᗮ := - (orthogonal_gc 𝕜 E).l_sup.symm +theorem inf_orthogonal (K₁ K₂ : Submodule 𝕜 E) : K₁ᗮ ⊓ K₂ᗮ = (K₁ ⊔ K₂)ᗮ := by + unsealing_newtype OrderDual => + exact (orthogonal_gc 𝕜 E).l_sup.symm /-- The inf of an indexed family of orthogonal subspaces equals the subspace orthogonal to the sup. -/ -theorem iInf_orthogonal {ι : Type*} (K : ι → Submodule 𝕜 E) : ⨅ i, (K i)ᗮ = (iSup K)ᗮ := - (orthogonal_gc 𝕜 E).l_iSup.symm +theorem iInf_orthogonal {ι : Type*} (K : ι → Submodule 𝕜 E) : ⨅ i, (K i)ᗮ = (iSup K)ᗮ := by + unsealing_newtype OrderDual => + exact (orthogonal_gc 𝕜 E).l_iSup.symm /-- The inf of a set of orthogonal subspaces equals the subspace orthogonal to the sup. -/ -theorem sInf_orthogonal (s : Set <| Submodule 𝕜 E) : ⨅ K ∈ s, Kᗮ = (sSup s)ᗮ := - (orthogonal_gc 𝕜 E).l_sSup.symm +theorem sInf_orthogonal (s : Set <| Submodule 𝕜 E) : ⨅ K ∈ s, Kᗮ = (sSup s)ᗮ := by + unsealing_newtype OrderDual => + exact (orthogonal_gc 𝕜 E).l_sSup.symm @[simp] theorem top_orthogonal_eq_bot : (⊤ : Submodule 𝕜 E)ᗮ = ⊥ := by @@ -489,7 +494,8 @@ variable (𝕜 E) /-- `orthogonal` gives a `GaloisConnection` between `ClosedSubmodule 𝕜 E` and its `OrderDual`. -/ theorem orthogonal_gc : - @GaloisConnection (ClosedSubmodule 𝕜 E) (ClosedSubmodule 𝕜 E)ᵒᵈ _ _ orthogonal orthogonal := + @GaloisConnection (ClosedSubmodule 𝕜 E) (ClosedSubmodule 𝕜 E)ᵒᵈ _ _ + (fun K ↦ OrderDual.toDual (orthogonal K)) (fun K ↦ orthogonal (OrderDual.ofDual K)) := fun _K₁ _K₂ => ⟨fun h _v hv _u hu => Submodule.inner_left_of_mem_orthogonal hv (h hu), fun h _v hv _u hu => Submodule.inner_left_of_mem_orthogonal hv (h hu)⟩ @@ -508,17 +514,20 @@ theorem orthogonal_orthogonal_monotone {K₁ K₂ : ClosedSubmodule 𝕜 E} (h : /-- The inf of two orthogonal subspaces equals the subspace orthogonal to the sup. -/ -theorem inf_orthogonal (K₁ K₂ : ClosedSubmodule 𝕜 E) : K₁ᗮ ⊓ K₂ᗮ = (K₁ ⊔ K₂)ᗮ := - (orthogonal_gc 𝕜 E).l_sup.symm +theorem inf_orthogonal (K₁ K₂ : ClosedSubmodule 𝕜 E) : K₁ᗮ ⊓ K₂ᗮ = (K₁ ⊔ K₂)ᗮ := by + unsealing_newtype OrderDual => + exact (orthogonal_gc 𝕜 E).l_sup.symm /-- The inf of an indexed family of orthogonal subspaces equals the subspace orthogonal to the sup. -/ -theorem iInf_orthogonal {ι : Type*} (K : ι → ClosedSubmodule 𝕜 E) : ⨅ i, (K i)ᗮ = (iSup K)ᗮ := - (orthogonal_gc 𝕜 E).l_iSup.symm +theorem iInf_orthogonal {ι : Type*} (K : ι → ClosedSubmodule 𝕜 E) : ⨅ i, (K i)ᗮ = (iSup K)ᗮ := by + unsealing_newtype OrderDual => + exact (orthogonal_gc 𝕜 E).l_iSup.symm /-- The inf of a set of orthogonal subspaces equals the subspace orthogonal to the sup. -/ -theorem sInf_orthogonal (s : Set <| ClosedSubmodule 𝕜 E) : ⨅ K ∈ s, Kᗮ = (sSup s)ᗮ := - (orthogonal_gc 𝕜 E).l_sSup.symm +theorem sInf_orthogonal (s : Set <| ClosedSubmodule 𝕜 E) : ⨅ K ∈ s, Kᗮ = (sSup s)ᗮ := by + unsealing_newtype OrderDual => + exact (orthogonal_gc 𝕜 E).l_sSup.symm @[simp] theorem top_orthogonal_eq_bot : (⊤ : ClosedSubmodule 𝕜 E)ᗮ = ⊥ := by ext x; simp diff --git a/mathlib4/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean b/mathlib4/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean index 04adf9e64..3199056b9 100644 --- a/mathlib4/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean +++ b/mathlib4/Mathlib/Analysis/InnerProductSpace/Projection/Submodule.lean @@ -173,8 +173,9 @@ theorem starProjection_tendsto_self {ι : Type*} [Preorder ι] trivial /-- The orthogonal complement satisfies `Kᗮᗮᗮ = Kᗮ`. -/ -theorem triorthogonal_eq_orthogonal : Kᗮᗮᗮ = Kᗮ := - (orthogonal_gc 𝕜 E).u_l_u_eq_u K +theorem triorthogonal_eq_orthogonal : Kᗮᗮᗮ = Kᗮ := by + unsealing_newtype OrderDual => + exact (orthogonal_gc 𝕜 E).u_l_u_eq_u K /-- The closure of `K` is the full space iff `Kᗮ` is trivial. -/ theorem topologicalClosure_eq_top_iff [CompleteSpace E] : diff --git a/mathlib4/Mathlib/Analysis/LocallyConvex/Polar.lean b/mathlib4/Mathlib/Analysis/LocallyConvex/Polar.lean index 1203a3829..c2d93a76d 100644 --- a/mathlib4/Mathlib/Analysis/LocallyConvex/Polar.lean +++ b/mathlib4/Mathlib/Analysis/LocallyConvex/Polar.lean @@ -90,19 +90,22 @@ theorem polar_gc : ⟨fun h _ hx _ hy => h hy _ hx, fun h _ hx _ hy => h hy _ hx⟩ @[simp] -theorem polar_iUnion {ι} {s : ι → Set E} : B.polar (⋃ i, s i) = ⋂ i, B.polar (s i) := - B.polar_gc.l_iSup +theorem polar_iUnion {ι} {s : ι → Set E} : B.polar (⋃ i, s i) = ⋂ i, B.polar (s i) := by + unsealing_newtype OrderDual => + exact B.polar_gc.l_iSup @[simp] -theorem polar_union {s t : Set E} : B.polar (s ∪ t) = B.polar s ∩ B.polar t := - B.polar_gc.l_sup +theorem polar_union {s t : Set E} : B.polar (s ∪ t) = B.polar s ∩ B.polar t := by + unsealing_newtype OrderDual => + exact B.polar_gc.l_sup theorem polar_antitone : Antitone (B.polar : Set E → Set F) := B.polar_gc.monotone_l @[simp] -theorem polar_empty : B.polar ∅ = Set.univ := - B.polar_gc.l_bot +theorem polar_empty : B.polar ∅ = Set.univ := by + unsealing_newtype OrderDual => + exact B.polar_gc.l_bot @[simp] theorem polar_singleton {a : E} : B.polar {a} = { y | ‖B a y‖ ≤ 1 } := le_antisymm diff --git a/mathlib4/Mathlib/Analysis/Normed/Group/Constructions.lean b/mathlib4/Mathlib/Analysis/Normed/Group/Constructions.lean index e08d2c5cd..9a577f5c5 100644 --- a/mathlib4/Mathlib/Analysis/Normed/Group/Constructions.lean +++ b/mathlib4/Mathlib/Analysis/Normed/Group/Constructions.lean @@ -206,23 +206,24 @@ namespace OrderDual -- See note [lower instance priority] @[to_additive] -instance (priority := 100) seminormedGroup [SeminormedGroup E] : SeminormedGroup Eᵒᵈ := - inferInstanceAs <| SeminormedGroup E +instance (priority := 100) seminormedGroup [SeminormedGroup E] : SeminormedGroup Eᵒᵈ where + dist_eq x y := SeminormedGroup.dist_eq (ofDual x) (ofDual y) -- See note [lower instance priority] @[to_additive] -instance (priority := 100) seminormedCommGroup [SeminormedCommGroup E] : SeminormedCommGroup Eᵒᵈ := - inferInstanceAs <| SeminormedCommGroup E +instance (priority := 100) seminormedCommGroup [SeminormedCommGroup E] : + SeminormedCommGroup Eᵒᵈ where + dist_eq x y := SeminormedGroup.dist_eq (ofDual x) (ofDual y) -- See note [lower instance priority] @[to_additive] -instance (priority := 100) normedGroup [NormedGroup E] : NormedGroup Eᵒᵈ := - inferInstanceAs <| NormedGroup E +instance (priority := 100) normedGroup [NormedGroup E] : NormedGroup Eᵒᵈ where + dist_eq x y := SeminormedGroup.dist_eq (ofDual x) (ofDual y) -- See note [lower instance priority] @[to_additive] -instance (priority := 100) normedCommGroup [NormedCommGroup E] : NormedCommGroup Eᵒᵈ := - inferInstanceAs <| NormedCommGroup E +instance (priority := 100) normedCommGroup [NormedCommGroup E] : NormedCommGroup Eᵒᵈ where + dist_eq x y := SeminormedGroup.dist_eq (ofDual x) (ofDual y) end OrderDual end OrderDual diff --git a/mathlib4/Mathlib/Analysis/Normed/Operator/Compact/FredholmAlternative.lean b/mathlib4/Mathlib/Analysis/Normed/Operator/Compact/FredholmAlternative.lean index 690de19e3..0a98d3a4f 100644 --- a/mathlib4/Mathlib/Analysis/Normed/Operator/Compact/FredholmAlternative.lean +++ b/mathlib4/Mathlib/Analysis/Normed/Operator/Compact/FredholmAlternative.lean @@ -130,7 +130,7 @@ private theorem exists_seq {S : End 𝕜 X} (hS_not_surj : ¬ (S : X → X).Surj (∀ n, 1 ≤ ‖f n‖) ∧ (∀ n, ‖f n‖ ≤ R) ∧ (∀ n, f n ∈ (S ^ n).range) ∧ (∀ n, ∀ y ∈ (S ^ (n + 1)).range, 1 ≤ ‖f n - y‖) := by -- Construct the sequence of submodules `V n := (S ^ n).range`, and show that they are closed. - let V (n : ℕ) : Submodule 𝕜 X := S.iterateRange n + let V (n : ℕ) : Submodule 𝕜 X := OrderDual.ofDual (S.iterateRange n) have hV_succ (n : ℕ) : V (n + 1) = (V n).map (S : End 𝕜 X) := LinearMap.iterateRange_succ have hV_closed (n : ℕ) : IsClosed (V n : Set X) := by induction n with diff --git a/mathlib4/Mathlib/Analysis/Normed/Order/Lattice.lean b/mathlib4/Mathlib/Analysis/Normed/Order/Lattice.lean index 2f23e4812..1cef8b67a 100644 --- a/mathlib4/Mathlib/Analysis/Normed/Order/Lattice.lean +++ b/mathlib4/Mathlib/Analysis/Normed/Order/Lattice.lean @@ -84,8 +84,8 @@ theorem dual_solid (a b : α) (h : b ⊓ -b ≤ a ⊓ -a) : ‖a‖ ≤ ‖b‖ normed lattice ordered group. -/ instance (priority := 100) OrderDual.instHasSolidNorm : - HasSolidNorm αᵒᵈ := - { solid := dual_solid (α := α) } + HasSolidNorm αᵒᵈ where + solid {x y} h := dual_solid (OrderDual.ofDual x) (OrderDual.ofDual y) h theorem norm_abs_eq_norm (a : α) : ‖|a|‖ = ‖a‖ := (solid (abs_abs a).le).antisymm (solid (abs_abs a).symm.le) @@ -139,8 +139,10 @@ instance (priority := 100) HasSolidNorm.continuousInf : ContinuousInf α := by -- see Note [lower instance priority] instance (priority := 100) HasSolidNorm.continuousSup {α : Type*} - [NormedAddCommGroup α] [Lattice α] [HasSolidNorm α] [IsOrderedAddMonoid α] : ContinuousSup α := - OrderDual.continuousSup αᵒᵈ + [NormedAddCommGroup α] [Lattice α] [HasSolidNorm α] [IsOrderedAddMonoid α] : + ContinuousSup α := by + unsealing_newtype OrderDual => + exact OrderDual.continuousSup αᵒᵈ -- see Note [lower instance priority] /-- diff --git a/mathlib4/Mathlib/Basic/ENNReal/Basic.lean b/mathlib4/Mathlib/Basic/ENNReal/Basic.lean index 75cadd3fa..f886b4573 100644 --- a/mathlib4/Mathlib/Basic/ENNReal/Basic.lean +++ b/mathlib4/Mathlib/Basic/ENNReal/Basic.lean @@ -456,20 +456,23 @@ theorem cinfi_ne_top [InfSet α] (f : ℝ≥0∞ → α) : ⨅ x : { x // x ≠ theorem iInf_ne_top [CompleteLattice α] (f : ℝ≥0∞ → α) : ⨅ (x) (_ : x ≠ ∞), f x = ⨅ x : ℝ≥0, f x := by rw [iInf_subtype', cinfi_ne_top] -theorem csupr_ne_top [SupSet α] (f : ℝ≥0∞ → α) : ⨆ x : { x // x ≠ ∞ }, f x = ⨆ x : ℝ≥0, f x := - @cinfi_ne_top αᵒᵈ _ _ +theorem csupr_ne_top [SupSet α] (f : ℝ≥0∞ → α) : ⨆ x : { x // x ≠ ∞ }, f x = ⨆ x : ℝ≥0, f x := by + unsealing_newtype OrderDual => + exact @cinfi_ne_top αᵒᵈ _ _ theorem iSup_ne_top [CompleteLattice α] (f : ℝ≥0∞ → α) : - ⨆ (x) (_ : x ≠ ∞), f x = ⨆ x : ℝ≥0, f x := - @iInf_ne_top αᵒᵈ _ _ + ⨆ (x) (_ : x ≠ ∞), f x = ⨆ x : ℝ≥0, f x := by + unsealing_newtype OrderDual => + exact @iInf_ne_top αᵒᵈ _ _ theorem iInf_ennreal {α : Type*} [CompleteLattice α] {f : ℝ≥0∞ → α} : ⨅ n, f n = (⨅ n : ℝ≥0, f n) ⊓ f ∞ := (iInf_option f).trans (inf_comm _ _) theorem iSup_ennreal {α : Type*} [CompleteLattice α] {f : ℝ≥0∞ → α} : - ⨆ n, f n = (⨆ n : ℝ≥0, f n) ⊔ f ∞ := - @iInf_ennreal αᵒᵈ _ _ + ⨆ n, f n = (⨆ n : ℝ≥0, f n) ⊔ f ∞ := by + unsealing_newtype OrderDual => + exact @iInf_ennreal αᵒᵈ _ _ /-- Coercion `ℝ≥0 → ℝ≥0∞` as a `RingHom`. -/ noncomputable def ofNNRealHom : ℝ≥0 →+* ℝ≥0∞ where diff --git a/mathlib4/Mathlib/Basic/ENNReal/Inv.lean b/mathlib4/Mathlib/Basic/ENNReal/Inv.lean index 40b1c582e..9dfc1069e 100644 --- a/mathlib4/Mathlib/Basic/ENNReal/Inv.lean +++ b/mathlib4/Mathlib/Basic/ENNReal/Inv.lean @@ -895,8 +895,13 @@ case that assumes `a ≠ ∞` but does not require `Nonempty ι`. -/ lemma iInf_div [Nonempty ι] (hinfty : a = 0 → ⨅ i, f i = 0 → ∃ i, f i = 0) : (⨅ i, f i) / a = ⨅ i, f i / a := iInf_div' hinfty fun _ ↦ ‹Nonempty ι› -lemma inv_iInf (f : ι → ℝ≥0∞) : (⨅ i, f i)⁻¹ = ⨆ i, (f i)⁻¹ := OrderIso.invENNReal.map_iInf _ -lemma inv_iSup (f : ι → ℝ≥0∞) : (⨆ i, f i)⁻¹ = ⨅ i, (f i)⁻¹ := OrderIso.invENNReal.map_iSup _ +lemma inv_iInf (f : ι → ℝ≥0∞) : (⨅ i, f i)⁻¹ = ⨆ i, (f i)⁻¹ := by + unsealing_newtype OrderDual => + exact OrderIso.invENNReal.map_iInf _ + +lemma inv_iSup (f : ι → ℝ≥0∞) : (⨆ i, f i)⁻¹ = ⨅ i, (f i)⁻¹ := by + unsealing_newtype OrderDual => + exact OrderIso.invENNReal.map_iSup _ lemma inv_sInf (s : Set ℝ≥0∞) : (sInf s)⁻¹ = ⨆ a ∈ s, a⁻¹ := by simp [sInf_eq_iInf, inv_iInf] lemma inv_sSup (s : Set ℝ≥0∞) : (sSup s)⁻¹ = ⨅ a ∈ s, a⁻¹ := by simp [sSup_eq_iSup, inv_iSup] diff --git a/mathlib4/Mathlib/Basic/Real/Pointwise.lean b/mathlib4/Mathlib/Basic/Real/Pointwise.lean index 980e28025..009245a3f 100644 --- a/mathlib4/Mathlib/Basic/Real/Pointwise.lean +++ b/mathlib4/Mathlib/Basic/Real/Pointwise.lean @@ -73,29 +73,31 @@ section Module variable [Module α ℝ] [IsOrderedModule α ℝ] {a : α} theorem Real.sInf_smul_of_nonpos (ha : a ≤ 0) (s : Set ℝ) : sInf (a • s) = a • sSup s := by - obtain rfl | hs := s.eq_empty_or_nonempty - · rw [smul_set_empty, Real.sInf_empty, Real.sSup_empty, smul_zero] - obtain rfl | ha' := ha.eq_or_lt - · rw [zero_smul_set hs, zero_smul] - exact csInf_singleton 0 - by_cases h : BddAbove s - · exact ((OrderIso.smulRightDual ℝ ha').map_csSup' hs h).symm - · rw [Real.sInf_of_not_bddBelow (mt (bddBelow_smul_iff_of_neg ha').1 h), - Real.sSup_of_not_bddAbove h, smul_zero] + unsealing_newtype OrderDual => + obtain rfl | hs := s.eq_empty_or_nonempty + · rw [smul_set_empty, Real.sInf_empty, Real.sSup_empty, smul_zero] + obtain rfl | ha' := ha.eq_or_lt + · rw [zero_smul_set hs, zero_smul] + exact csInf_singleton 0 + by_cases h : BddAbove s + · exact ((OrderIso.smulRightDual ℝ ha').map_csSup' hs h).symm + · rw [Real.sInf_of_not_bddBelow (mt (bddBelow_smul_iff_of_neg ha').1 h), + Real.sSup_of_not_bddAbove h, smul_zero] theorem Real.smul_iSup_of_nonpos (ha : a ≤ 0) (f : ι → ℝ) : (a • ⨆ i, f i) = ⨅ i, a • f i := (Real.sInf_smul_of_nonpos ha _).symm.trans <| congr_arg sInf <| (range_comp _ _).symm theorem Real.sSup_smul_of_nonpos (ha : a ≤ 0) (s : Set ℝ) : sSup (a • s) = a • sInf s := by - obtain rfl | hs := s.eq_empty_or_nonempty - · rw [smul_set_empty, Real.sSup_empty, Real.sInf_empty, smul_zero] - obtain rfl | ha' := ha.eq_or_lt - · rw [zero_smul_set hs, zero_smul] - exact csSup_singleton 0 - by_cases h : BddBelow s - · exact ((OrderIso.smulRightDual ℝ ha').map_csInf' hs h).symm - · rw [Real.sSup_of_not_bddAbove (mt (bddAbove_smul_iff_of_neg ha').1 h), - Real.sInf_of_not_bddBelow h, smul_zero] + unsealing_newtype OrderDual => + obtain rfl | hs := s.eq_empty_or_nonempty + · rw [smul_set_empty, Real.sSup_empty, Real.sInf_empty, smul_zero] + obtain rfl | ha' := ha.eq_or_lt + · rw [zero_smul_set hs, zero_smul] + exact csSup_singleton 0 + by_cases h : BddBelow s + · exact ((OrderIso.smulRightDual ℝ ha').map_csInf' hs h).symm + · rw [Real.sSup_of_not_bddAbove (mt (bddAbove_smul_iff_of_neg ha').1 h), + Real.sInf_of_not_bddBelow h, smul_zero] theorem Real.smul_iInf_of_nonpos (ha : a ≤ 0) (f : ι → ℝ) : (a • ⨅ i, f i) = ⨆ i, a • f i := (Real.sSup_smul_of_nonpos ha _).symm.trans <| congr_arg sSup <| (range_comp _ _).symm diff --git a/mathlib4/Mathlib/CategoryTheory/Abelian/Subobject.lean b/mathlib4/Mathlib/CategoryTheory/Abelian/Subobject.lean index 08831cebc..e3e19ef1a 100644 --- a/mathlib4/Mathlib/CategoryTheory/Abelian/Subobject.lean +++ b/mathlib4/Mathlib/CategoryTheory/Abelian/Subobject.lean @@ -36,10 +36,12 @@ since mathlib does not have a notion of quotient objects at the time of writing. def subobjectIsoSubobjectOp [Abelian C] (X : C) : Subobject X ≃o (Subobject (op X))ᵒᵈ := by refine OrderIso.ofHomInv (cokernelOrderHom X) (kernelOrderHom X) ?_ ?_ · change (cokernelOrderHom X).comp (kernelOrderHom X) = _ - refine OrderHom.ext _ _ (funext (Subobject.ind _ ?_)) + refine OrderHom.ext _ _ + (funext (OrderDual.toDual.surjective.forall.2 (Subobject.ind _ ?_))) intro A f hf dsimp only [OrderHom.comp_coe, Function.comp_apply, kernelOrderHom_coe, Subobject.lift_mk, - cokernelOrderHom_coe, OrderHom.id_coe, id] + cokernelOrderHom_coe, OrderHom.id_coe, id, OrderDual.ofDual_toDual] + refine OrderDual.toDual_inj.mpr ?_ refine Subobject.mk_eq_mk_of_comm _ _ ⟨?_, ?_, Quiver.Hom.unop_inj ?_, Quiver.Hom.unop_inj ?_⟩ ?_ · exact (Abelian.epiDesc f.unop _ (cokernel.condition (kernel.ι f.unop))).op @@ -54,7 +56,8 @@ def subobjectIsoSubobjectOp [Abelian C] (X : C) : Subobject X ≃o (Subobject (o refine OrderHom.ext _ _ (funext (Subobject.ind _ ?_)) intro A f hf dsimp only [OrderHom.comp_coe, Function.comp_apply, cokernelOrderHom_coe, Subobject.lift_mk, - kernelOrderHom_coe, OrderHom.id_coe, id, unop_op, Quiver.Hom.unop_op] + kernelOrderHom_coe, OrderHom.id_coe, id, unop_op, Quiver.Hom.unop_op, + OrderDual.ofDual_toDual] refine Subobject.mk_eq_mk_of_comm _ _ ⟨?_, ?_, ?_, ?_⟩ ?_ · exact Abelian.monoLift f _ (kernel.condition (cokernel.π f)) · exact kernel.lift _ _ (cokernel.condition f) @@ -67,6 +70,7 @@ def subobjectIsoSubobjectOp [Abelian C] (X : C) : Subobject X ≃o (Subobject (o instance wellPowered_opposite [Abelian C] [LocallySmall.{w} C] [WellPowered.{w} C] : WellPowered.{w} Cᵒᵖ where subobject_small X := - (small_congr (subobjectIsoSubobjectOp (unop X)).toEquiv).1 inferInstance + (small_congr ((subobjectIsoSubobjectOp (unop X)).toEquiv.trans OrderDual.ofDual)).1 + inferInstance end CategoryTheory.Abelian diff --git a/mathlib4/Mathlib/CategoryTheory/Localization/Bousfield.lean b/mathlib4/Mathlib/CategoryTheory/Localization/Bousfield.lean index 80f6ccb54..dc9eb4722 100644 --- a/mathlib4/Mathlib/CategoryTheory/Localization/Bousfield.lean +++ b/mathlib4/Mathlib/CategoryTheory/Localization/Bousfield.lean @@ -118,8 +118,9 @@ lemma le_isLocal_iff (P : ObjectProperty C) (W : MorphismProperty C) : lemma galoisConnection_isLocal : GaloisConnection (OrderDual.toDual ∘ isLocal (C := C)) - (MorphismProperty.isLocal ∘ OrderDual.ofDual) := - le_isLocal_iff + (MorphismProperty.isLocal ∘ OrderDual.ofDual) := by + unsealing_newtype OrderDual => + exact le_isLocal_iff end @@ -201,8 +202,9 @@ lemma le_isColocal_iff (P : ObjectProperty C) (W : MorphismProperty C) : lemma galoisConnection_isColocal : GaloisConnection (OrderDual.toDual ∘ isColocal (C := C)) - (MorphismProperty.isColocal ∘ OrderDual.ofDual) := - le_isColocal_iff + (MorphismProperty.isColocal ∘ OrderDual.ofDual) := by + unsealing_newtype OrderDual => + exact le_isColocal_iff end diff --git a/mathlib4/Mathlib/CategoryTheory/MorphismProperty/LiftingProperty.lean b/mathlib4/Mathlib/CategoryTheory/MorphismProperty/LiftingProperty.lean index 3612c6b1c..0b83939e5 100644 --- a/mathlib4/Mathlib/CategoryTheory/MorphismProperty/LiftingProperty.lean +++ b/mathlib4/Mathlib/CategoryTheory/MorphismProperty/LiftingProperty.lean @@ -106,25 +106,30 @@ lemma le_llp_iff_le_rlp (T' : MorphismProperty C) : lemma gc_llp_rlp : GaloisConnection (OrderDual.toDual (α := MorphismProperty C) ∘ llp) - (rlp ∘ OrderDual.ofDual) := - fun _ _ ↦ le_llp_iff_le_rlp _ _ + (rlp ∘ OrderDual.ofDual) := by + unsealing_newtype OrderDual => + exact fun _ _ ↦ le_llp_iff_le_rlp _ _ lemma le_llp_rlp : T ≤ T.rlp.llp := by rw [le_llp_iff_le_rlp] @[simp] -lemma rlp_llp_rlp : T.rlp.llp.rlp = T.rlp := - gc_llp_rlp.u_l_u_eq_u T +lemma rlp_llp_rlp : T.rlp.llp.rlp = T.rlp := by + unsealing_newtype OrderDual => + exact gc_llp_rlp.u_l_u_eq_u T @[simp] -lemma llp_rlp_llp : T.llp.rlp.llp = T.llp := - gc_llp_rlp.l_u_l_eq_l T +lemma llp_rlp_llp : T.llp.rlp.llp = T.llp := by + unsealing_newtype OrderDual => + exact gc_llp_rlp.l_u_l_eq_l T -lemma antitone_rlp : Antitone (rlp : MorphismProperty C → _) := - fun _ _ h ↦ gc_llp_rlp.monotone_u h +lemma antitone_rlp : Antitone (rlp : MorphismProperty C → _) := by + unsealing_newtype OrderDual => + exact fun _ _ h ↦ gc_llp_rlp.monotone_u h -lemma antitone_llp : Antitone (llp : MorphismProperty C → _) := - fun _ _ h ↦ gc_llp_rlp.monotone_l h +lemma antitone_llp : Antitone (llp : MorphismProperty C → _) := by + unsealing_newtype OrderDual => + exact fun _ _ h ↦ gc_llp_rlp.monotone_l h lemma pushouts_le_llp_rlp : T.pushouts ≤ T.rlp.llp := by intro A B i hi diff --git a/mathlib4/Mathlib/CategoryTheory/Subobject/ArtinianObject.lean b/mathlib4/Mathlib/CategoryTheory/Subobject/ArtinianObject.lean index 60d30eaa6..fb092f29f 100644 --- a/mathlib4/Mathlib/CategoryTheory/Subobject/ArtinianObject.lean +++ b/mathlib4/Mathlib/CategoryTheory/Subobject/ArtinianObject.lean @@ -91,18 +91,19 @@ set_option backward.defeqAttrib.useBackward true in lemma isArtinianObject_iff_isEventuallyConstant : IsArtinianObject X ↔ ∀ (F : ℕ ⥤ (MonoOver X)ᵒᵖ), IsFiltered.IsEventuallyConstant F := by - rw [isArtinianObject_iff_antitone_chain_condition] - refine ⟨fun h G ↦ ?_, fun h F ↦ ?_⟩ - · obtain ⟨n, hn⟩ := h ⟨_, (G ⋙ (Subobject.equivMonoOver X).inverse.op ⋙ - (orderDualEquivalence _).inverse).monotone⟩ - refine ⟨n, fun m hm ↦ ?_⟩ - rw [← isIso_unop_iff, MonoOver.isIso_iff_subobjectMk_eq] - exact (hn m (leOfHom hm)).symm - · obtain ⟨n, hn⟩ := h (F.monotone.functor ⋙ (orderDualEquivalence _).functor ⋙ - Subobject.representative.op) - refine ⟨n, fun m hm ↦ Eq.symm ?_⟩ - simpa [isIso_op_iff, isIso_iff_of_reflects_iso, PartialOrder.isIso_iff_eq] - using hn (homOfLE hm) + unsealing_newtype OrderDual => + rw [isArtinianObject_iff_antitone_chain_condition] + refine ⟨fun h G ↦ ?_, fun h F ↦ ?_⟩ + · obtain ⟨n, hn⟩ := h ⟨_, (G ⋙ (Subobject.equivMonoOver X).inverse.op ⋙ + (orderDualEquivalence _).inverse).monotone⟩ + refine ⟨n, fun m hm ↦ ?_⟩ + rw [← isIso_unop_iff, MonoOver.isIso_iff_subobjectMk_eq] + exact (hn m (leOfHom hm)).symm + · obtain ⟨n, hn⟩ := h (F.monotone.functor ⋙ (orderDualEquivalence _).functor ⋙ + Subobject.representative.op) + refine ⟨n, fun m hm ↦ Eq.symm ?_⟩ + simpa [isIso_op_iff, isIso_iff_of_reflects_iso, PartialOrder.isIso_iff_eq] + using hn (homOfLE hm) variable {X} in lemma isEventuallyConstant_of_isArtinianObject [IsArtinianObject X] @@ -124,12 +125,13 @@ instance [HasZeroObject C] : (isArtinianObject (C := C)).ContainsZero where lemma isArtinianObject_of_mono (i : X ⟶ Y) [Mono i] [IsArtinianObject Y] : IsArtinianObject X := by - rw [isArtinianObject_iff_antitone_chain_condition] - intro f - obtain ⟨n, hn⟩ := antitone_chain_condition_of_isArtinianObject - ⟨fun n ↦ (Subobject.map i).obj (f n), - fun _ _ h ↦ (Subobject.map i).monotone (f.2 h)⟩ - exact ⟨n, fun m hm ↦ Subobject.map_obj_injective i (hn m hm)⟩ + unsealing_newtype OrderDual => + rw [isArtinianObject_iff_antitone_chain_condition] + intro f + obtain ⟨n, hn⟩ := antitone_chain_condition_of_isArtinianObject + ⟨fun n ↦ (Subobject.map i).obj (f n), + fun _ _ h ↦ (Subobject.map i).monotone (f.2 h)⟩ + exact ⟨n, fun m hm ↦ Subobject.map_obj_injective i (hn m hm)⟩ instance : (isArtinianObject (C := C)).IsClosedUnderSubobjects where prop_of_mono f _ hY := by diff --git a/mathlib4/Mathlib/CategoryTheory/Subobject/Limits.lean b/mathlib4/Mathlib/CategoryTheory/Subobject/Limits.lean index b3da26297..f898cd008 100644 --- a/mathlib4/Mathlib/CategoryTheory/Subobject/Limits.lean +++ b/mathlib4/Mathlib/CategoryTheory/Subobject/Limits.lean @@ -260,7 +260,7 @@ set_option backward.isDefEq.respectTransparency false in of `X`. -/ @[simps] def cokernelOrderHom [HasCokernels C] (X : C) : Subobject X →o (Subobject (op X))ᵒᵈ where - toFun := + toFun x := OrderDual.toDual <| Subobject.lift (fun _ f _ => Subobject.mk (cokernel.π f).op) (by rintro A B f g hf hg i rfl @@ -269,7 +269,7 @@ def cokernelOrderHom [HasCokernels C] (X : C) : Subobject X →o (Subobject (op (isCokernelEpiComp (colimit.isColimit _) i.hom rfl)).symm · simp only [Iso.comp_inv_eq, Iso.op_hom, Iso.symm_hom, unop_comp, Quiver.Hom.unop_op, colimit.comp_coconePointUniqueUpToIso_hom, Cofork.ofπ_ι_app, - coequalizer.cofork_π]) + coequalizer.cofork_π]) x monotone' := Subobject.ind₂ _ <| by intro A B f g hf hg h @@ -284,7 +284,7 @@ set_option backward.isDefEq.respectTransparency false in `X`. -/ @[simps] def kernelOrderHom [HasKernels C] (X : C) : (Subobject (op X))ᵒᵈ →o Subobject X where - toFun := + toFun x := Subobject.lift (fun _ f _ => Subobject.mk (kernel.ι f.unop)) (by rintro A B f g hf hg i rfl @@ -294,10 +294,16 @@ def kernelOrderHom [HasKernels C] (X : C) : (Subobject (op X))ᵒᵈ →o Subobj (isKernelCompMono (limit.isLimit (parallelPair g.unop 0)) i.unop.hom rfl) · dsimp simp only [← Iso.eq_inv_comp, limit.conePointUniqueUpToIso_inv_comp, - Fork.ofι_π_app]) - monotone' := - Subobject.ind₂ _ <| by - intro A B f g hf hg h + Fork.ofι_π_app]) (OrderDual.ofDual x) + monotone' := by + intro x y h + cases x using OrderDual.rec + cases y using OrderDual.rec + rename_i x y + revert h + induction x, y using Subobject.ind₂ with + | _ f g => + intro h dsimp only [Subobject.lift_mk] refine Subobject.mk_le_mk_of_comm (kernel.lift g.unop (kernel.ι f.unop) ?_) ?_ · rw [← Subobject.ofMkLEMk_comp h, unop_comp, kernel.condition_assoc, zero_comp] diff --git a/mathlib4/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean b/mathlib4/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean index 1d6d22a9f..26c340b5c 100644 --- a/mathlib4/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean +++ b/mathlib4/Mathlib/Combinatorics/Enumerative/IncidenceAlgebra.lean @@ -568,13 +568,22 @@ end InversionTop section InversionBot variable [Ring 𝕜] [PartialOrder α] [OrderBot α] [LocallyFiniteOrder α] [DecidableEq α] -set_option backward.isDefEq.respectTransparency false in /-- A general form of Möbius inversion. Based on lemma 2.1.3 of Incidence Algebras by Spiegel and O'Donnell. -/ lemma moebius_inversion_bot (f g : α → 𝕜) (h : ∀ x, g x = ∑ y ∈ Iic x, f y) (x : α) : f x = ∑ y ∈ Iic x, mu 𝕜 y x * g y := by - convert! moebius_inversion_top (α := αᵒᵈ) f g h x using 3 - rw [← mu_toDual]; rfl + -- We can't keep the old defeq-abuse proof since the definition of `Ici` changed. + -- We need `Ici (α := αᵒᵈ) =?= Iic (α := α)`, but the definition of + -- `OrderDual.instLocallyFiniteOrderBot` involves `Finset.map` now. + have h' : ∀ y : αᵒᵈ, g (ofDual y) = ∑ z ∈ Ici y, f (ofDual z) := fun y ↦ by + rw [h (ofDual y)] + exact Finset.sum_equiv OrderDual.toDual + (fun _ ↦ by simp only [Finset.mem_Iic, Finset.mem_Ici]; exact Iff.rfl) fun _ _ ↦ rfl + have H := moebius_inversion_top (α := αᵒᵈ) (fun y ↦ f (ofDual y)) (fun y ↦ g (ofDual y)) h' + (toDual x) + refine H.trans (Finset.sum_equiv OrderDual.ofDual + (fun _ ↦ by simp only [Finset.mem_Iic, Finset.mem_Ici]; exact Iff.rfl) fun i _ ↦ ?_) + rw [show (mu 𝕜 (toDual x) i) = mu 𝕜 (toDual x) (toDual (ofDual i)) from rfl, mu_toDual] end InversionBot diff --git a/mathlib4/Mathlib/Combinatorics/Pigeonhole.lean b/mathlib4/Mathlib/Combinatorics/Pigeonhole.lean index 71c5c7213..897d29e84 100644 --- a/mathlib4/Mathlib/Combinatorics/Pigeonhole.lean +++ b/mathlib4/Mathlib/Combinatorics/Pigeonhole.lean @@ -124,8 +124,9 @@ if the total weight of a finite set of pigeons is less than `n • b`, and they pigeonholes, then for some pigeonhole, the total weight of the pigeons in this pigeonhole is less than `b`. -/ theorem exists_sum_fiber_lt_of_maps_to_of_sum_lt_nsmul (hf : ∀ a ∈ s, f a ∈ t) - (hb : ∑ x ∈ s, w x < #t • b) : ∃ y ∈ t, ∑ x ∈ s with f x = y, w x < b := - exists_lt_sum_fiber_of_maps_to_of_nsmul_lt_sum (M := Mᵒᵈ) hf hb + (hb : ∑ x ∈ s, w x < #t • b) : ∃ y ∈ t, ∑ x ∈ s with f x = y, w x < b := by + unsealing_newtype OrderDual => + exact exists_lt_sum_fiber_of_maps_to_of_nsmul_lt_sum (M := Mᵒᵈ) hf hb /-- The pigeonhole principle for finitely many pigeons counted by weight, strict inequality version: if the total weight of a finite set of pigeons is greater than `n • b`, they are sorted into some @@ -147,8 +148,9 @@ then for at least one of these `n` pigeonholes, the total weight of the pigeons is less than `b`. -/ theorem exists_sum_fiber_lt_of_sum_fiber_nonneg_of_sum_lt_nsmul (ht : ∀ y ∉ t, (0 : M) ≤ ∑ x ∈ s with f x = y, w x) (hb : ∑ x ∈ s, w x < #t • b) : - ∃ y ∈ t, ∑ x ∈ s with f x = y, w x < b := - exists_lt_sum_fiber_of_sum_fiber_nonpos_of_nsmul_lt_sum (M := Mᵒᵈ) ht hb + ∃ y ∈ t, ∑ x ∈ s with f x = y, w x < b := by + unsealing_newtype OrderDual => + exact exists_lt_sum_fiber_of_sum_fiber_nonpos_of_nsmul_lt_sum (M := Mᵒᵈ) ht hb /-! #### Non-strict inequality versions @@ -168,8 +170,9 @@ version: if the total weight of a finite set of pigeons is less than or equal to are sorted into `n > 0` pigeonholes, then for some pigeonhole, the total weight of the pigeons in this pigeonhole is less than or equal to `b`. -/ theorem exists_sum_fiber_le_of_maps_to_of_sum_le_nsmul (hf : ∀ a ∈ s, f a ∈ t) (ht : t.Nonempty) - (hb : ∑ x ∈ s, w x ≤ #t • b) : ∃ y ∈ t, ∑ x ∈ s with f x = y, w x ≤ b := - exists_le_sum_fiber_of_maps_to_of_nsmul_le_sum (M := Mᵒᵈ) hf ht hb + (hb : ∑ x ∈ s, w x ≤ #t • b) : ∃ y ∈ t, ∑ x ∈ s with f x = y, w x ≤ b := by + unsealing_newtype OrderDual => + exact exists_le_sum_fiber_of_maps_to_of_nsmul_le_sum (M := Mᵒᵈ) hf ht hb /-- The pigeonhole principle for finitely many pigeons counted by weight, non-strict inequality version: if the total weight of a finite set of pigeons is greater than or equal to `n • b`, they @@ -192,8 +195,9 @@ there is nonnegative, then for at least one of these `n` pigeonholes, the total pigeons in this pigeonhole is less than or equal to `b`. -/ theorem exists_sum_fiber_le_of_sum_fiber_nonneg_of_sum_le_nsmul (hf : ∀ y ∉ t, (0 : M) ≤ ∑ x ∈ s with f x = y, w x) (ht : t.Nonempty) - (hb : ∑ x ∈ s, w x ≤ #t • b) : ∃ y ∈ t, ∑ x ∈ s with f x = y, w x ≤ b := - exists_le_sum_fiber_of_sum_fiber_nonpos_of_nsmul_le_sum (M := Mᵒᵈ) hf ht hb + (hb : ∑ x ∈ s, w x ≤ #t • b) : ∃ y ∈ t, ∑ x ∈ s with f x = y, w x ≤ b := by + unsealing_newtype OrderDual => + exact exists_le_sum_fiber_of_sum_fiber_nonpos_of_nsmul_le_sum (M := Mᵒᵈ) hf ht hb end @@ -357,16 +361,18 @@ theorem exists_le_sum_fiber_of_nsmul_le_sum [Nonempty β] (hb : card β • b version: there is a pigeonhole with the total weight of pigeons in it less than `b` provided that the total number of pigeonholes times `b` is greater than the total weight of all pigeons. -/ theorem exists_sum_fiber_lt_of_sum_lt_nsmul (hb : ∑ x, w x < card β • b) : - ∃ y, ∑ x with f x = y, w x < b := - exists_lt_sum_fiber_of_nsmul_lt_sum (M := Mᵒᵈ) _ hb + ∃ y, ∑ x with f x = y, w x < b := by + unsealing_newtype OrderDual => + exact exists_lt_sum_fiber_of_nsmul_lt_sum (M := Mᵒᵈ) _ hb /-- The pigeonhole principle for finitely many pigeons of different weights, non-strict inequality version: there is a pigeonhole with the total weight of pigeons in it less than or equal to `b` provided that the total number of pigeonholes times `b` is greater than or equal to the total weight of all pigeons. -/ theorem exists_sum_fiber_le_of_sum_le_nsmul [Nonempty β] (hb : ∑ x, w x ≤ card β • b) : - ∃ y, ∑ x with f x = y, w x ≤ b := - exists_le_sum_fiber_of_nsmul_le_sum (M := Mᵒᵈ) _ hb + ∃ y, ∑ x with f x = y, w x ≤ b := by + unsealing_newtype OrderDual => + exact exists_le_sum_fiber_of_nsmul_le_sum (M := Mᵒᵈ) _ hb end diff --git a/mathlib4/Mathlib/Combinatorics/SetFamily/AhlswedeZhang.lean b/mathlib4/Mathlib/Combinatorics/SetFamily/AhlswedeZhang.lean index 3291ec6f1..5a3a3e16e 100644 --- a/mathlib4/Mathlib/Combinatorics/SetFamily/AhlswedeZhang.lean +++ b/mathlib4/Mathlib/Combinatorics/SetFamily/AhlswedeZhang.lean @@ -301,10 +301,14 @@ section BooleanAlgebra variable [BooleanAlgebra α] [DecidableLE α] @[simp] lemma compl_truncatedSup (s : Finset α) (a : α) : - (truncatedSup s a)ᶜ = truncatedInf sᶜˢ aᶜ := map_truncatedSup (OrderIso.compl α) _ _ + (truncatedSup s a)ᶜ = truncatedInf sᶜˢ aᶜ := by + unsealing_newtype OrderDual => + exact map_truncatedSup (OrderIso.compl α) _ _ @[simp] lemma compl_truncatedInf (s : Finset α) (a : α) : - (truncatedInf s a)ᶜ = truncatedSup sᶜˢ aᶜ := map_truncatedInf (OrderIso.compl α) _ _ + (truncatedInf s a)ᶜ = truncatedSup sᶜˢ aᶜ := by + unsealing_newtype OrderDual => + exact map_truncatedInf (OrderIso.compl α) _ _ end BooleanAlgebra diff --git a/mathlib4/Mathlib/Data/DFinsupp/Lex.lean b/mathlib4/Mathlib/Data/DFinsupp/Lex.lean index 8ca213b0c..c5e6157a0 100644 --- a/mathlib4/Mathlib/Data/DFinsupp/Lex.lean +++ b/mathlib4/Mathlib/Data/DFinsupp/Lex.lean @@ -95,10 +95,10 @@ instance Lex.isStrictOrder [∀ i, PartialOrder (α i)] : irrefl _ := lt_irrefl (α := Lex (∀ i, α i)) _ trans _ _ _ := lt_trans (α := Lex (∀ i, α i)) -set_option backward.isDefEq.respectTransparency false in instance Colex.isStrictOrder [∀ i, PartialOrder (α i)] : - IsStrictOrder (Colex (Π₀ i, α i)) (· < ·) := - Lex.isStrictOrder (ι := ιᵒᵈ) + IsStrictOrder (Colex (Π₀ i, α i)) (· < ·) where + irrefl _ := lt_irrefl (α := Colex (∀ i, α i)) _ + trans _ _ _ := lt_trans (α := Colex (∀ i, α i)) /-- The partial order on `DFinsupp`s obtained by the lexicographic ordering. See `DFinsupp.Lex.linearOrder` for a proof that this partial order is in fact linear. -/ @@ -124,7 +124,7 @@ theorem Lex.le_iff_of_unique [Unique ι] [∀ i, PartialOrder (α i)] {x y : Lex set_option backward.isDefEq.respectTransparency false in theorem Colex.le_iff_of_unique [Unique ι] [∀ i, PartialOrder (α i)] {x y : Colex (Π₀ i, α i)} : x ≤ y ↔ x default ≤ y default := - Lex.le_iff_of_unique (ι := ιᵒᵈ) + Pi.colex_le_iff_of_unique section LinearOrder @@ -148,9 +148,9 @@ private def lt_trichotomy_rec {P : Lex (Π₀ i, α i) → Lex (Π₀ i, α i) instance Lex.total_le : @Std.Total (Lex (Π₀ i, α i)) (· ≤ ·) where total := lt_trichotomy_rec (fun h ↦ Or.inl h.le) (fun h ↦ Or.inl h.le) fun h ↦ Or.inr h.le -set_option backward.isDefEq.respectTransparency false in -instance Colex.total_le : @Std.Total (Colex (Π₀ i, α i)) (· ≤ ·) := - Lex.total_le (ι := ιᵒᵈ) +set_option backward.isDefEq.respectTransparency.types false in +instance Colex.total_le : @Std.Total (Colex (Π₀ i, α i)) (· ≤ ·) := by + unsealing_newtype OrderDual => exact Lex.total_le (ι := ιᵒᵈ) set_option backward.privateInPublic true in set_option backward.privateInPublic.warn false in @@ -160,10 +160,11 @@ instance Lex.decidableLE : DecidableLE (Lex (Π₀ i, α i)) := (fun h ↦ isTrue <| Or.inl <| congr_arg _ h) fun h ↦ isFalse fun h' ↦ lt_irrefl _ (h.trans_le h') -set_option backward.isDefEq.respectTransparency false in /-- The less-or-equal relation for the colexicographic ordering is decidable. -/ instance Colex.decidableLE : DecidableLE (Colex (Π₀ i, α i)) := - Lex.decidableLE (ι := ιᵒᵈ) + -- Reuse lexicographic decidability with the index order reversed. + letI := LinearOrder.lift' (OrderDual.toDual : ι → ιᵒᵈ) OrderDual.toDual.injective + Lex.decidableLE set_option backward.privateInPublic true in set_option backward.privateInPublic.warn false in @@ -171,10 +172,10 @@ set_option backward.privateInPublic.warn false in instance Lex.decidableLT : DecidableLT (Lex (Π₀ i, α i)) := lt_trichotomy_rec (fun h ↦ isTrue h) (fun h ↦ isFalse h.not_lt) fun h ↦ isFalse h.asymm -set_option backward.isDefEq.respectTransparency false in /-- The less-than relation for the colexicographic ordering is decidable. -/ instance Colex.decidableLT : DecidableLT (Colex (Π₀ i, α i)) := - Lex.decidableLT (ι := ιᵒᵈ) + letI := LinearOrder.lift' (OrderDual.toDual : ι → ιᵒᵈ) OrderDual.toDual.injective + Lex.decidableLT /-- The linear order on `DFinsupp`s obtained by the lexicographic ordering. -/ instance Lex.linearOrder : LinearOrder (Lex (Π₀ i, α i)) where @@ -200,9 +201,9 @@ theorem toLex_monotone : Monotone (@toLex (Π₀ i, α i)) := by fun j hj ↦ notMem_neLocus.1 fun h ↦ (Finset.min'_le _ _ h).not_gt hj, (h _).lt_of_ne (mem_neLocus.1 <| Finset.min'_mem _ _)⟩ -set_option backward.isDefEq.respectTransparency false in -theorem toColex_monotone : Monotone (@toColex (Π₀ i, α i)) := - toLex_monotone (ι := ιᵒᵈ) +theorem toColex_monotone : Monotone (@toColex (Π₀ i, α i)) := by + unsealing_newtype OrderDual => + exact toLex_monotone (ι := ιᵒᵈ) (α := fun i ↦ α (OrderDual.ofDual i)) end Zero @@ -223,16 +224,17 @@ set_option backward.defeqAttrib.useBackward true in instance Lex.addLeftStrictMono : AddLeftStrictMono (Lex (Π₀ i, α i)) := ⟨fun _ _ _ ⟨a, lta, ha⟩ ↦ ⟨a, fun j ja ↦ congr_arg _ (lta j ja), by dsimp; gcongr⟩⟩ -set_option backward.isDefEq.respectTransparency false in -instance Colex.addLeftStrictMono : AddLeftStrictMono (Colex (Π₀ i, α i)) := - Lex.addLeftStrictMono (ι := ιᵒᵈ) +set_option backward.defeqAttrib.useBackward true in +set_option backward.isDefEq.respectTransparency.types false in +instance Colex.addLeftStrictMono : AddLeftStrictMono (Colex (Π₀ i, α i)) := by + unsealing_newtype OrderDual => exact Lex.addLeftStrictMono (ι := ιᵒᵈ) instance Lex.addLeftMono : AddLeftMono (Lex (Π₀ i, α i)) := addLeftMono_of_addLeftStrictMono _ -set_option backward.isDefEq.respectTransparency false in -instance Colex.addLeftMono : AddLeftMono (Colex (Π₀ i, α i)) := - Lex.addLeftMono (ι := ιᵒᵈ) +set_option backward.isDefEq.respectTransparency.types false in +instance Colex.addLeftMono : AddLeftMono (Colex (Π₀ i, α i)) := by + unsealing_newtype OrderDual => exact Lex.addLeftMono (ι := ιᵒᵈ) end Left @@ -245,16 +247,16 @@ instance Lex.addRightStrictMono : AddRightStrictMono (Lex (Π₀ i, α i)) := ⟨fun f _ _ ⟨a, lta, ha⟩ ↦ ⟨a, fun j ja ↦ congr_arg (· + ofLex f j) (lta j ja), by dsimp; gcongr⟩⟩ -set_option backward.isDefEq.respectTransparency false in +set_option backward.defeqAttrib.useBackward true in instance Colex.addRightStrictMono : AddRightStrictMono (Colex (Π₀ i, α i)) := - Lex.addRightStrictMono (ι := ιᵒᵈ) + ⟨fun f _ _ ⟨a, lta, ha⟩ ↦ + ⟨a, fun j ja ↦ congr_arg (· + ofColex f j) (lta j ja), by dsimp; gcongr⟩⟩ instance Lex.addRightMono : AddRightMono (Lex (Π₀ i, α i)) := addRightMono_of_addRightStrictMono _ -set_option backward.isDefEq.respectTransparency false in instance Colex.addRightMono : AddRightMono (Colex (Π₀ i, α i)) := - Lex.addRightMono (ι := ιᵒᵈ) + addRightMono_of_addRightStrictMono _ end Right @@ -292,22 +294,21 @@ instance Lex.isOrderedCancelAddMonoid [∀ i, AddCommMonoid (α i)] [∀ i, Part add_le_add_left _ _ h _ := add_le_add_left (α := Lex (∀ i, α i)) h _ le_of_add_le_add_left _ _ _ := le_of_add_le_add_left (α := Lex (∀ i, α i)) -set_option backward.isDefEq.respectTransparency false in instance Colex.isOrderedCancelAddMonoid [∀ i, AddCommMonoid (α i)] [∀ i, PartialOrder (α i)] [∀ i, IsOrderedCancelAddMonoid (α i)] : - IsOrderedCancelAddMonoid (Colex (Π₀ i, α i)) := - Lex.isOrderedCancelAddMonoid (ι := ιᵒᵈ) + IsOrderedCancelAddMonoid (Colex (Π₀ i, α i)) where + add_le_add_left _ _ h _ := add_le_add_left (α := Colex (∀ i, α i)) h _ + le_of_add_le_add_left _ _ _ := le_of_add_le_add_left (α := Colex (∀ i, α i)) instance Lex.isOrderedAddMonoid [∀ i, AddCommGroup (α i)] [∀ i, PartialOrder (α i)] [∀ i, IsOrderedAddMonoid (α i)] : IsOrderedAddMonoid (Lex (Π₀ i, α i)) where add_le_add_left _ _ := add_le_add_left -set_option backward.isDefEq.respectTransparency false in instance Colex.isOrderedAddMonoid [∀ i, AddCommGroup (α i)] [∀ i, PartialOrder (α i)] [∀ i, IsOrderedAddMonoid (α i)] : - IsOrderedAddMonoid (Colex (Π₀ i, α i)) := - Lex.isOrderedAddMonoid (ι := ιᵒᵈ) + IsOrderedAddMonoid (Colex (Π₀ i, α i)) where + add_le_add_left _ _ := add_le_add_left end OrderedAddMonoid diff --git a/mathlib4/Mathlib/Data/DFinsupp/WellFounded.lean b/mathlib4/Mathlib/Data/DFinsupp/WellFounded.lean index a4aa314cd..6f596610b 100644 --- a/mathlib4/Mathlib/Data/DFinsupp/WellFounded.lean +++ b/mathlib4/Mathlib/Data/DFinsupp/WellFounded.lean @@ -173,12 +173,13 @@ instance Lex.wellFoundedLT [LT ι] [@Std.Trichotomous ι (· < ·)] [hι : WellF WellFoundedLT (Lex (Π₀ i, α i)) := ⟨Lex.wellFounded' (fun _ _ => not_lt_zero) (fun i => (hα i).wf) hι.wf⟩ -set_option backward.isDefEq.respectTransparency false in -instance Colex.wellFoundedLT [LT ι] [@Std.Trichotomous ι (· < ·)] [WellFoundedLT ι] +instance Colex.wellFoundedLT [LT ι] [@Std.Trichotomous ι (· < ·)] [hι : WellFoundedLT ι] [∀ i, AddMonoid (α i)] [∀ i, PartialOrder (α i)] [∀ i, IsBotZeroClass (α i)] - [∀ i, WellFoundedLT (α i)] : + [hα : ∀ i, WellFoundedLT (α i)] : WellFoundedLT (Colex (Π₀ i, α i)) := - Lex.wellFoundedLT (ι := ιᵒᵈ) + haveI : @Std.Trichotomous ι (· > ·) := + ⟨fun a b h₁ h₂ ↦ Std.Trichotomous.trichotomous (r := (· < ·)) a b h₂ h₁⟩ + ⟨Lex.wellFounded' (r := (· > ·)) (fun _ _ ↦ not_lt_zero) (fun i ↦ (hα i).wf) hι.wf⟩ end DFinsupp @@ -199,10 +200,9 @@ instance Pi.Lex.wellFoundedLT [LinearOrder ι] [Finite ι] [∀ i, LT (α i)] [hwf : ∀ i, WellFoundedLT (α i)] : WellFoundedLT (Lex (∀ i, α i)) := ⟨Pi.Lex.wellFounded (· < ·) fun i => (hwf i).1⟩ -set_option backward.isDefEq.respectTransparency false in instance Pi.Colex.wellFoundedLT [LinearOrder ι] [Finite ι] [∀ i, LT (α i)] - [∀ i, WellFoundedLT (α i)] : WellFoundedLT (Colex (∀ i, α i)) := - Pi.Lex.wellFoundedLT (ι := ιᵒᵈ) + [hwf : ∀ i, WellFoundedLT (α i)] : WellFoundedLT (Colex (∀ i, α i)) := + ⟨Pi.Lex.wellFounded (· > ·) fun i => (hwf i).1⟩ instance Function.Lex.wellFoundedLT {α} [LinearOrder ι] [Finite ι] [LT α] [WellFoundedLT α] : WellFoundedLT (Lex (ι → α)) := @@ -217,10 +217,9 @@ instance DFinsupp.Lex.wellFoundedLT_of_finite [LinearOrder ι] [Finite ι] [∀ [∀ i, LT (α i)] [hwf : ∀ i, WellFoundedLT (α i)] : WellFoundedLT (Lex (Π₀ i, α i)) := ⟨DFinsupp.Lex.wellFounded_of_finite (· < ·) fun i => (hwf i).1⟩ -set_option backward.isDefEq.respectTransparency false in instance DFinsupp.Colex.wellFoundedLT_of_finite [LinearOrder ι] [Finite ι] [∀ i, Zero (α i)] [∀ i, LT (α i)] [hwf : ∀ i, WellFoundedLT (α i)] : WellFoundedLT (Colex (Π₀ i, α i)) := - DFinsupp.Lex.wellFoundedLT_of_finite (ι := ιᵒᵈ) + ⟨DFinsupp.Lex.wellFounded_of_finite (· > ·) fun i => (hwf i).1⟩ protected theorem DFinsupp.wellFoundedLT [∀ i, Zero (α i)] [∀ i, Preorder (α i)] [∀ i, WellFoundedLT (α i)] (hbot : ∀ ⦃i⦄ ⦃a : α i⦄, ¬a < 0) : WellFoundedLT (Π₀ i, α i) := diff --git a/mathlib4/Mathlib/Data/EReal/Operations.lean b/mathlib4/Mathlib/Data/EReal/Operations.lean index 39e54edd8..0a6a966e3 100644 --- a/mathlib4/Mathlib/Data/EReal/Operations.lean +++ b/mathlib4/Mathlib/Data/EReal/Operations.lean @@ -292,11 +292,12 @@ theorem lt_neg_comm {a b : EReal} : a < -b ↔ b < -a := by protected theorem lt_neg_of_lt_neg {a b : EReal} (h : a < -b) : b < -a := lt_neg_comm.mp h /-- Negation as an order reversing isomorphism on `EReal`. -/ -def negOrderIso : EReal ≃o ERealᵒᵈ := - { Equiv.neg EReal with - toFun := fun x => OrderDual.toDual (-x) - invFun := fun x => -OrderDual.ofDual x - map_rel_iff' := neg_le_neg_iff } +def negOrderIso : EReal ≃o ERealᵒᵈ where + toFun x := OrderDual.toDual (-x) + invFun x := -OrderDual.ofDual x + left_inv _ := neg_neg _ + right_inv _ := congrArg OrderDual.toDual (neg_neg _) + map_rel_iff' := neg_le_neg_iff lemma neg_add {x y : EReal} (h1 : x ≠ ⊥ ∨ y ≠ ⊤) (h2 : x ≠ ⊤ ∨ y ≠ ⊥) : -(x + y) = -x - y := by diff --git a/mathlib4/Mathlib/Data/Fin/Tuple/Basic.lean b/mathlib4/Mathlib/Data/Fin/Tuple/Basic.lean index 217f3978b..7e489a927 100644 --- a/mathlib4/Mathlib/Data/Fin/Tuple/Basic.lean +++ b/mathlib4/Mathlib/Data/Fin/Tuple/Basic.lean @@ -280,8 +280,9 @@ theorem le_cons [∀ i, Preorder (α i)] {x : α 0} {q : ∀ i, α i} {p : ∀ i forall_fin_succ.trans <| and_congr Iff.rfl <| forall_congr' fun j ↦ by simp [tail] theorem cons_le [∀ i, Preorder (α i)] {x : α 0} {q : ∀ i, α i} {p : ∀ i : Fin n, α i.succ} : - cons x p ≤ q ↔ x ≤ q 0 ∧ p ≤ tail q := - @le_cons _ (fun i ↦ (α i)ᵒᵈ) _ x q p + cons x p ≤ q ↔ x ≤ q 0 ∧ p ≤ tail q := by + unsealing_newtype OrderDual => + exact @le_cons _ (fun i ↦ (α i)ᵒᵈ) _ x q p theorem cons_le_cons [∀ i, Preorder (α i)] {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ} : cons x₀ x ≤ cons y₀ y ↔ x₀ ≤ y₀ ∧ x ≤ y := diff --git a/mathlib4/Mathlib/Data/Finset/Lattice/Fold.lean b/mathlib4/Mathlib/Data/Finset/Lattice/Fold.lean index 783cde945..8ae4f28fb 100644 --- a/mathlib4/Mathlib/Data/Finset/Lattice/Fold.lean +++ b/mathlib4/Mathlib/Data/Finset/Lattice/Fold.lean @@ -162,7 +162,7 @@ theorem sup_mono (h : s₁ ⊆ s₂) : s₁.sup f ≤ s₂.sup f := theorem monotone_sup (f : β → α) : Monotone fun s : Finset β => s.sup f := fun _ _ h => sup_mono h theorem antitone_inf {α} [SemilatticeInf α] [OrderTop α] (f : β → α) : - Antitone fun s : Finset β => s.inf f := monotone_sup (α := αᵒᵈ) f + Antitone fun s : Finset β => s.inf f := fun _ _ h => inf_mono h @[to_dual] protected theorem sup_comm (s : Finset β) (t : Finset γ) (f : β → γ → α) : @@ -345,13 +345,13 @@ theorem exists_sup_eq_iSup [CompleteLattice β] [WellFoundedGT β] (f : α → @[to_dual (attr := simp)] theorem toDual_sup [SemilatticeSup α] [OrderBot α] (s : Finset β) (f : β → α) : - toDual (s.sup f) = s.inf (toDual ∘ f) := - rfl + toDual (s.sup f) = s.inf (toDual ∘ f) := by + unsealing_newtype OrderDual => rfl @[to_dual (attr := simp)] theorem ofDual_sup [SemilatticeInf α] [OrderTop α] (s : Finset β) (f : β → αᵒᵈ) : - ofDual (s.sup f) = s.inf (ofDual ∘ f) := - rfl + ofDual (s.sup f) = s.inf (ofDual ∘ f) := by + unsealing_newtype OrderDual => rfl section DistribLattice @@ -409,24 +409,29 @@ theorem inf_sdiff_right (hs : s.Nonempty) (f : ι → α) (a : α) : | cons _ _ _ _ ih => rw [inf_cons, inf_cons, ih, inf_sdiff] theorem inf_himp_right (s : Finset ι) (f : ι → α) (a : α) : - (s.inf fun b => f b ⇨ a) = s.sup f ⇨ a := - @sup_sdiff_left αᵒᵈ _ _ _ _ _ + (s.inf fun b => f b ⇨ a) = s.sup f ⇨ a := by + unsealing_newtype OrderDual => + exact @sup_sdiff_left αᵒᵈ _ _ _ _ _ theorem sup_himp_right (hs : s.Nonempty) (f : ι → α) (a : α) : - (s.sup fun b => f b ⇨ a) = s.inf f ⇨ a := - @inf_sdiff_left αᵒᵈ _ _ _ hs _ _ + (s.sup fun b => f b ⇨ a) = s.inf f ⇨ a := by + unsealing_newtype OrderDual => + exact @inf_sdiff_left αᵒᵈ _ _ _ hs _ _ theorem sup_himp_left (hs : s.Nonempty) (f : ι → α) (a : α) : - (s.sup fun b => a ⇨ f b) = a ⇨ s.sup f := - @inf_sdiff_right αᵒᵈ _ _ _ hs _ _ + (s.sup fun b => a ⇨ f b) = a ⇨ s.sup f := by + unsealing_newtype OrderDual => + exact @inf_sdiff_right αᵒᵈ _ _ _ hs _ _ @[simp] -protected theorem compl_sup (s : Finset ι) (f : ι → α) : (s.sup f)ᶜ = s.inf fun i => (f i)ᶜ := - map_finset_sup (OrderIso.compl α) _ _ +protected theorem compl_sup (s : Finset ι) (f : ι → α) : (s.sup f)ᶜ = s.inf fun i => (f i)ᶜ := by + unsealing_newtype OrderDual => + exact map_finset_sup (OrderIso.compl α) _ _ @[simp] -protected theorem compl_inf (s : Finset ι) (f : ι → α) : (s.inf f)ᶜ = s.sup fun i => (f i)ᶜ := - map_finset_inf (OrderIso.compl α) _ _ +protected theorem compl_inf (s : Finset ι) (f : ι → α) : (s.inf f)ᶜ = s.sup fun i => (f i)ᶜ := by + unsealing_newtype OrderDual => + exact map_finset_inf (OrderIso.compl α) _ _ end BooleanAlgebra @@ -706,13 +711,13 @@ protected theorem sup'_apply {C : β → Type*} [∀ b : β, SemilatticeSup (C b @[to_dual (attr := simp)] theorem toDual_sup' [SemilatticeSup α] {s : Finset ι} (hs : s.Nonempty) (f : ι → α) : - toDual (s.sup' hs f) = s.inf' hs (toDual ∘ f) := - rfl + toDual (s.sup' hs f) = s.inf' hs (toDual ∘ f) := by + unsealing_newtype OrderDual => rfl @[to_dual (attr := simp)] theorem ofDual_sup' [SemilatticeInf α] {s : Finset ι} (hs : s.Nonempty) (f : ι → αᵒᵈ) : - ofDual (s.sup' hs f) = s.inf' hs (ofDual ∘ f) := - rfl + ofDual (s.sup' hs f) = s.inf' hs (ofDual ∘ f) := by + unsealing_newtype OrderDual => rfl section DistribLattice variable [DistribLattice α] {s : Finset ι} (hs : s.Nonempty) diff --git a/mathlib4/Mathlib/Data/Finset/Lattice/Pi.lean b/mathlib4/Mathlib/Data/Finset/Lattice/Pi.lean index 61ee351ef..a3e44a686 100644 --- a/mathlib4/Mathlib/Data/Finset/Lattice/Pi.lean +++ b/mathlib4/Mathlib/Data/Finset/Lattice/Pi.lean @@ -53,7 +53,9 @@ theorem inf_sup {κ : ι → Type*} (s : Finset ι) (t : ∀ i, Finset (κ i)) ( · simpa [ne_of_mem_of_not_mem hj hi] using! hg _ _ theorem sup_inf {κ : ι → Type*} (s : Finset ι) (t : ∀ i, Finset (κ i)) (f : ∀ i, κ i → α) : - (s.sup fun i => (t i).inf (f i)) = (s.pi t).inf fun g => s.attach.sup fun i => f _ <| g _ i.2 := - @inf_sup αᵒᵈ _ _ _ _ _ _ _ _ + (s.sup fun i => (t i).inf (f i)) = + (s.pi t).inf fun g => s.attach.sup fun i => f _ <| g _ i.2 := by + unsealing_newtype OrderDual => + exact @inf_sup αᵒᵈ _ _ _ _ _ _ _ _ end Finset diff --git a/mathlib4/Mathlib/Data/Finset/Lattice/Union.lean b/mathlib4/Mathlib/Data/Finset/Lattice/Union.lean index ecc7cdd1e..e6f9cb2bc 100644 --- a/mathlib4/Mathlib/Data/Finset/Lattice/Union.lean +++ b/mathlib4/Mathlib/Data/Finset/Lattice/Union.lean @@ -43,8 +43,9 @@ section Inf variable [SemilatticeInf α] [OrderTop α] @[simp, grind =] theorem inf_biUnion [DecidableEq β] (s : Finset γ) (t : γ → Finset β) : - (s.biUnion t).inf f = s.inf fun x => (t x).inf f := - @sup_biUnion αᵒᵈ _ _ _ _ _ _ _ _ + (s.biUnion t).inf f = s.inf fun x => (t x).inf f := by + unsealing_newtype OrderDual => + exact @sup_biUnion αᵒᵈ _ _ _ _ _ _ _ _ end Inf @@ -69,8 +70,10 @@ variable {s : Finset β} (H : s.Nonempty) (f : β → α) theorem inf'_biUnion [DecidableEq β] {s : Finset γ} (Hs : s.Nonempty) {t : γ → Finset β} (Ht : ∀ b, (t b).Nonempty) : - (s.biUnion t).inf' (Hs.biUnion fun b _ => Ht b) f = s.inf' Hs (fun b => (t b).inf' (Ht b) f) := - sup'_biUnion (α := αᵒᵈ) _ Hs Ht + (s.biUnion t).inf' (Hs.biUnion fun b _ => Ht b) f = + s.inf' Hs (fun b => (t b).inf' (Ht b) f) := by + unsealing_newtype OrderDual => + exact sup'_biUnion (α := αᵒᵈ) _ Hs Ht end Inf' diff --git a/mathlib4/Mathlib/Data/Finset/Max.lean b/mathlib4/Mathlib/Data/Finset/Max.lean index a6735d1f9..eb79368e6 100644 --- a/mathlib4/Mathlib/Data/Finset/Max.lean +++ b/mathlib4/Mathlib/Data/Finset/Max.lean @@ -192,13 +192,15 @@ theorem max'_union {s₁ s₂ : Finset α} (h₁ : s₁.Nonempty) (h₂ : s₂.N @[to_dual] theorem map_ofDual_max (s : Finset αᵒᵈ) : s.max.map ofDual = (s.image ofDual).min := by - rw [min_eq_inf_withTop, inf_image] - exact congr_fun WithTop.map_id _ + unsealing_newtype OrderDual => + rw [min_eq_inf_withTop, inf_image] + exact congr_fun WithTop.map_id _ @[to_dual] theorem map_toDual_max (s : Finset α) : s.max.map toDual = (s.image toDual).min := by - rw [min_eq_inf_withTop, inf_image] - exact congr_fun WithTop.map_id _ + unsealing_newtype OrderDual => + rw [min_eq_inf_withTop, inf_image] + exact congr_fun WithTop.map_id _ @[to_dual] theorem ofDual_max' {s : Finset αᵒᵈ} (hs : s.Nonempty) : diff --git a/mathlib4/Mathlib/Data/Finset/NAry.lean b/mathlib4/Mathlib/Data/Finset/NAry.lean index ecb42ef55..ea6238e18 100644 --- a/mathlib4/Mathlib/Data/Finset/NAry.lean +++ b/mathlib4/Mathlib/Data/Finset/NAry.lean @@ -549,28 +549,33 @@ lemma le_inf'_image₂ {g : γ → δ} {a : δ} (h : (image₂ f s t).Nonempty) lemma inf'_image₂_left (g : γ → δ) (h : (image₂ f s t).Nonempty) : inf' (image₂ f s t) h g = - inf' s h.of_image₂_left fun x ↦ inf' t h.of_image₂_right (g <| f x ·) := - sup'_image₂_left (δ := δᵒᵈ) g h + inf' s h.of_image₂_left fun x ↦ inf' t h.of_image₂_right (g <| f x ·) := by + unsealing_newtype OrderDual => + exact sup'_image₂_left (δ := δᵒᵈ) g h lemma inf'_image₂_right (g : γ → δ) (h : (image₂ f s t).Nonempty) : inf' (image₂ f s t) h g = - inf' t h.of_image₂_right fun y ↦ inf' s h.of_image₂_left (g <| f · y) := - sup'_image₂_right (δ := δᵒᵈ) g h + inf' t h.of_image₂_right fun y ↦ inf' s h.of_image₂_left (g <| f · y) := by + unsealing_newtype OrderDual => + exact sup'_image₂_right (δ := δᵒᵈ) g h variable [OrderTop δ] @[simp (default + 1)] -- otherwise `simp` doesn't use `forall_mem_image₂` lemma le_inf_image₂ {g : γ → δ} {a : δ} : - a ≤ inf (image₂ f s t) g ↔ ∀ x ∈ s, ∀ y ∈ t, a ≤ g (f x y) := - sup_image₂_le (δ := δᵒᵈ) + a ≤ inf (image₂ f s t) g ↔ ∀ x ∈ s, ∀ y ∈ t, a ≤ g (f x y) := by + unsealing_newtype OrderDual => + exact sup_image₂_le (δ := δᵒᵈ) variable (s t) -lemma inf_image₂_left (g : γ → δ) : inf (image₂ f s t) g = inf s fun x ↦ inf t (g ∘ f x) := - sup_image₂_left (δ := δᵒᵈ) .. +lemma inf_image₂_left (g : γ → δ) : inf (image₂ f s t) g = inf s fun x ↦ inf t (g ∘ f x) := by + unsealing_newtype OrderDual => + exact sup_image₂_left (δ := δᵒᵈ) .. -lemma inf_image₂_right (g : γ → δ) : inf (image₂ f s t) g = inf t fun y ↦ inf s (g <| f · y) := - sup_image₂_right (δ := δᵒᵈ) .. +lemma inf_image₂_right (g : γ → δ) : inf (image₂ f s t) g = inf t fun y ↦ inf s (g <| f · y) := by + unsealing_newtype OrderDual => + exact sup_image₂_right (δ := δᵒᵈ) .. end SemilatticeInf diff --git a/mathlib4/Mathlib/Data/Finset/PiInduction.lean b/mathlib4/Mathlib/Data/Finset/PiInduction.lean index 42e846a75..66e6b3026 100644 --- a/mathlib4/Mathlib/Data/Finset/PiInduction.lean +++ b/mathlib4/Mathlib/Data/Finset/PiInduction.lean @@ -106,7 +106,8 @@ theorem induction_on_pi_min [∀ i, LinearOrder (α i)] {p : (∀ i, Finset (α (step : ∀ (g : ∀ i, Finset (α i)) (i : ι) (x : α i), (∀ y ∈ g i, x < y) → p g → p (update g i (insert x (g i)))) : - p f := - induction_on_pi_max (α := fun i ↦ (α i)ᵒᵈ) _ h0 step + p f := by + unsealing_newtype OrderDual => + exact induction_on_pi_max (α := fun i ↦ (α i)ᵒᵈ) _ h0 step end Finset diff --git a/mathlib4/Mathlib/Data/Finset/Sigma.lean b/mathlib4/Mathlib/Data/Finset/Sigma.lean index 90c97fec4..4fc0608ca 100644 --- a/mathlib4/Mathlib/Data/Finset/Sigma.lean +++ b/mathlib4/Mathlib/Data/Finset/Sigma.lean @@ -111,8 +111,9 @@ theorem sup_sigma [SemilatticeSup β] [OrderBot β] : le_sup <| mem_sigma.2 ⟨hi, ha⟩⟩ theorem inf_sigma [SemilatticeInf β] [OrderTop β] : - (s.sigma t).inf f = s.inf fun i => (t i).inf fun b => f ⟨i, b⟩ := - @sup_sigma _ _ βᵒᵈ _ _ _ _ _ + (s.sigma t).inf f = s.inf fun i => (t i).inf fun b => f ⟨i, b⟩ := by + unsealing_newtype OrderDual => + exact @sup_sigma _ _ βᵒᵈ _ _ _ _ _ theorem _root_.biSup_finsetSigma [CompleteLattice β] (s : Finset ι) (t : ∀ i, Finset (α i)) (f : Sigma α → β) : ⨆ ij ∈ s.sigma t, f ij = ⨆ (i ∈ s) (j ∈ t i), f ⟨i, j⟩ := by @@ -123,8 +124,9 @@ theorem _root_.biSup_finsetSigma' [CompleteLattice β] (s : Finset ι) (t : ∀ Eq.symm (biSup_finsetSigma _ _ _) theorem _root_.biInf_finsetSigma [CompleteLattice β] (s : Finset ι) (t : ∀ i, Finset (α i)) - (f : Sigma α → β) : ⨅ ij ∈ s.sigma t, f ij = ⨅ (i ∈ s) (j ∈ t i), f ⟨i, j⟩ := - biSup_finsetSigma (β := βᵒᵈ) _ _ _ + (f : Sigma α → β) : ⨅ ij ∈ s.sigma t, f ij = ⨅ (i ∈ s) (j ∈ t i), f ⟨i, j⟩ := by + unsealing_newtype OrderDual => + exact biSup_finsetSigma (β := βᵒᵈ) _ _ _ theorem _root_.biInf_finsetSigma' [CompleteLattice β] (s : Finset ι) (t : ∀ i, Finset (α i)) (f : ∀ i, α i → β) : ⨅ (i ∈ s) (j ∈ t i), f i j = ⨅ ij ∈ s.sigma t, f ij.fst ij.snd := diff --git a/mathlib4/Mathlib/Data/Finsupp/Lex.lean b/mathlib4/Mathlib/Data/Finsupp/Lex.lean index 9780189ab..0c9c33f24 100644 --- a/mathlib4/Mathlib/Data/Finsupp/Lex.lean +++ b/mathlib4/Mathlib/Data/Finsupp/Lex.lean @@ -82,7 +82,7 @@ theorem Lex.lt_iff_of_unique [Unique α] [LT N] [Preorder α] {x y : Lex (α → set_option backward.isDefEq.respectTransparency false in theorem Colex.lt_iff_of_unique [Unique α] [LT N] [Preorder α] {x y : Colex (α →₀ N)} : x < y ↔ x default < y default := - Lex.lt_iff_of_unique (α := αᵒᵈ) + lex_iff_of_unique variable [LinearOrder α] @@ -90,8 +90,9 @@ instance Lex.isStrictOrder [PartialOrder N] : IsStrictOrder (Lex (α →₀ N)) irrefl _ := lt_irrefl (α := Lex (α → N)) _ trans _ _ _ := lt_trans (α := Lex (α → N)) -instance Colex.isStrictOrder [PartialOrder N] : IsStrictOrder (Colex (α →₀ N)) (· < ·) := - Lex.isStrictOrder (α := αᵒᵈ) +instance Colex.isStrictOrder [PartialOrder N] : IsStrictOrder (Colex (α →₀ N)) (· < ·) where + irrefl _ := lt_irrefl (α := Colex (α → N)) _ + trans _ _ _ := lt_trans (α := Colex (α → N)) /-- The partial order on `Finsupp`s obtained by the lexicographic ordering. See `Finsupp.Lex.linearOrder` for a proof that this partial order is in fact linear. -/ @@ -128,7 +129,7 @@ theorem Lex.le_iff_of_unique [Unique α] [PartialOrder N] {x y : Lex (α →₀ set_option backward.isDefEq.respectTransparency false in theorem Colex.le_iff_of_unique [Unique α] [PartialOrder N] {x y : Colex (α →₀ N)} : x ≤ y ↔ x default ≤ y default := - Lex.le_iff_of_unique (α := αᵒᵈ) + Pi.colex_le_iff_of_unique theorem Lex.single_strictAnti : StrictAnti fun (a : α) ↦ toLex (single a 1) := by intro a b h @@ -140,8 +141,9 @@ theorem Lex.single_strictAnti : StrictAnti fun (a : α) ↦ toLex (single a 1) : simp only [Finsupp.single_eq_of_ne hd.ne, Finsupp.single_eq_of_ne (hd.trans h).ne] · simp [h.ne'] -theorem Colex.single_strictMono : StrictMono fun (a : α) ↦ toColex (single a 1) := - fun _ _ h ↦ Lex.single_strictAnti (α := αᵒᵈ) h +theorem Colex.single_strictMono : StrictMono fun (a : α) ↦ toColex (single a 1) := by + unsealing_newtype OrderDual => + exact fun _ _ h ↦ Lex.single_strictAnti (α := αᵒᵈ) h theorem Lex.single_lt_iff {a b : α} : toLex (single b 1) < toLex (single a 1) ↔ a < b := Lex.single_strictAnti.lt_iff_gt @@ -160,8 +162,9 @@ variable [PartialOrder N] theorem toLex_monotone : Monotone (@toLex (α →₀ N)) := fun a b h ↦ DFinsupp.toLex_monotone (id h : ∀ i, (toDFinsupp a) i ≤ (toDFinsupp b) i) -theorem toColex_monotone : Monotone (@toColex (α →₀ N)) := - toLex_monotone (α := αᵒᵈ) +theorem toColex_monotone : Monotone (@toColex (α →₀ N)) := by + unsealing_newtype OrderDual => + exact toLex_monotone (α := αᵒᵈ) end NHasZero @@ -185,7 +188,7 @@ instance Lex.addLeftStrictMono : AddLeftStrictMono (Lex (α →₀ N)) := ⟨fun _ _ _ ⟨a, lta, ha⟩ ↦ ⟨a, fun j ja ↦ congr_arg _ (lta j ja), add_lt_add_right ha _⟩⟩ instance Colex.addLeftStrictMono : AddLeftStrictMono (Colex (α →₀ N)) := - Lex.addLeftStrictMono (α := αᵒᵈ) + ⟨fun _ _ _ ⟨a, lta, ha⟩ ↦ ⟨a, fun j ja ↦ congr_arg _ (lta j ja), add_lt_add_right ha _⟩⟩ instance Lex.addLeftMono : AddLeftMono (Lex (α →₀ N)) := addLeftMono_of_addLeftStrictMono _ @@ -203,8 +206,9 @@ set_option backward.isDefEq.respectTransparency false in instance Lex.addRightStrictMono : AddRightStrictMono (Lex (α →₀ N)) := ⟨fun f _ _ ⟨a, lta, ha⟩ ↦ ⟨a, fun j ja ↦ congr($(lta j ja) + f j), add_lt_add_left ha _⟩⟩ +set_option backward.isDefEq.respectTransparency false in instance Colex.addRightStrictMono : AddRightStrictMono (Colex (α →₀ N)) := - Lex.addRightStrictMono (α := αᵒᵈ) + ⟨fun f _ _ ⟨a, lta, ha⟩ ↦ ⟨a, fun j ja ↦ congr($(lta j ja) + f j), add_lt_add_left ha _⟩⟩ instance Lex.addRightMono : AddRightMono (Lex (α →₀ N)) := addRightMono_of_addRightStrictMono _ @@ -246,8 +250,9 @@ instance Lex.isOrderedCancelAddMonoid instance Colex.isOrderedCancelAddMonoid [AddCommMonoid N] [PartialOrder N] [IsOrderedCancelAddMonoid N] : - IsOrderedCancelAddMonoid (Colex (α →₀ N)) := - Lex.isOrderedCancelAddMonoid (α := αᵒᵈ) + IsOrderedCancelAddMonoid (Colex (α →₀ N)) := by + unsealing_newtype OrderDual => + exact Lex.isOrderedCancelAddMonoid (α := αᵒᵈ) end OrderedAddMonoid diff --git a/mathlib4/Mathlib/Data/Finsupp/WellFounded.lean b/mathlib4/Mathlib/Data/Finsupp/WellFounded.lean index 4945e7791..c337c0929 100644 --- a/mathlib4/Mathlib/Data/Finsupp/WellFounded.lean +++ b/mathlib4/Mathlib/Data/Finsupp/WellFounded.lean @@ -57,10 +57,12 @@ instance Lex.wellFoundedLT {α N} [LT α] [@Std.Trichotomous α (· < ·)] [hα [hN : WellFoundedLT N] : WellFoundedLT (Lex (α →₀ N)) := ⟨Lex.wellFounded' (fun _ => not_lt_zero) hN.wf hα.wf⟩ -instance Colex.wellFoundedLT {α N} [LT α] [@Std.Trichotomous α (· < ·)] [WellFoundedLT α] +instance Colex.wellFoundedLT {α N} [LT α] [@Std.Trichotomous α (· < ·)] [hα : WellFoundedLT α] [AddMonoid N] [PartialOrder N] [IsBotZeroClass N] - [WellFoundedLT N] : WellFoundedLT (Colex (α →₀ N)) := - Lex.wellFoundedLT (α := αᵒᵈ) + [hN : WellFoundedLT N] : WellFoundedLT (Colex (α →₀ N)) := + haveI : @Std.Trichotomous α (· > ·) := + ⟨fun a b h₁ h₂ ↦ Std.Trichotomous.trichotomous (r := (· < ·)) a b h₂ h₁⟩ + ⟨Lex.wellFounded' (r := (· > ·)) (fun _ => not_lt_zero) hN.wf hα.wf⟩ variable (r) @@ -73,8 +75,8 @@ theorem Lex.wellFoundedLT_of_finite [LinearOrder α] [Finite α] [LT N] ⟨Finsupp.Lex.wellFounded_of_finite (· < ·) hwf.1⟩ theorem Colex.wellFoundedLT_of_finite [LinearOrder α] [Finite α] [LT N] - [WellFoundedLT N] : WellFoundedLT (Colex (α →₀ N)) := - Lex.wellFoundedLT_of_finite (α := αᵒᵈ) + [hwf : WellFoundedLT N] : WellFoundedLT (Colex (α →₀ N)) := + ⟨Finsupp.Lex.wellFounded_of_finite (· > ·) hwf.1⟩ protected theorem wellFoundedLT [Preorder N] [WellFoundedLT N] (hbot : ∀ n : N, ¬n < 0) : WellFoundedLT (α →₀ N) := diff --git a/mathlib4/Mathlib/Data/Fintype/Card.lean b/mathlib4/Mathlib/Data/Fintype/Card.lean index a5807df22..04bfa51b0 100644 --- a/mathlib4/Mathlib/Data/Fintype/Card.lean +++ b/mathlib4/Mathlib/Data/Fintype/Card.lean @@ -192,7 +192,7 @@ theorem Fintype.card_plift (α : Type*) [Fintype α] : Fintype.card (PLift α) = @[simp] theorem Fintype.card_orderDual (α : Type*) [Fintype α] : Fintype.card αᵒᵈ = Fintype.card α := - rfl + Multiset.card_map _ _ @[simp] theorem Fintype.card_lex (α : Type*) [Fintype α] : Fintype.card (Lex α) = Fintype.card α := diff --git a/mathlib4/Mathlib/Data/Fintype/Defs.lean b/mathlib4/Mathlib/Data/Fintype/Defs.lean index d340b7661..71e82fc23 100644 --- a/mathlib4/Mathlib/Data/Fintype/Defs.lean +++ b/mathlib4/Mathlib/Data/Fintype/Defs.lean @@ -281,11 +281,13 @@ instance Bool.fintype : Fintype Bool := instance Ordering.fintype : Fintype Ordering := ⟨⟨{.lt, .eq, .gt}, by simp⟩, fun x => by cases x <;> simp⟩ -instance OrderDual.fintype (α : Type*) [Fintype α] : Fintype αᵒᵈ := - ‹Fintype α› +instance OrderDual.fintype (α : Type*) [Fintype α] : Fintype αᵒᵈ where + elems := ⟨(Finset.univ : Finset α).1.map OrderDual.mk, + Multiset.Nodup.map OrderDual.toDual.injective (Finset.univ : Finset α).2⟩ + complete a := Multiset.mem_map.2 ⟨a.ofDual', Finset.mem_univ_val _, rfl⟩ instance OrderDual.finite (α : Type*) [Finite α] : Finite αᵒᵈ := - ‹Finite α› + Finite.of_equiv α OrderDual.toDual instance Lex.fintype (α : Type*) [Fintype α] : Fintype (Lex α) := ‹Fintype α› diff --git a/mathlib4/Mathlib/Data/Fintype/Lattice.lean b/mathlib4/Mathlib/Data/Fintype/Lattice.lean index 06cad265e..8c8aed9cb 100644 --- a/mathlib4/Mathlib/Data/Fintype/Lattice.lean +++ b/mathlib4/Mathlib/Data/Fintype/Lattice.lean @@ -27,8 +27,9 @@ theorem sup_univ_eq_iSup [CompleteLattice β] (f : α → β) : Finset.univ.sup (sup_eq_iSup _ f).trans <| congr_arg _ <| funext fun _ => iSup_pos (mem_univ _) /-- A special case of `Finset.inf_eq_iInf` that omits the useless `x ∈ univ` binder. -/ -theorem inf_univ_eq_iInf [CompleteLattice β] (f : α → β) : Finset.univ.inf f = iInf f := - @sup_univ_eq_iSup _ βᵒᵈ _ _ (f : α → βᵒᵈ) +theorem inf_univ_eq_iInf [CompleteLattice β] (f : α → β) : Finset.univ.inf f = iInf f := by + unsealing_newtype OrderDual => + exact @sup_univ_eq_iSup _ βᵒᵈ _ _ (f : α → βᵒᵈ) @[simp] theorem fold_inf_univ [SemilatticeInf α] [OrderBot α] (a : α) : @@ -38,8 +39,9 @@ theorem fold_inf_univ [SemilatticeInf α] [OrderBot α] (a : α) : @[simp] theorem fold_sup_univ [SemilatticeSup α] [OrderTop α] (a : α) : - (Finset.univ.fold max a fun x => x) = ⊤ := - @fold_inf_univ αᵒᵈ _ _ _ _ + (Finset.univ.fold max a fun x => x) = ⊤ := by + unsealing_newtype OrderDual => + exact @fold_inf_univ αᵒᵈ ‹Fintype α› _ _ _ lemma mem_inf [DecidableEq α] {s : Finset ι} {f : ι → Finset α} {a : α} : a ∈ s.inf f ↔ ∀ i ∈ s, a ∈ f i := by induction s using Finset.cons_induction <;> simp [*] diff --git a/mathlib4/Mathlib/Data/Fintype/Order.lean b/mathlib4/Mathlib/Data/Fintype/Order.lean index e2b5cfaec..6b661cfbc 100644 --- a/mathlib4/Mathlib/Data/Fintype/Order.lean +++ b/mathlib4/Mathlib/Data/Fintype/Order.lean @@ -286,7 +286,7 @@ lemma le_ciSup (f : ι → α) (i : ι) : f i ≤ ⨆ j, f j := le_ciSup_of_le i le_rfl lemma ciInf_le (f : ι → α) (i : ι) : ⨅ j, f j ≤ f i := - le_ciSup (α := αᵒᵈ) f i + ciInf_le_of_le i le_rfl lemma ciSup_sup [Nonempty ι] {f : ι → α} {a : α} : (⨆ i, f i) ⊔ a = ⨆ i, f i ⊔ a := by @@ -295,8 +295,9 @@ lemma ciSup_sup [Nonempty ι] {f : ι → α} {a : α} : · exact le_ciSup_of_le (Classical.arbitrary ι) le_sup_right lemma ciInf_inf [Nonempty ι] {f : ι → α} {a : α} : - (⨅ i, f i) ⊓ a = ⨅ i, f i ⊓ a := - ciSup_sup (α := αᵒᵈ) .. + (⨅ i, f i) ⊓ a = ⨅ i, f i ⊓ a := by + unsealing_newtype OrderDual => + exact ciSup_sup (α := αᵒᵈ) .. lemma ciSup_prod (f : ι × ι' → α) : ⨆ a, f a = ⨆ i, ⨆ i', f (i, i') := @@ -304,7 +305,7 @@ lemma ciSup_prod (f : ι × ι' → α) : lemma ciInf_prod (f : ι × ι' → α) : ⨅ a, f a = ⨅ i, ⨅ i', f (i, i') := - ciSup_prod (α := αᵒᵈ) f + _root_.ciInf_prod (bddBelow_range f) end CCL @@ -323,34 +324,40 @@ lemma map_iSup_of_monotoneOn {s : Set α} {f : ι → α} {g : α → β} (hg : lemma map_iInf_of_monotoneOn {s : Set α} {f : ι → α} {g : α → β} (hg : MonotoneOn g s) (hs : ∀ i, f i ∈ s) : - g (⨅ i, f i) = ⨅ i, g (f i) := - map_iSup_of_monotoneOn (α := αᵒᵈ) (β := βᵒᵈ) (fun _ hi _ hj h ↦ hg hj hi h) hs + g (⨅ i, f i) = ⨅ i, g (f i) := by + unsealing_newtype OrderDual => + exact map_iSup_of_monotoneOn (α := αᵒᵈ) (β := βᵒᵈ) (fun _ hi _ hj h ↦ hg hj hi h) hs lemma map_iSup_of_antitoneOn {s : Set α} {f : ι → α} {g : α → β} (hg : AntitoneOn g s) (hs : ∀ i, f i ∈ s) : - g (⨆ i, f i) = ⨅ i, g (f i) := - map_iSup_of_monotoneOn (β := βᵒᵈ) hg hs + g (⨆ i, f i) = ⨅ i, g (f i) := by + unsealing_newtype OrderDual => + exact map_iSup_of_monotoneOn (β := βᵒᵈ) hg hs lemma map_iInf_of_antitoneOn {s : Set α} {f : ι → α} {g : α → β} (hg : AntitoneOn g s) (hs : ∀ i, f i ∈ s) : - g (⨅ i, f i) = ⨆ i, g (f i) := - map_iInf_of_monotoneOn (β := βᵒᵈ) hg hs + g (⨅ i, f i) = ⨆ i, g (f i) := by + unsealing_newtype OrderDual => + exact map_iInf_of_monotoneOn (β := βᵒᵈ) hg hs lemma map_iSup_of_monotone (f : ι → α) {g : α → β} (hg : Monotone g) : g (⨆ i, f i) = ⨆ i, g (f i) := map_iSup_of_monotoneOn (monotoneOn_univ.mpr hg) (fun i ↦ Set.mem_univ (f i)) lemma map_iInf_of_monotone (f : ι → α) {g : α → β} (hg : Monotone g) : - g (⨅ i, f i) = ⨅ i, g (f i) := - map_iSup_of_monotone (α := αᵒᵈ) (β := βᵒᵈ) f fun _ _ h ↦ hg h + g (⨅ i, f i) = ⨅ i, g (f i) := by + unsealing_newtype OrderDual => + exact map_iSup_of_monotone (α := αᵒᵈ) (β := βᵒᵈ) f fun _ _ h ↦ hg h lemma map_iSup_of_antitone (f : ι → α) {g : α → β} (hg : Antitone g) : - g (⨆ i, f i) = ⨅ i, g (f i) := - map_iSup_of_monotone (β := βᵒᵈ) f hg + g (⨆ i, f i) = ⨅ i, g (f i) := by + unsealing_newtype OrderDual => + exact map_iSup_of_monotone (β := βᵒᵈ) f hg lemma map_iInf_of_antitone (f : ι → α) {g : α → β} (hg : Antitone g) : - g (⨅ i, f i) = ⨆ i, g (f i) := - map_iInf_of_monotone (β := βᵒᵈ) f hg + g (⨅ i, f i) = ⨆ i, g (f i) := by + unsealing_newtype OrderDual => + exact map_iInf_of_monotone (β := βᵒᵈ) f hg @[to_dual ciInf_le_iff] theorem le_ciSup_iff {a : α} {f : ι → α} : a ≤ ⨆ i, f i ↔ ∃ x, a ≤ f x := by diff --git a/mathlib4/Mathlib/Data/Ordmap/Invariants.lean b/mathlib4/Mathlib/Data/Ordmap/Invariants.lean index f9b77f459..a8477cfc9 100644 --- a/mathlib4/Mathlib/Data/Ordmap/Invariants.lean +++ b/mathlib4/Mathlib/Data/Ordmap/Invariants.lean @@ -114,6 +114,20 @@ theorem Sized.size_eq_zero {t : Ordnode α} (ht : Sized t) : size t = 0 ↔ t = theorem Sized.pos {s l x r} (h : Sized (@node α s l x r)) : 0 < s := by rw [h.1]; apply Nat.le_add_left +/-! `map` -/ + +@[simp] +theorem map_id (t : Ordnode α) : t.map id = t := by + induction t <;> simp_all [map] + +@[simp] +theorem size_map {β} (f : α → β) (t : Ordnode α) : size (t.map f) = size t := by + cases t <;> rfl + +@[simp] +theorem sized_map {β} (f : α → β) (t : Ordnode α) : Sized (t.map f) ↔ Sized t := by + induction t <;> simp_all [map, Sized] + /-! `dual` -/ @@ -176,6 +190,13 @@ theorem Balanced.dual : ∀ {t : Ordnode α}, Balanced t → Balanced (dual t) | nil, _ => ⟨⟩ | node _ l _ r, ⟨b, bl, br⟩ => ⟨by rw [size_dual, size_dual]; exact b.symm, br.dual, bl.dual⟩ +theorem Balanced.dual_iff {t : Ordnode α} : Balanced (.dual t) ↔ Balanced t := + ⟨fun h => by rw [← dual_dual t]; exact h.dual, Balanced.dual⟩ + +@[simp] +theorem balanced_map {β} (f : α → β) (t : Ordnode α) : Balanced (t.map f) ↔ Balanced t := by + induction t <;> simp_all [map, Balanced] + /-! ### `rotate` and `balance` -/ @@ -541,14 +562,21 @@ theorem merge_node {ls ll lx lr rs rl rx rr} : set_option backward.isDefEq.respectTransparency false in -theorem dual_insert [LE α] [@Std.Total α (· ≤ ·)] [DecidableLE α] (x : α) : - ∀ t : Ordnode α, dual (Ordnode.insert x t) = @Ordnode.insert αᵒᵈ _ _ x (dual t) - | nil => rfl - | node _ l y r => by - have : @cmpLE αᵒᵈ _ _ x y = cmpLE y x := rfl - rw [Ordnode.insert, dual, Ordnode.insert, this, ← cmpLE_swap x y] - cases cmpLE x y <;> - simp [Ordering.swap, dual_balanceL, dual_balanceR, dual_insert] +theorem dual_insert [LE α] [@Std.Total α (· ≤ ·)] [DecidableLE α] (x : α) + (t : Ordnode α) : + (dual (Ordnode.insert x t)).map OrderDual.toDual = + Ordnode.insert (OrderDual.toDual x) ((dual t).map OrderDual.toDual) := by + unsealing_newtype OrderDual => + have map_toDual (t : Ordnode α) : t.map OrderDual.toDual = t := map_id t + simp only [map_toDual] + change dual (Ordnode.insert x t) = @Ordnode.insert αᵒᵈ _ _ x (dual t) + induction t with + | nil => rfl + | node s l y r ihl ihr => + have : @cmpLE αᵒᵈ _ _ x y = cmpLE y x := rfl + rw [Ordnode.insert, dual, Ordnode.insert, this, ← cmpLE_swap x y] + cases cmpLE x y <;> + simp [Ordering.swap, dual_balanceL, dual_balanceR, ihl, ihr] /-! ### `balance` properties -/ @@ -763,16 +791,18 @@ def Bounded : Ordnode α → WithBot α → WithTop α → Prop | nil, _, _ => True | node _ l x r, o₁, o₂ => Bounded l o₁ x ∧ Bounded r (↑x) o₂ -theorem Bounded.dual : - ∀ {t : Ordnode α} {o₁ o₂}, Bounded t o₁ o₂ → @Bounded αᵒᵈ _ (dual t) o₂ o₁ - | nil, o₁, o₂, h => by cases o₁ <;> cases o₂ <;> trivial - | node _ _ _ _, _, _, ⟨ol, Or⟩ => ⟨Or.dual, ol.dual⟩ - -set_option backward.isDefEq.respectTransparency false in theorem Bounded.dual_iff {t : Ordnode α} {o₁ o₂} : - Bounded t o₁ o₂ ↔ @Bounded αᵒᵈ _ (.dual t) o₂ o₁ := - ⟨Bounded.dual, fun h => by - have := Bounded.dual h; rwa [dual_dual, OrderDual.Preorder.dual_dual] at this⟩ + Bounded t o₁ o₂ ↔ + Bounded ((dual t).map OrderDual.toDual) (WithTop.toDual o₂) (WithBot.toDual o₁) := by + induction t generalizing o₁ o₂ with + | nil => cases o₁ <;> cases o₂ <;> rfl + | node s l x r ihl ihr => + change (_ ∧ _) ↔ (_ ∧ _) + exact (and_congr ihl ihr).trans and_comm + +theorem Bounded.dual {t : Ordnode α} {o₁ o₂} (h : Bounded t o₁ o₂) : + Bounded ((dual t).map OrderDual.toDual) (WithTop.toDual o₂) (WithBot.toDual o₁) := + Bounded.dual_iff.1 h theorem Bounded.weak_left : ∀ {t : Ordnode α} {o₁ o₂}, Bounded t o₁ o₂ → Bounded t ⊥ o₂ | nil, o₁, o₂, h => by cases o₂ <;> trivial diff --git a/mathlib4/Mathlib/Data/Ordmap/Ordset.lean b/mathlib4/Mathlib/Data/Ordmap/Ordset.lean index 0b0671f95..ff31c1532 100644 --- a/mathlib4/Mathlib/Data/Ordmap/Ordset.lean +++ b/mathlib4/Mathlib/Data/Ordmap/Ordset.lean @@ -97,24 +97,24 @@ theorem Valid'.node {s l} {x : α} {r o₁ o₂} (hl : Valid' o₁ l x) (hr : Va Valid' o₁ (@node α s l x r) o₂ := ⟨⟨hl.1, hr.1⟩, ⟨hs, hl.2, hr.2⟩, ⟨H, hl.3, hr.3⟩⟩ -set_option backward.isDefEq.respectTransparency false in -theorem Valid'.dual : ∀ {t : Ordnode α} {o₁ o₂}, Valid' o₁ t o₂ → @Valid' αᵒᵈ _ o₂ (dual t) o₁ - | .nil, _, _, h => valid'_nil h.1.dual - | .node _ l _ r, _, _, ⟨⟨ol, Or⟩, ⟨rfl, sl, sr⟩, ⟨b, bl, br⟩⟩ => - let ⟨ol', sl', bl'⟩ := Valid'.dual ⟨ol, sl, bl⟩ - let ⟨or', sr', br'⟩ := Valid'.dual ⟨Or, sr, br⟩ - ⟨⟨or', ol'⟩, ⟨by simp [size_dual, add_comm], sr', sl'⟩, - ⟨by rw [size_dual, size_dual]; exact b.symm, br', bl'⟩⟩ - -set_option backward.isDefEq.respectTransparency false in -theorem Valid'.dual_iff {t : Ordnode α} {o₁ o₂} : Valid' o₁ t o₂ ↔ @Valid' αᵒᵈ _ o₂ (.dual t) o₁ := - ⟨Valid'.dual, fun h => by - have := Valid'.dual h; rwa [dual_dual, OrderDual.Preorder.dual_dual] at this⟩ - -theorem Valid.dual {t : Ordnode α} : Valid t → @Valid αᵒᵈ _ (.dual t) := +theorem Valid'.dual_iff {t : Ordnode α} {o₁ o₂} : + Valid' o₁ t o₂ ↔ + Valid' (WithTop.toDual o₂) ((dual t).map OrderDual.toDual) (WithBot.toDual o₁) := by + constructor + · intro h + exact ⟨h.ord.dual, (sized_map ..).2 h.sz.dual, (balanced_map ..).2 h.bal.dual⟩ + · intro h + exact ⟨Bounded.dual_iff.2 h.ord, Sized.dual_iff.1 ((sized_map ..).1 h.sz), + Balanced.dual_iff.1 ((balanced_map ..).1 h.bal)⟩ + +theorem Valid'.dual {t : Ordnode α} {o₁ o₂} (h : Valid' o₁ t o₂) : + Valid' (WithTop.toDual o₂) ((dual t).map OrderDual.toDual) (WithBot.toDual o₁) := + Valid'.dual_iff.1 h + +theorem Valid.dual {t : Ordnode α} : Valid t → Valid ((dual t).map OrderDual.toDual) := Valid'.dual -theorem Valid.dual_iff {t : Ordnode α} : Valid t ↔ @Valid αᵒᵈ _ (.dual t) := +theorem Valid.dual_iff {t : Ordnode α} : Valid t ↔ Valid (t.dual.map OrderDual.toDual) := Valid'.dual_iff theorem Valid'.left {s l x r o₁ o₂} (H : Valid' o₁ (@Ordnode.node α s l x r) o₂) : Valid' o₁ l x := @@ -293,12 +293,17 @@ set_option backward.isDefEq.respectTransparency false in theorem Valid'.rotateR {l} {x : α} {r o₁ o₂} (hl : Valid' o₁ l x) (hr : Valid' x r o₂) (H1 : ¬size l + size r ≤ 1) (H2 : delta * size r < size l) (H3 : 2 * size l ≤ 9 * size r + 5 ∨ size l ≤ 3) : Valid' o₁ (@rotateR α l x r) o₂ := by - refine Valid'.dual_iff.2 ?_ - rw [dual_rotateR] - refine hr.dual.rotateL hl.dual ?_ ?_ ?_ - · rwa [size_dual, size_dual, add_comm] - · rwa [size_dual, size_dual] - · rwa [size_dual, size_dual] + unsealing_newtype OrderDual => + refine Valid'.dual_iff.2 ?_ + have map_toDual (t : Ordnode α) : t.map OrderDual.toDual = t := map_id t + rw [dual_rotateR, map_toDual] + have hl' := hl.dual + have hr' := hr.dual + simp only [map_toDual] at hl' hr' + refine hr'.rotateL hl' ?_ ?_ ?_ + · rwa [size_dual, size_dual, add_comm] + · rwa [size_dual, size_dual] + · rwa [size_dual, size_dual] theorem Valid'.balance'_aux {l} {x : α} {r o₁ o₂} (hl : Valid' o₁ l x) (hr : Valid' x r o₂) (H₁ : 2 * @size α r ≤ 9 * size l + 5 ∨ size r ≤ 3) @@ -362,17 +367,24 @@ set_option backward.isDefEq.respectTransparency false in theorem Valid'.balanceR_aux {l} {x : α} {r o₁ o₂} (hl : Valid' o₁ l x) (hr : Valid' x r o₂) (H₁ : size r = 0 → size l ≤ 1) (H₂ : 1 ≤ size r → 1 ≤ size l → size l ≤ delta * size r) (H₃ : 2 * @size α r ≤ 9 * size l + 5 ∨ size r ≤ 3) : Valid' o₁ (@balanceR α l x r) o₂ := by - rw [Valid'.dual_iff, dual_balanceR] - have := hr.dual.balanceL_aux hl.dual - rw [size_dual, size_dual] at this - exact this H₁ H₂ H₃ + unsealing_newtype OrderDual => + have map_toDual (t : Ordnode α) : t.map OrderDual.toDual = t := map_id t + rw [Valid'.dual_iff, dual_balanceR, map_toDual] + have := hr.dual.balanceL_aux hl.dual + simp only [map_toDual, size_dual] at this + exact this H₁ H₂ H₃ set_option backward.isDefEq.respectTransparency false in theorem Valid'.balanceR {l} {x : α} {r o₁ o₂} (hl : Valid' o₁ l x) (hr : Valid' x r o₂) (H : (∃ l', Raised (size l) l' ∧ BalancedSz l' (size r)) ∨ ∃ r', Raised r' (size r) ∧ BalancedSz (size l) r') : Valid' o₁ (@balanceR α l x r) o₂ := by - rw [Valid'.dual_iff, dual_balanceR]; exact hr.dual.balanceL hl.dual (balance_sz_dual H) + unsealing_newtype OrderDual => + have map_toDual (t : Ordnode α) : t.map OrderDual.toDual = t := map_id t + rw [Valid'.dual_iff, dual_balanceR, map_toDual] + have := hr.dual.balanceL hl.dual (by simpa only [size_map] using balance_sz_dual H) + simp only [map_toDual] at this + exact this theorem Valid'.eraseMax_aux {s l x r o₁ o₂} (H : Valid' o₁ (.node s l x r) o₂) : Valid' o₁ (@eraseMax α (.node' l x r)) ↑(findMax' x r) ∧ @@ -391,9 +403,15 @@ set_option backward.isDefEq.respectTransparency false in theorem Valid'.eraseMin_aux {s l} {x : α} {r o₁ o₂} (H : Valid' o₁ (.node s l x r) o₂) : Valid' ↑(findMin' l x) (@eraseMin α (.node' l x r)) o₂ ∧ size (.node' l x r) = size (eraseMin (.node' l x r)) + 1 := by - have := H.dual.eraseMax_aux - rwa [← dual_node', size_dual, ← dual_eraseMin, size_dual, ← Valid'.dual_iff, findMax'_dual] - at this + unsealing_newtype OrderDual => + have map_toDual (t : Ordnode α) : t.map OrderDual.toDual = t := map_id t + have H' := H.dual + simp only [map_toDual] at H' + have := H'.eraseMax_aux + rw [← dual_node', size_dual, ← dual_eraseMin, size_dual, findMax'_dual] at this + refine ⟨Valid'.dual_iff.2 ?_, this.2⟩ + simp only [map_toDual] + exact this.1 theorem eraseMin.valid : ∀ {t}, @Valid α _ t → Valid (eraseMin t) | nil, _ => valid_nil @@ -401,7 +419,10 @@ theorem eraseMin.valid : ∀ {t}, @Valid α _ t → Valid (eraseMin t) set_option backward.isDefEq.respectTransparency false in theorem eraseMax.valid {t} (h : @Valid α _ t) : Valid (eraseMax t) := by - rw [Valid.dual_iff, dual_eraseMax]; exact eraseMin.valid h.dual + unsealing_newtype OrderDual => + have map_toDual (t : Ordnode α) : t.map OrderDual.toDual = t := map_id t + rw [Valid.dual_iff, dual_eraseMax, map_toDual] + simpa only [map_toDual] using eraseMin.valid h.dual theorem Valid'.glue_aux {l r o₁ o₂} (hl : Valid' o₁ l o₂) (hr : Valid' o₁ r o₂) (sep : l.All fun x => r.All fun y => x < y) (bal : BalancedSz (size l) (size r)) : @@ -464,22 +485,29 @@ set_option backward.isDefEq.respectTransparency false in theorem Valid'.merge_aux {l r o₁ o₂} (hl : Valid' o₁ l o₂) (hr : Valid' o₁ r o₂) (sep : l.All fun x => r.All fun y => x < y) : Valid' o₁ (@merge α l r) o₂ ∧ size (merge l r) = size l + size r := by - induction l generalizing o₁ o₂ r with - | nil => exact ⟨hr, (zero_add _).symm⟩ - | node ls ll lx lr _ IHlr => ?_ - induction r generalizing o₁ o₂ with - | nil => exact ⟨hl, rfl⟩ - | node rs rl rx rr IHrl _ => ?_ - rw [merge_node]; split_ifs with h h_1 - · obtain ⟨v, e⟩ := IHrl (hl.of_lt hr.1.1.to_nil <| sep.imp fun x h => h.2.1) hr.left - (sep.imp fun x h => h.1) - exact Valid'.merge_aux₁ hl hr h v e - · obtain ⟨v, e⟩ := IHlr hl.right (hr.of_gt hl.1.2.to_nil sep.2.1) sep.2.2 - have := Valid'.merge_aux₁ hr.dual hl.dual h_1 v.dual - rw [size_dual, add_comm, size_dual, ← dual_balanceR, ← Valid'.dual_iff, size_dual, - add_comm rs] at this - exact this e - · refine Valid'.glue_aux hl hr sep (Or.inr ⟨not_lt.1 h_1, not_lt.1 h⟩) + unsealing_newtype OrderDual => + induction l generalizing o₁ o₂ r with + | nil => exact ⟨hr, (zero_add _).symm⟩ + | node ls ll lx lr _ IHlr => ?_ + induction r generalizing o₁ o₂ with + | nil => exact ⟨hl, rfl⟩ + | node rs rl rx rr IHrl _ => ?_ + rw [merge_node]; split_ifs with h h_1 + · obtain ⟨v, e⟩ := IHrl (hl.of_lt hr.1.1.to_nil <| sep.imp fun x h => h.2.1) hr.left + (sep.imp fun x h => h.1) + exact Valid'.merge_aux₁ hl hr h v e + · obtain ⟨v, e⟩ := IHlr hl.right (hr.of_gt hl.1.2.to_nil sep.2.1) sep.2.2 + have map_toDual (t : Ordnode α) : t.map OrderDual.toDual = t := map_id t + have hr' := hr.dual + have hl' := hl.dual + have v' := v.dual + simp only [map_toDual] at hr' hl' v' + have := Valid'.merge_aux₁ hr' hl' h_1 v' + rw [size_dual, add_comm, size_dual, ← dual_balanceR, size_dual, add_comm rs] at this + obtain ⟨hv, he⟩ := this e + refine ⟨Valid'.dual_iff.2 ?_, he⟩ + simpa only [map_toDual] using hv + · refine Valid'.glue_aux hl hr sep (Or.inr ⟨not_lt.1 h_1, not_lt.1 h⟩) theorem Valid.merge {l r} (hl : Valid l) (hr : Valid r) (sep : l.All fun x => r.All fun y => x < y) : Valid (@merge α l r) := diff --git a/mathlib4/Mathlib/Data/Set/Finite/Lattice.lean b/mathlib4/Mathlib/Data/Set/Finite/Lattice.lean index 95a116326..1bfaab8c9 100644 --- a/mathlib4/Mathlib/Data/Set/Finite/Lattice.lean +++ b/mathlib4/Mathlib/Data/Set/Finite/Lattice.lean @@ -313,8 +313,9 @@ theorem Finite.iSup_biInf_of_monotone {ι ι' α : Type*} [Preorder ι'] [Nonemp @[to_dual] theorem Finite.iSup_biInf_of_antitone {ι ι' α : Type*} [Preorder ι'] [Nonempty ι'] [IsCodirectedOrder ι'] [Order.Frame α] {s : Set ι} (hs : s.Finite) {f : ι → ι' → α} - (hf : ∀ i ∈ s, Antitone (f i)) : ⨆ j, ⨅ i ∈ s, f i j = ⨅ i ∈ s, ⨆ j, f i j := - @Finite.iSup_biInf_of_monotone ι ι'ᵒᵈ α _ _ _ _ _ hs _ fun i hi => (hf i hi).dual_left + (hf : ∀ i ∈ s, Antitone (f i)) : ⨆ j, ⨅ i ∈ s, f i j = ⨅ i ∈ s, ⨆ j, f i j := by + unsealing_newtype OrderDual => + exact @Finite.iSup_biInf_of_monotone ι ι'ᵒᵈ α _ _ _ _ _ hs _ fun i hi => (hf i hi).dual_left @[to_dual] theorem _root_.iSup_iInf_of_monotone {ι ι' α : Type*} [Finite ι] [Preorder ι'] [Nonempty ι'] @@ -325,8 +326,9 @@ theorem _root_.iSup_iInf_of_monotone {ι ι' α : Type*} [Finite ι] [Preorder @[to_dual] theorem _root_.iSup_iInf_of_antitone {ι ι' α : Type*} [Finite ι] [Preorder ι'] [Nonempty ι'] [IsCodirectedOrder ι'] [Order.Frame α] {f : ι → ι' → α} (hf : ∀ i, Antitone (f i)) : - ⨆ j, ⨅ i, f i j = ⨅ i, ⨆ j, f i j := - @iSup_iInf_of_monotone ι ι'ᵒᵈ α _ _ _ _ _ _ fun i => (hf i).dual_left + ⨆ j, ⨅ i, f i j = ⨅ i, ⨆ j, f i j := by + unsealing_newtype OrderDual => + exact @iSup_iInf_of_monotone ι ι'ᵒᵈ α _ _ _ _ _ _ fun i => (hf i).dual_left /-- An increasing union distributes over finite intersection. -/ theorem iUnion_iInter_of_monotone {ι ι' α : Type*} [Finite ι] [Preorder ι'] [IsDirectedOrder ι'] @@ -381,8 +383,9 @@ theorem _root_.iInf_iSup_eq_of_finite {ι : Sort v} {κ : ι → Sort w} [Order. Equiv.piOptionEquivProd_symm_apply, iSup_prod, ← inf_iSup_eq, ← iSup_inf_eq] theorem _root_.iSup_iInf_eq_of_finite {ι : Sort v} {κ : ι → Sort w} [Order.Coframe α] [Finite ι] - {f : ∀ a, κ a → α} : ⨆ a, ⨅ b, f a b = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := - iInf_iSup_eq_of_finite (α := αᵒᵈ) + {f : ∀ a, κ a → α} : ⨆ a, ⨅ b, f a b = ⨅ g : ∀ a, κ a, ⨆ a, f a (g a) := by + unsealing_newtype OrderDual => + exact iInf_iSup_eq_of_finite (α := αᵒᵈ) theorem Finite.biInf_iSup_eq {ι : Type v} {κ : ι → Sort w} [Nonempty (Π a, κ a)] [Order.Frame α] {s : Set ι} (hs : s.Finite) {f : Π a, κ a → α} : @@ -401,8 +404,9 @@ theorem Finite.biInf_iSup_eq {ι : Type v} {κ : ι → Sort w} [Nonempty (Π a, theorem Finite.biSup_iInf_eq {ι : Type v} {κ : ι → Sort w} [Nonempty (∀ a, κ a)] [Order.Coframe α] {s : Set ι} (hs : s.Finite) {f : ∀ a, κ a → α} : - ⨆ a ∈ s, ⨅ b, f a b = ⨅ g : ∀ a, κ a, ⨆ a ∈ s, f a (g a) := - hs.biInf_iSup_eq (α := αᵒᵈ) + ⨆ a ∈ s, ⨅ b, f a b = ⨅ g : ∀ a, κ a, ⨆ a ∈ s, f a (g a) := by + unsealing_newtype OrderDual => + exact hs.biInf_iSup_eq (α := αᵒᵈ) section diff --git a/mathlib4/Mathlib/Data/Set/Monotone.lean b/mathlib4/Mathlib/Data/Set/Monotone.lean index e1462d933..286b89c26 100644 --- a/mathlib4/Mathlib/Data/Set/Monotone.lean +++ b/mathlib4/Mathlib/Data/Set/Monotone.lean @@ -30,8 +30,9 @@ theorem _root_.MonotoneOn.congr (h₁ : MonotoneOn f₁ s) (h : s.EqOn f₁ f₂ rw [← h ha, ← h hb] exact h₁ ha hb hab -theorem _root_.AntitoneOn.congr (h₁ : AntitoneOn f₁ s) (h : s.EqOn f₁ f₂) : AntitoneOn f₂ s := - h₁.dual_right.congr h +theorem _root_.AntitoneOn.congr (h₁ : AntitoneOn f₁ s) (h : s.EqOn f₁ f₂) : AntitoneOn f₂ s := by + unsealing_newtype OrderDual => + exact h₁.dual_right.congr h theorem _root_.StrictMonoOn.congr (h₁ : StrictMonoOn f₁ s) (h : s.EqOn f₁ f₂) : StrictMonoOn f₂ s := by @@ -39,8 +40,10 @@ theorem _root_.StrictMonoOn.congr (h₁ : StrictMonoOn f₁ s) (h : s.EqOn f₁ rw [← h ha, ← h hb] exact h₁ ha hb hab -theorem _root_.StrictAntiOn.congr (h₁ : StrictAntiOn f₁ s) (h : s.EqOn f₁ f₂) : StrictAntiOn f₂ s := - h₁.dual_right.congr h +theorem _root_.StrictAntiOn.congr (h₁ : StrictAntiOn f₁ s) (h : s.EqOn f₁ f₂) : + StrictAntiOn f₂ s := by + unsealing_newtype OrderDual => + exact h₁.dual_right.congr h theorem EqOn.congr_monotoneOn (h : s.EqOn f₁ f₂) : MonotoneOn f₁ s ↔ MonotoneOn f₂ s := ⟨fun h₁ => h₁.congr h, fun h₂ => h₂.congr h.symm⟩ @@ -213,13 +216,15 @@ theorem strictMonoOn_of_rightInvOn_of_mapsTo [Preorder α] [LinearOrder β] theorem antitoneOn_of_rightInvOn_of_mapsTo [PartialOrder α] [LinearOrder β] {φ : β → α} {ψ : α → β} {t : Set β} {s : Set α} (hφ : AntitoneOn φ t) - (φψs : RightInvOn ψ φ s) (ψts : MapsTo ψ s t) : AntitoneOn ψ s := - (monotoneOn_of_rightInvOn_of_mapsTo hφ.dual_left φψs ψts).dual_right + (φψs : RightInvOn ψ φ s) (ψts : MapsTo ψ s t) : AntitoneOn ψ s := by + unsealing_newtype OrderDual => + exact (monotoneOn_of_rightInvOn_of_mapsTo hφ.dual_left φψs ψts).dual_right theorem strictAntiOn_of_rightInvOn_of_mapsTo [Preorder α] [LinearOrder β] {φ : β → α} {ψ : α → β} {t : Set β} {s : Set α} (hφ : StrictAntiOn φ t) - (φψs : RightInvOn ψ φ s) (ψts : MapsTo ψ s t) : StrictAntiOn ψ s := - (strictMonoOn_of_rightInvOn_of_mapsTo hφ.dual_left φψs ψts).dual_right + (φψs : RightInvOn ψ φ s) (ψts : MapsTo ψ s t) : StrictAntiOn ψ s := by + unsealing_newtype OrderDual => + exact (strictMonoOn_of_rightInvOn_of_mapsTo hφ.dual_left φψs ψts).dual_right theorem monotone_of_rightInverse [PartialOrder α] [LinearOrder β] {φ : β → α} {ψ : α → β} (hφ : Monotone φ) diff --git a/mathlib4/Mathlib/Data/Set/Piecewise.lean b/mathlib4/Mathlib/Data/Set/Piecewise.lean index dfb412ba4..30520b361 100644 --- a/mathlib4/Mathlib/Data/Set/Piecewise.lean +++ b/mathlib4/Mathlib/Data/Set/Piecewise.lean @@ -76,8 +76,9 @@ theorem piecewise_le {δ : α → Type*} [∀ i, Preorder (δ i)] {s : Set α} [ theorem le_piecewise {δ : α → Type*} [∀ i, Preorder (δ i)] {s : Set α} [∀ j, Decidable (j ∈ s)] {f₁ f₂ g : ∀ i, δ i} (h₁ : ∀ i ∈ s, g i ≤ f₁ i) (h₂ : ∀ i ∉ s, g i ≤ f₂ i) : - g ≤ s.piecewise f₁ f₂ := - @piecewise_le α (fun i => (δ i)ᵒᵈ) _ s _ _ _ _ h₁ h₂ + g ≤ s.piecewise f₁ f₂ := by + unsealing_newtype OrderDual => + exact @piecewise_le α (fun i => (δ i)ᵒᵈ) _ s _ _ _ _ h₁ h₂ @[gcongr] theorem piecewise_mono {δ : α → Type*} [∀ i, Preorder (δ i)] {s : Set α} diff --git a/mathlib4/Mathlib/Data/Set/Sigma.lean b/mathlib4/Mathlib/Data/Set/Sigma.lean index ac7b9d38b..2c61a312c 100644 --- a/mathlib4/Mathlib/Data/Set/Sigma.lean +++ b/mathlib4/Mathlib/Data/Set/Sigma.lean @@ -104,8 +104,9 @@ theorem _root_.biSup_sigma' (s : Set ι) (t : ∀ i, Set (α i)) (f : ∀ i, α Eq.symm (biSup_sigma _ _ _) theorem _root_.biInf_sigma (s : Set ι) (t : ∀ i, Set (α i)) (f : Sigma α → β) : - ⨅ ij ∈ s.sigma t, f ij = ⨅ (i ∈ s) (j ∈ t i), f ⟨i, j⟩ := - biSup_sigma (β := βᵒᵈ) _ _ _ + ⨅ ij ∈ s.sigma t, f ij = ⨅ (i ∈ s) (j ∈ t i), f ⟨i, j⟩ := by + unsealing_newtype OrderDual => + exact biSup_sigma (β := βᵒᵈ) _ _ _ theorem _root_.biInf_sigma' (s : Set ι) (t : ∀ i, Set (α i)) (f : ∀ i, α i → β) : ⨅ (i ∈ s) (j ∈ t i), f i j = ⨅ ij ∈ s.sigma t, f ij.fst ij.snd := diff --git a/mathlib4/Mathlib/Data/Sum/Order.lean b/mathlib4/Mathlib/Data/Sum/Order.lean index 828e12813..a74d46f7c 100644 --- a/mathlib4/Mathlib/Data/Sum/Order.lean +++ b/mathlib4/Mathlib/Data/Sum/Order.lean @@ -579,32 +579,33 @@ theorem sumAssoc_symm_apply_inr_inr : (sumAssoc α β γ).symm (inr (inr c)) = i rfl /-- `orderDual` is distributive over `⊕` up to an order isomorphism. -/ -def sumDualDistrib (α β : Type*) [LE α] [LE β] : (α ⊕ β)ᵒᵈ ≃o αᵒᵈ ⊕ βᵒᵈ := - { Equiv.refl _ with - map_rel_iff' := by +def sumDualDistrib (α β : Type*) [LE α] [LE β] : (α ⊕ β)ᵒᵈ ≃o αᵒᵈ ⊕ βᵒᵈ where + toEquiv := ofDual.trans (Equiv.sumCongr toDual toDual) + map_rel_iff' := by + unsealing_newtype OrderDual => rintro (a | a) (b | b) · change inl (toDual a) ≤ inl (toDual b) ↔ toDual (inl a) ≤ toDual (inl b) simp [toDual_le_toDual, inl_le_inl_iff] · exact iff_of_false (@not_inl_le_inr (OrderDual β) (OrderDual α) _ _ _ _) not_inr_le_inl · exact iff_of_false (@not_inr_le_inl (OrderDual α) (OrderDual β) _ _ _ _) not_inl_le_inr · change inr (toDual a) ≤ inr (toDual b) ↔ toDual (inr a) ≤ toDual (inr b) - simp [toDual_le_toDual, inr_le_inr_iff] } + simp [toDual_le_toDual, inr_le_inr_iff] @[simp] -theorem sumDualDistrib_inl : sumDualDistrib α β (toDual (inl a)) = inl (toDual a) := - rfl +theorem sumDualDistrib_inl : sumDualDistrib α β (toDual (inl a)) = inl (toDual a) := by + unsealing_newtype OrderDual => rfl @[simp] -theorem sumDualDistrib_inr : sumDualDistrib α β (toDual (inr b)) = inr (toDual b) := - rfl +theorem sumDualDistrib_inr : sumDualDistrib α β (toDual (inr b)) = inr (toDual b) := by + unsealing_newtype OrderDual => rfl @[simp] -theorem sumDualDistrib_symm_inl : (sumDualDistrib α β).symm (inl (toDual a)) = toDual (inl a) := - rfl +theorem sumDualDistrib_symm_inl : (sumDualDistrib α β).symm (inl (toDual a)) = toDual (inl a) := by + unsealing_newtype OrderDual => rfl @[simp] -theorem sumDualDistrib_symm_inr : (sumDualDistrib α β).symm (inr (toDual b)) = toDual (inr b) := - rfl +theorem sumDualDistrib_symm_inr : (sumDualDistrib α β).symm (inr (toDual b)) = toDual (inr b) := by + unsealing_newtype OrderDual => rfl /-- `Equiv.sumCongr` promoted to an order isomorphism between lexicographic sums. -/ @[simps! apply] @@ -675,10 +676,12 @@ theorem sumLexAssoc_symm_apply_inr_inr : (sumLexAssoc α β γ).symm (inr (inr c rfl /-- `OrderDual` is antidistributive over `⊕ₗ` up to an order isomorphism. -/ -def sumLexDualAntidistrib (α β : Type*) [LE α] [LE β] : (α ⊕ₗ β)ᵒᵈ ≃o βᵒᵈ ⊕ₗ αᵒᵈ := - { Equiv.sumComm α β with - map_rel_iff' := fun {a b} => by - rcases a with (a | a) <;> rcases b with (b | b) +def sumLexDualAntidistrib (α β : Type*) [LE α] [LE β] : (α ⊕ₗ β)ᵒᵈ ≃o βᵒᵈ ⊕ₗ αᵒᵈ where + toEquiv := ofDual.trans (ofLex.trans ((Equiv.sumComm α β).trans + ((Equiv.sumCongr toDual toDual).trans toLex))) + map_rel_iff' := by + unsealing_newtype OrderDual => + rintro (a | a) (b | b) · change toLex (inr <| toDual a) ≤ toLex (inr <| toDual b) ↔ toDual (toLex <| inl a) ≤ toDual (toLex <| inl b) @@ -690,27 +693,27 @@ def sumLexDualAntidistrib (α β : Type*) [LE α] [LE β] : (α ⊕ₗ β)ᵒᵈ · change toLex (inl <| toDual a) ≤ toLex (inl <| toDual b) ↔ toDual (toLex <| inr a) ≤ toDual (toLex <| inr b) - simp [toDual_le_toDual] } + simp [toDual_le_toDual] @[simp] theorem sumLexDualAntidistrib_inl : - sumLexDualAntidistrib α β (toDual (inl a)) = inr (toDual a) := - rfl + sumLexDualAntidistrib α β (toDual (inl a)) = inr (toDual a) := by + unsealing_newtype OrderDual => rfl @[simp] theorem sumLexDualAntidistrib_inr : - sumLexDualAntidistrib α β (toDual (inr b)) = inl (toDual b) := - rfl + sumLexDualAntidistrib α β (toDual (inr b)) = inl (toDual b) := by + unsealing_newtype OrderDual => rfl @[simp] theorem sumLexDualAntidistrib_symm_inl : - (sumLexDualAntidistrib α β).symm (inl (toDual b)) = toDual (inr b) := - rfl + (sumLexDualAntidistrib α β).symm (inl (toDual b)) = toDual (inr b) := by + unsealing_newtype OrderDual => rfl @[simp] theorem sumLexDualAntidistrib_symm_inr : - (sumLexDualAntidistrib α β).symm (inr (toDual a)) = toDual (inl a) := - rfl + (sumLexDualAntidistrib α β).symm (inr (toDual a)) = toDual (inl a) := by + unsealing_newtype OrderDual => rfl /-- `Equiv.sumEmpty` as an `OrderIso` with the lexicographic sum. -/ def sumLexEmpty [IsEmpty β] : Lex (α ⊕ β) ≃o α := diff --git a/mathlib4/Mathlib/FieldTheory/Galois/Basic.lean b/mathlib4/Mathlib/FieldTheory/Galois/Basic.lean index 30a0d4741..2b3bd2841 100644 --- a/mathlib4/Mathlib/FieldTheory/Galois/Basic.lean +++ b/mathlib4/Mathlib/FieldTheory/Galois/Basic.lean @@ -352,7 +352,7 @@ def intermediateFieldEquivSubgroup [FiniteDimensional F E] [IsGalois F E] : toFun := OrderDual.toDual ∘ IntermediateField.fixingSubgroup invFun := IntermediateField.fixedField ∘ OrderDual.ofDual left_inv K := fixedField_fixingSubgroup K - right_inv H := IntermediateField.fixingSubgroup_fixedField H + right_inv H := congrArg OrderDual.toDual (IntermediateField.fixingSubgroup_fixedField H.ofDual) map_rel_iff' {K L} := by rw [← fixedField_fixingSubgroup L, IntermediateField.le_iff_le, fixedField_fixingSubgroup L] rfl @@ -381,10 +381,11 @@ def galoisInsertionIntermediateFieldSubgroup [FiniteDimensional F E] : GaloisInsertion (OrderDual.toDual ∘ (IntermediateField.fixingSubgroup : IntermediateField F E → Subgroup Gal(E/F))) ((IntermediateField.fixedField : Subgroup Gal(E/F) → IntermediateField F E) ∘ - OrderDual.toDual) where - choice K _ := IntermediateField.fixingSubgroup K - gc K H := (IntermediateField.le_iff_le H K).symm - le_l_u H := le_of_eq (IntermediateField.fixingSubgroup_fixedField H).symm + OrderDual.ofDual) where + choice K _ := OrderDual.toDual (IntermediateField.fixingSubgroup K) + gc K H := (IntermediateField.le_iff_le H.ofDual K).symm + le_l_u H := + le_of_eq (congrArg OrderDual.toDual (IntermediateField.fixingSubgroup_fixedField H.ofDual)).symm choice_eq _ _ := rfl /-- The Galois correspondence as a `GaloisCoinsertion`. -/ @@ -392,7 +393,7 @@ def galoisCoinsertionIntermediateFieldSubgroup [FiniteDimensional F E] [IsGalois GaloisCoinsertion (OrderDual.toDual ∘ (IntermediateField.fixingSubgroup : IntermediateField F E → Subgroup Gal(E/F))) ((IntermediateField.fixedField : Subgroup Gal(E/F) → IntermediateField F E) ∘ - OrderDual.toDual) := + OrderDual.ofDual) := OrderIso.toGaloisCoinsertion intermediateFieldEquivSubgroup end IsGalois diff --git a/mathlib4/Mathlib/FieldTheory/Galois/Infinite.lean b/mathlib4/Mathlib/FieldTheory/Galois/Infinite.lean index f9523833f..f16a8afe0 100644 --- a/mathlib4/Mathlib/FieldTheory/Galois/Infinite.lean +++ b/mathlib4/Mathlib/FieldTheory/Galois/Infinite.lean @@ -195,11 +195,11 @@ lemma fixingSubgroup_fixedField (H : ClosedSubgroup Gal(K/k)) [IsGalois k K] : /-- The Galois correspondence from intermediate fields to closed subgroups. -/ def IntermediateFieldEquivClosedSubgroup [IsGalois k K] : IntermediateField k K ≃o (ClosedSubgroup Gal(K/k))ᵒᵈ where - toFun L := ⟨L.fixingSubgroup, fixingSubgroup_isClosed L⟩ - invFun H := IntermediateField.fixedField H.1 + toFun L := OrderDual.toDual ⟨L.fixingSubgroup, fixingSubgroup_isClosed L⟩ + invFun H := IntermediateField.fixedField (OrderDual.ofDual H).1 left_inv L := fixedField_fixingSubgroup L - right_inv H := by - simp_rw [fixingSubgroup_fixedField H] + right_inv H := congrArg OrderDual.toDual <| by + simp_rw [fixingSubgroup_fixedField (OrderDual.ofDual H)] rfl map_rel_iff' {K L} := by rw [← fixedField_fixingSubgroup L, IntermediateField.le_iff_le, fixedField_fixingSubgroup L] @@ -207,18 +207,18 @@ def IntermediateFieldEquivClosedSubgroup [IsGalois k K] : /-- The Galois correspondence as a `GaloisInsertion` -/ def GaloisInsertionIntermediateFieldClosedSubgroup [IsGalois k K] : - GaloisInsertion (OrderDual.toDual ∘ fun (E : IntermediateField k K) ↦ + GaloisInsertion (⇑OrderDual.toDual ∘ fun (E : IntermediateField k K) ↦ (⟨E.fixingSubgroup, fixingSubgroup_isClosed E⟩ : ClosedSubgroup Gal(K/k))) ((fun (H : ClosedSubgroup Gal(K/k)) ↦ IntermediateField.fixedField H) ∘ - OrderDual.toDual) := + ⇑OrderDual.ofDual) := OrderIso.toGaloisInsertion IntermediateFieldEquivClosedSubgroup /-- The Galois correspondence as a `GaloisCoinsertion` -/ def GaloisCoinsertionIntermediateFieldSubgroup [IsGalois k K] : - GaloisCoinsertion (OrderDual.toDual ∘ fun (E : IntermediateField k K) ↦ E.fixingSubgroup) - ((fun (H : Subgroup Gal(K/k)) ↦ IntermediateField.fixedField H) ∘ OrderDual.toDual) where - choice H _ := IntermediateField.fixedField H - gc E H := (IntermediateField.le_iff_le H E).symm + GaloisCoinsertion (⇑OrderDual.toDual ∘ fun (E : IntermediateField k K) ↦ E.fixingSubgroup) + ((fun (H : Subgroup Gal(K/k)) ↦ IntermediateField.fixedField H) ∘ ⇑OrderDual.ofDual) where + choice H _ := IntermediateField.fixedField (OrderDual.ofDual H) + gc E H := (IntermediateField.le_iff_le (OrderDual.ofDual H) E).symm u_l_le K := le_of_eq (fixedField_fixingSubgroup K) choice_eq _ _ := rfl @@ -240,23 +240,24 @@ set_option backward.isDefEq.respectTransparency false in open IntermediateField in theorem isOpen_iff_finite (L : IntermediateField k K) [IsGalois k K] : IsOpen L.fixingSubgroup.carrier ↔ FiniteDimensional k L := by - refine ⟨fun h ↦ ?_, fun h ↦ IntermediateField.fixingSubgroup_isOpen L⟩ - have : (IntermediateFieldEquivClosedSubgroup.toFun L).carrier ∈ nhds 1 := - IsOpen.mem_nhds h (congrFun rfl) - rw [GroupFilterBasis.nhds_one_eq] at this - rcases this with ⟨S, ⟨gp, ⟨M, hM, eq'⟩, eq⟩, sub⟩ - rw [← eq, ← eq'] at sub - have := hM.out - let L' : FiniteGaloisIntermediateField k K := { - normalClosure k M K with - finiteDimensional := normalClosure.is_finiteDimensional k M K - isGalois := IsGalois.normalClosure k M K } - have : L ≤ L'.1 := by - apply le_trans _ (IntermediateField.le_normalClosure M) - rw [← fixedField_fixingSubgroup M, IntermediateField.le_iff_le] - exact sub - let _ : Algebra L L'.1 := RingHom.toAlgebra (IntermediateField.inclusion this) - exact FiniteDimensional.left k L L'.1 + unsealing_newtype OrderDual => + refine ⟨fun h ↦ ?_, fun h ↦ IntermediateField.fixingSubgroup_isOpen L⟩ + have : (IntermediateFieldEquivClosedSubgroup.toFun L).carrier ∈ nhds 1 := + IsOpen.mem_nhds h (congrFun rfl) + rw [GroupFilterBasis.nhds_one_eq] at this + rcases this with ⟨S, ⟨gp, ⟨M, hM, eq'⟩, eq⟩, sub⟩ + rw [← eq, ← eq'] at sub + have := hM.out + let L' : FiniteGaloisIntermediateField k K := { + normalClosure k M K with + finiteDimensional := normalClosure.is_finiteDimensional k M K + isGalois := IsGalois.normalClosure k M K } + have : L ≤ L'.1 := by + apply le_trans _ (IntermediateField.le_normalClosure M) + rw [← fixedField_fixingSubgroup M, IntermediateField.le_iff_le] + exact sub + let _ : Algebra L L'.1 := RingHom.toAlgebra (IntermediateField.inclusion this) + exact FiniteDimensional.left k L L'.1 theorem normal_iff_isGalois (L : IntermediateField k K) [IsGalois k K] : L.fixingSubgroup.Normal ↔ IsGalois k L := by diff --git a/mathlib4/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean b/mathlib4/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean index f9c0bad6a..39ec976b3 100644 --- a/mathlib4/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean +++ b/mathlib4/Mathlib/FieldTheory/Galois/IsGaloisGroup.lean @@ -202,6 +202,8 @@ instance intermediateField [Finite G] [hGKL : IsGaloisGroup G K L] : have := hGKL.isGalois .of_mulEquiv_algEquiv e fun _ _ ↦ rfl +set_option synthInstance.maxHeartbeats 40000 in +-- Typeclass search for the field-range algebra exceeds the default heartbeat limit. attribute [local instance] FractionRing.liftAlgebra in /-- If `G` is a finite Galois group for `B / R` and `R ⊆ A ⊆ B` is a tower of commutative domains with `A` integrally closed, then the fixing subgroup of the image of `A` in `B` is a Galois group diff --git a/mathlib4/Mathlib/GroupTheory/ArchimedeanDensely.lean b/mathlib4/Mathlib/GroupTheory/ArchimedeanDensely.lean index 645bb4676..456f181c3 100644 --- a/mathlib4/Mathlib/GroupTheory/ArchimedeanDensely.lean +++ b/mathlib4/Mathlib/GroupTheory/ArchimedeanDensely.lean @@ -92,13 +92,16 @@ instance : Unique (ℤ ≃+o ℤᵒᵈ) where default := ⟨AddEquiv.neg ℤ |>.trans ⟨toDual, toDual_add⟩, by simp⟩ uniq e := OrderAddMonoidIso.toAddEquiv_injective <| by simp only [OrderAddMonoidIso.toAddEquiv_eq_coe] - refine Int.addEquiv_eq_refl_or_neg ((e : ℤ ≃+ ℤᵒᵈ).trans ⟨toDual, toDual_add⟩) + -- Compose with `ofDual` to apply the classification of additive equivalences of `ℤ`. + have key : (e : ℤ ≃+ ℤᵒᵈ).trans ⟨ofDual, ofDual_add⟩ = AddEquiv.neg ℤ := + Int.addEquiv_eq_refl_or_neg ((e : ℤ ≃+ ℤᵒᵈ).trans ⟨ofDual, ofDual_add⟩) |>.resolve_left fun H => by - replace H : e 1 = 1 := congr($H 1) - have h1 : 0 < e 1 := by - rw [← map_zero e, map_lt_map_iff] - simp - simp [H, ← ofDual_lt_ofDual] at h1 + replace H : ofDual (e 1) = 1 := congr($H 1) + have h1 : 0 < e 1 := by + rw [← map_zero e, map_lt_map_iff] + simp + simp [H, ← ofDual_lt_ofDual] at h1 + exact DFunLike.ext _ _ fun x ↦ congrArg toDual (congr($key x)) open Subgroup in /-- In two linearly ordered groups, the closure of an element of one group diff --git a/mathlib4/Mathlib/GroupTheory/GroupAction/FixingSubgroup.lean b/mathlib4/Mathlib/GroupTheory/GroupAction/FixingSubgroup.lean index d91e0dc0e..7066db096 100644 --- a/mathlib4/Mathlib/GroupTheory/GroupAction/FixingSubgroup.lean +++ b/mathlib4/Mathlib/GroupTheory/GroupAction/FixingSubgroup.lean @@ -73,20 +73,23 @@ theorem fixingSubmonoid_antitone : Antitone fun s : Set α => fixingSubmonoid M (fixingSubmonoid_fixedPoints_gc M α).monotone_l @[to_additive fixedPoints_antitone_addSubmonoid] -theorem fixedPoints_antitone : Antitone fun P : Submonoid M => fixedPoints P α := - (fixingSubmonoid_fixedPoints_gc M α).monotone_u.dual_left +theorem fixedPoints_antitone : Antitone fun P : Submonoid M => fixedPoints P α := by + unsealing_newtype OrderDual => + exact (fixingSubmonoid_fixedPoints_gc M α).monotone_u.dual_left /-- Fixing submonoid of union is intersection -/ @[to_additive] theorem fixingSubmonoid_union {s t : Set α} : - fixingSubmonoid M (s ∪ t) = fixingSubmonoid M s ⊓ fixingSubmonoid M t := - (fixingSubmonoid_fixedPoints_gc M α).l_sup + fixingSubmonoid M (s ∪ t) = fixingSubmonoid M s ⊓ fixingSubmonoid M t := by + unsealing_newtype OrderDual => + exact (fixingSubmonoid_fixedPoints_gc M α).l_sup /-- Fixing submonoid of iUnion is intersection -/ @[to_additive] theorem fixingSubmonoid_iUnion {ι : Sort*} {s : ι → Set α} : - fixingSubmonoid M (⋃ i, s i) = ⨅ i, fixingSubmonoid M (s i) := - (fixingSubmonoid_fixedPoints_gc M α).l_iSup + fixingSubmonoid M (⋃ i, s i) = ⨅ i, fixingSubmonoid M (s i) := by + unsealing_newtype OrderDual => + exact (fixingSubmonoid_fixedPoints_gc M α).l_iSup /-- Fixed points of sup of submonoids is intersection -/ @[to_additive] @@ -97,8 +100,9 @@ theorem fixedPoints_submonoid_sup {P Q : Submonoid M} : /-- Fixed points of iSup of submonoids is intersection -/ @[to_additive] theorem fixedPoints_submonoid_iSup {ι : Sort*} {P : ι → Submonoid M} : - fixedPoints (↥(iSup P)) α = ⋂ i, fixedPoints (P i) α := - (fixingSubmonoid_fixedPoints_gc M α).u_iInf + fixedPoints (↥(iSup P)) α = ⋂ i, fixedPoints (P i) α := by + unsealing_newtype OrderDual => + exact (fixingSubmonoid_fixedPoints_gc M α).u_iInf end Monoid @@ -137,28 +141,32 @@ theorem fixingSubgroup_fixedPoints_gc : fun _s _P => ⟨fun h s hs p => h p.2 ⟨s, hs⟩, fun h p hp s => h s.2 ⟨p, hp⟩⟩ @[to_additive (attr := simp)] -lemma fixingSubgroup_empty : fixingSubgroup M (∅ : Set α) = ⊤ := - GaloisConnection.l_bot (fixingSubgroup_fixedPoints_gc M α) +lemma fixingSubgroup_empty : fixingSubgroup M (∅ : Set α) = ⊤ := by + unsealing_newtype OrderDual => + exact GaloisConnection.l_bot (fixingSubgroup_fixedPoints_gc M α) @[to_additive] theorem fixingSubgroup_antitone : Antitone (fixingSubgroup M : Set α → Subgroup M) := (fixingSubgroup_fixedPoints_gc M α).monotone_l @[to_additive] -theorem fixedPoints_subgroup_antitone : Antitone fun P : Subgroup M => fixedPoints P α := - (fixingSubgroup_fixedPoints_gc M α).monotone_u.dual_left +theorem fixedPoints_subgroup_antitone : Antitone fun P : Subgroup M => fixedPoints P α := by + unsealing_newtype OrderDual => + exact (fixingSubgroup_fixedPoints_gc M α).monotone_u.dual_left /-- Fixing subgroup of union is intersection -/ @[to_additive] theorem fixingSubgroup_union {s t : Set α} : - fixingSubgroup M (s ∪ t) = fixingSubgroup M s ⊓ fixingSubgroup M t := - (fixingSubgroup_fixedPoints_gc M α).l_sup + fixingSubgroup M (s ∪ t) = fixingSubgroup M s ⊓ fixingSubgroup M t := by + unsealing_newtype OrderDual => + exact (fixingSubgroup_fixedPoints_gc M α).l_sup /-- Fixing subgroup of iUnion is intersection -/ @[to_additive] theorem fixingSubgroup_iUnion {ι : Sort*} {s : ι → Set α} : - fixingSubgroup M (⋃ i, s i) = ⨅ i, fixingSubgroup M (s i) := - (fixingSubgroup_fixedPoints_gc M α).l_iSup + fixingSubgroup M (⋃ i, s i) = ⨅ i, fixingSubgroup M (s i) := by + unsealing_newtype OrderDual => + exact (fixingSubgroup_fixedPoints_gc M α).l_iSup /-- Fixed points of sup of subgroups is intersection -/ @[to_additive] @@ -169,8 +177,9 @@ theorem fixedPoints_subgroup_sup {P Q : Subgroup M} : /-- Fixed points of iSup of subgroups is intersection -/ @[to_additive] theorem fixedPoints_subgroup_iSup {ι : Sort*} {P : ι → Subgroup M} : - fixedPoints (↥(iSup P)) α = ⋂ i, fixedPoints (P i) α := - (fixingSubgroup_fixedPoints_gc M α).u_iInf + fixedPoints (↥(iSup P)) α = ⋂ i, fixedPoints (P i) α := by + unsealing_newtype OrderDual => + exact (fixingSubgroup_fixedPoints_gc M α).u_iInf /-- The orbit of the fixing subgroup of `sᶜ` (i.e. the moving subgroup of `s`) is a subset of `s` -/ @[to_additive] diff --git a/mathlib4/Mathlib/LinearAlgebra/AffineSpace/Ordered.lean b/mathlib4/Mathlib/LinearAlgebra/AffineSpace/Ordered.lean index bbe7736ba..db7ec4aef 100644 --- a/mathlib4/Mathlib/LinearAlgebra/AffineSpace/Ordered.lean +++ b/mathlib4/Mathlib/LinearAlgebra/AffineSpace/Ordered.lean @@ -237,8 +237,9 @@ theorem map_le_lineMap_iff_slope_le_slope_left (h : 0 < r * (b - a)) : /-- Given `c = lineMap a b r`, `a < c`, the point `(c, f c)` is non-strictly above the segment `[(a, f a), (b, f b)]` if and only if `slope f a b ≤ slope f a c`. -/ theorem lineMap_le_map_iff_slope_le_slope_left (h : 0 < r * (b - a)) : - lineMap (f a) (f b) r ≤ f c ↔ slope f a b ≤ slope f a c := - map_le_lineMap_iff_slope_le_slope_left (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h + lineMap (f a) (f b) r ≤ f c ↔ slope f a b ≤ slope f a c := by + unsealing_newtype OrderDual => + exact map_le_lineMap_iff_slope_le_slope_left (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h /-- Given `c = lineMap a b r`, `a < c`, the point `(c, f c)` is strictly below the segment `[(a, f a), (b, f b)]` if and only if `slope f a c < slope f a b`. -/ @@ -250,8 +251,9 @@ theorem map_lt_lineMap_iff_slope_lt_slope_left (h : 0 < r * (b - a)) : /-- Given `c = lineMap a b r`, `a < c`, the point `(c, f c)` is strictly above the segment `[(a, f a), (b, f b)]` if and only if `slope f a b < slope f a c`. -/ theorem lineMap_lt_map_iff_slope_lt_slope_left (h : 0 < r * (b - a)) : - lineMap (f a) (f b) r < f c ↔ slope f a b < slope f a c := - map_lt_lineMap_iff_slope_lt_slope_left (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h + lineMap (f a) (f b) r < f c ↔ slope f a b < slope f a c := by + unsealing_newtype OrderDual => + exact map_lt_lineMap_iff_slope_lt_slope_left (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h /-- Given `c = lineMap a b r`, `c < b`, the point `(c, f c)` is non-strictly below the segment `[(a, f a), (b, f b)]` if and only if `slope f a b ≤ slope f c b`. -/ @@ -268,8 +270,9 @@ theorem map_le_lineMap_iff_slope_le_slope_right (h : 0 < (1 - r) * (b - a)) : /-- Given `c = lineMap a b r`, `c < b`, the point `(c, f c)` is non-strictly above the segment `[(a, f a), (b, f b)]` if and only if `slope f c b ≤ slope f a b`. -/ theorem lineMap_le_map_iff_slope_le_slope_right (h : 0 < (1 - r) * (b - a)) : - lineMap (f a) (f b) r ≤ f c ↔ slope f c b ≤ slope f a b := - map_le_lineMap_iff_slope_le_slope_right (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h + lineMap (f a) (f b) r ≤ f c ↔ slope f c b ≤ slope f a b := by + unsealing_newtype OrderDual => + exact map_le_lineMap_iff_slope_le_slope_right (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h /-- Given `c = lineMap a b r`, `c < b`, the point `(c, f c)` is strictly below the segment `[(a, f a), (b, f b)]` if and only if `slope f a b < slope f c b`. -/ @@ -281,8 +284,9 @@ theorem map_lt_lineMap_iff_slope_lt_slope_right (h : 0 < (1 - r) * (b - a)) : /-- Given `c = lineMap a b r`, `c < b`, the point `(c, f c)` is strictly above the segment `[(a, f a), (b, f b)]` if and only if `slope f c b < slope f a b`. -/ theorem lineMap_lt_map_iff_slope_lt_slope_right (h : 0 < (1 - r) * (b - a)) : - lineMap (f a) (f b) r < f c ↔ slope f c b < slope f a b := - map_lt_lineMap_iff_slope_lt_slope_right (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h + lineMap (f a) (f b) r < f c ↔ slope f c b < slope f a b := by + unsealing_newtype OrderDual => + exact map_lt_lineMap_iff_slope_lt_slope_right (E := Eᵒᵈ) (f := f) (a := a) (b := b) (r := r) h end @@ -296,8 +300,9 @@ theorem map_le_lineMap_iff_slope_le_slope (hab : a < b) (h₀ : 0 < r) (h₁ : r /-- Given `c = lineMap a b r`, `a < c < b`, the point `(c, f c)` is non-strictly above the segment `[(a, f a), (b, f b)]` if and only if `slope f c b ≤ slope f a c`. -/ theorem lineMap_le_map_iff_slope_le_slope (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) : - lineMap (f a) (f b) r ≤ f c ↔ slope f c b ≤ slope f a c := - map_le_lineMap_iff_slope_le_slope (E := Eᵒᵈ) hab h₀ h₁ + lineMap (f a) (f b) r ≤ f c ↔ slope f c b ≤ slope f a c := by + unsealing_newtype OrderDual => + exact map_le_lineMap_iff_slope_le_slope (E := Eᵒᵈ) (f := OrderDual.toDual ∘ f) hab h₀ h₁ /-- Given `c = lineMap a b r`, `a < c < b`, the point `(c, f c)` is strictly below the segment `[(a, f a), (b, f b)]` if and only if `slope f a c < slope f c b`. -/ @@ -309,8 +314,9 @@ theorem map_lt_lineMap_iff_slope_lt_slope (hab : a < b) (h₀ : 0 < r) (h₁ : r /-- Given `c = lineMap a b r`, `a < c < b`, the point `(c, f c)` is strictly above the segment `[(a, f a), (b, f b)]` if and only if `slope f c b < slope f a c`. -/ theorem lineMap_lt_map_iff_slope_lt_slope (hab : a < b) (h₀ : 0 < r) (h₁ : r < 1) : - lineMap (f a) (f b) r < f c ↔ slope f c b < slope f a c := - map_lt_lineMap_iff_slope_lt_slope (E := Eᵒᵈ) hab h₀ h₁ + lineMap (f a) (f b) r < f c ↔ slope f c b < slope f a c := by + unsealing_newtype OrderDual => + exact map_lt_lineMap_iff_slope_lt_slope (E := Eᵒᵈ) (f := OrderDual.toDual ∘ f) hab h₀ h₁ end LinearOrderedField diff --git a/mathlib4/Mathlib/LinearAlgebra/Dual/Defs.lean b/mathlib4/Mathlib/LinearAlgebra/Dual/Defs.lean index 12dbea9dd..fea24ca15 100644 --- a/mathlib4/Mathlib/LinearAlgebra/Dual/Defs.lean +++ b/mathlib4/Mathlib/LinearAlgebra/Dual/Defs.lean @@ -374,19 +374,21 @@ theorem dualAnnihilator_gc : GaloisConnection (OrderDual.toDual ∘ (dualAnnihilator : Submodule R M → Submodule R (Module.Dual R M))) (dualCoannihilator ∘ OrderDual.ofDual) := by - intro a b - induction b using OrderDual.rec - simp only [Function.comp_apply, OrderDual.toDual_le_toDual, OrderDual.ofDual_toDual, - SetLike.le_def, mem_dualAnnihilator, mem_dualCoannihilator] - grind + unsealing_newtype OrderDual => + intro a b + induction b using OrderDual.rec + simp only [Function.comp_apply, OrderDual.toDual_le_toDual, OrderDual.ofDual_toDual, + SetLike.le_def, mem_dualAnnihilator, mem_dualCoannihilator] + grind theorem le_dualAnnihilator_iff_le_dualCoannihilator {U : Submodule R (Module.Dual R M)} {V : Submodule R M} : U ≤ V.dualAnnihilator ↔ V ≤ U.dualCoannihilator := (dualAnnihilator_gc R M).le_iff_le @[simp] -theorem dualAnnihilator_bot : (⊥ : Submodule R M).dualAnnihilator = ⊤ := - (dualAnnihilator_gc R M).l_bot +theorem dualAnnihilator_bot : (⊥ : Submodule R M).dualAnnihilator = ⊤ := by + unsealing_newtype OrderDual => + exact (dualAnnihilator_gc R M).l_bot @[simp] theorem dualAnnihilator_top : (⊤ : Submodule R M).dualAnnihilator = ⊥ := by @@ -411,32 +413,38 @@ theorem le_dualAnnihilator_dualCoannihilator (U : Submodule R M) : (dualAnnihilator_gc R M).le_u_l U theorem le_dualCoannihilator_dualAnnihilator (U : Submodule R (Module.Dual R M)) : - U ≤ U.dualCoannihilator.dualAnnihilator := - (dualAnnihilator_gc R M).l_u_le U + U ≤ U.dualCoannihilator.dualAnnihilator := by + unsealing_newtype OrderDual => + exact (dualAnnihilator_gc R M).l_u_le U theorem dualAnnihilator_dualCoannihilator_dualAnnihilator (U : Submodule R M) : - U.dualAnnihilator.dualCoannihilator.dualAnnihilator = U.dualAnnihilator := - (dualAnnihilator_gc R M).l_u_l_eq_l U + U.dualAnnihilator.dualCoannihilator.dualAnnihilator = U.dualAnnihilator := by + unsealing_newtype OrderDual => + exact (dualAnnihilator_gc R M).l_u_l_eq_l U theorem dualCoannihilator_dualAnnihilator_dualCoannihilator (U : Submodule R (Module.Dual R M)) : - U.dualCoannihilator.dualAnnihilator.dualCoannihilator = U.dualCoannihilator := - (dualAnnihilator_gc R M).u_l_u_eq_u U + U.dualCoannihilator.dualAnnihilator.dualCoannihilator = U.dualCoannihilator := by + unsealing_newtype OrderDual => + exact (dualAnnihilator_gc R M).u_l_u_eq_u U theorem dualAnnihilator_sup_eq (U V : Submodule R M) : - (U ⊔ V).dualAnnihilator = U.dualAnnihilator ⊓ V.dualAnnihilator := - (dualAnnihilator_gc R M).l_sup + (U ⊔ V).dualAnnihilator = U.dualAnnihilator ⊓ V.dualAnnihilator := by + unsealing_newtype OrderDual => + exact (dualAnnihilator_gc R M).l_sup theorem dualCoannihilator_sup_eq (U V : Submodule R (Module.Dual R M)) : (U ⊔ V).dualCoannihilator = U.dualCoannihilator ⊓ V.dualCoannihilator := (dualAnnihilator_gc R M).u_inf theorem dualAnnihilator_iSup_eq {ι : Sort*} (U : ι → Submodule R M) : - (⨆ i : ι, U i).dualAnnihilator = ⨅ i : ι, (U i).dualAnnihilator := - (dualAnnihilator_gc R M).l_iSup + (⨆ i : ι, U i).dualAnnihilator = ⨅ i : ι, (U i).dualAnnihilator := by + unsealing_newtype OrderDual => + exact (dualAnnihilator_gc R M).l_iSup theorem dualCoannihilator_iSup_eq {ι : Sort*} (U : ι → Submodule R (Module.Dual R M)) : - (⨆ i : ι, U i).dualCoannihilator = ⨅ i : ι, (U i).dualCoannihilator := - (dualAnnihilator_gc R M).u_iInf + (⨆ i : ι, U i).dualCoannihilator = ⨅ i : ι, (U i).dualCoannihilator := by + unsealing_newtype OrderDual => + exact (dualAnnihilator_gc R M).u_iInf /-- See also `Subspace.dualAnnihilator_inf_eq` for vector subspaces. -/ theorem sup_dualAnnihilator_le_inf (U V : Submodule R M) : diff --git a/mathlib4/Mathlib/LinearAlgebra/Dual/Lemmas.lean b/mathlib4/Mathlib/LinearAlgebra/Dual/Lemmas.lean index db8c12a61..11ea2410e 100644 --- a/mathlib4/Mathlib/LinearAlgebra/Dual/Lemmas.lean +++ b/mathlib4/Mathlib/LinearAlgebra/Dual/Lemmas.lean @@ -464,7 +464,7 @@ def dualAnnihilatorGci (K V : Type*) [Field K] [AddCommGroup V] [Module K V] : GaloisCoinsertion (OrderDual.toDual ∘ (dualAnnihilator : Subspace K V → Subspace K (Module.Dual K V))) (dualCoannihilator ∘ OrderDual.ofDual) where - choice W _ := dualCoannihilator W + choice W _ := dualCoannihilator (OrderDual.ofDual W) gc := dualAnnihilator_gc K V u_l_le _ := dualAnnihilator_dualCoannihilator_eq.le choice_eq _ _ := rfl @@ -474,8 +474,9 @@ theorem dualAnnihilator_le_dualAnnihilator_iff {W W' : Subspace K V} : (dualAnnihilatorGci K V).l_le_l_iff theorem dualAnnihilator_inj {W W' : Subspace K V} : - W.dualAnnihilator = W'.dualAnnihilator ↔ W = W' := - ⟨fun h ↦ (dualAnnihilatorGci K V).l_injective h, congr_arg _⟩ + W.dualAnnihilator = W'.dualAnnihilator ↔ W = W' := by + unsealing_newtype OrderDual => + exact ⟨fun h ↦ (dualAnnihilatorGci K V).l_injective h, congr_arg _⟩ /-- Given a subspace `W` of `V` and an element of its dual `φ`, `dualLift W φ` is an arbitrary extension of `φ` to an element of the dual of `V`. @@ -1040,7 +1041,8 @@ def orderIsoFiniteCodimDim : invFun W := ⟨(ofDual W).1.dualCoannihilator, finiteDimensional_quot_dualCoannihilator_iff.mpr (ofDual W).2⟩ left_inv _ := Subtype.ext dualAnnihilator_dualCoannihilator_eq - right_inv W := have := (ofDual W).2; Subtype.ext dualCoannihilator_dualAnnihilator_eq + right_inv W := have := (ofDual W).2 + congrArg toDual (Subtype.ext dualCoannihilator_dualAnnihilator_eq) map_rel_iff' := dualAnnihilator_le_dualAnnihilator_iff open OrderDual in @@ -1052,7 +1054,7 @@ def orderIsoFiniteDimensional [FiniteDimensional K V] : toFun W := toDual W.dualAnnihilator invFun W := (ofDual W).dualCoannihilator left_inv _ := dualAnnihilator_dualCoannihilator_eq - right_inv _ := dualCoannihilator_dualAnnihilator_eq + right_inv _ := congrArg toDual dualCoannihilator_dualAnnihilator_eq map_rel_iff' := dualAnnihilator_le_dualAnnihilator_iff open Submodule in diff --git a/mathlib4/Mathlib/LinearAlgebra/SesquilinearForm/Orthogonal.lean b/mathlib4/Mathlib/LinearAlgebra/SesquilinearForm/Orthogonal.lean index b0cdcb563..07247368c 100644 --- a/mathlib4/Mathlib/LinearAlgebra/SesquilinearForm/Orthogonal.lean +++ b/mathlib4/Mathlib/LinearAlgebra/SesquilinearForm/Orthogonal.lean @@ -68,18 +68,21 @@ theorem mem_orthogonalBilin_iff_le_ker_flip {y : M₂} : variable (B) in lemma orthogonalBilin_gc : @GaloisConnection (Submodule R₁ M₁) (Submodule R₂ M₂)ᵒᵈ _ _ - (orthogonalBilin B) (orthogonalBilin B.flip) := + (fun S ↦ OrderDual.toDual (orthogonalBilin B S)) + (fun T ↦ orthogonalBilin B.flip (OrderDual.ofDual T)) := fun _ _ ↦ ⟨fun h _ hx _ hy ↦ h hy _ hx, fun h _ hy _ hx ↦ h hx _ hy⟩ theorem le_orthogonalBilin_flip_iff_le_orthogonalBilin {T : Submodule R₂ M₂} : - S ≤ orthogonalBilin B.flip T ↔ T ≤ orthogonalBilin B S := - ((orthogonalBilin_gc B) S T).symm + S ≤ orthogonalBilin B.flip T ↔ T ≤ orthogonalBilin B S := by + unsealing_newtype OrderDual => + exact ((orthogonalBilin_gc B) S T).symm alias ⟨le_orthogonalBilin_of_le_orthogonBilin_flip, le_orthogonalBilin_flip_of_le_orthogonBilin⟩ := le_orthogonalBilin_flip_iff_le_orthogonalBilin -@[simp] theorem orthogonalBilin_bot : orthogonalBilin B ⊥ = ⊤ := - (orthogonalBilin_gc B).l_bot +@[simp] theorem orthogonalBilin_bot : orthogonalBilin B ⊥ = ⊤ := by + unsealing_newtype OrderDual => + exact (orthogonalBilin_gc B).l_bot @[simp] theorem orthogonalBilin_ker : orthogonalBilin B (ker B) = ⊤ := by ext; simp +contextual @@ -108,16 +111,19 @@ theorem orthogonalBilin_span_singleton (x : M₁) : orthogonalBilin B (R₁ ∙ alias _root_.LinearMap.orthogonal_span_singleton_eq_to_lin_ker := orthogonalBilin_span_singleton theorem orthogonalBilin_sSup (s : Set (Submodule R₁ M₁)) : - orthogonalBilin B (sSup s) = ⨅ S ∈ s, orthogonalBilin B S := - (orthogonalBilin_gc B).l_sSup + orthogonalBilin B (sSup s) = ⨅ S ∈ s, orthogonalBilin B S := by + unsealing_newtype OrderDual => + exact (orthogonalBilin_gc B).l_sSup theorem orthogonalBilin_iSup {ι : Sort*} (f : ι → Submodule R₁ M₁) : - orthogonalBilin B (⨆ i, f i) = ⨅ i, orthogonalBilin B (f i) := - (orthogonalBilin_gc B).l_iSup + orthogonalBilin B (⨆ i, f i) = ⨅ i, orthogonalBilin B (f i) := by + unsealing_newtype OrderDual => + exact (orthogonalBilin_gc B).l_iSup theorem orthogonalBilin_sup (S T) : - orthogonalBilin B (S ⊔ T) = orthogonalBilin B S ⊓ orthogonalBilin B T := - (orthogonalBilin_gc B).l_sup + orthogonalBilin B (S ⊔ T) = orthogonalBilin B S ⊓ orthogonalBilin B T := by + unsealing_newtype OrderDual => + exact (orthogonalBilin_gc B).l_sup variable (B) in @[simp] theorem orthogonalBilin_sup_ker (S) : @@ -133,13 +139,15 @@ theorem le_orthogonalBilin_orthogonalBilin {I₂ : R₁ →+* R} {B : M₁ → fun n hn _m hm ↦ b _ _ (hm n hn) @[simp] theorem orthogonalBilin_orthogonalBilin_flip_orthogonalBilin (S) : - orthogonalBilin B (orthogonalBilin B.flip (orthogonalBilin B S)) = orthogonalBilin B S := - (orthogonalBilin_gc B).l_u_l_eq_l S + orthogonalBilin B (orthogonalBilin B.flip (orthogonalBilin B S)) = orthogonalBilin B S := by + unsealing_newtype OrderDual => + exact (orthogonalBilin_gc B).l_u_l_eq_l S @[simp] theorem orthogonalBilin_flip_orthogonalBilin_orthogonalBilin_flip (S : Submodule R₂ M₂) : orthogonalBilin B.flip (orthogonalBilin B (orthogonalBilin B.flip S)) = - orthogonalBilin B.flip S := - (orthogonalBilin_gc B).u_l_u_eq_u S + orthogonalBilin B.flip S := by + unsealing_newtype OrderDual => + exact (orthogonalBilin_gc B).u_l_u_eq_u S theorem orthogonalBilin_sup_orthogonalBilin_le_orthogonalBilin_inf (S T) : orthogonalBilin B S ⊔ orthogonalBilin B T ≤ orthogonalBilin B (S ⊓ T) := diff --git a/mathlib4/Mathlib/Logic/Small/Basic.lean b/mathlib4/Mathlib/Logic/Small/Basic.lean index bbb8f90d1..da2163bf5 100644 --- a/mathlib4/Mathlib/Logic/Small/Basic.lean +++ b/mathlib4/Mathlib/Logic/Small/Basic.lean @@ -76,4 +76,5 @@ instance small_quot {α : Type u} [Small.{v} α] (r : α → α → Prop) : Smal instance small_quotient {α : Type u} [Small.{v} α] (s : Setoid α) : Small.{v} (Quotient s) := small_of_surjective Quotient.mk_surjective -instance small_orderDual {α : Type*} [h : Small.{v} α] : Small.{v} αᵒᵈ := h +instance small_orderDual {α : Type*} [Small.{v} α] : Small.{v} αᵒᵈ := + small_of_surjective OrderDual.toDual.surjective diff --git a/mathlib4/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean b/mathlib4/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean index 7c7da67bd..2f6cc7ec9 100644 --- a/mathlib4/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean +++ b/mathlib4/Mathlib/MeasureTheory/Constructions/BorelSpace/Basic.lean @@ -171,13 +171,17 @@ elab_rules : tactic end Mathlib.Tactic.Borelize +/-- The topology of `αᵒᵈ` is coinduced by `toDual` and `MeasurableSet[αᵒᵈ] s` is by definition +`MeasurableSet (⇑toDual ⁻¹' s)`, so both classes transfer by taking preimages along `toDual`. -/ instance (priority := 100) OrderDual.opensMeasurableSpace {α : Type*} [TopologicalSpace α] - [MeasurableSpace α] [h : OpensMeasurableSpace α] : OpensMeasurableSpace αᵒᵈ where - borel_le := h.borel_le + [MeasurableSpace α] [OpensMeasurableSpace α] : OpensMeasurableSpace αᵒᵈ where + borel_le := generateFrom_le fun _s hs ↦ + OpensMeasurableSpace.borel_le (α := α) _ <| + GenerateMeasurable.basic _ (IsOpen.preimage continuous_toDual hs) instance (priority := 100) OrderDual.borelSpace {α : Type*} [TopologicalSpace α] - [MeasurableSpace α] [h : BorelSpace α] : BorelSpace αᵒᵈ where - measurable_eq := h.measurable_eq + [MeasurableSpace α] [h : BorelSpace α] : BorelSpace αᵒᵈ := by + unsealing_newtype OrderDual => exact ⟨h.measurable_eq⟩ /-- In a `BorelSpace` all open sets are measurable. -/ instance (priority := 100) BorelSpace.opensMeasurable {α : Type*} [TopologicalSpace α] diff --git a/mathlib4/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean b/mathlib4/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean index b7d71dcc3..9cd2716c7 100644 --- a/mathlib4/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean +++ b/mathlib4/Mathlib/MeasureTheory/Constructions/BorelSpace/Order.lean @@ -75,8 +75,10 @@ theorem borel_eq_generateFrom_Iio : borel α = .generateFrom (range Iio) := by intro a exact GenerateMeasurable.basic _ isOpen_Iio -theorem borel_eq_generateFrom_Ioi : borel α = .generateFrom (range Ioi) := - @borel_eq_generateFrom_Iio αᵒᵈ _ (by infer_instance : SecondCountableTopology α) _ _ +set_option backward.isDefEq.respectTransparency false in +theorem borel_eq_generateFrom_Ioi : borel α = .generateFrom (range Ioi) := by + unsealing_newtype OrderDual => + exact @borel_eq_generateFrom_Iio αᵒᵈ _ (by infer_instance : SecondCountableTopology α) _ _ theorem borel_eq_generateFrom_Iic : borel α = MeasurableSpace.generateFrom (range Iic) := by @@ -91,8 +93,9 @@ theorem borel_eq_generateFrom_Iic : rw [← compl_Ioi] exact (MeasurableSpace.measurableSet_generateFrom (mem_range.mpr ⟨u, rfl⟩)).compl -theorem borel_eq_generateFrom_Ici : borel α = MeasurableSpace.generateFrom (range Ici) := - @borel_eq_generateFrom_Iic αᵒᵈ _ _ _ _ +theorem borel_eq_generateFrom_Ici : borel α = MeasurableSpace.generateFrom (range Ici) := by + unsealing_newtype OrderDual => + exact @borel_eq_generateFrom_Iic αᵒᵈ _ _ _ _ end OrderTopology @@ -405,13 +408,14 @@ theorem Dense.borel_eq_generateFrom_Ioc_mem_aux {α : Type*} [TopologicalSpace [OrderTopology α] [SecondCountableTopology α] {s : Set α} (hd : Dense s) (hbot : ∀ x, IsTop x → x ∈ s) (hIoo : ∀ x y : α, x < y → Ioo x y = ∅ → x ∈ s) : borel α = .generateFrom { S : Set α | ∃ l ∈ s, ∃ u ∈ s, l < u ∧ Ioc l u = S } := by - convert! - hd.orderDual.borel_eq_generateFrom_Ico_mem_aux hbot fun x y hlt he => hIoo y x hlt _ using 2 - · ext s - constructor <;> rintro ⟨l, hl, u, hu, hlt, rfl⟩ - exacts [⟨u, hu, l, hl, hlt, Ico_toDual⟩, ⟨u, hu, l, hl, hlt, Ioc_toDual⟩] - · erw [Ioo_toDual] - exact he + unsealing_newtype OrderDual => + convert! + hd.orderDual.borel_eq_generateFrom_Ico_mem_aux hbot fun x y hlt he => hIoo y x hlt _ using 2 + · ext s + constructor <;> rintro ⟨l, hl, u, hu, hlt, rfl⟩ + exacts [⟨u, hu, l, hl, hlt, Ico_toDual⟩, ⟨u, hu, l, hl, hlt, Ioc_toDual⟩] + · erw [Ioo_toDual] + exact he theorem Dense.borel_eq_generateFrom_Ioc_mem {α : Type*} [TopologicalSpace α] [LinearOrder α] [OrderTopology α] [SecondCountableTopology α] [DenselyOrdered α] [NoMaxOrder α] {s : Set α} @@ -454,7 +458,6 @@ theorem ext_of_Ico_finite {α : Type*} [TopologicalSpace α] {m : MeasurableSpac rintro - ⟨a, b, hlt, rfl⟩ exact h hlt -set_option backward.isDefEq.respectTransparency false in /-- Two finite measures on a Borel space are equal if they agree on all open-closed intervals. If `α` is a conditionally complete linear order with no top element, `MeasureTheory.Measure.ext_of_Ioc` is an extensionality lemma with weaker assumptions on `μ` and @@ -463,9 +466,10 @@ theorem ext_of_Ioc_finite {α : Type*} [TopologicalSpace α] {m : MeasurableSpac [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α) [IsFiniteMeasure μ] (hμν : μ univ = ν univ) (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := by - refine @ext_of_Ico_finite αᵒᵈ _ _ _ _ _ ‹_› μ ν _ hμν fun a b hab => ?_ - erw [Ico_toDual (α := α)] - exact h hab + unsealing_newtype OrderDual => + refine @ext_of_Ico_finite αᵒᵈ _ _ _ _ _ ‹_› μ ν ‹_› hμν fun a b hab => ?_ + erw [Ico_toDual (α := α)] + exact h hab /-- Two measures which are finite on closed-open intervals are equal if they agree on all closed-open intervals. -/ @@ -498,8 +502,10 @@ theorem ext_of_Ioc' {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α} [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] [NoMinOrder α] (μ ν : Measure α) (hμ : ∀ ⦃a b⦄, a < b → μ (Ioc a b) ≠ ∞) (h : ∀ ⦃a b⦄, a < b → μ (Ioc a b) = ν (Ioc a b)) : μ = ν := by - refine @ext_of_Ico' αᵒᵈ _ _ _ _ _ ‹_› _ μ ν ?_ ?_ <;> intro a b hab <;> erw [Ico_toDual (α := α)] - exacts [hμ hab, h hab] + unsealing_newtype OrderDual => + refine @ext_of_Ico' αᵒᵈ _ _ _ _ _ ‹_› _ μ ν ?_ ?_ <;> + intro a b hab <;> erw [Ico_toDual (α := α)] + exacts [hμ hab, h hab] /-- Two measures which are finite on closed-open intervals are equal if they agree on all closed-open intervals. -/ @@ -532,13 +538,13 @@ theorem ext_of_Iic {α : Type*} [TopologicalSpace α] {m : MeasurableSpace α} finiteness · finiteness -set_option backward.isDefEq.respectTransparency false in /-- Two finite measures on a Borel space are equal if they agree on all left-closed right-infinite intervals. -/ theorem ext_of_Ici {α : Type*} [TopologicalSpace α] {_ : MeasurableSpace α} [SecondCountableTopology α] [LinearOrder α] [OrderTopology α] [BorelSpace α] (μ ν : Measure α) - [IsFiniteMeasure μ] (h : ∀ a, μ (Ici a) = ν (Ici a)) : μ = ν := - @ext_of_Iic αᵒᵈ _ _ _ _ _ ‹_› _ _ _ h + [IsFiniteMeasure μ] (h : ∀ a, μ (Ici a) = ν (Ici a)) : μ = ν := by + unsealing_newtype OrderDual => + exact @ext_of_Iic αᵒᵈ _ _ _ _ _ ‹_› _ _ ‹_› h /-- Two measures which are finite on closed intervals are equal if they agree on all closed intervals. -/ @@ -680,8 +686,9 @@ lemma measurable_iInf_of_upperSemicontinuous [CompleteLinearOrder β] [OrderTopo {ι : Type*} [TopologicalSpace ι] [SeparableSpace ι] {f : ι → δ → β} (mf : ∀ t, Measurable (f t)) (cf : ∀ x, UpperSemicontinuous (f · x)) : - Measurable (⨅ i, f i) := - measurable_iSup_of_lowerSemicontinuous (β := βᵒᵈ) mf cf + Measurable (⨅ i, f i) := by + unsealing_newtype OrderDual => + exact measurable_iSup_of_lowerSemicontinuous (β := βᵒᵈ) mf cf theorem LowerSemicontinuous.measurable [TopologicalSpace δ] [OpensMeasurableSpace δ] {f : δ → α} (hf : LowerSemicontinuous f) : Measurable f := @@ -771,21 +778,24 @@ theorem AEMeasurable.isLUB {ι} {μ : Measure δ} [Countable ι] {f : ι → δ /-- If a function is the greatest lower bound of countably many measurable functions, then it is measurable. -/ theorem Measurable.isGLB {ι} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, Measurable (f i)) - (hg : ∀ b, IsGLB { a | ∃ i, f i b = a } (g b)) : Measurable g := - Measurable.isLUB (α := αᵒᵈ) hf hg + (hg : ∀ b, IsGLB { a | ∃ i, f i b = a } (g b)) : Measurable g := by + unsealing_newtype OrderDual => + exact Measurable.isLUB (α := αᵒᵈ) hf hg /-- If a function is the greatest lower bound of countably many measurable functions on a measurable set `s`, and coincides with a measurable function outside of `s`, then it is measurable. -/ theorem Measurable.isGLB_of_mem {ι} [Countable ι] {f : ι → δ → α} {g g' : δ → α} (hf : ∀ i, Measurable (f i)) {s : Set δ} (hs : MeasurableSet s) (hg : ∀ b ∈ s, IsGLB { a | ∃ i, f i b = a } (g b)) - (hg' : EqOn g g' sᶜ) (g'_meas : Measurable g') : Measurable g := - Measurable.isLUB_of_mem (α := αᵒᵈ) hf hs hg hg' g'_meas + (hg' : EqOn g g' sᶜ) (g'_meas : Measurable g') : Measurable g := by + unsealing_newtype OrderDual => + exact Measurable.isLUB_of_mem (α := αᵒᵈ) hf hs hg hg' g'_meas theorem AEMeasurable.isGLB {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α} {g : δ → α} (hf : ∀ i, AEMeasurable (f i) μ) (hg : ∀ᵐ b ∂μ, IsGLB { a | ∃ i, f i b = a } (g b)) : - AEMeasurable g μ := - AEMeasurable.isLUB (α := αᵒᵈ) hf hg + AEMeasurable g μ := by + unsealing_newtype OrderDual => + exact AEMeasurable.isLUB (α := αᵒᵈ) hf hg protected theorem Monotone.measurable [LinearOrder β] [OrderClosedTopology β] {f : β → α} (hf : Monotone f) : Measurable f := @@ -799,13 +809,15 @@ theorem aemeasurable_restrict_of_monotoneOn [LinearOrder β] [OrderClosedTopolog aemeasurable_restrict_of_measurable_subtype hs this.measurable protected theorem Antitone.measurable [LinearOrder β] [OrderClosedTopology β] {f : β → α} - (hf : Antitone f) : Measurable f := - @Monotone.measurable αᵒᵈ β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ hf + (hf : Antitone f) : Measurable f := by + unsealing_newtype OrderDual => + exact @Monotone.measurable αᵒᵈ β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ hf theorem aemeasurable_restrict_of_antitoneOn [LinearOrder β] [OrderClosedTopology β] {μ : Measure β} {s : Set β} (hs : MeasurableSet s) {f : β → α} (hf : AntitoneOn f s) : - AEMeasurable f (μ.restrict s) := - @aemeasurable_restrict_of_monotoneOn αᵒᵈ β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ _ hs _ hf + AEMeasurable f (μ.restrict s) := by + unsealing_newtype OrderDual => + exact @aemeasurable_restrict_of_monotoneOn αᵒᵈ β _ _ ‹_› _ _ _ _ _ ‹_› _ _ _ _ hs _ hf theorem MeasurableSet.of_mem_nhdsGT_aux {s : Set α} (h : ∀ x ∈ s, s ∈ 𝓝[>] x) (h' : ∀ x ∈ s, ∃ y, x < y) : MeasurableSet s := by @@ -874,8 +886,9 @@ lemma measurableSet_bddAbove_range {ι} [Countable ι] {f : ι → δ → α} (h exact MeasurableSet.iUnion (fun n ↦ B (u n)) lemma measurableSet_bddBelow_range {ι} [Countable ι] {f : ι → δ → α} (hf : ∀ i, Measurable (f i)) : - MeasurableSet {b | BddBelow (range (fun i ↦ f i b))} := - measurableSet_bddAbove_range (α := αᵒᵈ) hf + MeasurableSet {b | BddBelow (range (fun i ↦ f i b))} := by + unsealing_newtype OrderDual => + exact measurableSet_bddAbove_range (α := αᵒᵈ) hf end LinearOrder @@ -938,13 +951,15 @@ protected theorem AEMeasurable.iSup {ι} {μ : Measure δ} [Countable ι] {f : @[fun_prop] protected theorem Measurable.iInf {ι} [Countable ι] {f : ι → δ → α} (hf : ∀ i, Measurable (f i)) : - Measurable fun b => ⨅ i, f i b := - .iSup (α := αᵒᵈ) hf + Measurable fun b => ⨅ i, f i b := by + unsealing_newtype OrderDual => + exact .iSup (α := αᵒᵈ) hf @[fun_prop] protected theorem AEMeasurable.iInf {ι} {μ : Measure δ} [Countable ι] {f : ι → δ → α} - (hf : ∀ i, AEMeasurable (f i) μ) : AEMeasurable (fun b => ⨅ i, f i b) μ := - .iSup (α := αᵒᵈ) hf + (hf : ∀ i, AEMeasurable (f i) μ) : AEMeasurable (fun b => ⨅ i, f i b) μ := by + unsealing_newtype OrderDual => + exact .iSup (α := αᵒᵈ) hf protected theorem Measurable.sSup {ι} {f : ι → δ → α} {s : Set ι} (hs : s.Countable) (hf : ∀ i ∈ s, Measurable (f i)) : @@ -955,8 +970,9 @@ protected theorem Measurable.sSup {ι} {f : ι → δ → α} {s : Set ι} (hs : protected theorem Measurable.sInf {ι} {f : ι → δ → α} {s : Set ι} (hs : s.Countable) (hf : ∀ i ∈ s, Measurable (f i)) : - Measurable fun x => sInf ((fun i => f i x) '' s) := - .sSup (α := αᵒᵈ) hs hf + Measurable fun x => sInf ((fun i => f i x) '' s) := by + unsealing_newtype OrderDual => + exact .sSup (α := αᵒᵈ) hs hf theorem Measurable.biSup {ι} (s : Set ι) {f : ι → δ → α} (hs : s.Countable) (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun b => ⨆ i ∈ s, f i b := by @@ -986,12 +1002,14 @@ theorem AEMeasurable.biSup {ι} {μ : Measure δ} (s : Set ι) {f : ι → δ exact iSup_congr fun i => iSup_congr (hb i) theorem Measurable.biInf {ι} (s : Set ι) {f : ι → δ → α} (hs : s.Countable) - (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun b => ⨅ i ∈ s, f i b := - .biSup (α := αᵒᵈ) s hs hf + (hf : ∀ i ∈ s, Measurable (f i)) : Measurable fun b => ⨅ i ∈ s, f i b := by + unsealing_newtype OrderDual => + exact .biSup (α := αᵒᵈ) s hs hf theorem AEMeasurable.biInf {ι} {μ : Measure δ} (s : Set ι) {f : ι → δ → α} (hs : s.Countable) - (hf : ∀ i ∈ s, AEMeasurable (f i) μ) : AEMeasurable (fun b => ⨅ i ∈ s, f i b) μ := - .biSup (α := αᵒᵈ) s hs hf + (hf : ∀ i ∈ s, AEMeasurable (f i) μ) : AEMeasurable (fun b => ⨅ i ∈ s, f i b) μ := by + unsealing_newtype OrderDual => + exact .biSup (α := αᵒᵈ) s hs hf /-- `liminf` over a general filter is measurable. See `Measurable.liminf` for the version over `ℕ`. -/ @@ -1049,8 +1067,9 @@ theorem Measurable.liminf' {ι ι'} {f : ι → δ → α} {v : Filter ι} (hf : -/ theorem Measurable.limsup' {ι ι'} {f : ι → δ → α} {u : Filter ι} (hf : ∀ i, Measurable (f i)) {p : ι' → Prop} {s : ι' → Set ι} (hu : u.HasCountableBasis p s) (hs : ∀ i, (s i).Countable) : - Measurable fun x => limsup (fun i => f i x) u := - .liminf' (α := αᵒᵈ) hf hu hs + Measurable fun x => limsup (fun i => f i x) u := by + unsealing_newtype OrderDual => + exact .liminf' (α := αᵒᵈ) hf hu hs /-- `liminf` over `ℕ` is measurable. See `Measurable.liminf'` for a version with a general filter. -/ diff --git a/mathlib4/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean b/mathlib4/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean index ba288244a..55dfbb348 100644 --- a/mathlib4/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean +++ b/mathlib4/Mathlib/MeasureTheory/Constructions/Polish/Basic.lean @@ -975,8 +975,9 @@ theorem MeasurableSet.image_of_monotoneOn [SecondCountableTopology β] /-- The image of a measurable set under an antitone map is measurable. -/ theorem MeasurableSet.image_of_antitoneOn [SecondCountableTopology β] - (ht : MeasurableSet t) (hg : AntitoneOn g t) : MeasurableSet (g '' t) := - (ht.image_of_monotoneOn hg.dual_right :) + (ht : MeasurableSet t) (hg : AntitoneOn g t) : MeasurableSet (g '' t) := by + unsealing_newtype OrderDual => + exact (ht.image_of_monotoneOn hg.dual_right :) end LinearOrder diff --git a/mathlib4/Mathlib/MeasureTheory/Function/AEEqOfLIntegral.lean b/mathlib4/Mathlib/MeasureTheory/Function/AEEqOfLIntegral.lean index 5cb80314e..31f6da590 100644 --- a/mathlib4/Mathlib/MeasureTheory/Function/AEEqOfLIntegral.lean +++ b/mathlib4/Mathlib/MeasureTheory/Function/AEEqOfLIntegral.lean @@ -46,8 +46,9 @@ theorem ae_const_le_iff_forall_lt_measure_zero {β} [LinearOrder β] [Topologica lemma ae_le_const_iff_forall_gt_measure_zero {β} [LinearOrder β] [TopologicalSpace β] [OrderTopology β] [FirstCountableTopology β] {μ : Measure α} (f : α → β) (c : β) : - (∀ᵐ x ∂μ, f x ≤ c) ↔ ∀ b, c < b → μ {x | b ≤ f x} = 0 := - ae_const_le_iff_forall_lt_measure_zero (β := βᵒᵈ) _ _ + (∀ᵐ x ∂μ, f x ≤ c) ↔ ∀ b, c < b → μ {x | b ≤ f x} = 0 := by + unsealing_newtype OrderDual => + exact ae_const_le_iff_forall_lt_measure_zero (β := βᵒᵈ) _ _ theorem ae_le_of_forall_setLIntegral_le_of_sigmaFinite₀ [SigmaFinite μ] {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) diff --git a/mathlib4/Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean b/mathlib4/Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean index d4bea7630..d94e3dbd8 100644 --- a/mathlib4/Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean +++ b/mathlib4/Mathlib/MeasureTheory/Function/AEMeasurableSequence.lean @@ -117,7 +117,8 @@ theorem iSup [SupSet β] [Countable ι] (hf : ∀ i, AEMeasurable (f i) μ) simp [iSup_apply, hx] theorem iInf [InfSet β] [Countable ι] (hf : ∀ i, AEMeasurable (f i) μ) - (hp : ∀ᵐ x ∂μ, p x fun n ↦ f n x) : ⨅ n, aeSeq hf p n =ᵐ[μ] ⨅ n, f n := - iSup (β := βᵒᵈ) hf hp + (hp : ∀ᵐ x ∂μ, p x fun n ↦ f n x) : ⨅ n, aeSeq hf p n =ᵐ[μ] ⨅ n, f n := by + unsealing_newtype OrderDual => + exact iSup (β := βᵒᵈ) hf hp end aeSeq diff --git a/mathlib4/Mathlib/MeasureTheory/Function/EssSup.lean b/mathlib4/Mathlib/MeasureTheory/Function/EssSup.lean index daae5e3c3..6caf8d667 100644 --- a/mathlib4/Mathlib/MeasureTheory/Function/EssSup.lean +++ b/mathlib4/Mathlib/MeasureTheory/Function/EssSup.lean @@ -55,7 +55,7 @@ theorem essSup_congr_ae {f g : α → β} (hfg : f =ᵐ[μ] g) : essSup f μ = e limsup_congr hfg theorem essInf_congr_ae {f g : α → β} (hfg : f =ᵐ[μ] g) : essInf f μ = essInf g μ := - @essSup_congr_ae α βᵒᵈ _ _ _ _ _ hfg + liminf_congr hfg @[simp] theorem essSup_const' [NeZero μ] (c : β) : essSup (fun _ : α => c) μ = c := @@ -290,8 +290,9 @@ theorem essSup_measure_zero {m : MeasurableSpace α} {f : α → β} : essSup f le_bot_iff.mp (sInf_le (by simp)) @[simp] -theorem essInf_measure_zero {_ : MeasurableSpace α} {f : α → β} : essInf f (0 : Measure α) = ⊤ := - @essSup_measure_zero α βᵒᵈ _ _ _ +theorem essInf_measure_zero {_ : MeasurableSpace α} {f : α → β} : essInf f (0 : Measure α) = ⊤ := by + unsealing_newtype OrderDual => + exact @essSup_measure_zero α βᵒᵈ _ _ _ theorem essSup_const_bot : essSup (fun _ : α => (⊥ : β)) μ = (⊥ : β) := limsup_const_bot diff --git a/mathlib4/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean b/mathlib4/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean index dc00e515b..742a9514f 100644 --- a/mathlib4/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean +++ b/mathlib4/Mathlib/MeasureTheory/Function/LocallyIntegrable.lean @@ -511,8 +511,9 @@ theorem integrable_iff_integrableAtFilter_atBot [LinearOrder X] [OrderTop X] [Co exact h.1.filter_mono cocompact_le_atBot theorem integrable_iff_integrableAtFilter_atTop [LinearOrder X] [OrderBot X] [CompactIccSpace X] : - Integrable f μ ↔ IntegrableAtFilter f atTop μ ∧ LocallyIntegrable f μ := - integrable_iff_integrableAtFilter_atBot (X := Xᵒᵈ) + Integrable f μ ↔ IntegrableAtFilter f atTop μ ∧ LocallyIntegrable f μ := by + unsealing_newtype OrderDual => + exact integrable_iff_integrableAtFilter_atBot (X := Xᵒᵈ) variable {a : X} @@ -525,8 +526,9 @@ theorem integrableOn_Iic_iff_integrableAtFilter_atBot [LinearOrder X] [CompactIc exact h.integrableOn_compact_subset Icc_subset_Iic_self isCompact_Icc theorem integrableOn_Ici_iff_integrableAtFilter_atTop [LinearOrder X] [CompactIccSpace X] : - IntegrableOn f (Ici a) μ ↔ IntegrableAtFilter f atTop μ ∧ LocallyIntegrableOn f (Ici a) μ := - integrableOn_Iic_iff_integrableAtFilter_atBot (X := Xᵒᵈ) + IntegrableOn f (Ici a) μ ↔ IntegrableAtFilter f atTop μ ∧ LocallyIntegrableOn f (Ici a) μ := by + unsealing_newtype OrderDual => + exact integrableOn_Iic_iff_integrableAtFilter_atBot (X := Xᵒᵈ) theorem integrableOn_Iio_iff_integrableAtFilter_atBot_nhdsWithin [LinearOrder X] [CompactIccSpace X] [NoMinOrder X] [OrderTopology X] : @@ -544,8 +546,9 @@ theorem integrableOn_Iio_iff_integrableAtFilter_atBot_nhdsWithin theorem integrableOn_Ioi_iff_integrableAtFilter_atTop_nhdsWithin [LinearOrder X] [CompactIccSpace X] [NoMaxOrder X] [OrderTopology X] : IntegrableOn f (Ioi a) μ ↔ IntegrableAtFilter f atTop μ ∧ - IntegrableAtFilter f (𝓝[>] a) μ ∧ LocallyIntegrableOn f (Ioi a) μ := - integrableOn_Iio_iff_integrableAtFilter_atBot_nhdsWithin (X := Xᵒᵈ) + IntegrableAtFilter f (𝓝[>] a) μ ∧ LocallyIntegrableOn f (Ioi a) μ := by + unsealing_newtype OrderDual => + exact integrableOn_Iio_iff_integrableAtFilter_atBot_nhdsWithin (X := Xᵒᵈ) end MeasureTheory @@ -661,22 +664,22 @@ theorem MonotoneOn.memLp_isCompact [IsFiniteMeasureOnCompacts μ] (hs : IsCompac · exact hmono.memLp_of_measure_ne_top (hs.isLeast_sInf h) (hs.isGreatest_sSup h) hs.measure_lt_top.ne hs.measurableSet -set_option backward.isDefEq.respectTransparency.types false in theorem AntitoneOn.memLp_top (hanti : AntitoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (h's : MeasurableSet s) : - MemLp f ∞ (μ.restrict s) := - MonotoneOn.memLp_top (E := Eᵒᵈ) hanti ha hb h's + MemLp f ∞ (μ.restrict s) := by + unsealing_newtype OrderDual => + exact MonotoneOn.memLp_top (E := Eᵒᵈ) hanti ha hb h's -set_option backward.isDefEq.respectTransparency.types false in theorem AntitoneOn.memLp_of_measure_ne_top (hanti : AntitoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (hs : μ s ≠ ∞) (h's : MeasurableSet s) : - MemLp f p (μ.restrict s) := - MonotoneOn.memLp_of_measure_ne_top (E := Eᵒᵈ) hanti ha hb hs h's + MemLp f p (μ.restrict s) := by + unsealing_newtype OrderDual => + exact MonotoneOn.memLp_of_measure_ne_top (E := Eᵒᵈ) hanti ha hb hs h's -set_option backward.isDefEq.respectTransparency.types false in theorem AntitoneOn.memLp_isCompact [IsFiniteMeasureOnCompacts μ] (hs : IsCompact s) - (hanti : AntitoneOn f s) : MemLp f p (μ.restrict s) := - MonotoneOn.memLp_isCompact (E := Eᵒᵈ) hs hanti + (hanti : AntitoneOn f s) : MemLp f p (μ.restrict s) := by + unsealing_newtype OrderDual => + exact MonotoneOn.memLp_isCompact (E := Eᵒᵈ) hs hanti theorem MonotoneOn.integrableOn_of_measure_ne_top (hmono : MonotoneOn f s) {a b : X} (ha : IsLeast s a) (hb : IsGreatest s b) (hs : μ s ≠ ∞) (h's : MeasurableSet s) : @@ -708,10 +711,10 @@ theorem Monotone.locallyIntegrable [IsLocallyFiniteMeasure μ] (hmono : Monotone (hmono.monotoneOn _).integrableOn_of_measure_ne_top (isLeast_Icc ab) (isGreatest_Icc ab) ((measure_mono abU).trans_lt h'U).ne measurableSet_Icc -set_option backward.isDefEq.respectTransparency.types false in theorem Antitone.locallyIntegrable [IsLocallyFiniteMeasure μ] (hanti : Antitone f) : - LocallyIntegrable f μ := - hanti.dual_right.locallyIntegrable + LocallyIntegrable f μ := by + unsealing_newtype OrderDual => + exact hanti.dual_right.locallyIntegrable end Monotone diff --git a/mathlib4/Mathlib/MeasureTheory/Integral/IntegrableOn.lean b/mathlib4/Mathlib/MeasureTheory/Integral/IntegrableOn.lean index a61d29fe0..b2c032f08 100644 --- a/mathlib4/Mathlib/MeasureTheory/Integral/IntegrableOn.lean +++ b/mathlib4/Mathlib/MeasureTheory/Integral/IntegrableOn.lean @@ -555,8 +555,9 @@ theorem integrableAtFilter_atBot_iff [Preorder α] [IsCodirectedOrder α] [Nonem exact ⟨t, hi.mono_set fun _ hx ↦ ht _ hx⟩ theorem integrableAtFilter_atTop_iff [Preorder α] [IsDirectedOrder α] [Nonempty α] : - IntegrableAtFilter f atTop μ ↔ ∃ a, IntegrableOn f (Ici a) μ := - integrableAtFilter_atBot_iff (α := αᵒᵈ) + IntegrableAtFilter f atTop μ ↔ ∃ a, IntegrableOn f (Ici a) μ := by + unsealing_newtype OrderDual => + exact integrableAtFilter_atBot_iff (α := αᵒᵈ) @[gcongr] lemma IntegrableAtFilter.mono_measure (hf : IntegrableAtFilter f l μ) (h : ν ≤ μ) : diff --git a/mathlib4/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean b/mathlib4/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean index 99d112e52..57bb36bd3 100644 --- a/mathlib4/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean +++ b/mathlib4/Mathlib/MeasureTheory/Integral/IntegralEqImproper.lean @@ -153,8 +153,9 @@ theorem aecover_Ici (ha : Tendsto a l atBot) : AECover μ l fun i => Ici (a i) w ae_eventually_mem := ae_of_all μ ha.eventually_le_atBot measurableSet _ := measurableSet_Ici -theorem aecover_Iic (hb : Tendsto b l atTop) : AECover μ l fun i => Iic <| b i := - aecover_Ici (α := αᵒᵈ) hb +theorem aecover_Iic (hb : Tendsto b l atTop) : AECover μ l fun i => Iic <| b i where + ae_eventually_mem := ae_of_all μ hb.eventually_ge_atTop + measurableSet _ := measurableSet_Iic theorem aecover_Icc (ha : Tendsto a l atBot) (hb : Tendsto b l atTop) : AECover μ l fun i => Icc (a i) (b i) := @@ -173,7 +174,9 @@ theorem aecover_Ioi [NoMinOrder α] : AECover μ l fun i => Ioi (a i) where measurableSet _ := measurableSet_Ioi include hb in -theorem aecover_Iio [NoMaxOrder α] : AECover μ l fun i => Iio (b i) := aecover_Ioi (α := αᵒᵈ) hb +theorem aecover_Iio [NoMaxOrder α] : AECover μ l fun i => Iio (b i) where + ae_eventually_mem := ae_of_all μ hb.eventually_gt_atTop + measurableSet _ := measurableSet_Iio include ha hb @@ -201,16 +204,19 @@ theorem aecover_Ioi_of_Ioi : AECover (μ.restrict (Ioi A)) l fun i ↦ Ioi (a i) measurableSet _ := measurableSet_Ioi include hb in -theorem aecover_Iio_of_Iio : AECover (μ.restrict (Iio B)) l fun i ↦ Iio (b i) := - aecover_Ioi_of_Ioi (α := αᵒᵈ) hb +theorem aecover_Iio_of_Iio : AECover (μ.restrict (Iio B)) l fun i ↦ Iio (b i) where + ae_eventually_mem := (ae_restrict_mem measurableSet_Iio).mono fun _x hx ↦ hb.eventually <| + eventually_gt_nhds hx + measurableSet _ := measurableSet_Iio include ha in theorem aecover_Ioi_of_Ici : AECover (μ.restrict (Ioi A)) l fun i ↦ Ici (a i) := (aecover_Ioi_of_Ioi ha).superset (fun _ ↦ Ioi_subset_Ici_self) fun _ ↦ measurableSet_Ici include hb in -theorem aecover_Iio_of_Iic : AECover (μ.restrict (Iio B)) l fun i ↦ Iic (b i) := - aecover_Ioi_of_Ici (α := αᵒᵈ) hb +theorem aecover_Iio_of_Iic : AECover (μ.restrict (Iio B)) l fun i ↦ Iic (b i) := by + unsealing_newtype OrderDual => + exact aecover_Ioi_of_Ici (α := αᵒᵈ) hb include hb hc in theorem aecover_Iio_of_Ico : AECover (μ.restrict (Iio B)) l fun i ↦ Ico (c i) (b i) where diff --git a/mathlib4/Mathlib/MeasureTheory/Integral/IntervalIntegral/Basic.lean b/mathlib4/Mathlib/MeasureTheory/Integral/IntervalIntegral/Basic.lean index 2504147e2..58d7faa27 100644 --- a/mathlib4/Mathlib/MeasureTheory/Integral/IntervalIntegral/Basic.lean +++ b/mathlib4/Mathlib/MeasureTheory/Integral/IntervalIntegral/Basic.lean @@ -530,10 +530,10 @@ theorem MonotoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Monotone rw [intervalIntegrable_iff] exact (hu.integrableOn_isCompact isCompact_uIcc).mono_set Ioc_subset_Icc_self -set_option backward.isDefEq.respectTransparency.types false in theorem AntitoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : AntitoneOn u (uIcc a b)) : - IntervalIntegrable u μ a b := - hu.dual_right.intervalIntegrable + IntervalIntegrable u μ a b := by + unsealing_newtype OrderDual => + exact hu.dual_right.intervalIntegrable theorem Monotone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Monotone u) : IntervalIntegrable u μ a b := diff --git a/mathlib4/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean b/mathlib4/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean index bee480950..6d8fc5fb9 100644 --- a/mathlib4/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean +++ b/mathlib4/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean @@ -58,7 +58,13 @@ variable {α β γ δ : Type*} {ι : Sort*} {s t u : Set α} `MeasurableSet.iUnion` instead. -/ measurableSet_iUnion : ∀ f : ℕ → Set α, (∀ i, MeasurableSet' (f i)) → MeasurableSet' (⋃ i, f i) -instance [h : MeasurableSpace α] : MeasurableSpace αᵒᵈ := h +instance [h : MeasurableSpace α] : MeasurableSpace αᵒᵈ where + MeasurableSet' s := h.MeasurableSet' (⇑OrderDual.toDual ⁻¹' s) + measurableSet_empty := h.measurableSet_empty + measurableSet_compl _s hs := h.measurableSet_compl _ hs + measurableSet_iUnion f hf := + Set.preimage_iUnion (f := ⇑OrderDual.toDual) (s := f) ▸ + h.measurableSet_iUnion (fun i ↦ ⇑OrderDual.toDual ⁻¹' f i) hf /-- `MeasurableSet s` means that `s` is measurable (in the ambient measure space on `α`) -/ def MeasurableSet [MeasurableSpace α] (s : Set α) : Prop := diff --git a/mathlib4/Mathlib/MeasureTheory/Measure/Continuity.lean b/mathlib4/Mathlib/MeasureTheory/Measure/Continuity.lean index be390e716..4e2ba3c41 100644 --- a/mathlib4/Mathlib/MeasureTheory/Measure/Continuity.lean +++ b/mathlib4/Mathlib/MeasureTheory/Measure/Continuity.lean @@ -80,8 +80,9 @@ theorem _root_.Monotone.measure_iUnion [Preorder ι] [IsDirectedOrder ι] theorem _root_.Antitone.measure_iUnion [Preorder ι] [IsCodirectedOrder ι] [(atBot : Filter ι).IsCountablyGenerated] (hs : Antitone s) : - μ (⋃ i, s i) = ⨆ i, μ (s i) := - hs.dual_left.measure_iUnion + μ (⋃ i, s i) = ⨆ i, μ (s i) := by + unsealing_newtype OrderDual => + exact hs.dual_left.measure_iUnion /-- Continuity from below: the measure of the union of a sequence of (not necessarily measurable) sets is the supremum of the measures of the partial unions. -/ @@ -167,8 +168,9 @@ is equal to the infimum of the measures. -/ theorem _root_.Antitone.measure_iInter [Preorder ι] [IsDirectedOrder ι] [(atTop : Filter ι).IsCountablyGenerated] (hs : Antitone s) (hsm : ∀ i, NullMeasurableSet (s i) μ) (hfin : ∃ i, μ (s i) ≠ ∞) : - μ (⋂ i, s i) = ⨅ i, μ (s i) := - hs.dual_left.measure_iInter hsm hfin + μ (⋂ i, s i) = ⨅ i, μ (s i) := by + unsealing_newtype OrderDual => + exact hs.dual_left.measure_iInter hsm hfin /-- Continuity from above (a.e. version): the measure of the intersection of a family of sets that is almost everywhere antitone @@ -177,8 +179,9 @@ lemma measure_iInter_of_ae_antitone [Preorder ι] [IsDirectedOrder ι] [(atTop : Filter ι).IsCountablyGenerated] (hs : ∀ᵐ ω ∂μ, Antitone (ω ∈ s ·)) (hsm : ∀ (i : ι), NullMeasurableSet (s i) μ) (hfin : ∃ i, μ (s i) ≠ ∞) : μ (⋂ i, s i) = ⨅ i, μ (s i) := by - refine measure_iInter_of_ae_monotone (ι := ιᵒᵈ) ?_ hsm hfin - filter_upwards [hs] with ω hω using hω.dual_left + unsealing_newtype OrderDual => + refine measure_iInter_of_ae_monotone (ι := ιᵒᵈ) ?_ hsm hfin + filter_upwards [hs] with ω hω using hω.dual_left /-- Continuity from above: the measure of the intersection of a sequence of measurable sets is the infimum of the measures of the partial intersections. -/ @@ -203,8 +206,9 @@ theorem tendsto_measure_iUnion_atTop [Preorder ι] [IsCountablyGenerated (atTop exact tendsto_atTop_iSup fun n m hnm => measure_mono <| hm hnm theorem tendsto_measure_iUnion_atBot [Preorder ι] [IsCountablyGenerated (atBot : Filter ι)] - (hm : Antitone s) : Tendsto (μ ∘ s) atBot (𝓝 (μ (⋃ n, s n))) := - tendsto_measure_iUnion_atTop (ι := ιᵒᵈ) hm.dual_left + (hm : Antitone s) : Tendsto (μ ∘ s) atBot (𝓝 (μ (⋃ n, s n))) := by + unsealing_newtype OrderDual => + exact tendsto_measure_iUnion_atTop (ι := ιᵒᵈ) hm.dual_left /-- Continuity from below: the measure of the union of a sequence of (not necessarily measurable) sets is the limit of the measures of the partial unions. -/ @@ -230,8 +234,9 @@ theorem tendsto_measure_iInter_atTop [Preorder ι] sets is the limit of the measures. -/ theorem tendsto_measure_iInter_atBot [Preorder ι] [IsCountablyGenerated (atBot : Filter ι)] (hs : ∀ i, NullMeasurableSet (s i) μ) (hm : Monotone s) - (hf : ∃ i, μ (s i) ≠ ∞) : Tendsto (μ ∘ s) atBot (𝓝 (μ (⋂ n, s n))) := - tendsto_measure_iInter_atTop (ι := ιᵒᵈ) hs hm.dual_left hf + (hf : ∃ i, μ (s i) ≠ ∞) : Tendsto (μ ∘ s) atBot (𝓝 (μ (⋂ n, s n))) := by + unsealing_newtype OrderDual => + exact tendsto_measure_iInter_atTop (ι := ιᵒᵈ) hs hm.dual_left hf /-- Continuity from above: the measure of the intersection of a sequence of measurable sets such that one has finite measure is the limit of the measures of the partial intersections. -/ diff --git a/mathlib4/Mathlib/MeasureTheory/Measure/Interval.lean b/mathlib4/Mathlib/MeasureTheory/Measure/Interval.lean index de7fa6079..faef7c3a5 100644 --- a/mathlib4/Mathlib/MeasureTheory/Measure/Interval.lean +++ b/mathlib4/Mathlib/MeasureTheory/Measure/Interval.lean @@ -60,8 +60,9 @@ theorem tendsto_measure_Iic_atTop [(atTop : Filter α).IsCountablyGenerated] exact tendsto_measure_iUnion_atTop monotone_Iic theorem tendsto_measure_Ici_atBot [(atBot : Filter α).IsCountablyGenerated] - (μ : Measure α) : Tendsto (fun x => μ (Ici x)) atBot (𝓝 (μ univ)) := - tendsto_measure_Iic_atTop (α := αᵒᵈ) μ + (μ : Measure α) : Tendsto (fun x => μ (Ici x)) atBot (𝓝 (μ univ)) := by + unsealing_newtype OrderDual => + exact tendsto_measure_Iic_atTop (α := αᵒᵈ) μ end Preorder @@ -72,8 +73,9 @@ variable [PartialOrder α] {a b : α} theorem Iio_ae_eq_Iic' (ha : μ {a} = 0) : Iio a =ᵐ[μ] Iic a := by rw [← Iic_sdiff_right, sdiff_ae_eq_self, measure_mono_null Set.inter_subset_right ha] -theorem Ioi_ae_eq_Ici' (ha : μ {a} = 0) : Ioi a =ᵐ[μ] Ici a := - Iio_ae_eq_Iic' (α := αᵒᵈ) ha +theorem Ioi_ae_eq_Ici' (ha : μ {a} = 0) : Ioi a =ᵐ[μ] Ici a := by + unsealing_newtype OrderDual => + exact Iio_ae_eq_Iic' (α := αᵒᵈ) ha theorem Ioo_ae_eq_Ioc' (hb : μ {b} = 0) : Ioo a b =ᵐ[μ] Ioc a b := .inter .rfl (Iio_ae_eq_Iic' hb) diff --git a/mathlib4/Mathlib/MeasureTheory/Order/Lattice.lean b/mathlib4/Mathlib/MeasureTheory/Order/Lattice.lean index ba451d7bb..93419280f 100644 --- a/mathlib4/Mathlib/MeasureTheory/Order/Lattice.lean +++ b/mathlib4/Mathlib/MeasureTheory/Order/Lattice.lean @@ -68,21 +68,35 @@ variable {M : Type*} [MeasurableSpace M] section OrderDual +/-- `MeasurableSet[Mᵒᵈ] s` is by definition `MeasurableSet (⇑toDual ⁻¹' s)`, so both directions of +the order dualisation are measurable on the nose. -/ +private lemma measurable_toDual : Measurable (OrderDual.toDual : M → Mᵒᵈ) := fun _ hs ↦ hs + +private lemma measurable_ofDual : Measurable (OrderDual.ofDual : Mᵒᵈ → M) := fun _ hs ↦ hs + instance (priority := 100) OrderDual.instMeasurableSup [Min M] [MeasurableInf M] : - MeasurableSup Mᵒᵈ := - ⟨@measurable_const_inf M _ _ _, @measurable_inf_const M _ _ _⟩ + MeasurableSup Mᵒᵈ where + measurable_const_sup c := + measurable_toDual.comp ((measurable_const_inf (OrderDual.ofDual c)).comp measurable_ofDual) + measurable_sup_const c := + measurable_toDual.comp ((measurable_inf_const (OrderDual.ofDual c)).comp measurable_ofDual) instance (priority := 100) OrderDual.instMeasurableInf [Max M] [MeasurableSup M] : - MeasurableInf Mᵒᵈ := - ⟨@measurable_const_sup M _ _ _, @measurable_sup_const M _ _ _⟩ + MeasurableInf Mᵒᵈ where + measurable_const_inf c := + measurable_toDual.comp ((measurable_const_sup (OrderDual.ofDual c)).comp measurable_ofDual) + measurable_inf_const c := + measurable_toDual.comp ((measurable_sup_const (OrderDual.ofDual c)).comp measurable_ofDual) instance (priority := 100) OrderDual.instMeasurableSup₂ [Min M] [MeasurableInf₂ M] : - MeasurableSup₂ Mᵒᵈ := - ⟨@measurable_inf M _ _ _⟩ + MeasurableSup₂ Mᵒᵈ where + measurable_sup := measurable_toDual.comp (measurable_inf.comp + ((measurable_ofDual.comp measurable_fst).prodMk (measurable_ofDual.comp measurable_snd))) instance (priority := 100) OrderDual.instMeasurableInf₂ [Max M] [MeasurableSup₂ M] : - MeasurableInf₂ Mᵒᵈ := - ⟨@measurable_sup M _ _ _⟩ + MeasurableInf₂ Mᵒᵈ where + measurable_inf := measurable_toDual.comp (measurable_sup.comp + ((measurable_ofDual.comp measurable_fst).prodMk (measurable_ofDual.comp measurable_snd))) end OrderDual diff --git a/mathlib4/Mathlib/MeasureTheory/PiSystem.lean b/mathlib4/Mathlib/MeasureTheory/PiSystem.lean index 7685f54d8..d02f1f583 100644 --- a/mathlib4/Mathlib/MeasureTheory/PiSystem.lean +++ b/mathlib4/Mathlib/MeasureTheory/PiSystem.lean @@ -163,8 +163,9 @@ theorem isPiSystem_image_Iio (s : Set α) : IsPiSystem (Iio '' s) := by theorem isPiSystem_Iio : IsPiSystem (range Iio : Set (Set α)) := @image_univ α _ Iio ▸ isPiSystem_image_Iio univ -theorem isPiSystem_image_Ioi (s : Set α) : IsPiSystem (Ioi '' s) := - @isPiSystem_image_Iio αᵒᵈ _ s +theorem isPiSystem_image_Ioi (s : Set α) : IsPiSystem (Ioi '' s) := by + unsealing_newtype OrderDual => + exact @isPiSystem_image_Iio αᵒᵈ _ s theorem isPiSystem_Ioi : IsPiSystem (range Ioi : Set (Set α)) := @image_univ α _ Ioi ▸ isPiSystem_image_Ioi univ @@ -176,8 +177,9 @@ theorem isPiSystem_image_Iic (s : Set α) : IsPiSystem (Iic '' s) := by theorem isPiSystem_Iic : IsPiSystem (range Iic : Set (Set α)) := @image_univ α _ Iic ▸ isPiSystem_image_Iic univ -theorem isPiSystem_image_Ici (s : Set α) : IsPiSystem (Ici '' s) := - @isPiSystem_image_Iic αᵒᵈ _ s +theorem isPiSystem_image_Ici (s : Set α) : IsPiSystem (Ici '' s) := by + unsealing_newtype OrderDual => + exact @isPiSystem_image_Iic αᵒᵈ _ s theorem isPiSystem_Ici : IsPiSystem (range Ici : Set (Set α)) := @image_univ α _ Ici ▸ isPiSystem_image_Ici univ diff --git a/mathlib4/Mathlib/Order/Antichain.lean b/mathlib4/Mathlib/Order/Antichain.lean index 7f5c30ca4..2aabaeac3 100644 --- a/mathlib4/Mathlib/Order/Antichain.lean +++ b/mathlib4/Mathlib/Order/Antichain.lean @@ -166,15 +166,20 @@ theorem preimage_iso_iff [LE α] [LE β] {t : Set β} {φ : α ≃o β} : IsAntichain (· ≤ ·) (φ ⁻¹' t) ↔ IsAntichain (· ≤ ·) t := ⟨fun h => (φ.image_preimage t).subst (h.image_iso φ), fun h => h.preimage_iso _⟩ -theorem to_dual [LE α] (hs : IsAntichain (· ≤ ·) s) : @IsAntichain αᵒᵈ (· ≤ ·) s := - fun _ ha _ hb hab => hs hb ha hab.symm +theorem to_dual [LE α] (hs : IsAntichain (· ≤ ·) s) : + @IsAntichain αᵒᵈ (· ≤ ·) (⇑OrderDual.ofDual ⁻¹' s) := by + unsealing_newtype OrderDual => + exact fun _ ha _ hb hab => hs hb ha hab.symm -theorem to_dual_iff [LE α] : IsAntichain (· ≤ ·) s ↔ @IsAntichain αᵒᵈ (· ≤ ·) s := - ⟨to_dual, to_dual⟩ +theorem to_dual_iff [LE α] : + IsAntichain (· ≤ ·) s ↔ @IsAntichain αᵒᵈ (· ≤ ·) (⇑OrderDual.ofDual ⁻¹' s) := by + unsealing_newtype OrderDual => + exact ⟨to_dual, to_dual⟩ theorem image_compl [BooleanAlgebra α] (hs : IsAntichain (· ≤ ·) s) : - IsAntichain (· ≤ ·) (compl '' s) := - (hs.image_embedding (OrderIso.compl α).toOrderEmbedding).flip + IsAntichain (· ≤ ·) (compl '' s) := by + unsealing_newtype OrderDual => + exact (hs.image_embedding (OrderIso.compl α).toOrderEmbedding).flip theorem preimage_compl [BooleanAlgebra α] (hs : IsAntichain (· ≤ ·) s) : IsAntichain (· ≤ ·) (compl ⁻¹' s) := fun _ ha _ ha' hne hle => @@ -260,8 +265,9 @@ theorem IsAntichain.top_mem_iff [OrderTop α] (hs : IsAntichain (· ≤ ·) s) : theorem IsAntichain.minimal_mem_iff (hs : IsAntichain (· ≤ ·) s) : Minimal (· ∈ s) a ↔ a ∈ s := ⟨fun h ↦ h.prop, fun h ↦ ⟨h, fun _ hys hyx ↦ (hs.eq hys h hyx).symm.le⟩⟩ -theorem IsAntichain.maximal_mem_iff (hs : IsAntichain (· ≤ ·) s) : Maximal (· ∈ s) a ↔ a ∈ s := - hs.to_dual.minimal_mem_iff +theorem IsAntichain.maximal_mem_iff (hs : IsAntichain (· ≤ ·) s) : Maximal (· ∈ s) a ↔ a ∈ s := by + unsealing_newtype OrderDual => + exact hs.to_dual.minimal_mem_iff /-- If `t` is an antichain shadowing and including the set of maximal elements of `s`, then `t` *is* the set of maximal elements of `s`. -/ @@ -279,8 +285,9 @@ alias IsAntichain.eq_setOf_maximal := IsAntichain.eq_setOfPred_maximal then `t` *is* the set of minimal elements of `s`. -/ theorem IsAntichain.eq_setOfPred_minimal (ht : IsAntichain (· ≤ ·) t) (h : ∀ x, Minimal (· ∈ s) x → x ∈ t) (hs : ∀ a ∈ t, ∃ b, a ≤ b ∧ Minimal (· ∈ s) b) : - {x | Minimal (· ∈ s) x} = t := - ht.to_dual.eq_setOfPred_maximal h hs + {x | Minimal (· ∈ s) x} = t := by + unsealing_newtype OrderDual => + exact ht.to_dual.eq_setOfPred_maximal h hs @[deprecated (since := "2026-07-09")] alias IsAntichain.eq_setOf_minimal := IsAntichain.eq_setOfPred_minimal @@ -309,8 +316,9 @@ theorem setOfPred_maximal_antichain (P : α → Prop) : IsAntichain (· ≤ ·) @[deprecated (since := "2026-07-09")] alias setOf_maximal_antichain := setOfPred_maximal_antichain -theorem setOfPred_minimal_antichain (P : α → Prop) : IsAntichain (· ≤ ·) {x | Minimal P x} := - (setOfPred_maximal_antichain (α := αᵒᵈ) P).swap +theorem setOfPred_minimal_antichain (P : α → Prop) : IsAntichain (· ≤ ·) {x | Minimal P x} := by + unsealing_newtype OrderDual => + exact (setOfPred_maximal_antichain (α := αᵒᵈ) P).swap @[deprecated (since := "2026-07-09")] alias setOf_minimal_antichain := setOfPred_minimal_antichain diff --git a/mathlib4/Mathlib/Order/Antisymmetrization.lean b/mathlib4/Mathlib/Order/Antisymmetrization.lean index 7edcc1789..6d923830b 100644 --- a/mathlib4/Mathlib/Order/Antisymmetrization.lean +++ b/mathlib4/Mathlib/Order/Antisymmetrization.lean @@ -369,15 +369,13 @@ variable (α) noncomputable def OrderEmbedding.ofAntisymmetrization : Antisymmetrization α (· ≤ ·) ↪o α := { Quotient.outRelEmbedding _ with toFun := _root_.ofAntisymmetrization _ } -set_option backward.isDefEq.respectTransparency false in /-- `Antisymmetrization` and `orderDual` commute. -/ def OrderIso.dualAntisymmetrization : (Antisymmetrization α (· ≤ ·))ᵒᵈ ≃o Antisymmetrization αᵒᵈ (· ≤ ·) where - toFun := (Quotient.map' id) fun _ _ => And.symm - invFun := (Quotient.map' id) fun _ _ => And.symm - left_inv a := Quotient.inductionOn' a fun a => by simp_rw [Quotient.map'_mk'', id] - right_inv a := Quotient.inductionOn' a fun a => by simp_rw [Quotient.map'_mk'', id] - map_rel_iff' := @fun a b => Quotient.inductionOn₂' a b fun _ _ => Iff.rfl + toEquiv := ofDual.trans (Quotient.congr toDual fun _ _ => and_comm) + map_rel_iff' := by + unsealing_newtype OrderDual => + exact @fun a b => Quotient.inductionOn₂' a b fun _ _ => Iff.rfl @[simp] theorem OrderIso.dualAntisymmetrization_apply (a : α) : diff --git a/mathlib4/Mathlib/Order/Atoms.lean b/mathlib4/Mathlib/Order/Atoms.lean index f2a586b5d..353866347 100644 --- a/mathlib4/Mathlib/Order/Atoms.lean +++ b/mathlib4/Mathlib/Order/Atoms.lean @@ -156,13 +156,15 @@ def IsCoatom [OrderTop α] (a : α) : Prop := @[simp] theorem isCoatom_dual_iff_isAtom [OrderBot α] {a : α} : - IsCoatom (OrderDual.toDual a) ↔ IsAtom a := - Iff.rfl + IsCoatom (OrderDual.toDual a) ↔ IsAtom a := by + unsealing_newtype OrderDual => + exact Iff.rfl @[simp] theorem isAtom_dual_iff_isCoatom [OrderTop α] {a : α} : - IsAtom (OrderDual.toDual a) ↔ IsCoatom a := - Iff.rfl + IsAtom (OrderDual.toDual a) ↔ IsCoatom a := by + unsealing_newtype OrderDual => + exact Iff.rfl alias ⟨_, IsAtom.dual⟩ := isCoatom_dual_iff_isAtom @@ -170,14 +172,17 @@ alias ⟨_, IsCoatom.dual⟩ := isAtom_dual_iff_isCoatom variable [OrderTop α] {a x : α} -theorem IsCoatom.Ici (ha : IsCoatom a) (hax : x ≤ a) : IsCoatom (⟨a, hax⟩ : Set.Ici x) := - ha.dual.Iic hax +theorem IsCoatom.Ici (ha : IsCoatom a) (hax : x ≤ a) : IsCoatom (⟨a, hax⟩ : Set.Ici x) := by + unsealing_newtype OrderDual => + exact ha.dual.Iic hax -theorem IsCoatom.of_isCoatom_coe_Ici {a : Set.Ici x} (ha : IsCoatom a) : IsCoatom (a : α) := - @IsAtom.of_isAtom_coe_Iic αᵒᵈ _ _ x a ha +theorem IsCoatom.of_isCoatom_coe_Ici {a : Set.Ici x} (ha : IsCoatom a) : IsCoatom (a : α) := by + unsealing_newtype OrderDual => + exact @IsAtom.of_isAtom_coe_Iic αᵒᵈ _ _ x a ha -theorem isCoatom_iff_ge_of_le : IsCoatom a ↔ a ≠ ⊤ ∧ ∀ b ≠ ⊤, a ≤ b → b ≤ a := - isAtom_iff_le_of_ge (α := αᵒᵈ) +theorem isCoatom_iff_ge_of_le : IsCoatom a ↔ a ≠ ⊤ ∧ ∀ b ≠ ⊤, a ≤ b → b ≤ a := by + unsealing_newtype OrderDual => + exact isAtom_iff_le_of_ge (α := αᵒᵈ) lemma IsCoatom.ne_top (ha : IsCoatom a) : a ≠ ⊤ := ha.1 @@ -187,16 +192,19 @@ section PartialOrder variable [PartialOrder α] [OrderTop α] {a b x : α} -theorem IsCoatom.lt_iff (h : IsCoatom a) : a < x ↔ x = ⊤ := - h.dual.lt_iff +theorem IsCoatom.lt_iff (h : IsCoatom a) : a < x ↔ x = ⊤ := by + unsealing_newtype OrderDual => + exact h.dual.lt_iff -theorem IsCoatom.le_iff (h : IsCoatom a) : a ≤ x ↔ x = ⊤ ∨ x = a := - h.dual.le_iff +theorem IsCoatom.le_iff (h : IsCoatom a) : a ≤ x ↔ x = ⊤ ∨ x = a := by + unsealing_newtype OrderDual => + exact h.dual.le_iff lemma IsCoatom.lt_top (h : IsCoatom a) : a < ⊤ := h.lt_iff.mpr rfl -lemma IsCoatom.le_iff_eq (ha : IsCoatom a) (hb : b ≠ ⊤) : a ≤ b ↔ b = a := ha.dual.le_iff_eq hb +lemma IsCoatom.le_iff_eq (ha : IsCoatom a) (hb : b ≠ ⊤) : a ≤ b ↔ b = a := + ha.le_iff.trans <| or_iff_right hb lemma IsCoatom.ne_iff_eq_top (ha : IsCoatom a) (hab : a ≤ b) : b ≠ a ↔ b = ⊤ where mp := (ha.le_iff.1 hab).resolve_right @@ -206,14 +214,15 @@ lemma IsCoatom.ne_top_iff_eq (ha : IsCoatom a) (hab : a ≤ b) : b ≠ ⊤ ↔ b (ha.ne_iff_eq_top hab).not_right.symm theorem IsCoatom.Ici_eq (h : IsCoatom a) : Set.Ici a = {⊤, a} := - h.dual.Iic_eq + Set.ext fun _ => h.le_iff lemma Set.Ioi_eq_singleton_top_iff : Ioi a = {⊤} ↔ IsCoatom a := by simp [IsCoatom, superset_antisymm_iff, lt_top_iff_ne_top] @[simp] -theorem covBy_top_iff : a ⋖ ⊤ ↔ IsCoatom a := - toDual_covBy_toDual_iff.symm.trans bot_covBy_iff +theorem covBy_top_iff : a ⋖ ⊤ ↔ IsCoatom a := by + unsealing_newtype OrderDual => + exact toDual_covBy_toDual_iff.symm.trans bot_covBy_iff alias ⟨CovBy.isCoatom, IsCoatom.covBy_top⟩ := covBy_top_iff @@ -255,8 +264,9 @@ end PartialOrder section Coframe variable [Coframe α] {f : ι → α} {s : Set α} {a : α} -protected lemma IsCoatom.iInf_le (ha : IsCoatom a) : iInf f ≤ a ↔ ∃ i, f i ≤ a := - IsAtom.le_iSup (α := αᵒᵈ) ha +protected lemma IsCoatom.iInf_le (ha : IsCoatom a) : iInf f ≤ a ↔ ∃ i, f i ≤ a := by + unsealing_newtype OrderDual => + exact IsAtom.le_iSup (α := αᵒᵈ) ha protected lemma IsCoatom.sInf_le (ha : IsCoatom a) : sInf s ≤ a ↔ ∃ b ∈ s, b ≤ a := by simp [sInf_eq_iInf', ha.iInf_le] @@ -353,14 +363,16 @@ lemma IsCoatomic.exists_coatom [OrderTop α] [Nontrivial α] [IsCoatomic α] : variable {α} @[simp] -theorem isCoatomic_dual_iff_isAtomic [OrderBot α] : IsCoatomic αᵒᵈ ↔ IsAtomic α := - ⟨fun h => ⟨fun b => by apply h.eq_top_or_exists_le_coatom⟩, fun h => - ⟨fun b => by apply h.eq_bot_or_exists_atom_le⟩⟩ +theorem isCoatomic_dual_iff_isAtomic [OrderBot α] : IsCoatomic αᵒᵈ ↔ IsAtomic α := by + unsealing_newtype OrderDual => + exact ⟨fun h => ⟨fun b => by apply h.eq_top_or_exists_le_coatom⟩, fun h => + ⟨fun b => by apply h.eq_bot_or_exists_atom_le⟩⟩ @[simp] -theorem isAtomic_dual_iff_isCoatomic [OrderTop α] : IsAtomic αᵒᵈ ↔ IsCoatomic α := - ⟨fun h => ⟨fun b => by apply h.eq_bot_or_exists_atom_le⟩, fun h => - ⟨fun b => by apply h.eq_top_or_exists_le_coatom⟩⟩ +theorem isAtomic_dual_iff_isCoatomic [OrderTop α] : IsAtomic αᵒᵈ ↔ IsCoatomic α := by + unsealing_newtype OrderDual => + exact ⟨fun h => ⟨fun b => by apply h.eq_bot_or_exists_atom_le⟩, fun h => + ⟨fun b => by apply h.eq_top_or_exists_le_coatom⟩⟩ namespace IsAtomic @@ -398,10 +410,11 @@ theorem isAtomic_iff_forall_isAtomic_Iic [OrderBot α] : (Exists.imp' (↑) fun ⟨_, _⟩ => And.imp_left IsAtom.of_isAtom_coe_Iic)⟩⟩ theorem isCoatomic_iff_forall_isCoatomic_Ici [OrderTop α] : - IsCoatomic α ↔ ∀ x : α, IsCoatomic (Set.Ici x) := - isAtomic_dual_iff_isCoatomic.symm.trans <| - isAtomic_iff_forall_isAtomic_Iic.trans <| - forall_congr' fun _ => isCoatomic_dual_iff_isAtomic.symm.trans Iff.rfl + IsCoatomic α ↔ ∀ x : α, IsCoatomic (Set.Ici x) := by + unsealing_newtype OrderDual => + exact isAtomic_dual_iff_isCoatomic.symm.trans <| + isAtomic_iff_forall_isAtomic_Iic.trans <| + forall_congr' fun _ => isCoatomic_dual_iff_isAtomic.symm.trans Iff.rfl section StronglyAtomic @@ -436,7 +449,8 @@ theorem isStronglyAtomic_dual_iff_is_stronglyCoatomic : @[simp] theorem isStronglyCoatomic_dual_iff_is_stronglyAtomic : IsStronglyCoatomic αᵒᵈ ↔ IsStronglyAtomic α := by - rw [← isStronglyAtomic_dual_iff_is_stronglyCoatomic]; rfl + unsealing_newtype OrderDual => + rw [← isStronglyAtomic_dual_iff_is_stronglyCoatomic]; rfl instance OrderDual.instIsStronglyCoatomic [IsStronglyAtomic α] : IsStronglyCoatomic αᵒᵈ := by rwa [isStronglyCoatomic_dual_iff_is_stronglyAtomic] @@ -466,8 +480,9 @@ theorem Set.OrdConnected.isStronglyAtomic [IsStronglyAtomic α] {s : Set α} using! hcx.lt, fun y hy hy' ↦ hcx.2 (by simpa using! hy) (by simpa using! hy')⟩, hxd⟩ theorem Set.OrdConnected.isStronglyCoatomic [IsStronglyCoatomic α] {s : Set α} - (h : Set.OrdConnected s) : IsStronglyCoatomic s := - isStronglyAtomic_dual_iff_is_stronglyCoatomic.1 h.dual.isStronglyAtomic + (h : Set.OrdConnected s) : IsStronglyCoatomic s := by + unsealing_newtype OrderDual => + exact isStronglyAtomic_dual_iff_is_stronglyCoatomic.1 h.dual.isStronglyAtomic instance [IsStronglyAtomic α] {s : Set α} [Set.OrdConnected s] : IsStronglyAtomic s := Set.OrdConnected.isStronglyAtomic <| by assumption @@ -512,8 +527,9 @@ theorem isAtomic_of_orderBot_wellFounded_lt [OrderBot α] @[deprecated instIsStronglyAtomicOfWellFoundedLT +typeChanged (since := "2026-08-01")] theorem isCoatomic_of_orderTop_gt_wellFounded [OrderTop α] - (h : WellFounded ((· > ·) : α → α → Prop)) : IsCoatomic α := - isAtomic_dual_iff_isCoatomic.1 (@isAtomic_of_orderBot_wellFounded_lt αᵒᵈ _ _ h) + (h : WellFounded ((· > ·) : α → α → Prop)) : IsCoatomic α := by + unsealing_newtype OrderDual => + exact isAtomic_dual_iff_isCoatomic.1 (@isAtomic_of_orderBot_wellFounded_lt αᵒᵈ _ _ h) end WellFounded @@ -577,12 +593,14 @@ export IsCoatomistic (isGLB_coatoms) variable {α} @[simp] -theorem isCoatomistic_dual_iff_isAtomistic [OrderBot α] : IsCoatomistic αᵒᵈ ↔ IsAtomistic α := - ⟨fun h => ⟨fun b => by apply h.isGLB_coatoms⟩, fun h => ⟨fun b => by apply h.isLUB_atoms⟩⟩ +theorem isCoatomistic_dual_iff_isAtomistic [OrderBot α] : IsCoatomistic αᵒᵈ ↔ IsAtomistic α := by + unsealing_newtype OrderDual => + exact ⟨fun h => ⟨fun b => by apply h.isGLB_coatoms⟩, fun h => ⟨fun b => by apply h.isLUB_atoms⟩⟩ @[simp] -theorem isAtomistic_dual_iff_isCoatomistic [OrderTop α] : IsAtomistic αᵒᵈ ↔ IsCoatomistic α := - ⟨fun h => ⟨fun b => by apply h.isLUB_atoms⟩, fun h => ⟨fun b => by apply h.isGLB_coatoms⟩⟩ +theorem isAtomistic_dual_iff_isCoatomistic [OrderTop α] : IsAtomistic αᵒᵈ ↔ IsCoatomistic α := by + unsealing_newtype OrderDual => + exact ⟨fun h => ⟨fun b => by apply h.isLUB_atoms⟩, fun h => ⟨fun b => by apply h.isGLB_coatoms⟩⟩ namespace IsAtomistic @@ -744,12 +762,13 @@ lemma IsSimpleOrder.of_forall_eq_top {α : Type*} [LE α] [BoundedOrder α] [Non theorem isSimpleOrder_iff_isSimpleOrder_orderDual [LE α] [BoundedOrder α] : IsSimpleOrder α ↔ IsSimpleOrder αᵒᵈ := by - constructor <;> intro i - · exact - { eq_bot_or_eq_top := fun a => Or.symm (eq_bot_or_eq_top (OrderDual.ofDual a) : _ ∨ _) } - · exact - { exists_pair_ne := @exists_pair_ne αᵒᵈ _ - eq_bot_or_eq_top := fun a => Or.symm (eq_bot_or_eq_top (OrderDual.toDual a)) } + unsealing_newtype OrderDual => + constructor <;> intro i + · exact + { eq_bot_or_eq_top := fun a => Or.symm (eq_bot_or_eq_top (OrderDual.ofDual a) : _ ∨ _) } + · exact + { exists_pair_ne := @exists_pair_ne αᵒᵈ _ + eq_bot_or_eq_top := fun a => Or.symm (eq_bot_or_eq_top (OrderDual.toDual a)) } theorem IsSimpleOrder.bot_ne_top [LE α] [BoundedOrder α] [IsSimpleOrder α] : (⊥ : α) ≠ (⊤ : α) := by obtain ⟨a, b, h⟩ := exists_pair_ne α @@ -964,8 +983,9 @@ theorem isSimpleOrder_iff_isAtom_top [PartialOrder α] [BoundedOrder α] : eq_bot_or_eq_top := fun a => ((eq_or_lt_of_le le_top).imp_right (h.2 a)).symm }⟩ theorem isSimpleOrder_iff_isCoatom_bot [PartialOrder α] [BoundedOrder α] : - IsSimpleOrder α ↔ IsCoatom (⊥ : α) := - isSimpleOrder_iff_isSimpleOrder_orderDual.trans isSimpleOrder_iff_isAtom_top + IsSimpleOrder α ↔ IsCoatom (⊥ : α) := by + unsealing_newtype OrderDual => + exact isSimpleOrder_iff_isSimpleOrder_orderDual.trans isSimpleOrder_iff_isAtom_top namespace Set @@ -995,8 +1015,9 @@ theorem isAtom_of_map_bot_of_image [OrderBot α] [OrderBot β] (f : β ↪o α) exact CovBy.of_image f (hbot.symm ▸ hb) theorem isCoatom_of_map_top_of_image [OrderTop α] [OrderTop β] (f : β ↪o α) (htop : f ⊤ = ⊤) - {b : β} (hb : IsCoatom (f b)) : IsCoatom b := - f.dual.isAtom_of_map_bot_of_image htop hb + {b : β} (hb : IsCoatom (f b)) : IsCoatom b := by + unsealing_newtype OrderDual => + exact f.dual.isAtom_of_map_bot_of_image htop hb end OrderEmbedding @@ -1052,27 +1073,32 @@ namespace GaloisCoinsertion variable [PartialOrder α] [PartialOrder β] theorem isCoatom_of_l_top [OrderTop α] [OrderTop β] {l : α → β} {u : β → α} - (gi : GaloisCoinsertion l u) (hbot : l ⊤ = ⊤) {a : α} (hb : IsCoatom (l a)) : IsCoatom a := - gi.dual.isAtom_of_u_bot hbot hb.dual + (gi : GaloisCoinsertion l u) (hbot : l ⊤ = ⊤) {a : α} (hb : IsCoatom (l a)) : IsCoatom a := by + unsealing_newtype OrderDual => + exact gi.dual.isAtom_of_u_bot hbot hb.dual theorem isCoatom_iff [OrderTop α] [OrderTop β] [IsCoatomic β] {l : α → β} {u : β → α} (gi : GaloisCoinsertion l u) (htop : l ⊤ = ⊤) (h_coatom : ∀ b, IsCoatom b → l (u b) = b) - (b : β) : IsCoatom (u b) ↔ IsCoatom b := - gi.dual.isAtom_iff htop h_coatom b + (b : β) : IsCoatom (u b) ↔ IsCoatom b := by + unsealing_newtype OrderDual => + exact gi.dual.isAtom_iff htop h_coatom b theorem isCoatom_iff' [OrderTop α] [OrderTop β] [IsCoatomic β] {l : α → β} {u : β → α} (gi : GaloisCoinsertion l u) (htop : l ⊤ = ⊤) (h_coatom : ∀ b, IsCoatom b → l (u b) = b) - (a : α) : IsCoatom (l a) ↔ IsCoatom a := - gi.dual.isAtom_iff' htop h_coatom a + (a : α) : IsCoatom (l a) ↔ IsCoatom a := by + unsealing_newtype OrderDual => + exact gi.dual.isAtom_iff' htop h_coatom a theorem isAtom_of_image [OrderBot α] [OrderBot β] {l : α → β} {u : β → α} - (gi : GaloisCoinsertion l u) {a : α} (hb : IsAtom (l a)) : IsAtom a := - gi.dual.isCoatom_of_image hb.dual + (gi : GaloisCoinsertion l u) {a : α} (hb : IsAtom (l a)) : IsAtom a := by + unsealing_newtype OrderDual => + exact gi.dual.isCoatom_of_image hb.dual theorem isAtom_iff [OrderBot α] [OrderBot β] [IsAtomic β] {l : α → β} {u : β → α} (gi : GaloisCoinsertion l u) (h_atom : ∀ b, IsAtom b → l (u b) = b) (a : α) : - IsAtom (l a) ↔ IsAtom a := - gi.dual.isCoatom_iff h_atom a + IsAtom (l a) ↔ IsAtom a := by + unsealing_newtype OrderDual => + exact gi.dual.isCoatom_iff h_atom a end GaloisCoinsertion @@ -1087,8 +1113,9 @@ theorem isAtom_iff [OrderBot α] [OrderBot β] (f : α ≃o β) (a : α) : IsAto @[simp] theorem isCoatom_iff [OrderTop α] [OrderTop β] (f : α ≃o β) (a : α) : - IsCoatom (f a) ↔ IsCoatom a := - f.dual.isAtom_iff a + IsCoatom (f a) ↔ IsCoatom a := by + unsealing_newtype OrderDual => + exact f.dual.isAtom_iff a theorem isSimpleOrder_iff [BoundedOrder α] [BoundedOrder β] (f : α ≃o β) : IsSimpleOrder α ↔ IsSimpleOrder β := by @@ -1250,9 +1277,10 @@ instance isAtomic [∀ i, PartialOrder (π i)] [∀ i, OrderBot (π i)] [∀ i, by classical exact ⟨Function.update ⊥ i a, isAtom_single ha, update_le_iff.2 ⟨hab, by simp⟩⟩ instance isCoatomic [∀ i, PartialOrder (π i)] [∀ i, OrderTop (π i)] [∀ i, IsCoatomic (π i)] : - IsCoatomic (∀ i, π i) := - isAtomic_dual_iff_isCoatomic.1 <| - show IsAtomic (∀ i, (π i)ᵒᵈ) from inferInstance + IsCoatomic (∀ i, π i) := by + unsealing_newtype OrderDual => + exact isAtomic_dual_iff_isCoatomic.1 <| + show IsAtomic (∀ i, (π i)ᵒᵈ) from inferInstance instance isAtomistic [∀ i, PartialOrder (π i)] [∀ i, OrderBot (π i)] [∀ i, IsAtomistic (π i)] : IsAtomistic (∀ i, π i) where @@ -1269,9 +1297,10 @@ instance isAtomistic [∀ i, PartialOrder (π i)] [∀ i, OrderBot (π i)] [∀ exact hj ⟨Function.update ⊥ i x, ⟨⟨_, x, hx₁, rfl⟩, by simp [update_le_iff, hx₂]⟩, by simp⟩ instance isCoatomistic [∀ i, CompleteLattice (π i)] [∀ i, IsCoatomistic (π i)] : - IsCoatomistic (∀ i, π i) := - isAtomistic_dual_iff_isCoatomistic.1 <| - show IsAtomistic (∀ i, (π i)ᵒᵈ) from inferInstance + IsCoatomistic (∀ i, π i) := by + unsealing_newtype OrderDual => + exact isAtomistic_dual_iff_isCoatomistic.1 <| + show IsAtomistic (∀ i, (π i)ᵒᵈ) from inferInstance end Pi diff --git a/mathlib4/Mathlib/Order/Atoms/Finite.lean b/mathlib4/Mathlib/Order/Atoms/Finite.lean index 1d76ec180..b7e9faf38 100644 --- a/mathlib4/Mathlib/Order/Atoms/Finite.lean +++ b/mathlib4/Mathlib/Order/Atoms/Finite.lean @@ -120,7 +120,8 @@ theorem exists_covby_infinite_Ici_of_infinite_Ici [IsStronglyAtomic α] theorem exists_covby_infinite_Iic_of_infinite_Iic [IsStronglyCoatomic α] (ha : (Set.Iic a).Infinite) (hfin : {x | x ⋖ a}.Finite) : ∃ b, b ⋖ a ∧ (Set.Iic b).Infinite := by - simp_rw [← toDual_covBy_toDual_iff (α := α)] at hfin ⊢ - exact exists_covby_infinite_Ici_of_infinite_Ici (α := αᵒᵈ) ha hfin + unsealing_newtype OrderDual => + simp_rw [← toDual_covBy_toDual_iff (α := α)] at hfin ⊢ + exact exists_covby_infinite_Ici_of_infinite_Ici (α := αᵒᵈ) ha hfin end IsStronglyAtomic diff --git a/mathlib4/Mathlib/Order/BooleanAlgebra/Basic.lean b/mathlib4/Mathlib/Order/BooleanAlgebra/Basic.lean index 09b31007d..2bb5b3140 100644 --- a/mathlib4/Mathlib/Order/BooleanAlgebra/Basic.lean +++ b/mathlib4/Mathlib/Order/BooleanAlgebra/Basic.lean @@ -540,8 +540,8 @@ theorem sdiff_compl : x \ yᶜ = x ⊓ y := by rw [sdiff_eq, compl_compl] instance OrderDual.instBooleanAlgebra : BooleanAlgebra αᵒᵈ where __ := instDistribLattice α __ := instHeytingAlgebra - sdiff_eq _ _ := @himp_eq α _ _ _ - himp_eq _ _ := @sdiff_eq α _ _ _ + sdiff_eq a b := congrArg OrderDual.mk (himp_eq (x := b.ofDual') (y := a.ofDual')) + himp_eq a b := congrArg OrderDual.mk (sdiff_eq (x := b.ofDual') (y := a.ofDual')) inf_compl_le_bot a := (@codisjoint_hnot_right _ _ (ofDual a)).top_le top_le_sup_compl a := (@disjoint_compl_right _ _ (ofDual a)).le_bot @@ -552,14 +552,16 @@ theorem compl_sdiff : (x \ y)ᶜ = x ⇨ y := by rw [sdiff_eq, himp_eq, compl_inf, compl_compl, sup_comm] @[simp] -theorem compl_himp : (x ⇨ y)ᶜ = x \ y := - @compl_sdiff αᵒᵈ _ _ _ +theorem compl_himp : (x ⇨ y)ᶜ = x \ y := by + unsealing_newtype OrderDual => + exact @compl_sdiff αᵒᵈ _ _ _ theorem compl_sdiff_compl : xᶜ \ yᶜ = y \ x := by rw [sdiff_compl, sdiff_eq, inf_comm] @[simp] -theorem compl_himp_compl : xᶜ ⇨ yᶜ = y ⇨ x := - @compl_sdiff_compl αᵒᵈ _ _ _ +theorem compl_himp_compl : xᶜ ⇨ yᶜ = y ⇨ x := by + unsealing_newtype OrderDual => + exact @compl_sdiff_compl αᵒᵈ _ _ _ theorem disjoint_compl_left_iff : Disjoint xᶜ y ↔ y ≤ x := by rw [← le_compl_iff_disjoint_left, compl_compl] @@ -567,11 +569,12 @@ theorem disjoint_compl_left_iff : Disjoint xᶜ y ↔ y ≤ x := by theorem disjoint_compl_right_iff : Disjoint x yᶜ ↔ x ≤ y := by rw [← le_compl_iff_disjoint_right, compl_compl] -theorem codisjoint_himp_self_left : Codisjoint (x ⇨ y) x := - @disjoint_sdiff_self_left αᵒᵈ _ _ _ +theorem codisjoint_himp_self_left : Codisjoint (x ⇨ y) x := by + unsealing_newtype OrderDual => + exact @disjoint_sdiff_self_left αᵒᵈ _ _ _ theorem codisjoint_himp_self_right : Codisjoint x (x ⇨ y) := - @disjoint_sdiff_self_right αᵒᵈ _ _ _ + codisjoint_himp_self_left.symm theorem himp_le : x ⇨ y ≤ z ↔ y ≤ z ∧ Codisjoint x z := by rw [himp_eq, sup_le_iff, and_congr_right_iff] diff --git a/mathlib4/Mathlib/Order/Bounded.lean b/mathlib4/Mathlib/Order/Bounded.lean index 200ca7f31..e163a11be 100644 --- a/mathlib4/Mathlib/Order/Bounded.lean +++ b/mathlib4/Mathlib/Order/Bounded.lean @@ -30,6 +30,22 @@ namespace Set variable {α : Type*} {r : α → α → Prop} {s t : Set α} +/-! ### Passing to the order dual + +`Bounded`/`Unbounded` for the reversed relation on `α` is the same statement as the original +relation on `αᵒᵈ`, but the quantifiers range over different types, so the translation needs +these bridges. -/ + +theorem bounded_dual_iff : + Bounded (fun a b : αᵒᵈ ↦ r (OrderDual.ofDual a) (OrderDual.ofDual b)) + (⇑OrderDual.ofDual ⁻¹' s) ↔ Bounded r s := + OrderDual.exists.trans (exists_congr fun _ ↦ OrderDual.forall) + +theorem unbounded_dual_iff : + Unbounded (fun a b : αᵒᵈ ↦ r (OrderDual.ofDual a) (OrderDual.ofDual b)) + (⇑OrderDual.ofDual ⁻¹' s) ↔ Unbounded r s := + OrderDual.forall.trans (forall_congr' fun _ ↦ OrderDual.exists) + /-! ### Subsets of bounded and unbounded sets -/ @@ -108,12 +124,14 @@ theorem unbounded_gt_of_unbounded_ge [Preorder α] (h : Unbounded (· ≥ ·) s) ⟨b, hb, fun hba' => hba (le_of_lt hba')⟩ theorem bounded_ge_iff_bounded_gt [Preorder α] [NoMinOrder α] : - Bounded (· ≥ ·) s ↔ Bounded (· > ·) s := - @bounded_le_iff_bounded_lt αᵒᵈ _ _ _ + Bounded (· ≥ ·) s ↔ Bounded (· > ·) s := by + unsealing_newtype OrderDual => + exact @bounded_le_iff_bounded_lt αᵒᵈ _ _ _ theorem unbounded_gt_iff_unbounded_ge [Preorder α] [NoMinOrder α] : - Unbounded (· > ·) s ↔ Unbounded (· ≥ ·) s := - @unbounded_lt_iff_unbounded_le αᵒᵈ _ _ _ + Unbounded (· > ·) s ↔ Unbounded (· ≥ ·) s := by + unsealing_newtype OrderDual => + exact @unbounded_lt_iff_unbounded_le αᵒᵈ _ _ _ /-! ### The universal set -/ @@ -317,54 +335,66 @@ theorem unbounded_lt_inter_lt [LinearOrder α] [NoMaxOrder α] (a : α) : theorem bounded_ge_inter_not_ge [SemilatticeInf α] (a : α) : - Bounded (· ≥ ·) (s ∩ { b | ¬a ≤ b }) ↔ Bounded (· ≥ ·) s := - @bounded_le_inter_not_le αᵒᵈ s _ a + Bounded (· ≥ ·) (s ∩ { b | ¬a ≤ b }) ↔ Bounded (· ≥ ·) s := by + unsealing_newtype OrderDual => + exact @bounded_le_inter_not_le αᵒᵈ s _ a theorem unbounded_ge_inter_not_ge [SemilatticeInf α] (a : α) : - Unbounded (· ≥ ·) (s ∩ { b | ¬a ≤ b }) ↔ Unbounded (· ≥ ·) s := - @unbounded_le_inter_not_le αᵒᵈ s _ a + Unbounded (· ≥ ·) (s ∩ { b | ¬a ≤ b }) ↔ Unbounded (· ≥ ·) s := by + unsealing_newtype OrderDual => + exact @unbounded_le_inter_not_le αᵒᵈ s _ a theorem bounded_ge_inter_gt [LinearOrder α] (a : α) : - Bounded (· ≥ ·) (s ∩ { b | b < a }) ↔ Bounded (· ≥ ·) s := - @bounded_le_inter_lt αᵒᵈ s _ a + Bounded (· ≥ ·) (s ∩ { b | b < a }) ↔ Bounded (· ≥ ·) s := by + unsealing_newtype OrderDual => + exact @bounded_le_inter_lt αᵒᵈ s _ a theorem unbounded_ge_inter_gt [LinearOrder α] (a : α) : - Unbounded (· ≥ ·) (s ∩ { b | b < a }) ↔ Unbounded (· ≥ ·) s := - @unbounded_le_inter_lt αᵒᵈ s _ a + Unbounded (· ≥ ·) (s ∩ { b | b < a }) ↔ Unbounded (· ≥ ·) s := by + unsealing_newtype OrderDual => + exact @unbounded_le_inter_lt αᵒᵈ s _ a theorem bounded_ge_inter_ge [LinearOrder α] (a : α) : - Bounded (· ≥ ·) (s ∩ { b | b ≤ a }) ↔ Bounded (· ≥ ·) s := - @bounded_le_inter_le αᵒᵈ s _ a + Bounded (· ≥ ·) (s ∩ { b | b ≤ a }) ↔ Bounded (· ≥ ·) s := by + unsealing_newtype OrderDual => + exact @bounded_le_inter_le αᵒᵈ s _ a theorem unbounded_ge_iff_unbounded_inter_ge [LinearOrder α] (a : α) : - Unbounded (· ≥ ·) (s ∩ { b | b ≤ a }) ↔ Unbounded (· ≥ ·) s := - @unbounded_le_inter_le αᵒᵈ s _ a + Unbounded (· ≥ ·) (s ∩ { b | b ≤ a }) ↔ Unbounded (· ≥ ·) s := by + unsealing_newtype OrderDual => + exact @unbounded_le_inter_le αᵒᵈ s _ a /-! #### Greater than -/ theorem bounded_gt_inter_not_gt [SemilatticeInf α] (a : α) : - Bounded (· > ·) (s ∩ { b | ¬a < b }) ↔ Bounded (· > ·) s := - @bounded_lt_inter_not_lt αᵒᵈ s _ a + Bounded (· > ·) (s ∩ { b | ¬a < b }) ↔ Bounded (· > ·) s := by + unsealing_newtype OrderDual => + exact @bounded_lt_inter_not_lt αᵒᵈ s _ a theorem unbounded_gt_inter_not_gt [SemilatticeInf α] (a : α) : - Unbounded (· > ·) (s ∩ { b | ¬a < b }) ↔ Unbounded (· > ·) s := - @unbounded_lt_inter_not_lt αᵒᵈ s _ a + Unbounded (· > ·) (s ∩ { b | ¬a < b }) ↔ Unbounded (· > ·) s := by + unsealing_newtype OrderDual => + exact @unbounded_lt_inter_not_lt αᵒᵈ s _ a theorem bounded_gt_inter_ge [LinearOrder α] (a : α) : - Bounded (· > ·) (s ∩ { b | b ≤ a }) ↔ Bounded (· > ·) s := - @bounded_lt_inter_le αᵒᵈ s _ a + Bounded (· > ·) (s ∩ { b | b ≤ a }) ↔ Bounded (· > ·) s := by + unsealing_newtype OrderDual => + exact @bounded_lt_inter_le αᵒᵈ s _ a theorem unbounded_inter_ge [LinearOrder α] (a : α) : - Unbounded (· > ·) (s ∩ { b | b ≤ a }) ↔ Unbounded (· > ·) s := - @unbounded_lt_inter_le αᵒᵈ s _ a + Unbounded (· > ·) (s ∩ { b | b ≤ a }) ↔ Unbounded (· > ·) s := by + unsealing_newtype OrderDual => + exact @unbounded_lt_inter_le αᵒᵈ s _ a theorem bounded_gt_inter_gt [LinearOrder α] [NoMinOrder α] (a : α) : - Bounded (· > ·) (s ∩ { b | b < a }) ↔ Bounded (· > ·) s := - @bounded_lt_inter_lt αᵒᵈ s _ _ a + Bounded (· > ·) (s ∩ { b | b < a }) ↔ Bounded (· > ·) s := by + unsealing_newtype OrderDual => + exact @bounded_lt_inter_lt αᵒᵈ s _ _ a theorem unbounded_gt_inter_gt [LinearOrder α] [NoMinOrder α] (a : α) : - Unbounded (· > ·) (s ∩ { b | b < a }) ↔ Unbounded (· > ·) s := - @unbounded_lt_inter_lt αᵒᵈ s _ _ a + Unbounded (· > ·) (s ∩ { b | b < a }) ↔ Unbounded (· > ·) s := by + unsealing_newtype OrderDual => + exact @unbounded_lt_inter_lt αᵒᵈ s _ _ a end Set diff --git a/mathlib4/Mathlib/Order/BoundedOrder/Basic.lean b/mathlib4/Mathlib/Order/BoundedOrder/Basic.lean index c2a53f604..d39707221 100644 --- a/mathlib4/Mathlib/Order/BoundedOrder/Basic.lean +++ b/mathlib4/Mathlib/Order/BoundedOrder/Basic.lean @@ -232,17 +232,20 @@ variable (α) @[to_dual] instance [h : Bot α] : Top αᵒᵈ := - ⟨h.bot⟩ + ⟨OrderDual.mk h.bot⟩ @[to_dual] instance [LE α] [h : OrderBot α] : OrderTop αᵒᵈ where - le_top := h.bot_le + le_top a := h.bot_le a.ofDual' @[to_dual (attr := simp)] lemma ofDual_top [Bot α] : ofDual ⊤ = (⊥ : α) := rfl @[to_dual (attr := simp)] lemma toDual_top [Top α] : toDual (⊤ : α) = ⊥ := rfl -@[to_dual (attr := simp)] lemma ofDual_eq_top [Top α] {a : αᵒᵈ} : ofDual a = ⊤ ↔ a = ⊥ := .rfl -@[to_dual (attr := simp)] lemma toDual_eq_top [Bot α] {a : α} : toDual a = ⊤ ↔ a = ⊥ := .rfl +@[to_dual (attr := simp)] +lemma ofDual_eq_top [Top α] {a : αᵒᵈ} : ofDual a = ⊤ ↔ a = ⊥ := by + unsealing_newtype OrderDual => rfl +@[to_dual (attr := simp)] +lemma toDual_eq_top [Bot α] {a : α} : toDual a = ⊤ ↔ a = ⊥ := toDual_inj (b := ⊥) end OrderDual diff --git a/mathlib4/Mathlib/Order/Bounds/Basic.lean b/mathlib4/Mathlib/Order/Bounds/Basic.lean index 28f73dfb5..9b6a1fe73 100644 --- a/mathlib4/Mathlib/Order/Bounds/Basic.lean +++ b/mathlib4/Mathlib/Order/Bounds/Basic.lean @@ -73,22 +73,54 @@ theorem not_bddAbove_iff {α : Type*} [LinearOrder α] {s : Set α} : simp only [not_bddAbove_iff', not_le] @[to_dual (attr := simp)] -lemma bddAbove_preimage_ofDual {s : Set α} : BddAbove (ofDual ⁻¹' s) ↔ BddBelow s := Iff.rfl +lemma upperBounds_preimage_ofDual {s : Set α} : + upperBounds (ofDual ⁻¹' s) = ofDual ⁻¹' lowerBounds s := + Set.ext fun _ ↦ + ⟨fun h _ hy ↦ h (show toDual _ ∈ ofDual ⁻¹' s from hy), fun h _ hy ↦ h hy⟩ @[to_dual (attr := simp)] -lemma bddAbove_preimage_toDual {s : Set αᵒᵈ} : BddAbove (toDual ⁻¹' s) ↔ BddBelow s := Iff.rfl +lemma upperBounds_preimage_toDual {s : Set αᵒᵈ} : + upperBounds (toDual ⁻¹' s) = toDual ⁻¹' lowerBounds s := + Set.ext fun _ ↦ + ⟨fun h _ hy ↦ h (show ofDual _ ∈ toDual ⁻¹' s from hy), fun h _ hy ↦ h hy⟩ + +@[to_dual (attr := simp)] +lemma bddAbove_preimage_ofDual {s : Set α} : BddAbove (ofDual ⁻¹' s) ↔ BddBelow s := by + unsealing_newtype OrderDual => + exact Iff.rfl + +@[to_dual (attr := simp)] +lemma bddAbove_preimage_toDual {s : Set αᵒᵈ} : BddAbove (toDual ⁻¹' s) ↔ BddBelow s := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual] -theorem BddAbove.dual (h : BddAbove s) : BddBelow (ofDual ⁻¹' s) := - h +theorem BddAbove.dual (h : BddAbove s) : BddBelow (ofDual ⁻¹' s) := by + unsealing_newtype OrderDual => + exact h @[to_dual] -theorem IsLeast.dual (h : IsLeast s a) : IsGreatest (ofDual ⁻¹' s) (toDual a) := - h +theorem IsLeast.dual (h : IsLeast s a) : IsGreatest (ofDual ⁻¹' s) (toDual a) := by + unsealing_newtype OrderDual => + exact h @[to_dual] -theorem IsLUB.dual (h : IsLUB s a) : IsGLB (ofDual ⁻¹' s) (toDual a) := - h +theorem IsLUB.dual (h : IsLUB s a) : IsGLB (ofDual ⁻¹' s) (toDual a) := by + unsealing_newtype OrderDual => + exact h + +@[to_dual (attr := simp)] +lemma isLUB_preimage_ofDual {s : Set α} {a : α} : IsLUB (ofDual ⁻¹' s) (toDual a) ↔ IsGLB s a := + ⟨fun h ↦ ⟨fun y hy ↦ h.1 (show toDual y ∈ ofDual ⁻¹' s from hy), + fun b hb ↦ h.2 (show toDual b ∈ upperBounds (ofDual ⁻¹' s) from fun _ hc ↦ hb hc)⟩, + IsGLB.dual⟩ + +@[to_dual (attr := simp)] +lemma isLUB_preimage_toDual {s : Set αᵒᵈ} {a : αᵒᵈ} : + IsLUB (toDual ⁻¹' s) (ofDual a) ↔ IsGLB s a := + ⟨fun h ↦ ⟨fun y hy ↦ h.1 (show ofDual y ∈ toDual ⁻¹' s from hy), + fun b hb ↦ h.2 (show ofDual b ∈ upperBounds (toDual ⁻¹' s) from fun _ hc ↦ hb hc)⟩, + fun h ↦ ⟨fun _ hy ↦ h.1 hy, fun _ hb ↦ h.2 fun y hy ↦ hb (a := ofDual y) hy⟩⟩ /-- If `a` is the least element of a set `s`, then subtype `s` is an order with bottom element. -/ @[to_dual @@ -425,8 +457,9 @@ theorem bddAbove_iff_exists_ge [SemilatticeSup γ] {s : Set γ} (x₀ : γ) : @[to_dual existing bddAbove_iff_exists_ge] theorem bddBelow_iff_exists_le [SemilatticeInf γ] {s : Set γ} (x₀ : γ) : - BddBelow s ↔ ∃ x, x ≤ x₀ ∧ ∀ y ∈ s, x ≤ y := - bddAbove_iff_exists_ge (toDual x₀) + BddBelow s ↔ ∃ x, x ≤ x₀ ∧ ∀ y ∈ s, x ≤ y := by + unsealing_newtype OrderDual => + exact bddAbove_iff_exists_ge (toDual x₀) @[to_dual exists_le] theorem BddAbove.exists_ge [SemilatticeSup γ] {s : Set γ} (hs : BddAbove s) (x₀ : γ) : diff --git a/mathlib4/Mathlib/Order/Bounds/Image.lean b/mathlib4/Mathlib/Order/Bounds/Image.lean index 5af1f503e..d49d1e166 100644 --- a/mathlib4/Mathlib/Order/Bounds/Image.lean +++ b/mathlib4/Mathlib/Order/Bounds/Image.lean @@ -67,31 +67,34 @@ variable [Preorder α] [Preorder β] {f : α → β} {s t : Set α} {a : α} @[to_dual] theorem mem_upperBounds_image (Hf : AntitoneOn f t) (Hst : s ⊆ t) (Has : a ∈ lowerBounds s) : - a ∈ t → f a ∈ upperBounds (f '' s) := - Hf.dual_right.mem_lowerBounds_image Hst Has + a ∈ t → f a ∈ upperBounds (f '' s) := by + unsealing_newtype OrderDual => + exact Hf.dual_right.mem_lowerBounds_image Hst Has @[to_dual] theorem mem_upperBounds_image_self (Hf : AntitoneOn f t) : a ∈ lowerBounds t → a ∈ t → f a ∈ upperBounds (f '' t) := - Hf.dual_right.mem_lowerBounds_image_self + Hf.mem_upperBounds_image subset_rfl @[to_dual] theorem image_lowerBounds_subset_upperBounds_image (Hf : AntitoneOn f t) (Hst : s ⊆ t) : - f '' (lowerBounds s ∩ t) ⊆ upperBounds (f '' s) := - Hf.dual_right.image_lowerBounds_subset_lowerBounds_image Hst + f '' (lowerBounds s ∩ t) ⊆ upperBounds (f '' s) := by + unsealing_newtype OrderDual => + exact Hf.dual_right.image_lowerBounds_subset_lowerBounds_image Hst /-- The image under an antitone function of a set which is bounded above is bounded below. -/ @[to_dual /-- The image under an antitone function of a set which is bounded below is bounded above. -/] theorem map_bddAbove (Hf : AntitoneOn f t) (Hst : s ⊆ t) : - (upperBounds s ∩ t).Nonempty → BddBelow (f '' s) := - Hf.dual_right.map_bddAbove Hst + (upperBounds s ∩ t).Nonempty → BddBelow (f '' s) := by + unsealing_newtype OrderDual => + exact Hf.dual_right.map_bddAbove Hst /-- An antitone map sends a greatest element of a set to a least element of its image. -/ @[to_dual /-- An antitone map sends a least element of a set to a greatest element of its image. -/] -theorem map_isGreatest (Hf : AntitoneOn f t) : IsGreatest t a → IsLeast (f '' t) (f a) := - Hf.dual_right.map_isGreatest +theorem map_isGreatest (Hf : AntitoneOn f t) (Ha : IsGreatest t a) : IsLeast (f '' t) (f a) := + ⟨mem_image_of_mem _ Ha.1, Hf.mem_lowerBounds_image_self Ha.2 Ha.1⟩ end AntitoneOn @@ -133,24 +136,26 @@ variable [Preorder α] [Preorder β] {f : α → β} (hf : Antitone f) {a : α} include hf @[to_dual] -theorem mem_upperBounds_image : a ∈ lowerBounds s → f a ∈ upperBounds (f '' s) := - hf.dual_right.mem_lowerBounds_image +theorem mem_upperBounds_image (Ha : a ∈ lowerBounds s) : f a ∈ upperBounds (f '' s) := + forall_mem_image.2 fun _ H => hf (Ha H) @[to_dual] -theorem image_lowerBounds_subset_upperBounds_image : f '' lowerBounds s ⊆ upperBounds (f '' s) := - hf.dual_right.image_lowerBounds_subset_lowerBounds_image +theorem image_lowerBounds_subset_upperBounds_image : + f '' lowerBounds s ⊆ upperBounds (f '' s) := by + unsealing_newtype OrderDual => + exact hf.dual_right.image_lowerBounds_subset_lowerBounds_image /-- The image under an antitone function of a set which is bounded above is bounded below. -/ @[to_dual /-- The image under an antitone function of a set which is bounded below is bounded above. -/] -theorem map_bddAbove : BddAbove s → BddBelow (f '' s) := - hf.dual_right.map_bddAbove +theorem map_bddAbove : BddAbove s → BddBelow (f '' s) + | ⟨C, hC⟩ => ⟨f C, hf.mem_lowerBounds_image hC⟩ /-- An antitone map sends a greatest element of a set to a least element of its image. -/ @[to_dual /-- An antitone map sends a least element of a set to a greatest element of its image. -/] -theorem map_isGreatest : IsGreatest s a → IsLeast (f '' s) (f a) := - hf.dual_right.map_isGreatest +theorem map_isGreatest (Ha : IsGreatest s a) : IsLeast (f '' s) (f a) := + ⟨mem_image_of_mem _ Ha.1, hf.mem_lowerBounds_image Ha.2⟩ end Antitone diff --git a/mathlib4/Mathlib/Order/Bounds/Lattice.lean b/mathlib4/Mathlib/Order/Bounds/Lattice.lean index 69095c6a9..886e1ac39 100644 --- a/mathlib4/Mathlib/Order/Bounds/Lattice.lean +++ b/mathlib4/Mathlib/Order/Bounds/Lattice.lean @@ -33,8 +33,9 @@ theorem gc_upperBounds_lowerBounds : GaloisConnection @[to_dual (attr := simp)] theorem upperBounds_iUnion : - upperBounds (⋃ i, s i) = ⋂ i, upperBounds (s i) := - gc_upperBounds_lowerBounds.l_iSup + upperBounds (⋃ i, s i) = ⋂ i, upperBounds (s i) := by + unsealing_newtype OrderDual => + exact gc_upperBounds_lowerBounds.l_iSup @[to_dual] theorem isLUB_iUnion_iff_of_isLUB {u : ι → α} (hs : ∀ i, IsLUB (s i) (u i)) (c : α) : diff --git a/mathlib4/Mathlib/Order/Category/BddDistLat.lean b/mathlib4/Mathlib/Order/Category/BddDistLat.lean index a99ff1551..e99d5a5e9 100644 --- a/mathlib4/Mathlib/Order/Category/BddDistLat.lean +++ b/mathlib4/Mathlib/Order/Category/BddDistLat.lean @@ -198,7 +198,7 @@ def dualEquiv : BddDistLat ≌ BddDistLat where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end BddDistLat diff --git a/mathlib4/Mathlib/Order/Category/BddLat.lean b/mathlib4/Mathlib/Order/Category/BddLat.lean index 11d997b57..a9efc65ca 100644 --- a/mathlib4/Mathlib/Order/Category/BddLat.lean +++ b/mathlib4/Mathlib/Order/Category/BddLat.lean @@ -181,7 +181,7 @@ def dualEquiv : BddLat ≌ BddLat where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end BddLat diff --git a/mathlib4/Mathlib/Order/Category/BddOrd.lean b/mathlib4/Mathlib/Order/Category/BddOrd.lean index c44264e52..6444417c1 100644 --- a/mathlib4/Mathlib/Order/Category/BddOrd.lean +++ b/mathlib4/Mathlib/Order/Category/BddOrd.lean @@ -182,7 +182,7 @@ def dualEquiv : BddOrd ≌ BddOrd where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end BddOrd @@ -193,5 +193,5 @@ theorem bddOrd_dual_comp_forget_to_partOrd : theorem bddOrd_dual_comp_forget_to_bipointed : BddOrd.dual ⋙ forget₂ BddOrd Bipointed = - forget₂ BddOrd Bipointed ⋙ Bipointed.swap := - rfl + forget₂ BddOrd Bipointed ⋙ Bipointed.swap := by + unsealing_newtype OrderDual => rfl diff --git a/mathlib4/Mathlib/Order/Category/BoolAlg.lean b/mathlib4/Mathlib/Order/Category/BoolAlg.lean index 8761ea5a2..f9a149100 100644 --- a/mathlib4/Mathlib/Order/Category/BoolAlg.lean +++ b/mathlib4/Mathlib/Order/Category/BoolAlg.lean @@ -191,7 +191,7 @@ def dualEquiv : BoolAlg ≌ BoolAlg where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end BoolAlg diff --git a/mathlib4/Mathlib/Order/Category/CompleteLat.lean b/mathlib4/Mathlib/Order/Category/CompleteLat.lean index 1b32bfad6..e0519c3e9 100644 --- a/mathlib4/Mathlib/Order/Category/CompleteLat.lean +++ b/mathlib4/Mathlib/Order/Category/CompleteLat.lean @@ -84,7 +84,7 @@ def dualEquiv : CompleteLat ≌ CompleteLat where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end CompleteLat diff --git a/mathlib4/Mathlib/Order/Category/DistLat.lean b/mathlib4/Mathlib/Order/Category/DistLat.lean index 14f0779b7..2491eae37 100644 --- a/mathlib4/Mathlib/Order/Category/DistLat.lean +++ b/mathlib4/Mathlib/Order/Category/DistLat.lean @@ -172,7 +172,7 @@ def dualEquiv : DistLat ≌ DistLat where functor := dual inverse := dual unitIso := NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) fun _ => rfl - counitIso := NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) fun _ => rfl + counitIso := NatIso.ofComponents (fun X => Iso.mk <| (OrderIso.dualDual X).symm) fun _ => rfl end DistLat diff --git a/mathlib4/Mathlib/Order/Category/FinBddDistLat.lean b/mathlib4/Mathlib/Order/Category/FinBddDistLat.lean index 306765d9b..39411e45d 100644 --- a/mathlib4/Mathlib/Order/Category/FinBddDistLat.lean +++ b/mathlib4/Mathlib/Order/Category/FinBddDistLat.lean @@ -187,7 +187,7 @@ def dualEquiv : FinBddDistLat ≌ FinBddDistLat where functor := dual inverse := dual unitIso := NatIso.ofComponents (fun X => Iso.mk (α := X) <| OrderIso.dualDual X) - counitIso := NatIso.ofComponents (fun X => Iso.mk <| OrderIso.dualDual X) + counitIso := NatIso.ofComponents (fun X => Iso.mk <| (OrderIso.dualDual X).symm) end FinBddDistLat diff --git a/mathlib4/Mathlib/Order/Category/FinBoolAlg.lean b/mathlib4/Mathlib/Order/Category/FinBoolAlg.lean index d3c5dc317..db2127b81 100644 --- a/mathlib4/Mathlib/Order/Category/FinBoolAlg.lean +++ b/mathlib4/Mathlib/Order/Category/FinBoolAlg.lean @@ -111,7 +111,7 @@ def dualEquiv : FinBoolAlg ≌ FinBoolAlg where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end FinBoolAlg diff --git a/mathlib4/Mathlib/Order/Category/FinPartOrd.lean b/mathlib4/Mathlib/Order/Category/FinPartOrd.lean index edb69172a..0a03eceb5 100644 --- a/mathlib4/Mathlib/Order/Category/FinPartOrd.lean +++ b/mathlib4/Mathlib/Order/Category/FinPartOrd.lean @@ -119,7 +119,7 @@ def dualEquiv : FinPartOrd ≌ FinPartOrd where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end FinPartOrd diff --git a/mathlib4/Mathlib/Order/Category/Lat.lean b/mathlib4/Mathlib/Order/Category/Lat.lean index c0c1efd04..9ee6b03cd 100644 --- a/mathlib4/Mathlib/Order/Category/Lat.lean +++ b/mathlib4/Mathlib/Order/Category/Lat.lean @@ -172,7 +172,7 @@ def dualEquiv : Lat ≌ Lat where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end Lat diff --git a/mathlib4/Mathlib/Order/Category/LinOrd.lean b/mathlib4/Mathlib/Order/Category/LinOrd.lean index aed3b2b3e..5f185ac2b 100644 --- a/mathlib4/Mathlib/Order/Category/LinOrd.lean +++ b/mathlib4/Mathlib/Order/Category/LinOrd.lean @@ -147,7 +147,7 @@ def dualEquiv : LinOrd ≌ LinOrd where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end LinOrd diff --git a/mathlib4/Mathlib/Order/Category/NonemptyFinLinOrd.lean b/mathlib4/Mathlib/Order/Category/NonemptyFinLinOrd.lean index 8ec87477f..82b9b884c 100644 --- a/mathlib4/Mathlib/Order/Category/NonemptyFinLinOrd.lean +++ b/mathlib4/Mathlib/Order/Category/NonemptyFinLinOrd.lean @@ -125,7 +125,7 @@ def dualEquiv : NonemptyFinLinOrd ≌ NonemptyFinLinOrd where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) : Mono f ↔ Function.Injective f := by diff --git a/mathlib4/Mathlib/Order/Category/PartOrd.lean b/mathlib4/Mathlib/Order/Category/PartOrd.lean index bdb54db44..41a438474 100644 --- a/mathlib4/Mathlib/Order/Category/PartOrd.lean +++ b/mathlib4/Mathlib/Order/Category/PartOrd.lean @@ -157,7 +157,7 @@ def dualEquiv : PartOrd ≌ PartOrd where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm /-- The ulift functor `PartOrd.{u} ⥤ PartOrd.{max u v}`. -/ @[simps] @@ -208,7 +208,10 @@ def preordToPartOrdForgetAdjunction : def preordToPartOrdCompToDualIsoToDualCompPreordToPartOrd : preordToPartOrd.{u} ⋙ PartOrd.dual ≅ Preord.dual ⋙ preordToPartOrd := NatIso.ofComponents (fun _ => PartOrd.Iso.mk <| OrderIso.dualAntisymmetrization _) - (fun _ => PartOrd.ext fun x => Quotient.inductionOn' x fun _ => rfl) + (fun _ => PartOrd.ext fun x => by + cases x using OrderDual.rec + rename_i x + exact Quotient.inductionOn' x fun _ => rfl) -- `simp`-normal form for `preordToPartOrdCompToDualIsoToDualCompPreordToPartOrd_inv_app_hom_coe` @[simp] diff --git a/mathlib4/Mathlib/Order/Category/PartOrdEmb.lean b/mathlib4/Mathlib/Order/Category/PartOrdEmb.lean index a627535aa..8289045ce 100644 --- a/mathlib4/Mathlib/Order/Category/PartOrdEmb.lean +++ b/mathlib4/Mathlib/Order/Category/PartOrdEmb.lean @@ -198,7 +198,7 @@ def dualEquiv : PartOrdEmb ≌ PartOrdEmb where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end PartOrdEmb diff --git a/mathlib4/Mathlib/Order/Category/Preord.lean b/mathlib4/Mathlib/Order/Category/Preord.lean index 299f3ad87..243d68ad7 100644 --- a/mathlib4/Mathlib/Order/Category/Preord.lean +++ b/mathlib4/Mathlib/Order/Category/Preord.lean @@ -158,7 +158,7 @@ def dualEquiv : Preord ≌ Preord where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => Iso.mk <| (OrderIso.dualDual X).symm end Preord diff --git a/mathlib4/Mathlib/Order/Category/Semilat.lean b/mathlib4/Mathlib/Order/Category/Semilat.lean index 264ca5258..2db1da079 100644 --- a/mathlib4/Mathlib/Order/Category/Semilat.lean +++ b/mathlib4/Mathlib/Order/Category/Semilat.lean @@ -170,7 +170,7 @@ def SemilatSupCatEquivSemilatInfCat : SemilatSupCat ≌ SemilatInfCat where functor := SemilatSupCat.dual inverse := SemilatInfCat.dual unitIso := NatIso.ofComponents fun X => SemilatSupCat.Iso.mk <| OrderIso.dualDual X - counitIso := NatIso.ofComponents fun X => SemilatInfCat.Iso.mk <| OrderIso.dualDual X + counitIso := NatIso.ofComponents fun X => SemilatInfCat.Iso.mk <| (OrderIso.dualDual X).symm theorem SemilatSupCat_dual_comp_forget_to_partOrd : SemilatSupCat.dual ⋙ forget₂ SemilatInfCat PartOrd = diff --git a/mathlib4/Mathlib/Order/Circular.lean b/mathlib4/Mathlib/Order/Circular.lean index 073192dbe..0189cf8e4 100644 --- a/mathlib4/Mathlib/Order/Circular.lean +++ b/mathlib4/Mathlib/Order/Circular.lean @@ -421,21 +421,23 @@ abbrev LinearOrder.toCircularOrder (α : Type*) [LinearOrder α] : CircularOrder namespace OrderDual instance btw (α : Type*) [h : Btw α] : Btw αᵒᵈ := - ⟨fun a b c => h.btw c b a⟩ + ⟨fun a b c => h.btw c.ofDual' b.ofDual' a.ofDual'⟩ instance sbtw (α : Type*) [h : SBtw α] : SBtw αᵒᵈ := - ⟨fun a b c => h.sbtw c b a⟩ + ⟨fun a b c => h.sbtw c.ofDual' b.ofDual' a.ofDual'⟩ instance circularPreorder (α : Type*) [CircularPreorder α] : CircularPreorder αᵒᵈ where btw_refl _ := btw_refl _ btw_cyclic_left {_ _ _} := @btw_cyclic_right α _ _ _ _ sbtw_trans_left {_ _ _ _} habc hbdc := hbdc.trans_right habc - sbtw_iff_btw_not_btw {a b c} := @sbtw_iff_btw_not_btw α _ c b a + sbtw_iff_btw_not_btw {a b c} := @sbtw_iff_btw_not_btw α _ c.ofDual' b.ofDual' a.ofDual' instance circularPartialOrder (α : Type*) [CircularPartialOrder α] : CircularPartialOrder αᵒᵈ where - btw_antisymm := fun {_ _ _} habc hcba => @btw_antisymm α _ _ _ _ hcba habc + btw_antisymm := fun {_ _ _} habc hcba => + (@btw_antisymm α _ _ _ _ hcba habc).imp (congrArg OrderDual.mk) + (Or.imp (congrArg OrderDual.mk) (congrArg OrderDual.mk)) instance (α : Type*) [CircularOrder α] : CircularOrder αᵒᵈ where - btw_total := fun {a b c} => @btw_total α _ c b a + btw_total := fun {a b c} => @btw_total α _ c.ofDual' b.ofDual' a.ofDual' end OrderDual diff --git a/mathlib4/Mathlib/Order/Compare.lean b/mathlib4/Mathlib/Order/Compare.lean index de59b5764..cd8a4a8bc 100644 --- a/mathlib4/Mathlib/Order/Compare.lean +++ b/mathlib4/Mathlib/Order/Compare.lean @@ -110,14 +110,16 @@ open Ordering OrderDual @[simp] theorem toDual_compares_toDual [LT α] {a b : α} {o : Ordering} : Compares o (toDual a) (toDual b) ↔ Compares o b a := by - cases o - exacts [Iff.rfl, eq_comm, Iff.rfl] + unsealing_newtype OrderDual => + cases o + exacts [Iff.rfl, eq_comm, Iff.rfl] @[simp] theorem ofDual_compares_ofDual [LT α] {a b : αᵒᵈ} {o : Ordering} : Compares o (ofDual a) (ofDual b) ↔ Compares o b a := by - cases o - exacts [Iff.rfl, eq_comm, Iff.rfl] + unsealing_newtype OrderDual => + cases o + exacts [Iff.rfl, eq_comm, Iff.rfl] theorem cmp_compares [LinearOrder α] (a b : α) : (cmp a b).Compares a b := by obtain h | h | h := lt_trichotomy a b <;> simp [cmp, cmpUsing, h, h.not_gt] diff --git a/mathlib4/Mathlib/Order/CompleteBooleanAlgebra.lean b/mathlib4/Mathlib/Order/CompleteBooleanAlgebra.lean index 91b16c073..61fe0b2d6 100644 --- a/mathlib4/Mathlib/Order/CompleteBooleanAlgebra.lean +++ b/mathlib4/Mathlib/Order/CompleteBooleanAlgebra.lean @@ -452,8 +452,9 @@ theorem iSup_inf_of_monotone {ι : Type*} [Preorder ι] [IsDirectedOrder ι] {f @[to_dual] theorem iSup_inf_of_antitone {ι : Type*} [Preorder ι] [IsCodirectedOrder ι] {f g : ι → α} - (hf : Antitone f) (hg : Antitone g) : ⨆ i, f i ⊓ g i = (⨆ i, f i) ⊓ ⨆ i, g i := - @iSup_inf_of_monotone α _ ιᵒᵈ _ _ f g hf.dual_left hg.dual_left + (hf : Antitone f) (hg : Antitone g) : ⨆ i, f i ⊓ g i = (⨆ i, f i) ⊓ ⨆ i, g i := by + unsealing_newtype OrderDual => + exact @iSup_inf_of_monotone α _ ιᵒᵈ _ _ f g hf.dual_left hg.dual_left theorem himp_eq_sSup : a ⇨ b = sSup {w | w ⊓ a ≤ b} := (isGreatest_himp a b).isLUB.sSup_eq.symm @@ -533,7 +534,9 @@ instance OrderDual.instCompletelyDistribLattice [CompletelyDistribLattice α] : CompletelyDistribLattice αᵒᵈ where __ := instFrame __ := instCoframe - iInf_iSup_eq _ := iSup_iInf_eq (α := α) + iInf_iSup_eq f := OrderDual.ofDual_inj.mp <| by + simp only [ofDual_iInf, ofDual_iSup] + exact iSup_iInf_eq (α := α) (f := fun a b => OrderDual.ofDual (f a b)) instance Prod.instCompletelyDistribLattice [CompletelyDistribLattice α] [CompletelyDistribLattice β] : CompletelyDistribLattice (α × β) where diff --git a/mathlib4/Mathlib/Order/CompleteLattice/Basic.lean b/mathlib4/Mathlib/Order/CompleteLattice/Basic.lean index dc37f211d..0f80d154b 100644 --- a/mathlib4/Mathlib/Order/CompleteLattice/Basic.lean +++ b/mathlib4/Mathlib/Order/CompleteLattice/Basic.lean @@ -321,8 +321,9 @@ theorem Monotone.le_map_iSup [CompleteLattice β] {f : α → β} (hf : Monotone @[to_dual map_iSup_le] theorem Antitone.le_map_iInf [CompleteLattice β] {f : α → β} (hf : Antitone f) : - ⨆ i, f (s i) ≤ f (iInf s) := - hf.dual_left.le_map_iSup + ⨆ i, f (s i) ≤ f (iInf s) := by + unsealing_newtype OrderDual => + exact hf.dual_left.le_map_iSup @[to_dual map_iInf₂_le] theorem Monotone.le_map_iSup₂ [CompleteLattice β] {f : α → β} (hf : Monotone f) (s : ∀ i, κ i → α) : @@ -331,8 +332,9 @@ theorem Monotone.le_map_iSup₂ [CompleteLattice β] {f : α → β} (hf : Monot @[to_dual map_iSup₂_le] theorem Antitone.le_map_iInf₂ [CompleteLattice β] {f : α → β} (hf : Antitone f) (s : ∀ i, κ i → α) : - ⨆ (i) (j), f (s i j) ≤ f (⨅ (i) (j), s i j) := - hf.dual_left.le_map_iSup₂ _ + ⨆ (i) (j), f (s i j) ≤ f (⨅ (i) (j), s i j) := by + unsealing_newtype OrderDual => + exact hf.dual_left.le_map_iSup₂ _ @[to_dual map_sInf_le] theorem Monotone.le_map_sSup [CompleteLattice β] {s : Set α} {f : α → β} (hf : Monotone f) : @@ -340,8 +342,9 @@ theorem Monotone.le_map_sSup [CompleteLattice β] {s : Set α} {f : α → β} ( @[to_dual map_sSup_le] theorem Antitone.le_map_sInf [CompleteLattice β] {s : Set α} {f : α → β} (hf : Antitone f) : - ⨆ a ∈ s, f a ≤ f (sInf s) := - hf.dual_left.le_map_sSup + ⨆ a ∈ s, f a ≤ f (sInf s) := by + unsealing_newtype OrderDual => + exact hf.dual_left.le_map_sSup @[to_dual] theorem OrderIso.map_iSup [CompleteLattice β] (f : α ≃o β) (x : ι → α) : diff --git a/mathlib4/Mathlib/Order/CompleteLattice/Defs.lean b/mathlib4/Mathlib/Order/CompleteLattice/Defs.lean index 491f5e047..3ffc12fa7 100644 --- a/mathlib4/Mathlib/Order/CompleteLattice/Defs.lean +++ b/mathlib4/Mathlib/Order/CompleteLattice/Defs.lean @@ -50,7 +50,7 @@ variable {α β : Type*} {ι : Sort*} @[to_dual] instance OrderDual.supSet (α) [h : InfSet α] : SupSet αᵒᵈ := - ⟨fun s ↦ h.sInf s⟩ + ⟨fun s ↦ OrderDual.mk (h.sInf (⇑toDual ⁻¹' s))⟩ /-- Note that we rarely use `CompleteSemilatticeSup` (in fact, any such object is always a `CompleteLattice`, so it's usually best to start there). @@ -131,7 +131,7 @@ end @[to_dual] instance {α : Type*} [CompleteSemilatticeInf α] : CompleteSemilatticeSup αᵒᵈ where - isLUB_sSup := isGLB_sInf (α := α) + isLUB_sSup s := (isGLB_sInf (α := α) (⇑toDual ⁻¹' s)).dual /-- A complete lattice is a bounded lattice which has suprema and infima for every subset. -/ class CompleteLattice (α : Type*) extends Lattice α, CompleteSemilatticeSup α, @@ -293,12 +293,12 @@ theorem ofDual_sSup [InfSet α] (s : Set αᵒᵈ) : ofDual (sSup s) = sInf (toD rfl @[to_dual (attr := simp)] -theorem toDual_iSup [SupSet α] (f : ι → α) : toDual (⨆ i, f i) = ⨅ i, toDual (f i) := - rfl +theorem toDual_iSup [SupSet α] (f : ι → α) : toDual (⨆ i, f i) = ⨅ i, toDual (f i) := by + unsealing_newtype OrderDual => rfl @[to_dual (attr := simp)] -theorem ofDual_iSup [InfSet α] (f : ι → αᵒᵈ) : ofDual (⨆ i, f i) = ⨅ i, ofDual (f i) := - rfl +theorem ofDual_iSup [InfSet α] (f : ι → αᵒᵈ) : ofDual (⨆ i, f i) = ⨅ i, ofDual (f i) := by + unsealing_newtype OrderDual => rfl end OrderDual diff --git a/mathlib4/Mathlib/Order/CompleteLattice/Group.lean b/mathlib4/Mathlib/Order/CompleteLattice/Group.lean index 123f0321a..997011145 100644 --- a/mathlib4/Mathlib/Order/CompleteLattice/Group.lean +++ b/mathlib4/Mathlib/Order/CompleteLattice/Group.lean @@ -23,8 +23,9 @@ lemma iSup_mul_le (u v : ι → α) : @[to_additive] lemma le_iInf_mul (u v : ι → α) : - (⨅ i, u i) * ⨅ i, v i ≤ ⨅ i, u i * v i := - iSup_mul_le (α := αᵒᵈ) .. + (⨅ i, u i) * ⨅ i, v i ≤ ⨅ i, u i * v i := by + unsealing_newtype OrderDual => + exact iSup_mul_le (α := αᵒᵈ) .. @[to_additive] lemma iSup₂_mul_le (u v : (i : ι) → κ i → α) : @@ -35,5 +36,6 @@ lemma iSup₂_mul_le (u v : (i : ι) → κ i → α) : @[to_additive] lemma le_iInf₂_mul (u v : (i : ι) → κ i → α) : - (⨅ (i) (j), u i j) * ⨅ (i) (j), v i j ≤ ⨅ (i) (j), u i j * v i j := - iSup₂_mul_le (α := αᵒᵈ) .. + (⨅ (i) (j), u i j) * ⨅ (i) (j), v i j ≤ ⨅ (i) (j), u i j * v i j := by + unsealing_newtype OrderDual => + exact iSup₂_mul_le (α := αᵒᵈ) .. diff --git a/mathlib4/Mathlib/Order/CompleteLattice/Lemmas.lean b/mathlib4/Mathlib/Order/CompleteLattice/Lemmas.lean index 64f48949f..f9876f832 100644 --- a/mathlib4/Mathlib/Order/CompleteLattice/Lemmas.lean +++ b/mathlib4/Mathlib/Order/CompleteLattice/Lemmas.lean @@ -74,8 +74,10 @@ theorem iSup_ge_eq_iSup_nat_add (u : ℕ → α) (n : ℕ) : ⨆ i ≥ n, u i = theorem Monotone.iSup_nat_add {f : ℕ → α} (hf : Monotone f) (k : ℕ) : ⨆ n, f (n + k) = ⨆ n, f n := le_antisymm (iSup_le fun i => le_iSup _ (i + k)) <| iSup_mono fun i => hf <| Nat.le_add_right i k -theorem Antitone.iInf_nat_add {f : ℕ → α} (hf : Antitone f) (k : ℕ) : ⨅ n, f (n + k) = ⨅ n, f n := - hf.dual_right.iSup_nat_add k +theorem Antitone.iInf_nat_add {f : ℕ → α} (hf : Antitone f) (k : ℕ) : + ⨅ n, f (n + k) = ⨅ n, f n := by + unsealing_newtype OrderDual => + exact hf.dual_right.iSup_nat_add k -- Not `@[simp]` since the subterm `?f (i + ?k)` produces an ugly higher-order unification problem. -- (Although the `simpNF` linter does not complain.) @@ -90,9 +92,11 @@ theorem iSup_iInf_ge_nat_add (f : ℕ → α) (k : ℕ) : -- (Although the `simpNF` linter does not complain.) -- See: https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/complete_lattice.20and.20has_sup/near/316497982 @[to_dual existing] -theorem iInf_iSup_ge_nat_add : - ∀ (f : ℕ → α) (k : ℕ), ⨅ n, ⨆ i ≥ n, f (i + k) = ⨅ n, ⨆ i ≥ n, f i := - @iSup_iInf_ge_nat_add αᵒᵈ _ +theorem iInf_iSup_ge_nat_add (f : ℕ → α) (k : ℕ) : + ⨅ n, ⨆ i ≥ n, f (i + k) = ⨅ n, ⨆ i ≥ n, f i := by + have hf : Antitone fun n => ⨆ i ≥ n, f i := fun n m h => biSup_mono fun i => h.trans + rw [← Antitone.iInf_nat_add hf k] + · simp_rw [iSup_ge_eq_iSup_nat_add, ← Nat.add_assoc] @[to_dual inf_iInf_nat_succ] theorem sup_iSup_nat_succ (u : ℕ → α) : (u 0 ⊔ ⨆ i, u (i + 1)) = ⨆ i, u i := diff --git a/mathlib4/Mathlib/Order/CompleteLattice/PiLex.lean b/mathlib4/Mathlib/Order/CompleteLattice/PiLex.lean index f2b762c64..e6a76cf8b 100644 --- a/mathlib4/Mathlib/Order/CompleteLattice/PiLex.lean +++ b/mathlib4/Mathlib/Order/CompleteLattice/PiLex.lean @@ -62,23 +62,29 @@ private theorem isGLB_sInf {s : Set (Πₗ i, α i)} : IsGLB s (sInf s) := by refine ha.2.not_ge <| le_sInf_apply fun f hf hf' ↦ apply_le_of_toLex (h hf) ?_ simp_all +private def ofDual (f : Πₗ i, (α i)ᵒᵈ) : Πₗ i, α i := + toLex fun i => OrderDual.ofDual (f i) + -- TODO: figure out how to use `to_dual` here @[no_expose] instance : SupSet (Πₗ i, α i) where - sSup s := sInf (α := Πₗ i, (α i)ᵒᵈ) s + sSup s := ofDual (sInf (ofDual ⁻¹' s)) theorem sSup_apply (s : Set (Πₗ i, α i)) (i : ι) : - sSup s i = ⨆ e : {e ∈ s | ∀ j < i, e j = sSup s j}, e.1 i := - sInf_apply (α := fun i ↦ (α i)ᵒᵈ) .. + sSup s i = ⨆ e : {e ∈ s | ∀ j < i, e j = sSup s j}, e.1 i := by + unsealing_newtype OrderDual => + exact sInf_apply (α := fun i ↦ (α i)ᵒᵈ) .. theorem le_sSup_apply {s : Set (Πₗ i, α i)} {i : ι} {e : Πₗ i, α i} - (he : e ∈ s) (h : ∀ j < i, e j = sSup s j) : e i ≤ sSup s i := - sInf_apply_le (α := fun i ↦ (α i)ᵒᵈ) he h + (he : e ∈ s) (h : ∀ j < i, e j = sSup s j) : e i ≤ sSup s i := by + unsealing_newtype OrderDual => + exact sInf_apply_le (α := fun i ↦ (α i)ᵒᵈ) he h theorem sSup_apply_le {s : Set (Πₗ i, α i)} {i : ι} {e : Πₗ i, α i} - (h : ∀ f ∈ s, (∀ j < i, f j = sSup s j) → f i ≤ e i) : sSup s i ≤ e i := - le_sInf_apply (α := fun i ↦ (α i)ᵒᵈ) h + (h : ∀ f ∈ s, (∀ j < i, f j = sSup s j) → f i ≤ e i) : sSup s i ≤ e i := by + unsealing_newtype OrderDual => + exact le_sInf_apply (α := fun i ↦ (α i)ᵒᵈ) h private theorem isLUB_sSup {s : Set (Πₗ i, α i)} : IsLUB s (sSup s) := by refine ⟨fun e he ↦ ?_, fun e h ↦ ?_⟩ @@ -104,54 +110,66 @@ end Lex /-! ### Colexicographic ordering -/ namespace Colex + +private def ofLexDual (f : Πₗ i : ιᵒᵈ, α (OrderDual.ofDual i)) : Colex ((i : ι) → α i) := + toColex fun i => f (OrderDual.toDual i) + variable [WellFoundedGT ι] -set_option backward.isDefEq.respectTransparency false in @[no_expose] instance : InfSet (Colex ((i : ι) → α i)) where - sInf s := sInf (α := Πₗ i : ιᵒᵈ, α i) s + sInf s := ofLexDual (sInf (ofLexDual ⁻¹' s)) set_option backward.isDefEq.respectTransparency false in theorem sInf_apply (s : Set (Colex ((i : ι) → α i))) (i : ι) : - sInf s i = ⨅ e : {e ∈ s | ∀ j > i, e j = sInf s j}, e.1 i := - Lex.sInf_apply (ι := ιᵒᵈ) s i + sInf s i = ⨅ e : {e ∈ s | ∀ j > i, e j = sInf s j}, e.1 i := by + unsealing_newtype OrderDual => + exact Lex.sInf_apply (ι := ιᵒᵈ) s i set_option backward.isDefEq.respectTransparency false in theorem sInf_apply_le {s : Set (Colex ((i : ι) → α i))} {i : ι} {e : Colex ((i : ι) → α i)} - (he : e ∈ s) (h : ∀ j > i, e j = sInf s j) : sInf s i ≤ e i := - Lex.sInf_apply_le (ι := ιᵒᵈ) he h + (he : e ∈ s) (h : ∀ j > i, e j = sInf s j) : sInf s i ≤ e i := by + unsealing_newtype OrderDual => + exact Lex.sInf_apply_le (ι := ιᵒᵈ) he h set_option backward.isDefEq.respectTransparency false in theorem le_sInf_apply {s : Set (Colex ((i : ι) → α i))} {i : ι} {e : Colex ((i : ι) → α i)} - (h : ∀ f ∈ s, (∀ j > i, f j = sInf s j) → e i ≤ f i) : e i ≤ sInf s i := - Lex.le_sInf_apply (ι := ιᵒᵈ) h + (h : ∀ f ∈ s, (∀ j > i, f j = sInf s j) → e i ≤ f i) : e i ≤ sInf s i := by + unsealing_newtype OrderDual => + exact Lex.le_sInf_apply (ι := ιᵒᵈ) h -- TODO: figure out how to use `to_dual` here -set_option backward.isDefEq.respectTransparency false in @[no_expose] instance : SupSet (Colex ((i : ι) → α i)) where - sSup s := sSup (α := Πₗ i : ιᵒᵈ, α i) s + sSup s := ofLexDual (sSup (ofLexDual ⁻¹' s)) set_option backward.isDefEq.respectTransparency false in theorem sSup_apply (s : Set (Colex ((i : ι) → α i))) (i : ι) : - sSup s i = ⨆ e : {e ∈ s | ∀ j > i, e j = sSup s j}, e.1 i := - Lex.sSup_apply (ι := ιᵒᵈ) s i + sSup s i = ⨆ e : {e ∈ s | ∀ j > i, e j = sSup s j}, e.1 i := by + unsealing_newtype OrderDual => + exact Lex.sSup_apply (ι := ιᵒᵈ) s i set_option backward.isDefEq.respectTransparency false in theorem le_sSup_apply {s : Set (Colex ((i : ι) → α i))} {i : ι} {e : Colex ((i : ι) → α i)} - (he : e ∈ s) (h : ∀ j > i, e j = sSup s j) : e i ≤ sSup s i := - Lex.le_sSup_apply (ι := ιᵒᵈ) he h + (he : e ∈ s) (h : ∀ j > i, e j = sSup s j) : e i ≤ sSup s i := by + unsealing_newtype OrderDual => + exact Lex.le_sSup_apply (ι := ιᵒᵈ) he h set_option backward.isDefEq.respectTransparency false in theorem sSup_apply_le {s : Set (Colex ((i : ι) → α i))} {i : ι} {e : Colex ((i : ι) → α i)} - (h : ∀ f ∈ s, (∀ j > i, f j = sSup s j) → f i ≤ e i) : sSup s i ≤ e i := - Lex.sSup_apply_le (ι := ιᵒᵈ) h + (h : ∀ f ∈ s, (∀ j > i, f j = sSup s j) → f i ≤ e i) : sSup s i ≤ e i := by + unsealing_newtype OrderDual => + exact Lex.sSup_apply_le (ι := ιᵒᵈ) h set_option backward.isDefEq.respectTransparency false in noncomputable instance completeLattice : CompleteLattice (Colex ((i : ι) → α i)) where - isLUB_sSup _ := by exact Lex.isLUB_sSup (ι := ιᵒᵈ) - isGLB_sInf _ := by exact Lex.isGLB_sInf (ι := ιᵒᵈ) + isLUB_sSup _ := by + unsealing_newtype OrderDual => + exact Lex.isLUB_sSup (ι := ιᵒᵈ) + isGLB_sInf _ := by + unsealing_newtype OrderDual => + exact Lex.isGLB_sInf (ι := ιᵒᵈ) noncomputable instance : CompleteLinearOrder (Colex ((i : ι) → α i)) where __ := linearOrder diff --git a/mathlib4/Mathlib/Order/Concept.lean b/mathlib4/Mathlib/Order/Concept.lean index 9527914ce..687f832db 100644 --- a/mathlib4/Mathlib/Order/Concept.lean +++ b/mathlib4/Mathlib/Order/Concept.lean @@ -109,8 +109,9 @@ theorem lowerPolar_union (t₁ t₂ : Set β) : @[simp] theorem upperPolar_iUnion (f : ι → Set α) : - upperPolar r (⋃ i, f i) = ⋂ i, upperPolar r (f i) := - (gc_upperPolar_lowerPolar r).l_iSup + upperPolar r (⋃ i, f i) = ⋂ i, upperPolar r (f i) := by + unsealing_newtype OrderDual => + exact (gc_upperPolar_lowerPolar r).l_iSup @[simp] theorem lowerPolar_iUnion (f : ι → Set β) : @@ -118,16 +119,17 @@ theorem lowerPolar_iUnion (f : ι → Set β) : upperPolar_iUnion .. theorem upperPolar_iUnion₂ (f : ∀ i, κ i → Set α) : - upperPolar r (⋃ (i) (j), f i j) = ⋂ (i) (j), upperPolar r (f i j) := - (gc_upperPolar_lowerPolar r).l_iSup₂ + upperPolar r (⋃ (i) (j), f i j) = ⋂ (i) (j), upperPolar r (f i j) := by + simp theorem lowerPolar_iUnion₂ (f : ∀ i, κ i → Set β) : lowerPolar r (⋃ (i) (j), f i j) = ⋂ (i) (j), lowerPolar r (f i j) := upperPolar_iUnion₂ .. theorem subset_lowerPolar_upperPolar (s : Set α) : - s ⊆ lowerPolar r (upperPolar r s) := - (gc_upperPolar_lowerPolar r).le_u_l _ + s ⊆ lowerPolar r (upperPolar r s) := by + unsealing_newtype OrderDual => + exact (gc_upperPolar_lowerPolar r).le_u_l _ theorem subset_upperPolar_lowerPolar (t : Set β) : t ⊆ upperPolar r (lowerPolar r t) := @@ -135,8 +137,9 @@ theorem subset_upperPolar_lowerPolar (t : Set β) : @[simp] theorem upperPolar_lowerPolar_upperPolar (s : Set α) : - upperPolar r (lowerPolar r <| upperPolar r s) = upperPolar r s := - (gc_upperPolar_lowerPolar r).l_u_l_eq_l _ + upperPolar r (lowerPolar r <| upperPolar r s) = upperPolar r s := by + unsealing_newtype OrderDual => + exact (gc_upperPolar_lowerPolar r).l_u_l_eq_l _ @[simp] theorem lowerPolar_upperPolar_lowerPolar (t : Set β) : @@ -149,11 +152,13 @@ theorem upperPolar_anti : Antitone (upperPolar r) := theorem lowerPolar_anti : Antitone (lowerPolar r) := upperPolar_anti _ -theorem lowerPolar_upperPolar_monotone : Monotone (lowerPolar r ∘ upperPolar r) := - (gc_upperPolar_lowerPolar r).monotone_u_comp_l +theorem lowerPolar_upperPolar_monotone : Monotone (lowerPolar r ∘ upperPolar r) := by + unsealing_newtype OrderDual => + exact (gc_upperPolar_lowerPolar r).monotone_u_comp_l -theorem upperPolar_lowerPolar_monotone : Monotone (upperPolar r ∘ lowerPolar r) := - (gc_lowerPolar_upperPolar r).monotone_u_comp_l +theorem upperPolar_lowerPolar_monotone : Monotone (upperPolar r ∘ lowerPolar r) := by + unsealing_newtype OrderDual => + exact (gc_lowerPolar_upperPolar r).monotone_u_comp_l /-- The `extentClosure` of a set is the smallest extent containing it. See `IsExtent.lowerPolar_upperPolar_subset` for this proof. -/ @@ -191,8 +196,9 @@ theorem isExtent_iff : IsExtent r s ↔ lowerPolar r (upperPolar r s) = s := alias ⟨IsExtent.eq, _⟩ := isExtent_iff @[simp] -protected theorem IsExtent.univ : IsExtent r univ := - isExtent_iff.2 (gc_upperPolar_lowerPolar r).u_l_top +protected theorem IsExtent.univ : IsExtent r univ := by + unsealing_newtype OrderDual => + exact isExtent_iff.2 (gc_upperPolar_lowerPolar r).u_l_top protected theorem IsExtent.inter {s' : Set α} : IsExtent r s → IsExtent r s' → IsExtent r (s ∩ s') := by @@ -599,7 +605,7 @@ theorem swap_lt_swap_iff : c.swap < d.swap ↔ d < c := def swapEquiv : (Concept α β r)ᵒᵈ ≃o Concept β α (Function.swap r) where toFun := swap ∘ ofDual invFun := toDual ∘ swap - left_inv := swap_swap + left_inv x := congrArg OrderDual.toDual (swap_swap (OrderDual.ofDual x)) right_inv := swap_swap map_rel_iff' := swap_le_swap_iff diff --git a/mathlib4/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean b/mathlib4/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean index c1d0a08e8..94aaeccbf 100644 --- a/mathlib4/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean +++ b/mathlib4/Mathlib/Order/ConditionallyCompleteLattice/Basic.lean @@ -173,13 +173,21 @@ namespace OrderDual instance instConditionallyCompleteLattice (α : Type*) [ConditionallyCompleteLattice α] : ConditionallyCompleteLattice αᵒᵈ where - isLUB_csSup := ConditionallyCompleteLattice.isGLB_csInf (α := α) - isGLB_csInf := ConditionallyCompleteLattice.isLUB_csSup (α := α) + isLUB_csSup s hs hb := isGLB_preimage_toDual.1 <| + ConditionallyCompleteLattice.isGLB_csInf (⇑toDual ⁻¹' s) + (hs.elim fun x hx ↦ ⟨ofDual x, hx⟩) (bddBelow_preimage_toDual.2 hb) + isGLB_csInf s hs hb := isLUB_preimage_toDual.1 <| + ConditionallyCompleteLattice.isLUB_csSup (⇑toDual ⁻¹' s) + (hs.elim fun x hx ↦ ⟨ofDual x, hx⟩) (bddAbove_preimage_toDual.2 hb) instance (α : Type*) [ConditionallyCompleteLinearOrder α] : ConditionallyCompleteLinearOrder αᵒᵈ where - csSup_of_not_bddAbove := ConditionallyCompleteLinearOrder.csInf_of_not_bddBelow (α := α) - csInf_of_not_bddBelow := ConditionallyCompleteLinearOrder.csSup_of_not_bddAbove (α := α) + csSup_of_not_bddAbove s H := congrArg OrderDual.mk + (ConditionallyCompleteLinearOrder.csInf_of_not_bddBelow (⇑toDual ⁻¹' s) + fun h ↦ H (bddBelow_preimage_toDual.1 h)) + csInf_of_not_bddBelow s H := congrArg OrderDual.mk + (ConditionallyCompleteLinearOrder.csSup_of_not_bddAbove (⇑toDual ⁻¹' s) + fun h ↦ H (bddAbove_preimage_toDual.1 h)) __ := OrderDual.instConditionallyCompleteLattice α __ := OrderDual.instLinearOrder α @@ -753,9 +761,10 @@ theorem MonotoneOn.sInf_image_Icc [Preorder α] [ConditionallyCompleteLattice β theorem AntitoneOn.sInf_image_Icc [Preorder α] [ConditionallyCompleteLattice β] {f : α → β} {a b : α} (hab : a ≤ b) (h' : AntitoneOn f (Icc a b)) : sInf (f '' Icc a b) = f b := by - have : Icc a b = Icc (α := αᵒᵈ) (toDual b) (toDual a) := by rw [Icc_toDual]; rfl - rw [this] at h' ⊢ - exact h'.dual_left.sInf_image_Icc (α := αᵒᵈ) hab + unsealing_newtype OrderDual => + have : Icc a b = Icc (α := αᵒᵈ) (toDual b) (toDual a) := by rw [Icc_toDual]; rfl + rw [this] at h' ⊢ + exact h'.dual_left.sInf_image_Icc (α := αᵒᵈ) hab /-! ### Supremum/infimum of `Set.image2` @@ -782,20 +791,26 @@ theorem csSup_image2_eq_csSup_csSup (h₁ : ∀ b, GaloisConnection (swap l b) ( @[to_dual] theorem csSup_image2_eq_csSup_csInf (h₁ : ∀ b, GaloisConnection (swap l b) (u₁ b)) (h₂ : ∀ a, GaloisConnection (l a ∘ ofDual) (toDual ∘ u₂ a)) : - s.Nonempty → BddAbove s → t.Nonempty → BddBelow t → sSup (image2 l s t) = l (sSup s) (sInf t) := - csSup_image2_eq_csSup_csSup (β := βᵒᵈ) h₁ h₂ + s.Nonempty → BddAbove s → t.Nonempty → BddBelow t → + sSup (image2 l s t) = l (sSup s) (sInf t) := by + unsealing_newtype OrderDual => + exact csSup_image2_eq_csSup_csSup (β := βᵒᵈ) h₁ h₂ @[to_dual] theorem csSup_image2_eq_csInf_csSup (h₁ : ∀ b, GaloisConnection (swap l b ∘ ofDual) (toDual ∘ u₁ b)) (h₂ : ∀ a, GaloisConnection (l a) (u₂ a)) : - s.Nonempty → BddBelow s → t.Nonempty → BddAbove t → sSup (image2 l s t) = l (sInf s) (sSup t) := - csSup_image2_eq_csSup_csSup (α := αᵒᵈ) h₁ h₂ + s.Nonempty → BddBelow s → t.Nonempty → BddAbove t → + sSup (image2 l s t) = l (sInf s) (sSup t) := by + unsealing_newtype OrderDual => + exact csSup_image2_eq_csSup_csSup (α := αᵒᵈ) h₁ h₂ @[to_dual] theorem csSup_image2_eq_csInf_csInf (h₁ : ∀ b, GaloisConnection (swap l b ∘ ofDual) (toDual ∘ u₁ b)) (h₂ : ∀ a, GaloisConnection (l a ∘ ofDual) (toDual ∘ u₂ a)) : - s.Nonempty → BddBelow s → t.Nonempty → BddBelow t → sSup (image2 l s t) = l (sInf s) (sInf t) := - csSup_image2_eq_csSup_csSup (α := αᵒᵈ) (β := βᵒᵈ) h₁ h₂ + s.Nonempty → BddBelow s → t.Nonempty → BddBelow t → + sSup (image2 l s t) = l (sInf s) (sInf t) := by + unsealing_newtype OrderDual => + exact csSup_image2_eq_csSup_csSup (α := αᵒᵈ) (β := βᵒᵈ) h₁ h₂ end diff --git a/mathlib4/Mathlib/Order/ConditionallyCompleteLattice/Group.lean b/mathlib4/Mathlib/Order/ConditionallyCompleteLattice/Group.lean index 8c04bae12..786613743 100644 --- a/mathlib4/Mathlib/Order/ConditionallyCompleteLattice/Group.lean +++ b/mathlib4/Mathlib/Order/ConditionallyCompleteLattice/Group.lean @@ -48,8 +48,9 @@ theorem le_mul_ciInf [MulLeftMono α] {a : α} {g : α} {h : ι → α} @[to_additive] theorem mul_ciSup_le [MulLeftMono α] {a : α} {g : α} {h : ι → α} - (H : ∀ j, g * h j ≤ a) : g * iSup h ≤ a := - le_mul_ciInf (α := αᵒᵈ) H + (H : ∀ j, g * h j ≤ a) : g * iSup h ≤ a := by + unsealing_newtype OrderDual => + exact le_mul_ciInf (α := αᵒᵈ) H @[to_additive] theorem le_ciInf_mul [MulRightMono α] {a : α} {g : ι → α} @@ -58,8 +59,9 @@ theorem le_ciInf_mul [MulRightMono α] {a : α} {g : ι → α} @[to_additive] theorem ciSup_mul_le [MulRightMono α] {a : α} {g : ι → α} - {h : α} (H : ∀ i, g i * h ≤ a) : iSup g * h ≤ a := - le_ciInf_mul (α := αᵒᵈ) H + {h : α} (H : ∀ i, g i * h ≤ a) : iSup g * h ≤ a := by + unsealing_newtype OrderDual => + exact le_ciInf_mul (α := αᵒᵈ) H @[to_additive] theorem le_ciInf_mul_ciInf [MulLeftMono α] [MulRightMono α] {a : α} {g : ι → α} {h : ι' → α} diff --git a/mathlib4/Mathlib/Order/ConditionallyCompletePartialOrder/Basic.lean b/mathlib4/Mathlib/Order/ConditionallyCompletePartialOrder/Basic.lean index 7648a5d6e..21f1fc025 100644 --- a/mathlib4/Mathlib/Order/ConditionallyCompletePartialOrder/Basic.lean +++ b/mathlib4/Mathlib/Order/ConditionallyCompletePartialOrder/Basic.lean @@ -31,11 +31,21 @@ namespace OrderDual instance [ConditionallyCompletePartialOrderSup α] : ConditionallyCompletePartialOrderInf αᵒᵈ where - isGLB_csInf_of_directed _ h_dir h_non h_bdd := h_dir.isLUB_csSup (α := α) h_non h_bdd + isGLB_csInf_of_directed s h_dir h_non h_bdd := + (DirectedOn.isLUB_csSup (α := α) (s := ⇑toDual ⁻¹' s) + (fun x hx y hy ↦ + let ⟨z, hz, hxz, hyz⟩ := h_dir (toDual x) hx (toDual y) hy + ⟨ofDual z, hz, hxz, hyz⟩) + (h_non.elim fun x hx ↦ ⟨ofDual x, hx⟩) (bddAbove_preimage_toDual.2 h_bdd)).dual instance [ConditionallyCompletePartialOrderInf α] : ConditionallyCompletePartialOrderSup αᵒᵈ where - isLUB_csSup_of_directed _ h_dir h_non h_bdd := h_dir.isGLB_csInf (α := α) h_non h_bdd + isLUB_csSup_of_directed s h_dir h_non h_bdd := + (DirectedOn.isGLB_csInf (α := α) (s := ⇑toDual ⁻¹' s) + (fun x hx y hy ↦ + let ⟨z, hz, hxz, hyz⟩ := h_dir (toDual x) hx (toDual y) hy + ⟨ofDual z, hz, hxz, hyz⟩) + (h_non.elim fun x hx ↦ ⟨ofDual x, hx⟩) (bddBelow_preimage_toDual.2 h_bdd)).dual instance [ConditionallyCompletePartialOrder α] : ConditionallyCompletePartialOrder αᵒᵈ where diff --git a/mathlib4/Mathlib/Order/CountableSupClosed.lean b/mathlib4/Mathlib/Order/CountableSupClosed.lean index eac59e77f..8f51d943b 100644 --- a/mathlib4/Mathlib/Order/CountableSupClosed.lean +++ b/mathlib4/Mathlib/Order/CountableSupClosed.lean @@ -161,12 +161,14 @@ end Finset open OrderDual @[to_dual (attr := simp)] lemma countableSupClosed_preimage_toDual [LE α] {s : Set αᵒᵈ} : - CountableSupClosed (toDual ⁻¹' s) ↔ CountableInfClosed s := - ⟨fun h ↦ ⟨h.isLUB_mem⟩, fun h ↦ ⟨h.isGLB_mem⟩⟩ + CountableSupClosed (toDual ⁻¹' s) ↔ CountableInfClosed s := by + unsealing_newtype OrderDual => + exact ⟨fun h ↦ ⟨h.isLUB_mem⟩, fun h ↦ ⟨h.isGLB_mem⟩⟩ @[to_dual (attr := simp)] lemma countableSupClosed_preimage_ofDual [LE α] {s : Set α} : - CountableSupClosed (ofDual ⁻¹' s) ↔ CountableInfClosed s := - ⟨fun h ↦ ⟨h.isLUB_mem⟩, fun h ↦ ⟨h.isGLB_mem⟩⟩ + CountableSupClosed (ofDual ⁻¹' s) ↔ CountableInfClosed s := by + unsealing_newtype OrderDual => + exact ⟨fun h ↦ ⟨h.isLUB_mem⟩, fun h ↦ ⟨h.isGLB_mem⟩⟩ @[to_dual] alias ⟨_, CountableSupClosed.dual⟩ := countableInfClosed_preimage_ofDual diff --git a/mathlib4/Mathlib/Order/Cover.lean b/mathlib4/Mathlib/Order/Cover.lean index abf88058a..092653f67 100644 --- a/mathlib4/Mathlib/Order/Cover.lean +++ b/mathlib4/Mathlib/Order/Cover.lean @@ -128,12 +128,14 @@ theorem apply_wcovBy_apply_iff {E : Type*} [EquivLike E α β] [OrderIsoClass E (ordConnected_range (e : α ≃o β)).apply_wcovBy_apply_iff ((e : α ≃o β) : α ↪o β) @[simp, to_dual self] -theorem toDual_wcovBy_toDual_iff : toDual b ⩿ toDual a ↔ a ⩿ b := - and_congr_right' <| forall_congr' fun _ => forall_comm +theorem toDual_wcovBy_toDual_iff : toDual b ⩿ toDual a ↔ a ⩿ b := by + unsealing_newtype OrderDual => + exact and_congr_right' <| forall_congr' fun _ => forall_comm @[simp, to_dual self] -theorem ofDual_wcovBy_ofDual_iff {a b : αᵒᵈ} : ofDual a ⩿ ofDual b ↔ b ⩿ a := - and_congr_right' <| forall_congr' fun _ => forall_comm +theorem ofDual_wcovBy_ofDual_iff {a b : αᵒᵈ} : ofDual a ⩿ ofDual b ↔ b ⩿ a := by + unsealing_newtype OrderDual => + exact and_congr_right' <| forall_congr' fun _ => forall_comm @[to_dual self] alias ⟨_, WCovBy.toDual⟩ := toDual_wcovBy_toDual_iff @@ -223,12 +225,14 @@ theorem denselyOrdered_iff_forall_not_covBy : DenselyOrdered α ↔ ∀ a b : α ⟨fun _ _ hab => exists_lt_lt_of_not_covBy hab <| h _ _⟩⟩ @[to_dual self, simp] -theorem toDual_covBy_toDual_iff : toDual b ⋖ toDual a ↔ a ⋖ b := - and_congr_right' <| forall_congr' fun _ => forall_comm +theorem toDual_covBy_toDual_iff : toDual b ⋖ toDual a ↔ a ⋖ b := by + unsealing_newtype OrderDual => + exact and_congr_right' <| forall_congr' fun _ => forall_comm @[to_dual self, simp] -theorem ofDual_covBy_ofDual_iff {a b : αᵒᵈ} : ofDual a ⋖ ofDual b ↔ b ⋖ a := - and_congr_right' <| forall_congr' fun _ => forall_comm +theorem ofDual_covBy_ofDual_iff {a b : αᵒᵈ} : ofDual a ⋖ ofDual b ↔ b ⋖ a := by + unsealing_newtype OrderDual => + exact and_congr_right' <| forall_congr' fun _ => forall_comm @[to_dual self] alias ⟨_, CovBy.toDual⟩ := toDual_covBy_toDual_iff diff --git a/mathlib4/Mathlib/Order/Directed.lean b/mathlib4/Mathlib/Order/Directed.lean index ec998634c..35712b776 100644 --- a/mathlib4/Mathlib/Order/Directed.lean +++ b/mathlib4/Mathlib/Order/Directed.lean @@ -126,8 +126,9 @@ theorem Directed.extend_bot [Preorder α] [OrderBot α] {e : ι → β} {f : ι /-- A set stable by infimum is `≥`-directed. -/ theorem directedOn_of_inf_mem [SemilatticeInf α] {S : Set α} - (H : ∀ ⦃i j⦄, i ∈ S → j ∈ S → i ⊓ j ∈ S) : DirectedOn (· ≥ ·) S := - directedOn_of_sup_mem (α := αᵒᵈ) H + (H : ∀ ⦃i j⦄, i ∈ S → j ∈ S → i ⊓ j ∈ S) : DirectedOn (· ≥ ·) S := by + unsealing_newtype OrderDual => + exact directedOn_of_sup_mem (α := αᵒᵈ) H theorem Std.Total.directed [Std.Total r] (f : ι → α) : Directed r f := fun i j => Or.casesOn (total_of r (f i) (f j)) (fun h => ⟨j, h, refl _⟩) fun h => ⟨i, refl _, h⟩ @@ -191,8 +192,10 @@ theorem exists_ge_ge [LE α] [IsDirectedOrder α] (a b : α) : ∃ c, a ≤ c directed_of (· ≤ ·) a b @[to_dual isDirected_le] -instance OrderDual.isDirected_ge [LE α] [IsDirectedOrder α] : IsCodirectedOrder αᵒᵈ := by - assumption +instance OrderDual.isDirected_ge [LE α] [IsDirectedOrder α] : IsCodirectedOrder αᵒᵈ where + directed a b := + let ⟨c, hc, hc'⟩ := directed_of (α := α) (· ≤ ·) a.ofDual' b.ofDual' + ⟨OrderDual.mk c, hc, hc'⟩ /-- A monotone function on an upwards-directed type is directed. -/ @[to_dual (reorder := H (i j)) directed_of_isDirected_ge diff --git a/mathlib4/Mathlib/Order/Disjoint.lean b/mathlib4/Mathlib/Order/Disjoint.lean index 7d5339050..f00ed1b16 100644 --- a/mathlib4/Mathlib/Order/Disjoint.lean +++ b/mathlib4/Mathlib/Order/Disjoint.lean @@ -276,8 +276,9 @@ theorem Codisjoint.inf_left (ha : Codisjoint a c) (hb : Codisjoint b c) : Codisj theorem Codisjoint.inf_right (hb : Codisjoint a b) (hc : Codisjoint a c) : Codisjoint a (b ⊓ c) := codisjoint_inf_right.2 ⟨hb, hc⟩ -theorem Codisjoint.left_le_of_le_inf_right (h : a ⊓ b ≤ c) (hd : Codisjoint b c) : a ≤ c := - @Disjoint.left_le_of_le_sup_right αᵒᵈ _ _ _ _ _ h hd.symm +theorem Codisjoint.left_le_of_le_inf_right (h : a ⊓ b ≤ c) (hd : Codisjoint b c) : a ≤ c := by + unsealing_newtype OrderDual => + exact @Disjoint.left_le_of_le_sup_right αᵒᵈ _ _ _ _ _ h hd.symm theorem Codisjoint.left_le_of_le_inf_left (h : b ⊓ a ≤ c) (hd : Codisjoint b c) : a ≤ c := hd.left_le_of_le_inf_right <| by rwa [inf_comm] @@ -290,18 +291,21 @@ open OrderDual @[to_dual] theorem Disjoint.dual [PartialOrder α] [OrderBot α] {a b : α} : - Disjoint a b → Codisjoint (toDual a) (toDual b) := - id + Disjoint a b → Codisjoint (toDual a) (toDual b) := by + unsealing_newtype OrderDual => + exact id @[to_dual (attr := simp, grind =)] theorem disjoint_toDual_iff [PartialOrder α] [OrderTop α] {a b : α} : - Disjoint (toDual a) (toDual b) ↔ Codisjoint a b := - Iff.rfl + Disjoint (toDual a) (toDual b) ↔ Codisjoint a b := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual (attr := simp, grind =)] theorem disjoint_ofDual_iff [PartialOrder α] [OrderBot α] {a b : αᵒᵈ} : - Disjoint (ofDual a) (ofDual b) ↔ Codisjoint a b := - Iff.rfl + Disjoint (ofDual a) (ofDual b) ↔ Codisjoint a b := by + unsealing_newtype OrderDual => + exact Iff.rfl section DistribLattice @@ -345,10 +349,12 @@ protected theorem symm (h : IsCompl x y) : IsCompl y x := lemma _root_.isCompl_comm : IsCompl x y ↔ IsCompl y x := ⟨IsCompl.symm, IsCompl.symm⟩ theorem dual (h : IsCompl x y) : IsCompl (toDual x) (toDual y) := - ⟨h.2, h.1⟩ + ⟨h.2.dual, h.1.dual⟩ -theorem ofDual {a b : αᵒᵈ} (h : IsCompl a b) : IsCompl (ofDual a) (ofDual b) := - ⟨h.2, h.1⟩ +theorem ofDual {a b : αᵒᵈ} (h : IsCompl a b) : + IsCompl (OrderDual.ofDual a) (OrderDual.ofDual b) := by + unsealing_newtype OrderDual => + exact ⟨h.2, h.1⟩ end BoundedPartialOrder @@ -401,8 +407,9 @@ theorem le_left_iff (h : IsCompl x y) : z ≤ x ↔ Disjoint z y := theorem le_right_iff (h : IsCompl x y) : z ≤ y ↔ Disjoint z x := h.symm.le_left_iff -theorem left_le_iff (h : IsCompl x y) : x ≤ z ↔ Codisjoint z y := - h.dual.le_left_iff +theorem left_le_iff (h : IsCompl x y) : x ≤ z ↔ Codisjoint z y := by + unsealing_newtype OrderDual => + exact h.dual.le_left_iff theorem right_le_iff (h : IsCompl x y) : y ≤ z ↔ Codisjoint z x := h.symm.left_le_iff @@ -445,8 +452,9 @@ protected theorem disjoint_iff [OrderBot α] [OrderBot β] {x y : α × β} : @[grind =] protected theorem codisjoint_iff [OrderTop α] [OrderTop β] {x y : α × β} : - Codisjoint x y ↔ Codisjoint x.1 y.1 ∧ Codisjoint x.2 y.2 := - @Prod.disjoint_iff αᵒᵈ βᵒᵈ _ _ _ _ _ _ + Codisjoint x y ↔ Codisjoint x.1 y.1 ∧ Codisjoint x.2 y.2 := by + unsealing_newtype OrderDual => + exact @Prod.disjoint_iff αᵒᵈ βᵒᵈ _ _ _ _ _ _ @[grind =] protected theorem isCompl_iff [BoundedOrder α] [BoundedOrder β] {x y : α × β} : @@ -478,11 +486,13 @@ theorem eq_top_of_isCompl_bot (h : IsCompl x ⊥) : x = ⊤ := by rw [← sup_bo theorem eq_top_of_bot_isCompl (h : IsCompl ⊥ x) : x = ⊤ := eq_top_of_isCompl_bot h.symm -theorem eq_bot_of_isCompl_top (h : IsCompl x ⊤) : x = ⊥ := - eq_top_of_isCompl_bot h.dual +theorem eq_bot_of_isCompl_top (h : IsCompl x ⊤) : x = ⊥ := by + unsealing_newtype OrderDual => + exact eq_top_of_isCompl_bot h.dual -theorem eq_bot_of_top_isCompl (h : IsCompl ⊤ x) : x = ⊥ := - eq_top_of_bot_isCompl h.dual +theorem eq_bot_of_top_isCompl (h : IsCompl ⊤ x) : x = ⊥ := by + unsealing_newtype OrderDual => + exact eq_top_of_bot_isCompl h.dual end @@ -540,8 +550,8 @@ variable [Lattice α] [BoundedOrder α] [ComplementedLattice α] instance : ComplementedLattice αᵒᵈ := ⟨fun a ↦ - let ⟨b, hb⟩ := exists_isCompl (show α from a) - ⟨b, hb.dual⟩⟩ + let ⟨b, hb⟩ := exists_isCompl (OrderDual.ofDual a) + ⟨OrderDual.toDual b, hb.dual⟩⟩ end ComplementedLattice diff --git a/mathlib4/Mathlib/Order/Filter/AtTopBot/Basic.lean b/mathlib4/Mathlib/Order/Filter/AtTopBot/Basic.lean index 73cfaa73e..5f733812d 100644 --- a/mathlib4/Mathlib/Order/Filter/AtTopBot/Basic.lean +++ b/mathlib4/Mathlib/Order/Filter/AtTopBot/Basic.lean @@ -38,7 +38,9 @@ theorem atTop_basis [Nonempty α] : (@atTop α _).HasBasis (fun _ => True) Ici : @[to_dual existing] lemma atBot_basis {α : Type*} [Preorder α] [IsCodirectedOrder α] [Nonempty α] : - (@atBot α _).HasBasis (fun _ => True) Iic := atTop_basis (α := αᵒᵈ) + (@atBot α _).HasBasis (fun _ => True) Iic := by + unsealing_newtype OrderDual => + exact atTop_basis (α := αᵒᵈ) @[to_dual] lemma atTop_basis_Ioi [Nonempty α] [NoMaxOrder α] : (@atTop α _).HasBasis (fun _ => True) Ioi := @@ -94,8 +96,9 @@ lemma exists_eventually_atTop {r : α → β → Prop} : @[to_dual existing] lemma exists_eventually_atBot {α : Type*} [Preorder α] [IsCodirectedOrder α] [Nonempty α] - {r : α → β → Prop} : (∃ b, ∀ᶠ a in atBot, r a b) ↔ ∀ᶠ a₀ in atBot, ∃ b, ∀ a ≤ a₀, r a b := - exists_eventually_atTop (α := αᵒᵈ) + {r : α → β → Prop} : (∃ b, ∀ᶠ a in atBot, r a b) ↔ ∀ᶠ a₀ in atBot, ∃ b, ∀ a ≤ a₀, r a b := by + unsealing_newtype OrderDual => + exact exists_eventually_atTop (α := αᵒᵈ) @[to_dual] theorem map_atTop_eq {f : α → β} : atTop.map f = ⨅ a, 𝓟 (f '' { a' | a ≤ a' }) := @@ -186,8 +189,10 @@ theorem tendsto_atTop_atTop : Tendsto f atTop atTop ↔ ∀ b : β, ∃ i : α, tendsto_iInf.trans <| forall_congr' fun _ => tendsto_atTop_principal @[to_dual] -theorem tendsto_atTop_atBot : Tendsto f atTop atBot ↔ ∀ b : β, ∃ i : α, ∀ a : α, i ≤ a → f a ≤ b := - tendsto_atTop_atTop (β := βᵒᵈ) +theorem tendsto_atTop_atBot : Tendsto f atTop atBot ↔ ∀ b : β, ∃ i : α, ∀ a : + α, i ≤ a → f a ≤ b := by + unsealing_newtype OrderDual => + exact tendsto_atTop_atTop (β := βᵒᵈ) @[to_dual] theorem tendsto_atTop_atTop_iff_of_monotone (hf : Monotone f) : @@ -200,8 +205,9 @@ alias _root_.Monotone.tendsto_atTop_atTop_iff := tendsto_atTop_atTop_iff_of_mono @[to_dual] theorem tendsto_atTop_atBot_iff_of_antitone (hf : Antitone f) : - Tendsto f atTop atBot ↔ ∀ b : β, ∃ a, f a ≤ b := - tendsto_atTop_atTop_iff_of_monotone (β := βᵒᵈ) hf + Tendsto f atTop atBot ↔ ∀ b : β, ∃ a, f a ≤ b := by + unsealing_newtype OrderDual => + exact tendsto_atTop_atTop_iff_of_monotone (β := βᵒᵈ) hf end IsDirected diff --git a/mathlib4/Mathlib/Order/Filter/AtTopBot/CompleteLattice.lean b/mathlib4/Mathlib/Order/Filter/AtTopBot/CompleteLattice.lean index 909d731fe..5e672ea57 100644 --- a/mathlib4/Mathlib/Order/Filter/AtTopBot/CompleteLattice.lean +++ b/mathlib4/Mathlib/Order/Filter/AtTopBot/CompleteLattice.lean @@ -70,8 +70,9 @@ if the codomain of `f` is a conditionally complete linear order or a complete la -/] theorem _root_.Antitone.ciSup_comp_tendsto_atBot [Preorder β] [ConditionallyCompleteLattice γ] {l : Filter α} [l.NeBot] {f : β → γ} (hf : Antitone f) (hb : BddAbove (range f)) - {g : α → β} (hg : Tendsto g l atBot) : ⨆ a, f (g a) = ⨆ b, f b := - hf.dual_left.ciSup_comp_tendsto_atTop hb hg + {g : α → β} (hg : Tendsto g l atBot) : ⨆ a, f (g a) = ⨆ b, f b := by + unsealing_newtype OrderDual => + exact hf.dual_left.ciSup_comp_tendsto_atTop hb hg /-- If `f` is a monotone function taking values in a conditionally complete linear order and `g` tends to `atTop` along a nontrivial filter, @@ -98,8 +99,9 @@ and `g` tends to `atBot` along a nontrivial filter, then the indexed supremum of `f ∘ g` is equal to the indexed supremum of `f`. -/] theorem _root_.Antitone.ciInf_comp_tendsto_atTop_of_linearOrder [Preorder β] [ConditionallyCompleteLinearOrder γ] {l : Filter α} [l.NeBot] {f : β → γ} (hf : Antitone f) - {g : α → β} (hg : Tendsto g l atTop) : ⨅ a, f (g a) = ⨅ b, f b := - hf.dual_left.ciInf_comp_tendsto_atBot_of_linearOrder hg + {g : α → β} (hg : Tendsto g l atTop) : ⨅ a, f (g a) = ⨅ b, f b := by + unsealing_newtype OrderDual => + exact hf.dual_left.ciInf_comp_tendsto_atBot_of_linearOrder hg /-- If `f` is a monotone function taking values in a complete lattice and `g` tends to `atTop` along a nontrivial filter, diff --git a/mathlib4/Mathlib/Order/Filter/AtTopBot/CountablyGenerated.lean b/mathlib4/Mathlib/Order/Filter/AtTopBot/CountablyGenerated.lean index 2152dd3ac..629de5349 100644 --- a/mathlib4/Mathlib/Order/Filter/AtTopBot/CountablyGenerated.lean +++ b/mathlib4/Mathlib/Order/Filter/AtTopBot/CountablyGenerated.lean @@ -43,7 +43,10 @@ instance instIsCountablyGeneratedAtTopProd [Preorder α] [IsCountablyGenerated ( @[to_dual] instance _root_.OrderDual.instIsCountablyGeneratedAtTop [Preorder α] - [IsCountablyGenerated (atBot : Filter α)] : IsCountablyGenerated (atTop : Filter αᵒᵈ) := ‹_› + [IsCountablyGenerated (atBot : Filter α)] : IsCountablyGenerated (atTop : Filter αᵒᵈ) := by + unsealing_newtype OrderDual => + change IsCountablyGenerated (atBot : Filter α) + infer_instance @[to_dual] lemma atTop_countable_basis [Preorder α] [IsDirectedOrder α] [Nonempty α] [Countable α] : @@ -75,8 +78,9 @@ theorem exists_seq_monotone_tendsto_atTop_atTop (α : Type*) [Preorder α] [None theorem exists_seq_antitone_tendsto_atTop_atBot (α : Type*) [Preorder α] [Nonempty α] [IsCodirectedOrder α] [(atBot : Filter α).IsCountablyGenerated] : - ∃ xs : ℕ → α, Antitone xs ∧ Tendsto xs atTop atBot := - exists_seq_monotone_tendsto_atTop_atTop αᵒᵈ + ∃ xs : ℕ → α, Antitone xs ∧ Tendsto xs atTop atBot := by + unsealing_newtype OrderDual => + exact exists_seq_monotone_tendsto_atTop_atTop αᵒᵈ /-- An abstract version of continuity of sequentially continuous functions on metric spaces: if a filter `k` is countably generated then `Tendsto f k l` iff for every sequence `u` diff --git a/mathlib4/Mathlib/Order/Filter/AtTopBot/Finset.lean b/mathlib4/Mathlib/Order/Filter/AtTopBot/Finset.lean index 545a70a94..5800a705a 100644 --- a/mathlib4/Mathlib/Order/Filter/AtTopBot/Finset.lean +++ b/mathlib4/Mathlib/Order/Filter/AtTopBot/Finset.lean @@ -87,8 +87,15 @@ theorem tendsto_finset_Iic_atTop_atTop [Preorder α] [LocallyFiniteOrderBot α] simp [not_ne_iff.mp <| Filter.neBot_iff.not.mp h] theorem tendsto_finset_Ici_atBot_atTop [Preorder α] [LocallyFiniteOrderTop α] : - Tendsto (Finset.Ici (α := α)) atBot atTop := - tendsto_finset_Iic_atTop_atTop (α := αᵒᵈ) + Tendsto (Finset.Ici (α := α)) atBot atTop := by + rcases isEmpty_or_nonempty α with _ | _ + · exact tendsto_of_isEmpty + by_cases h : IsCodirectedOrder α + · refine tendsto_atTop.2 fun s ↦ ?_ + obtain ⟨a, ha⟩ := (directed_id (r := ((· ≥ ·) : α → α → Prop))).finset_le s + exact (eventually_le_atBot a).mono fun b hb c hc ↦ by simpa using hb.trans (ha c hc) + · obtain h := Filter.atBot_neBot_iff.not.mpr (fun h' ↦ h h'.2) + simp [not_ne_iff.mp <| Filter.neBot_iff.not.mp h] section Card diff --git a/mathlib4/Mathlib/Order/Filter/AtTopBot/Group.lean b/mathlib4/Mathlib/Order/Filter/AtTopBot/Group.lean index bead54a6c..2076e4be6 100644 --- a/mathlib4/Mathlib/Order/Filter/AtTopBot/Group.lean +++ b/mathlib4/Mathlib/Order/Filter/AtTopBot/Group.lean @@ -32,8 +32,9 @@ theorem tendsto_atTop_mul_left_of_le' (C : G) (hf : ∀ᶠ x in l, C ≤ f x) (h @[to_additive] theorem tendsto_atBot_mul_left_of_ge' (C : G) (hf : ∀ᶠ x in l, f x ≤ C) (hg : Tendsto g l atBot) : - Tendsto (fun x => f x * g x) l atBot := - tendsto_atTop_mul_left_of_le' (G := Gᵒᵈ) _ C hf hg + Tendsto (fun x => f x * g x) l atBot := by + unsealing_newtype OrderDual => + exact tendsto_atTop_mul_left_of_le' (G := Gᵒᵈ) _ C hf hg @[to_additive] theorem tendsto_atTop_mul_left_of_le (C : G) (hf : ∀ x, C ≤ f x) (hg : Tendsto g l atTop) : @@ -42,8 +43,9 @@ theorem tendsto_atTop_mul_left_of_le (C : G) (hf : ∀ x, C ≤ f x) (hg : Tends @[to_additive] theorem tendsto_atBot_mul_left_of_ge (C : G) (hf : ∀ x, f x ≤ C) (hg : Tendsto g l atBot) : - Tendsto (fun x => f x * g x) l atBot := - tendsto_atTop_mul_left_of_le (G := Gᵒᵈ) _ C hf hg + Tendsto (fun x => f x * g x) l atBot := by + unsealing_newtype OrderDual => + exact tendsto_atTop_mul_left_of_le (G := Gᵒᵈ) _ C hf hg @[to_additive] theorem tendsto_atTop_mul_right_of_le' (C : G) (hf : Tendsto f l atTop) (hg : ∀ᶠ x in l, C ≤ g x) : @@ -52,8 +54,9 @@ theorem tendsto_atTop_mul_right_of_le' (C : G) (hf : Tendsto f l atTop) (hg : @[to_additive] theorem tendsto_atBot_mul_right_of_ge' (C : G) (hf : Tendsto f l atBot) (hg : ∀ᶠ x in l, g x ≤ C) : - Tendsto (fun x => f x * g x) l atBot := - tendsto_atTop_mul_right_of_le' (G := Gᵒᵈ) _ C hf hg + Tendsto (fun x => f x * g x) l atBot := by + unsealing_newtype OrderDual => + exact tendsto_atTop_mul_right_of_le' (G := Gᵒᵈ) _ C hf hg @[to_additive] theorem tendsto_atTop_mul_right_of_le (C : G) (hf : Tendsto f l atTop) (hg : ∀ x, C ≤ g x) : @@ -62,8 +65,9 @@ theorem tendsto_atTop_mul_right_of_le (C : G) (hf : Tendsto f l atTop) (hg : ∀ @[to_additive] theorem tendsto_atBot_mul_right_of_ge (C : G) (hf : Tendsto f l atBot) (hg : ∀ x, g x ≤ C) : - Tendsto (fun x => f x * g x) l atBot := - tendsto_atTop_mul_right_of_le (G := Gᵒᵈ) _ C hf hg + Tendsto (fun x => f x * g x) l atBot := by + unsealing_newtype OrderDual => + exact tendsto_atTop_mul_right_of_le (G := Gᵒᵈ) _ C hf hg @[to_additive] theorem tendsto_atTop_mul_const_left (C : G) (hf : Tendsto f l atTop) : @@ -72,8 +76,9 @@ theorem tendsto_atTop_mul_const_left (C : G) (hf : Tendsto f l atTop) : @[to_additive] theorem tendsto_atBot_mul_const_left (C : G) (hf : Tendsto f l atBot) : - Tendsto (fun x => C * f x) l atBot := - tendsto_atTop_mul_const_left (G := Gᵒᵈ) _ C hf + Tendsto (fun x => C * f x) l atBot := by + unsealing_newtype OrderDual => + exact tendsto_atTop_mul_const_left (G := Gᵒᵈ) _ C hf @[to_additive] theorem tendsto_atTop_mul_const_right (C : G) (hf : Tendsto f l atTop) : @@ -82,42 +87,51 @@ theorem tendsto_atTop_mul_const_right (C : G) (hf : Tendsto f l atTop) : @[to_additive] theorem tendsto_atBot_mul_const_right (C : G) (hf : Tendsto f l atBot) : - Tendsto (fun x => f x * C) l atBot := - tendsto_atTop_mul_const_right (G := Gᵒᵈ) _ C hf + Tendsto (fun x => f x * C) l atBot := by + unsealing_newtype OrderDual => + exact tendsto_atTop_mul_const_right (G := Gᵒᵈ) _ C hf @[to_additive] -theorem map_inv_atBot : map (Inv.inv : G → G) atBot = atTop := - (OrderIso.inv G).map_atBot +theorem tendsto_inv_atTop_atBot : Tendsto (Inv.inv : G → G) atTop atBot := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).tendsto_atTop @[to_additive] -theorem map_inv_atTop : map (Inv.inv : G → G) atTop = atBot := - (OrderIso.inv G).map_atTop +theorem tendsto_inv_atBot_atTop : Tendsto (Inv.inv : G → G) atBot atTop := by + unsealing_newtype OrderDual => + exact tendsto_inv_atTop_atBot (G := Gᵒᵈ) @[to_additive] -theorem comap_inv_atBot : comap (Inv.inv : G → G) atBot = atTop := - (OrderIso.inv G).comap_atTop +theorem map_inv_atBot : map (Inv.inv : G → G) atBot = atTop := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).map_atBot @[to_additive] -theorem comap_inv_atTop : comap (Inv.inv : G → G) atTop = atBot := - (OrderIso.inv G).comap_atBot +theorem map_inv_atTop : map (Inv.inv : G → G) atTop = atBot := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).map_atTop @[to_additive] -theorem tendsto_inv_atTop_atBot : Tendsto (Inv.inv : G → G) atTop atBot := - (OrderIso.inv G).tendsto_atTop +theorem comap_inv_atBot : comap (Inv.inv : G → G) atBot = atTop := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).comap_atTop @[to_additive] -theorem tendsto_inv_atBot_atTop : Tendsto (Inv.inv : G → G) atBot atTop := - tendsto_inv_atTop_atBot (G := Gᵒᵈ) +theorem comap_inv_atTop : comap (Inv.inv : G → G) atTop = atBot := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).comap_atBot variable {l} @[to_additive (attr := simp)] -theorem tendsto_inv_atTop_iff : Tendsto (fun x => (f x)⁻¹) l atTop ↔ Tendsto f l atBot := - (OrderIso.inv G).tendsto_atBot_iff +theorem tendsto_inv_atTop_iff : Tendsto (fun x => (f x)⁻¹) l atTop ↔ Tendsto f l atBot := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).tendsto_atBot_iff @[to_additive (attr := simp)] -theorem tendsto_inv_atBot_iff : Tendsto (fun x => (f x)⁻¹) l atBot ↔ Tendsto f l atTop := - (OrderIso.inv G).tendsto_atTop_iff +theorem tendsto_inv_atBot_iff : Tendsto (fun x => (f x)⁻¹) l atBot ↔ Tendsto f l atTop := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).tendsto_atTop_iff @[to_additive (attr := simp)] theorem tendsto_comp_inv_atTop_iff {f : G → α} : diff --git a/mathlib4/Mathlib/Order/Filter/AtTopBot/Monoid.lean b/mathlib4/Mathlib/Order/Filter/AtTopBot/Monoid.lean index f0d86677a..9361a8d53 100644 --- a/mathlib4/Mathlib/Order/Filter/AtTopBot/Monoid.lean +++ b/mathlib4/Mathlib/Order/Filter/AtTopBot/Monoid.lean @@ -30,8 +30,9 @@ theorem Tendsto.one_eventuallyLE_mul_atTop (hf : 1 ≤ᶠ[l] f) (hg : Tendsto g @[to_additive] theorem Tendsto.eventuallyLE_one_mul_atBot (hf : f ≤ᶠ[l] 1) (hg : Tendsto g l atBot) : - Tendsto (fun x => f x * g x) l atBot := - hg.one_eventuallyLE_mul_atTop (M := Mᵒᵈ) hf + Tendsto (fun x => f x * g x) l atBot := by + unsealing_newtype OrderDual => + exact hg.one_eventuallyLE_mul_atTop (M := Mᵒᵈ) hf @[to_additive] theorem Tendsto.one_le_mul_atTop (hf : ∀ x, 1 ≤ f x) (hg : Tendsto g l atTop) : @@ -50,8 +51,9 @@ theorem Tendsto.atTop_mul_one_eventuallyLE (hf : Tendsto f l atTop) (hg : 1 ≤ @[to_additive] theorem Tendsto.atBot_mul_eventuallyLE_one (hf : Tendsto f l atBot) (hg : g ≤ᶠ[l] 1) : - Tendsto (fun x => f x * g x) l atBot := - hf.atTop_mul_one_eventuallyLE (M := Mᵒᵈ) hg + Tendsto (fun x => f x * g x) l atBot := by + unsealing_newtype OrderDual => + exact hf.atTop_mul_one_eventuallyLE (M := Mᵒᵈ) hg @[to_additive] theorem Tendsto.atTop_mul_one_le (hf : Tendsto f l atTop) (hg : ∀ x, 1 ≤ g x) : @@ -78,8 +80,9 @@ Earlier, this name was used for a similar lemma about rings (with conclusion `f which is now called `Filter.Tendsto.atBot_mul_atBot₀`. -/ @[to_additive] theorem Tendsto.atBot_mul_atBot (hf : Tendsto f l atBot) (hg : Tendsto g l atBot) : - Tendsto (fun x => f x * g x) l atBot := - hf.atTop_mul_atTop (M := Mᵒᵈ) hg + Tendsto (fun x => f x * g x) l atBot := by + unsealing_newtype OrderDual => + exact hf.atTop_mul_atTop (M := Mᵒᵈ) hg @[to_additive nsmul_atTop] theorem Tendsto.atTop_pow (hf : Tendsto f l atTop) {n : ℕ} (hn : 0 < n) : @@ -89,8 +92,9 @@ theorem Tendsto.atTop_pow (hf : Tendsto f l atTop) {n : ℕ} (hn : 0 < n) : @[to_additive nsmul_atBot] theorem Tendsto.atBot_pow (hf : Tendsto f l atBot) {n : ℕ} (hn : 0 < n) : - Tendsto (fun x => f x ^ n) l atBot := - Tendsto.atTop_pow (M := Mᵒᵈ) hf hn + Tendsto (fun x => f x ^ n) l atBot := by + unsealing_newtype OrderDual => + exact Tendsto.atTop_pow (M := Mᵒᵈ) hf hn end OrderedCommMonoid @@ -107,8 +111,10 @@ theorem Tendsto.atTop_of_const_mul (C : M) (hf : Tendsto (C * f ·) l atTop) : T tendsto_atTop.2 fun b ↦ (tendsto_atTop.1 hf (C * b)).mono fun _ ↦ le_of_mul_le_mul_left' @[to_additive] -theorem Tendsto.atBot_of_const_mul (C : M) (hf : Tendsto (C * f ·) l atBot) : Tendsto f l atBot := - hf.atTop_of_const_mul (M := Mᵒᵈ) +theorem Tendsto.atBot_of_const_mul (C : M) (hf : Tendsto (C * f ·) l atBot) : + Tendsto f l atBot := by + unsealing_newtype OrderDual => + exact hf.atTop_of_const_mul (M := Mᵒᵈ) /-- In an ordered cancellative multiplicative monoid, if `f x * C → +∞`, then `f x → +∞`. @@ -119,8 +125,10 @@ theorem Tendsto.atTop_of_mul_const (C : M) (hf : Tendsto (f · * C) l atTop) : T tendsto_atTop.2 fun b => (tendsto_atTop.1 hf (b * C)).mono fun _ => le_of_mul_le_mul_right' @[to_additive] -theorem Tendsto.atBot_of_mul_const (C : M) (hf : Tendsto (f · * C) l atBot) : Tendsto f l atBot := - hf.atTop_of_mul_const (M := Mᵒᵈ) +theorem Tendsto.atBot_of_mul_const (C : M) (hf : Tendsto (f · * C) l atBot) : + Tendsto f l atBot := by + unsealing_newtype OrderDual => + exact hf.atTop_of_mul_const (M := Mᵒᵈ) /-- If `f` is eventually bounded from above along `l` and `f * g` tends to `+∞`, then `g` tends to `+∞`. -/ @@ -134,8 +142,9 @@ theorem Tendsto.atTop_of_isBoundedUnder_le_mul (hf : IsBoundedUnder (· ≤ ·) @[to_additive] theorem Tendsto.atBot_of_isBoundedUnder_ge_mul (hf : IsBoundedUnder (· ≥ ·) l f) - (h : Tendsto (fun x => f x * g x) l atBot) : Tendsto g l atBot := - h.atTop_of_isBoundedUnder_le_mul (M := Mᵒᵈ) hf + (h : Tendsto (fun x => f x * g x) l atBot) : Tendsto g l atBot := by + unsealing_newtype OrderDual => + exact h.atTop_of_isBoundedUnder_le_mul (M := Mᵒᵈ) hf @[to_additive] theorem Tendsto.atTop_of_le_const_mul (hf : ∃ C, ∀ x, f x ≤ C) @@ -144,8 +153,9 @@ theorem Tendsto.atTop_of_le_const_mul (hf : ∃ C, ∀ x, f x ≤ C) @[to_additive] theorem Tendsto.atBot_of_const_le_mul (hf : ∃ C, ∀ x, C ≤ f x) - (hfg : Tendsto (fun x ↦ f x * g x) l atBot) : Tendsto g l atBot := - Tendsto.atTop_of_le_const_mul (M := Mᵒᵈ) hf hfg + (hfg : Tendsto (fun x ↦ f x * g x) l atBot) : Tendsto g l atBot := by + unsealing_newtype OrderDual => + exact Tendsto.atTop_of_le_const_mul (M := Mᵒᵈ) hf hfg @[to_additive] theorem Tendsto.atTop_of_mul_isBoundedUnder_le (hg : IsBoundedUnder (· ≤ ·) l g) @@ -156,8 +166,9 @@ theorem Tendsto.atTop_of_mul_isBoundedUnder_le (hg : IsBoundedUnder (· ≤ ·) @[to_additive] theorem Tendsto.atBot_of_mul_isBoundedUnder_ge (hg : IsBoundedUnder (· ≥ ·) l g) - (h : Tendsto (fun x => f x * g x) l atBot) : Tendsto f l atBot := - h.atTop_of_mul_isBoundedUnder_le (M := Mᵒᵈ) hg + (h : Tendsto (fun x => f x * g x) l atBot) : Tendsto f l atBot := by + unsealing_newtype OrderDual => + exact h.atTop_of_mul_isBoundedUnder_le (M := Mᵒᵈ) hg @[to_additive] theorem Tendsto.atTop_of_mul_le_const (hg : ∃ C, ∀ x, g x ≤ C) @@ -166,8 +177,9 @@ theorem Tendsto.atTop_of_mul_le_const (hg : ∃ C, ∀ x, g x ≤ C) @[to_additive] theorem Tendsto.atBot_of_mul_const_le (hg : ∃ C, ∀ x, C ≤ g x) - (hfg : Tendsto (fun x ↦ f x * g x) l atBot) : Tendsto f l atBot := - Tendsto.atTop_of_mul_le_const (M := Mᵒᵈ) hg hfg + (hfg : Tendsto (fun x ↦ f x * g x) l atBot) : Tendsto f l atBot := by + unsealing_newtype OrderDual => + exact Tendsto.atTop_of_mul_le_const (M := Mᵒᵈ) hg hfg end OrderedCancelCommMonoid diff --git a/mathlib4/Mathlib/Order/Filter/AtTopBot/Tendsto.lean b/mathlib4/Mathlib/Order/Filter/AtTopBot/Tendsto.lean index a5a86187f..9a0805204 100644 --- a/mathlib4/Mathlib/Order/Filter/AtTopBot/Tendsto.lean +++ b/mathlib4/Mathlib/Order/Filter/AtTopBot/Tendsto.lean @@ -113,8 +113,9 @@ then the upper bounds of the range of `f ∘ g` are the same as the upper bounds of the range of `f`. -/] theorem _root_.Antitone.lowerBounds_range_comp_tendsto_atTop [Preorder β] [Preorder γ] {l : Filter α} [l.NeBot] {f : β → γ} (hf : Antitone f) {g : α → β} (hg : Tendsto g l atTop) : - lowerBounds (range (f ∘ g)) = lowerBounds (range f) := - hf.dual_left.lowerBounds_range_comp_tendsto_atBot hg + lowerBounds (range (f ∘ g)) = lowerBounds (range f) := by + unsealing_newtype OrderDual => + exact hf.dual_left.lowerBounds_range_comp_tendsto_atBot hg @[to_dual] theorem tendsto_atTop_atTop_of_monotone [Preorder α] [Preorder β] {f : α → β} (hf : Monotone f) @@ -126,8 +127,9 @@ theorem tendsto_atTop_atTop_of_monotone [Preorder α] [Preorder β] {f : α → @[to_dual] theorem tendsto_atTop_atBot_of_antitone [Preorder α] [Preorder β] {f : α → β} (hf : Antitone f) - (h : ∀ b, ∃ a, f a ≤ b) : Tendsto f atTop atBot := - @tendsto_atTop_atTop_of_monotone _ βᵒᵈ _ _ _ hf h + (h : ∀ b, ∃ a, f a ≤ b) : Tendsto f atTop atBot := by + unsealing_newtype OrderDual => + exact @tendsto_atTop_atTop_of_monotone _ βᵒᵈ _ _ _ hf h @[to_dual] alias _root_.Monotone.tendsto_atTop_atTop := tendsto_atTop_atTop_of_monotone diff --git a/mathlib4/Mathlib/Order/Filter/Bases/Basic.lean b/mathlib4/Mathlib/Order/Filter/Bases/Basic.lean index ccaf7386e..2bc6633b6 100644 --- a/mathlib4/Mathlib/Order/Filter/Bases/Basic.lean +++ b/mathlib4/Mathlib/Order/Filter/Bases/Basic.lean @@ -574,9 +574,10 @@ theorem HasBasis.eq_iInf (h : l.HasBasis (fun _ => True) s) : l = ⨅ i, 𝓟 (s simpa only [iInf_true] using h.eq_biInf theorem hasBasis_iInf_principal {s : ι → Set α} (h : Directed (· ≥ ·) s) [Nonempty ι] : - (⨅ i, 𝓟 (s i)).HasBasis (fun _ => True) s := - ⟨fun t => by - simpa only [true_and] using! mem_iInf_of_directed (h.mono_comp _ monotone_principal.dual) t⟩ + (⨅ i, 𝓟 (s i)).HasBasis (fun _ => True) s := by + unsealing_newtype OrderDual => + exact ⟨fun t => by + simpa only [true_and] using! mem_iInf_of_directed (h.mono_comp _ monotone_principal.dual) t⟩ theorem hasBasis_biInf_principal {s : β → Set α} {S : Set β} (h : DirectedOn (s ⁻¹'o (· ≥ ·)) S) (ne : S.Nonempty) : (⨅ i ∈ S, 𝓟 (s i)).HasBasis (fun i => i ∈ S) s := @@ -730,8 +731,9 @@ theorem HasBasis.prod_same_index_mono {ι : Type*} [LinearOrder ι] {p : ι → theorem HasBasis.prod_same_index_anti {ι : Type*} [LinearOrder ι] {p : ι → Prop} {sa : ι → Set α} {sb : ι → Set β} (hla : la.HasBasis p sa) (hlb : lb.HasBasis p sb) (hsa : AntitoneOn sa { i | p i }) (hsb : AntitoneOn sb { i | p i }) : - (la ×ˢ lb).HasBasis p fun i => sa i ×ˢ sb i := - @HasBasis.prod_same_index_mono _ _ _ _ ιᵒᵈ _ _ _ _ hla hlb hsa.dual_left hsb.dual_left + (la ×ˢ lb).HasBasis p fun i => sa i ×ˢ sb i := by + unsealing_newtype OrderDual => + exact @HasBasis.prod_same_index_mono _ _ _ _ ιᵒᵈ _ _ _ _ hla hlb hsa.dual_left hsb.dual_left theorem HasBasis.prod_self (hl : la.HasBasis pa sa) : (la ×ˢ la).HasBasis pa fun i => sa i ×ˢ sa i := diff --git a/mathlib4/Mathlib/Order/Filter/Basic.lean b/mathlib4/Mathlib/Order/Filter/Basic.lean index 13734fc09..810fded90 100644 --- a/mathlib4/Mathlib/Order/Filter/Basic.lean +++ b/mathlib4/Mathlib/Order/Filter/Basic.lean @@ -200,11 +200,13 @@ theorem mkOfClosure_sets {s : Set (Set α)} {hs : (generate s).sets = s} : /-- Galois insertion from sets of sets into filters. -/ def giGenerate (α : Type*) : - @GaloisInsertion (Set (Set α)) (Filter α)ᵒᵈ _ _ Filter.generate Filter.sets where + @GaloisInsertion (Set (Set α)) (Filter α)ᵒᵈ _ _ (OrderDual.toDual ∘ Filter.generate) + (Filter.sets ∘ OrderDual.ofDual) where gc _ _ := le_generate_iff le_l_u _ _ h := GenerateSets.basic h - choice s hs := Filter.mkOfClosure s (le_antisymm hs <| le_generate_iff.1 <| le_rfl) - choice_eq _ _ := mkOfClosure_sets + choice s hs := + OrderDual.toDual (Filter.mkOfClosure s (le_antisymm hs <| le_generate_iff.1 <| le_rfl)) + choice_eq _ _ := congrArg OrderDual.toDual mkOfClosure_sets theorem mem_inf_iff {f g : Filter α} {s : Set α} : s ∈ f ⊓ g ↔ ∃ t₁ ∈ f, ∃ t₂ ∈ g, s = t₁ ∩ t₂ := Iff.rfl @@ -286,28 +288,34 @@ theorem bot_sets_eq : (⊥ : Filter α).sets = univ := rfl as the second alternative, to be used as an instance. -/ theorem eq_or_neBot (f : Filter α) : f = ⊥ ∨ NeBot f := (eq_or_ne f ⊥).imp_right NeBot.mk -theorem sup_sets_eq {f g : Filter α} : (f ⊔ g).sets = f.sets ∩ g.sets := - (giGenerate α).gc.u_inf +theorem sup_sets_eq {f g : Filter α} : (f ⊔ g).sets = f.sets ∩ g.sets := by + unsealing_newtype OrderDual => + exact (giGenerate α).gc.u_inf -theorem sSup_sets_eq {s : Set (Filter α)} : (sSup s).sets = ⋂ f ∈ s, (f : Filter α).sets := - (giGenerate α).gc.u_sInf +theorem sSup_sets_eq {s : Set (Filter α)} : (sSup s).sets = ⋂ f ∈ s, (f : Filter α).sets := by + unsealing_newtype OrderDual => + exact (giGenerate α).gc.u_sInf -theorem iSup_sets_eq {f : ι → Filter α} : (iSup f).sets = ⋂ i, (f i).sets := - (giGenerate α).gc.u_iInf +theorem iSup_sets_eq {f : ι → Filter α} : (iSup f).sets = ⋂ i, (f i).sets := by + unsealing_newtype OrderDual => + exact (giGenerate α).gc.u_iInf -theorem generate_empty : Filter.generate ∅ = (⊤ : Filter α) := - (giGenerate α).gc.l_bot +theorem generate_empty : Filter.generate ∅ = (⊤ : Filter α) := by + unsealing_newtype OrderDual => + exact (giGenerate α).gc.l_bot theorem generate_univ : Filter.generate univ = (⊥ : Filter α) := bot_unique fun _ _ => GenerateSets.basic (mem_univ _) theorem generate_union {s t : Set (Set α)} : - Filter.generate (s ∪ t) = Filter.generate s ⊓ Filter.generate t := - (giGenerate α).gc.l_sup + Filter.generate (s ∪ t) = Filter.generate s ⊓ Filter.generate t := by + unsealing_newtype OrderDual => + exact (giGenerate α).gc.l_sup theorem generate_iUnion {s : ι → Set (Set α)} : - Filter.generate (⋃ i, s i) = ⨅ i, Filter.generate (s i) := - (giGenerate α).gc.l_iSup + Filter.generate (⋃ i, s i) = ⨅ i, Filter.generate (s i) := by + unsealing_newtype OrderDual => + exact (giGenerate α).gc.l_iSup @[simp] theorem mem_sup {f g : Filter α} {s : Set α} : s ∈ f ⊔ g ↔ s ∈ f ∧ s ∈ g := diff --git a/mathlib4/Mathlib/Order/Filter/Cofinite.lean b/mathlib4/Mathlib/Order/Filter/Cofinite.lean index 1de23b668..5a4bcfb12 100644 --- a/mathlib4/Mathlib/Order/Filter/Cofinite.lean +++ b/mathlib4/Mathlib/Order/Filter/Cofinite.lean @@ -239,12 +239,14 @@ theorem Filter.Tendsto.exists_forall_le [Nonempty α] [LinearOrder β] {f : α theorem Filter.Tendsto.exists_within_forall_ge [LinearOrder β] {s : Set α} (hs : s.Nonempty) {f : α → β} (hf : Filter.Tendsto f Filter.cofinite Filter.atBot) : - ∃ a₀ ∈ s, ∀ a ∈ s, f a ≤ f a₀ := - @Filter.Tendsto.exists_within_forall_le _ βᵒᵈ _ _ hs _ hf + ∃ a₀ ∈ s, ∀ a ∈ s, f a ≤ f a₀ := by + unsealing_newtype OrderDual => + exact @Filter.Tendsto.exists_within_forall_le _ βᵒᵈ _ _ hs _ hf theorem Filter.Tendsto.exists_forall_ge [Nonempty α] [LinearOrder β] {f : α → β} - (hf : Tendsto f cofinite atBot) : ∃ a₀, ∀ a, f a ≤ f a₀ := - @Filter.Tendsto.exists_forall_le _ βᵒᵈ _ _ _ hf + (hf : Tendsto f cofinite atBot) : ∃ a₀, ∀ a, f a ≤ f a₀ := by + unsealing_newtype OrderDual => + exact @Filter.Tendsto.exists_forall_le _ βᵒᵈ _ _ _ hf theorem Function.Surjective.le_map_cofinite {f : α → β} (hf : Surjective f) : cofinite ≤ map f cofinite := fun _ h => .of_preimage h hf diff --git a/mathlib4/Mathlib/Order/Filter/Extr.lean b/mathlib4/Mathlib/Order/Filter/Extr.lean index 5f806dabb..30edca899 100644 --- a/mathlib4/Mathlib/Order/Filter/Extr.lean +++ b/mathlib4/Mathlib/Order/Filter/Extr.lean @@ -148,8 +148,9 @@ theorem IsMinOn.isGLB (ha : a ∈ s) (hfsa : IsMinOn f s a) : exact ⟨fun hba x hx ↦ le_trans hba (hfsa hx), fun hb ↦ hb a ha⟩ theorem IsMaxOn.isLUB (ha : a ∈ s) (hfsa : IsMaxOn f s a) : - IsLUB {f x | x ∈ s} (f a) := - IsMinOn.isGLB (α := αᵒᵈ) (β := βᵒᵈ) ha hfsa + IsLUB {f x | x ∈ s} (f a) := by + unsealing_newtype OrderDual => + exact IsMinOn.isGLB (α := αᵒᵈ) (β := βᵒᵈ) ha hfsa theorem IsMaxOn.bddAbove (h : IsMaxOn f s a) : BddAbove (f '' s) := @@ -708,8 +709,9 @@ theorem Filter.EventuallyEq.isMaxFilter_iff {α β : Type*} [Preorder β] {f g : theorem Filter.EventuallyLE.isMinFilter {α β : Type*} [Preorder β] {f g : α → β} {a : α} {l : Filter α} (hle : f ≤ᶠ[l] g) (hfga : f a = g a) (h : IsMinFilter f l a) : - IsMinFilter g l a := - @Filter.EventuallyLE.isMaxFilter _ βᵒᵈ _ _ _ _ _ hle hfga h + IsMinFilter g l a := by + unsealing_newtype OrderDual => + exact @Filter.EventuallyLE.isMaxFilter _ βᵒᵈ _ _ _ _ _ hle hfga h theorem IsMinFilter.congr {α β : Type*} [Preorder β] {f g : α → β} {a : α} {l : Filter α} (h : IsMinFilter f l a) (heq : f =ᶠ[l] g) (hfga : f a = g a) : IsMinFilter g l a := @@ -741,8 +743,9 @@ theorem IsMaxOn.iSup_eq (hx₀ : x₀ ∈ s) (h : IsMaxOn f s x₀) : ⨆ x : s, haveI : Nonempty s := ⟨⟨x₀, hx₀⟩⟩ ciSup_eq_of_forall_le_of_forall_lt_exists_gt (fun x => h x.2) fun _w hw => ⟨⟨x₀, hx₀⟩, hw⟩ -theorem IsMinOn.iInf_eq (hx₀ : x₀ ∈ s) (h : IsMinOn f s x₀) : ⨅ x : s, f x = f x₀ := - @IsMaxOn.iSup_eq αᵒᵈ β _ _ _ _ hx₀ h +theorem IsMinOn.iInf_eq (hx₀ : x₀ ∈ s) (h : IsMinOn f s x₀) : ⨅ x : s, f x = f x₀ := by + unsealing_newtype OrderDual => + exact @IsMaxOn.iSup_eq αᵒᵈ β _ _ _ _ hx₀ h end ConditionallyCompleteLinearOrder @@ -769,10 +772,11 @@ section SemilatticeInf variable [SemilatticeInf β] [OrderTop β] {D : α → β} {s : Finset α} theorem inf_eq_of_isMinOn {a : α} (hmem : a ∈ s) (hmax : IsMinOn D s a) : s.inf D = D a := - sup_eq_of_isMaxOn (α := αᵒᵈ) (β := βᵒᵈ) hmem hmax.dual + (Finset.inf_le hmem).antisymm (Finset.le_inf hmax) theorem inf_eq_of_min [Nonempty α] {b : β} (hb : b ∈ Set.range D) (hmem : D.invFun b ∈ s) - (hmin : ∀ a ∈ s, b ≤ D a) : s.inf D = b := - sup_eq_of_max (α := αᵒᵈ) (β := βᵒᵈ) hb hmem hmin + (hmin : ∀ a ∈ s, b ≤ D a) : s.inf D = b := by + unsealing_newtype OrderDual => + exact sup_eq_of_max (α := αᵒᵈ) (β := βᵒᵈ) hb hmem hmin end SemilatticeInf diff --git a/mathlib4/Mathlib/Order/Filter/IsBounded.lean b/mathlib4/Mathlib/Order/Filter/IsBounded.lean index b6a92917e..266a2887e 100644 --- a/mathlib4/Mathlib/Order/Filter/IsBounded.lean +++ b/mathlib4/Mathlib/Order/Filter/IsBounded.lean @@ -383,14 +383,16 @@ theorem _root_.OrderIso.isBoundedUnder_le_comp [LE α] [LE β] (e : α ≃o β) @[to_additive (attr := simp)] theorem isBoundedUnder_le_inv [CommGroup α] [Preorder α] [IsOrderedMonoid α] {l : Filter β} {u : β → α} : - (IsBoundedUnder (· ≤ ·) l fun x => (u x)⁻¹) ↔ IsBoundedUnder (· ≥ ·) l u := - (OrderIso.inv α).isBoundedUnder_ge_comp + (IsBoundedUnder (· ≤ ·) l fun x => (u x)⁻¹) ↔ IsBoundedUnder (· ≥ ·) l u := by + unsealing_newtype OrderDual => + exact (OrderIso.inv α).isBoundedUnder_ge_comp @[to_additive (attr := simp)] theorem isBoundedUnder_ge_inv [CommGroup α] [Preorder α] [IsOrderedMonoid α] {l : Filter β} {u : β → α} : - (IsBoundedUnder (· ≥ ·) l fun x => (u x)⁻¹) ↔ IsBoundedUnder (· ≤ ·) l u := - (OrderIso.inv α).isBoundedUnder_le_comp + (IsBoundedUnder (· ≥ ·) l fun x => (u x)⁻¹) ↔ IsBoundedUnder (· ≤ ·) l u := by + unsealing_newtype OrderDual => + exact (OrderIso.inv α).isBoundedUnder_le_comp @[to_dual] theorem IsBoundedUnder.sup [SemilatticeSup α] {f : Filter β} {u v : β → α} : @@ -445,8 +447,9 @@ theorem Monotone.isBoundedUnder_le_comp_iff [Nonempty β] [LinearOrder β] [Preo @[to_dual isBoundedUnder_ge_comp_iff] theorem Antitone.isBoundedUnder_le_comp_iff [Nonempty β] [LinearOrder β] [Preorder γ] [NoMaxOrder γ] {g : β → γ} {f : α → β} {l : Filter α} (hg : Antitone g) (hg' : Tendsto g atBot atTop) : - IsBoundedUnder (· ≤ ·) l (g ∘ f) ↔ IsBoundedUnder (fun x1 x2 ↦ x2 ≤ x1) l f := - hg.dual_right.isBoundedUnder_ge_comp_iff hg' + IsBoundedUnder (· ≤ ·) l (g ∘ f) ↔ IsBoundedUnder (fun x1 x2 ↦ x2 ≤ x1) l f := by + unsealing_newtype OrderDual => + exact hg.dual_right.isBoundedUnder_ge_comp_iff hg' end Order diff --git a/mathlib4/Mathlib/Order/Filter/Pointwise.lean b/mathlib4/Mathlib/Order/Filter/Pointwise.lean index f4606c09d..11d3d388a 100644 --- a/mathlib4/Mathlib/Order/Filter/Pointwise.lean +++ b/mathlib4/Mathlib/Order/Filter/Pointwise.lean @@ -261,8 +261,9 @@ end InvolutiveInv @[to_additive (attr := simp)] lemma inv_atTop {G : Type*} [CommGroup G] [Preorder G] [IsOrderedMonoid G] : - (atTop : Filter G)⁻¹ = atBot := - (OrderIso.inv G).map_atTop + (atTop : Filter G)⁻¹ = atBot := by + unsealing_newtype OrderDual => + exact (OrderIso.inv G).map_atTop /-! ### Filter addition/multiplication -/ diff --git a/mathlib4/Mathlib/Order/Fin/Tuple.lean b/mathlib4/Mathlib/Order/Fin/Tuple.lean index 7776171da..fd8871f31 100644 --- a/mathlib4/Mathlib/Order/Fin/Tuple.lean +++ b/mathlib4/Mathlib/Order/Fin/Tuple.lean @@ -126,8 +126,9 @@ lemma monotone_vecCons : Monotone (vecCons a f) ↔ a ≤ f 0 ∧ Monotone f := @[simp] lemma strictAnti_vecCons : StrictAnti (vecCons a f) ↔ f 0 < a ∧ StrictAnti f := liftFun_vecCons (· > ·) -@[simp] lemma antitone_vecCons : Antitone (vecCons a f) ↔ f 0 ≤ a ∧ Antitone f := - monotone_vecCons (α := αᵒᵈ) +@[simp] lemma antitone_vecCons : Antitone (vecCons a f) ↔ f 0 ≤ a ∧ Antitone f := by + unsealing_newtype OrderDual => + exact monotone_vecCons (α := αᵒᵈ) @[simp] lemma antitone_vecEmpty : Antitone (vecCons a vecEmpty) | ⟨0, _⟩, ⟨0, _⟩, _ => le_rfl diff --git a/mathlib4/Mathlib/Order/FixedPoints.lean b/mathlib4/Mathlib/Order/FixedPoints.lean index 138741726..8e32b7dae 100644 --- a/mathlib4/Mathlib/Order/FixedPoints.lean +++ b/mathlib4/Mathlib/Order/FixedPoints.lean @@ -101,28 +101,34 @@ theorem le_gfp {a : α} (h : a ≤ f a) : a ≤ f.gfp := theorem gfp_le {a : α} (h : ∀ b, b ≤ f b → b ≤ a) : f.gfp ≤ a := sSup_le h -theorem isFixedPt_gfp : IsFixedPt f f.gfp := - f.dual.isFixedPt_lfp +theorem gfp_le_map {a : α} (ha : f.gfp ≤ a) : f.gfp ≤ f a := by + unsealing_newtype OrderDual => + exact f.dual.map_le_lfp ha @[simp] -theorem map_gfp : f f.gfp = f.gfp := - f.dual.map_lfp +theorem map_gfp : f f.gfp = f.gfp := by + unsealing_newtype OrderDual => + exact f.dual.map_lfp -theorem map_le_gfp {a : α} (ha : a ≤ f.gfp) : f a ≤ f.gfp := - f.dual.lfp_le_map ha +theorem isFixedPt_gfp : IsFixedPt f f.gfp := + f.map_gfp -theorem gfp_le_map {a : α} (ha : f.gfp ≤ a) : f.gfp ≤ f a := - f.dual.map_le_lfp ha +theorem map_le_gfp {a : α} (ha : a ≤ f.gfp) : f a ≤ f.gfp := by + unsealing_newtype OrderDual => + exact f.dual.lfp_le_map ha -theorem isGreatest_gfp_le : IsGreatest { a | a ≤ f a } f.gfp := - f.dual.isLeast_lfp_le +theorem isGreatest_gfp_le : IsGreatest { a | a ≤ f a } f.gfp := by + unsealing_newtype OrderDual => + exact f.dual.isLeast_lfp_le -theorem isGreatest_gfp : IsGreatest (fixedPoints f) f.gfp := - f.dual.isLeast_lfp +theorem isGreatest_gfp : IsGreatest (fixedPoints f) f.gfp := by + unsealing_newtype OrderDual => + exact f.dual.isLeast_lfp theorem gfp_induction {p : α → Prop} (step : ∀ a, p a → f.gfp ≤ a → p (f a)) - (hInf : ∀ s, (∀ a ∈ s, p a) → p (sInf s)) : p f.gfp := - f.dual.lfp_induction step hInf + (hInf : ∀ s, (∀ a ∈ s, p a) → p (sInf s)) : p f.gfp := by + unsealing_newtype OrderDual => + exact f.dual.lfp_induction step hInf theorem lfp_le_gfp : f.lfp ≤ f.gfp := f.lfp_le_fixed f.isFixedPt_gfp @@ -138,8 +144,9 @@ theorem map_lfp_comp : f (g.comp f).lfp = (f.comp g).lfp := le_antisymm ((f.comp g).map_lfp ▸ f.mono (lfp_le_fixed _ <| congr_arg g (f.comp g).map_lfp)) <| lfp_le _ (congr_arg f (g.comp f).map_lfp).le -theorem map_gfp_comp : f (g.comp f).gfp = (f.comp g).gfp := - f.dual.map_lfp_comp g.dual +theorem map_gfp_comp : f (g.comp f).gfp = (f.comp g).gfp := by + unsealing_newtype OrderDual => + exact f.dual.map_lfp_comp g.dual -- Diagonal rule theorem lfp_lfp (h : α →o α →o α) : (lfp.comp h).lfp = h.onDiag.lfp := by @@ -152,8 +159,9 @@ theorem lfp_lfp (h : α →o α →o α) : (lfp.comp h).lfp = h.onDiag.lfp := by _ = (h a).lfp := (h a).map_lfp _ = a := ha -theorem gfp_gfp (h : α →o α →o α) : (gfp.comp h).gfp = h.onDiag.gfp := - @lfp_lfp αᵒᵈ _ <| (OrderHom.dualIso αᵒᵈ αᵒᵈ).symm.toOrderEmbedding.toOrderHom.comp h.dual +theorem gfp_gfp (h : α →o α →o α) : (gfp.comp h).gfp = h.onDiag.gfp := by + unsealing_newtype OrderDual => + exact @lfp_lfp αᵒᵈ _ <| (OrderHom.dualIso αᵒᵈ αᵒᵈ).symm.toOrderEmbedding.toOrderHom.comp h.dual end Eqn @@ -164,6 +172,9 @@ variable [CompleteLattice α] (f : α →o α) theorem gfp_const_inf_le (x : α) : (const α x ⊓ f).gfp ≤ x := (gfp_le _) fun _ hb => hb.trans inf_le_left +theorem le_lfp_const_sup (x : α) : x ≤ (const α x ⊔ f).lfp := + (le_lfp _) fun _ hb => le_sup_left.trans hb + /-- Previous fixed point of a monotone map. If `f` is a monotone self-map of a complete lattice and `x` is a point such that `f x ≤ x`, then `f.prevFixed x hx` is the greatest fixed point of `f` that is less than or equal to `x`. -/ @@ -179,13 +190,15 @@ def prevFixed (x : α) (hx : f x ≤ x) : fixedPoints f := `x` is a point such that `x ≤ f x`, then `f.nextFixed x hx` is the least fixed point of `f` that is greater than or equal to `x`. -/ def nextFixed (x : α) (hx : x ≤ f x) : fixedPoints f := - { f.dual.prevFixed x hx with val := (const α x ⊔ f).lfp } + ⟨(const α x ⊔ f).lfp, by + unsealing_newtype OrderDual => + exact (f.dual.prevFixed x hx).property⟩ theorem prevFixed_le {x : α} (hx : f x ≤ x) : ↑(f.prevFixed x hx) ≤ x := f.gfp_const_inf_le x theorem le_nextFixed {x : α} (hx : x ≤ f x) : x ≤ f.nextFixed x hx := - f.dual.prevFixed_le hx + f.le_lfp_const_sup x theorem nextFixed_le {x : α} (hx : x ≤ f x) {y : fixedPoints f} (h : x ≤ y) : f.nextFixed x hx ≤ y := @@ -198,8 +211,9 @@ theorem nextFixed_le_iff {x : α} (hx : x ≤ f x) {y : fixedPoints f} : @[simp] theorem le_prevFixed_iff {x : α} (hx : f x ≤ x) {y : fixedPoints f} : - y ≤ f.prevFixed x hx ↔ ↑y ≤ x := - f.dual.nextFixed_le_iff hx + y ≤ f.prevFixed x hx ↔ ↑y ≤ x := by + unsealing_newtype OrderDual => + exact f.dual.nextFixed_le_iff hx theorem le_prevFixed {x : α} (hx : f x ≤ x) {y : fixedPoints f} (h : ↑y ≤ x) : y ≤ f.prevFixed x hx := @@ -211,8 +225,9 @@ theorem le_map_sup_fixedPoints (x y : fixedPoints f) : (x ⊔ y : α) ≤ f (x _ ≤ f (x ⊔ y) := f.mono.le_map_sup x y -- Porting note: `x ⊓ y` without the `.val`s fails to synthesize `Inf` instance -theorem map_inf_fixedPoints_le (x y : fixedPoints f) : f (x ⊓ y) ≤ x.val ⊓ y.val := - f.dual.le_map_sup_fixedPoints x y +theorem map_inf_fixedPoints_le (x y : fixedPoints f) : f (x ⊓ y) ≤ x.val ⊓ y.val := by + unsealing_newtype OrderDual => + exact f.dual.le_map_sup_fixedPoints x y theorem le_map_sSup_subset_fixedPoints (A : Set α) (hA : A ⊆ fixedPoints f) : sSup A ≤ f (sSup A) := @@ -247,7 +262,9 @@ instance : SemilatticeSup (fixedPoints f) where instance : SemilatticeInf (fixedPoints f) where __ : PartialOrder (fixedPoints f) := inferInstance inf x y := f.prevFixed (x ⊓ y) (f.map_inf_fixedPoints_le x y) - __ := OrderDual.instSemilatticeInf (fixedPoints f.dual) + inf_le_left _ _ := Subtype.coe_le_coe.1 <| (f.prevFixed_le _).trans inf_le_left + inf_le_right _ _ := Subtype.coe_le_coe.1 <| (f.prevFixed_le _).trans inf_le_right + le_inf _ _ _ hzx hzy := f.le_prevFixed _ <| le_inf hzx hzy /-- **Knaster-Tarski Theorem**: The fixed points of `f` form a complete lattice. -/ instance completeLattice : CompleteLattice (fixedPoints f) where @@ -280,7 +297,8 @@ theorem lfp_eq_sSup_iterate (h : ωScottContinuous f) : exact ωSup_iterate_le_prefixedPoint ⟨f, h.map_ωSup_of_orderHom⟩ ⊥ bot_le h_a bot_le theorem gfp_eq_sInf_iterate (h : ωScottContinuous f.dual) : - f.gfp = ⨅ n, f^[n] ⊤ := - lfp_eq_sSup_iterate f.dual h + f.gfp = ⨅ n, f^[n] ⊤ := by + unsealing_newtype OrderDual => + exact lfp_eq_sSup_iterate f.dual h end fixedPoints diff --git a/mathlib4/Mathlib/Order/GaloisConnection/Basic.lean b/mathlib4/Mathlib/Order/GaloisConnection/Basic.lean index 7a9a593a6..fdb621390 100644 --- a/mathlib4/Mathlib/Order/GaloisConnection/Basic.lean +++ b/mathlib4/Mathlib/Order/GaloisConnection/Basic.lean @@ -157,22 +157,25 @@ theorem isLUB_image2_of_isLUB_isLUB (h₁ : ∀ b, GaloisConnection (swap l b) ( theorem isLUB_image2_of_isLUB_isGLB (h₁ : ∀ b, GaloisConnection (swap l b) (u₁ b)) (h₂ : ∀ a, GaloisConnection (l a ∘ ofDual) (toDual ∘ u₂ a)) (ha₀ : IsLUB s a₀) (hb₀ : IsGLB t b₀) : - IsLUB (image2 l s t) (l a₀ b₀) := - isLUB_image2_of_isLUB_isLUB (β := βᵒᵈ) h₁ h₂ ha₀ hb₀ + IsLUB (image2 l s t) (l a₀ b₀) := by + unsealing_newtype OrderDual => + exact isLUB_image2_of_isLUB_isLUB (β := βᵒᵈ) h₁ h₂ ha₀ hb₀ @[to_dual] theorem isLUB_image2_of_isGLB_isLUB (h₁ : ∀ b, GaloisConnection (swap l b ∘ ofDual) (toDual ∘ u₁ b)) (h₂ : ∀ a, GaloisConnection (l a) (u₂ a)) (ha₀ : IsGLB s a₀) (hb₀ : IsLUB t b₀) : - IsLUB (image2 l s t) (l a₀ b₀) := - isLUB_image2_of_isLUB_isLUB (α := αᵒᵈ) h₁ h₂ ha₀ hb₀ + IsLUB (image2 l s t) (l a₀ b₀) := by + unsealing_newtype OrderDual => + exact isLUB_image2_of_isLUB_isLUB (α := αᵒᵈ) h₁ h₂ ha₀ hb₀ @[to_dual] theorem isLUB_image2_of_isGLB_isGLB (h₁ : ∀ b, GaloisConnection (swap l b ∘ ofDual) (toDual ∘ u₁ b)) (h₂ : ∀ a, GaloisConnection (l a ∘ ofDual) (toDual ∘ u₂ a)) (ha₀ : IsGLB s a₀) (hb₀ : IsGLB t b₀) : - IsLUB (image2 l s t) (l a₀ b₀) := - isLUB_image2_of_isLUB_isLUB (α := αᵒᵈ) (β := βᵒᵈ) h₁ h₂ ha₀ hb₀ + IsLUB (image2 l s t) (l a₀ b₀) := by + unsealing_newtype OrderDual => + exact isLUB_image2_of_isLUB_isLUB (α := αᵒᵈ) (β := βᵒᵈ) h₁ h₂ ha₀ hb₀ end LUB_GLB @@ -189,19 +192,22 @@ theorem sSup_image2_eq_sSup_sSup (h₁ : ∀ b, GaloisConnection (swap l b) (u @[to_dual] theorem sSup_image2_eq_sSup_sInf (h₁ : ∀ b, GaloisConnection (swap l b) (u₁ b)) (h₂ : ∀ a, GaloisConnection (l a ∘ ofDual) (toDual ∘ u₂ a)) : - sSup (image2 l s t) = l (sSup s) (sInf t) := - sSup_image2_eq_sSup_sSup (β := βᵒᵈ) h₁ h₂ + sSup (image2 l s t) = l (sSup s) (sInf t) := by + unsealing_newtype OrderDual => + exact sSup_image2_eq_sSup_sSup (β := βᵒᵈ) h₁ h₂ @[to_dual] theorem sSup_image2_eq_sInf_sSup (h₁ : ∀ b, GaloisConnection (swap l b ∘ ofDual) (toDual ∘ u₁ b)) - (h₂ : ∀ a, GaloisConnection (l a) (u₂ a)) : sSup (image2 l s t) = l (sInf s) (sSup t) := - sSup_image2_eq_sSup_sSup (α := αᵒᵈ) h₁ h₂ + (h₂ : ∀ a, GaloisConnection (l a) (u₂ a)) : sSup (image2 l s t) = l (sInf s) (sSup t) := by + unsealing_newtype OrderDual => + exact sSup_image2_eq_sSup_sSup (α := αᵒᵈ) h₁ h₂ @[to_dual] theorem sSup_image2_eq_sInf_sInf (h₁ : ∀ b, GaloisConnection (swap l b ∘ ofDual) (toDual ∘ u₁ b)) (h₂ : ∀ a, GaloisConnection (l a ∘ ofDual) (toDual ∘ u₂ a)) : - sSup (image2 l s t) = l (sInf s) (sInf t) := - sSup_image2_eq_sSup_sSup (α := αᵒᵈ) (β := βᵒᵈ) h₁ h₂ + sSup (image2 l s t) = l (sInf s) (sInf t) := by + unsealing_newtype OrderDual => + exact sSup_image2_eq_sSup_sSup (α := αᵒᵈ) (β := βᵒᵈ) h₁ h₂ end CompleteLattice @@ -419,8 +425,9 @@ theorem gc_sSup_Iic [CompleteSemilatticeSup α] : /-- `toDual ∘ Ici` and `sInf ∘ ofDual` form a Galois connection. -/ theorem gc_Ici_sInf [CompleteSemilatticeInf α] : - GaloisConnection (toDual ∘ Ici : α → (Set α)ᵒᵈ) (sInf ∘ ofDual : (Set α)ᵒᵈ → α) := - fun _ _ ↦ le_sInf_iff.symm + GaloisConnection (toDual ∘ Ici : α → (Set α)ᵒᵈ) (sInf ∘ ofDual : (Set α)ᵒᵈ → α) := by + unsealing_newtype OrderDual => + exact fun _ _ ↦ le_sInf_iff.symm /-- `sSup` and `Iic` form a Galois insertion. -/ def giSSupIic [CompleteSemilatticeSup α] : @@ -433,7 +440,8 @@ alias gi_sSup_Iic := giSSupIic /-- `toDual ∘ Ici` and `sInf ∘ ofDual` form a Galois coinsertion. -/ def gciIciSInf [CompleteSemilatticeInf α] : GaloisCoinsertion (toDual ∘ Ici : α → (Set α)ᵒᵈ) (sInf ∘ ofDual : (Set α)ᵒᵈ → α) := - gc_Ici_sInf.toGaloisCoinsertion fun _ ↦ sInf_le le_rfl + gc_Ici_sInf.toGaloisCoinsertion fun a ↦ by + simpa only [Function.comp_apply, ofDual_toDual] using sInf_le (s := Ici a) (a := a) le_rfl @[deprecated (since := "2026-07-18")] alias gci_Ici_sInf := gciIciSInf diff --git a/mathlib4/Mathlib/Order/GaloisConnection/Defs.lean b/mathlib4/Mathlib/Order/GaloisConnection/Defs.lean index c58fdb6b9..9f87b0b20 100644 --- a/mathlib4/Mathlib/Order/GaloisConnection/Defs.lean +++ b/mathlib4/Mathlib/Order/GaloisConnection/Defs.lean @@ -59,8 +59,9 @@ theorem monotone_intro (hu : Monotone u) (hl : Monotone l) (h_u_l : ∀ a, a ≤ @[to_dual self] protected theorem dual {l : α → β} {u : β → α} (gc : GaloisConnection l u) : GaloisConnection (OrderDual.toDual ∘ u ∘ OrderDual.ofDual) - (OrderDual.toDual ∘ l ∘ OrderDual.ofDual) := - fun a b => (gc b a).symm + (OrderDual.toDual ∘ l ∘ OrderDual.ofDual) := by + unsealing_newtype OrderDual => + exact fun a b => (gc b a).symm variable (gc : GaloisConnection l u) include gc @@ -297,14 +298,22 @@ end GaloisInsertion `β`. -/ @[to_dual /-- Make a `GaloisCoinsertion` between `αᵒᵈ` and `βᵒᵈ` from a `GaloisInsertion` between `α` and `β`. -/] -def GaloisCoinsertion.dual [Preorder α] [Preorder β] {l : α → β} {u : β → α} : - GaloisCoinsertion l u → GaloisInsertion (toDual ∘ u ∘ ofDual) (toDual ∘ l ∘ ofDual) := - fun x => ⟨x.1, x.2.dual, x.3, x.4⟩ +def GaloisCoinsertion.dual [Preorder α] [Preorder β] {l : α → β} {u : β → α} + (x : GaloisCoinsertion l u) : + GaloisInsertion (toDual ∘ u ∘ ofDual) (toDual ∘ l ∘ ofDual) where + choice b h := toDual (x.choice (ofDual b) h) + gc := x.gc.dual + le_l_u := by unsealing_newtype OrderDual => exact x.u_l_le + choice_eq := by unsealing_newtype OrderDual => exact x.choice_eq /-- Make a `GaloisInsertion` between `α` and `β` from a `GaloisCoinsertion` between `αᵒᵈ` and `βᵒᵈ`. -/ @[to_dual /-- Make a `GaloisCoinsertion` between `α` and `β` from a `GaloisInsertion` between `αᵒᵈ` and `βᵒᵈ`. -/] -def GaloisCoinsertion.ofDual [Preorder α] [Preorder β] {l : αᵒᵈ → βᵒᵈ} {u : βᵒᵈ → αᵒᵈ} : - GaloisCoinsertion l u → GaloisInsertion (ofDual ∘ u ∘ toDual) (ofDual ∘ l ∘ toDual) := - fun x => ⟨x.1, x.2.dual, x.3, x.4⟩ +def GaloisCoinsertion.ofDual [Preorder α] [Preorder β] {l : αᵒᵈ → βᵒᵈ} {u : βᵒᵈ → αᵒᵈ} + (x : GaloisCoinsertion l u) : + GaloisInsertion (ofDual ∘ u ∘ toDual) (ofDual ∘ l ∘ toDual) where + choice b h := OrderDual.ofDual (x.choice (toDual b) h) + gc := by unsealing_newtype OrderDual => exact x.gc.dual + le_l_u := by unsealing_newtype OrderDual => exact x.u_l_le + choice_eq := by unsealing_newtype OrderDual => exact x.choice_eq diff --git a/mathlib4/Mathlib/Order/Grade.lean b/mathlib4/Mathlib/Order/Grade.lean index 7a44f9112..8c9397a36 100644 --- a/mathlib4/Mathlib/Order/Grade.lean +++ b/mathlib4/Mathlib/Order/Grade.lean @@ -224,10 +224,10 @@ instance OrderDual.gradeOrder [GradeOrder 𝕆 α] : GradeOrder 𝕆ᵒᵈ αᵒ covBy_grade _ _ h := (h.ofDual.grade _).toDual instance OrderDual.gradeMinOrder [GradeMaxOrder 𝕆 α] : GradeMinOrder 𝕆ᵒᵈ αᵒᵈ := - { OrderDual.gradeOrder with isMin_grade := fun _ => IsMax.grade (α := α) 𝕆 } + { OrderDual.gradeOrder with isMin_grade := fun _ h => (h.ofDual.grade 𝕆).toDual } instance OrderDual.gradeMaxOrder [GradeMinOrder 𝕆 α] : GradeMaxOrder 𝕆ᵒᵈ αᵒᵈ := - { OrderDual.gradeOrder with isMax_grade := fun _ => IsMin.grade (α := α) 𝕆 } + { OrderDual.gradeOrder with isMax_grade := fun _ h => (h.ofDual.grade 𝕆).toDual } instance [GradeBoundedOrder 𝕆 α] : GradeBoundedOrder 𝕆ᵒᵈ αᵒᵈ := { OrderDual.gradeMinOrder, OrderDual.gradeMaxOrder with } diff --git a/mathlib4/Mathlib/Order/Heyting/Basic.lean b/mathlib4/Mathlib/Order/Heyting/Basic.lean index e9310e68c..225709829 100644 --- a/mathlib4/Mathlib/Order/Heyting/Basic.lean +++ b/mathlib4/Mathlib/Order/Heyting/Basic.lean @@ -709,14 +709,14 @@ instance OrderDual.instCoheytingAlgebra : CoheytingAlgebra αᵒᵈ where hnot := toDual ∘ compl ∘ ofDual sdiff a b := toDual (ofDual b ⇨ ofDual a) sdiff_le_iff a b c := by rw [sup_comm]; exact le_himp_iff - top_sdiff := @himp_bot α _ + top_sdiff a := congrArg OrderDual.mk (himp_bot (OrderDual.ofDual a)) @[to_dual existing] instance OrderDual.instHeytingAlgebra {α : Type u_2} [CoheytingAlgebra α] : HeytingAlgebra αᵒᵈ where compl := toDual ∘ hnot ∘ ofDual himp a b := toDual (ofDual b \ ofDual a) le_himp_iff a b c := by rw [inf_comm]; exact sdiff_le_iff - himp_bot := @top_sdiff' α _ + himp_bot a := congrArg OrderDual.mk (top_sdiff' (OrderDual.ofDual a)) @[to_dual (attr := simp)] theorem ofDual_hnot (a : αᵒᵈ) : ofDual (¬a) = (ofDual a)ᶜ := diff --git a/mathlib4/Mathlib/Order/Hom/Basic.lean b/mathlib4/Mathlib/Order/Hom/Basic.lean index b63b7cbf4..61aaa9e94 100644 --- a/mathlib4/Mathlib/Order/Hom/Basic.lean +++ b/mathlib4/Mathlib/Order/Hom/Basic.lean @@ -504,7 +504,7 @@ theorem orderHom_eq_id [Subsingleton α] (g : α →o α) : g = OrderHom.id := protected def dual : (α →o β) ≃ (αᵒᵈ →o βᵒᵈ) where toFun f := ⟨(OrderDual.toDual : β → βᵒᵈ) ∘ (f : α → β) ∘ (OrderDual.ofDual : αᵒᵈ → α), f.mono.dual⟩ - invFun f := ⟨OrderDual.ofDual ∘ f ∘ OrderDual.toDual, f.mono.dual⟩ + invFun f := ⟨OrderDual.ofDual ∘ f ∘ OrderDual.toDual, fun _ _ h ↦ f.mono h⟩ @[simp] theorem dual_id : (OrderHom.id : α →o α).dual = OrderHom.id := @@ -527,7 +527,7 @@ theorem symm_dual_comp (g : βᵒᵈ →o γᵒᵈ) (f : αᵒᵈ →o βᵒᵈ) /-- `OrderHom.dual` as an order isomorphism. -/ def dualIso (α β : Type*) [Preorder α] [Preorder β] : (α →o β) ≃o (αᵒᵈ →o βᵒᵈ)ᵒᵈ where toEquiv := OrderHom.dual.trans OrderDual.toDual - map_rel_iff' := Iff.rfl + map_rel_iff' := ⟨fun h x ↦ h (OrderDual.toDual x), fun h x ↦ h (OrderDual.ofDual x)⟩ /-- Lift an order homomorphism `f : α →o β` to an order homomorphism `ULift α →o ULift β` in a higher universe. -/ @@ -655,7 +655,8 @@ protected theorem isWellOrder [IsWellOrder β (· < ·)] (f : α ↪o β) : IsWe /-- An order embedding is also an order embedding between dual orders. -/ protected def dual : αᵒᵈ ↪o βᵒᵈ := - ⟨f.toEmbedding, f.map_rel_iff⟩ + ⟨⟨fun a ↦ OrderDual.toDual (f (OrderDual.ofDual a)), fun _ _ h ↦ + congrArg OrderDual.mk (f.injective (congrArg OrderDual.ofDual' h))⟩, f.map_rel_iff⟩ /-- A preorder which embeds into a well-founded preorder is itself well-founded. -/ @[to_dual /-- A preorder which embeds into a preorder in which `(· > ·)` is well-founded @@ -736,8 +737,9 @@ lemma Disjoint.of_orderEmbedding [OrderBot α] [OrderBot β] {a₁ a₂ : α} : /-- If the images by an order embedding of two elements are codisjoint, then they are themselves codisjoint. -/ lemma Codisjoint.of_orderEmbedding [OrderTop α] [OrderTop β] {a₁ a₂ : α} : - Codisjoint (f a₁) (f a₂) → Codisjoint a₁ a₂ := - Disjoint.of_orderEmbedding (α := αᵒᵈ) (β := βᵒᵈ) f.dual + Codisjoint (f a₁) (f a₂) → Codisjoint a₁ a₂ := by + unsealing_newtype OrderDual => + exact Disjoint.of_orderEmbedding (α := αᵒᵈ) (β := βᵒᵈ) f.dual /-- If the images by an order embedding of two elements are complements, then they are themselves complements. -/ @@ -1013,8 +1015,9 @@ theorem prodComm_symm : (prodComm : α × β ≃o β × α).symm = prodComm := variable (α) /-- The order isomorphism between a type and its double dual. -/ -def dualDual : α ≃o αᵒᵈᵒᵈ := - refl α +def dualDual : α ≃o αᵒᵈᵒᵈ where + toEquiv := OrderDual.toDual.trans OrderDual.toDual + map_rel_iff' := Iff.rfl @[simp] theorem coe_dualDual : ⇑(dualDual α) = toDual ∘ toDual := @@ -1212,7 +1215,7 @@ end StrictMono /-- An order isomorphism is also an order isomorphism between dual orders. -/ protected def OrderIso.dual [LE α] [LE β] (f : α ≃o β) : αᵒᵈ ≃o βᵒᵈ := - ⟨f.toEquiv, f.le_iff_le⟩ + ⟨OrderDual.ofDual.trans (f.toEquiv.trans OrderDual.toDual), f.le_iff_le⟩ section variable [LE α] [LE β] (f : α ≃o β) diff --git a/mathlib4/Mathlib/Order/Hom/Bounded.lean b/mathlib4/Mathlib/Order/Hom/Bounded.lean index 95142ff2e..1475ea56f 100644 --- a/mathlib4/Mathlib/Order/Hom/Bounded.lean +++ b/mathlib4/Mathlib/Order/Hom/Bounded.lean @@ -477,8 +477,9 @@ variable [LE α] [OrderTop α] [LE β] [OrderTop β] [LE γ] [OrderTop γ] Reinterpret a bot homomorphism as a top homomorphism between the dual lattices. -/] protected def dual : TopHom α β ≃ BotHom αᵒᵈ βᵒᵈ where - toFun f := ⟨f, f.map_top'⟩ - invFun f := ⟨f, f.map_bot'⟩ + toFun f := ⟨fun a ↦ OrderDual.mk (f a.ofDual'), congrArg OrderDual.mk f.map_top'⟩ + invFun f := ⟨fun a ↦ OrderDual.ofDual' (f (OrderDual.mk a)), congrArg OrderDual.ofDual' + f.map_bot'⟩ @[to_dual (attr := simp)] theorem dual_id : TopHom.dual (TopHom.id α) = BotHom.id _ := @@ -511,8 +512,10 @@ protected def dual : BoundedOrderHom α β ≃ BoundedOrderHom αᵒᵈ βᵒᵈ where - toFun f := ⟨f.toOrderHom.dual, f.map_bot', f.map_top'⟩ - invFun f := ⟨OrderHom.dual.symm f.toOrderHom, f.map_bot', f.map_top'⟩ + toFun f := ⟨f.toOrderHom.dual, congrArg OrderDual.mk f.map_bot', + congrArg OrderDual.mk f.map_top'⟩ + invFun f := ⟨OrderHom.dual.symm f.toOrderHom, congrArg OrderDual.ofDual' f.map_bot', + congrArg OrderDual.ofDual' f.map_top'⟩ @[simp] theorem dual_id : (BoundedOrderHom.id α).dual = BoundedOrderHom.id _ := diff --git a/mathlib4/Mathlib/Order/Hom/BoundedLattice.lean b/mathlib4/Mathlib/Order/Hom/BoundedLattice.lean index fd59ccf1f..60274e379 100644 --- a/mathlib4/Mathlib/Order/Hom/BoundedLattice.lean +++ b/mathlib4/Mathlib/Order/Hom/BoundedLattice.lean @@ -507,8 +507,8 @@ lattices. -/ Reinterpret a finitary infimum homomorphism as a finitary supremum homomorphism between the dual lattices. -/] def dual : SupBotHom α β ≃ InfTopHom αᵒᵈ βᵒᵈ where - toFun f := ⟨SupHom.dual f.toSupHom, f.map_bot'⟩ - invFun f := ⟨SupHom.dual.symm f.toInfHom, f.map_top'⟩ + toFun f := ⟨SupHom.dual f.toSupHom, congrArg OrderDual.mk f.map_bot'⟩ + invFun f := ⟨SupHom.dual.symm f.toInfHom, congrArg OrderDual.ofDual' f.map_top'⟩ @[to_dual (attr := simp)] theorem dual_id : SupBotHom.dual (SupBotHom.id α) = InfTopHom.id _ := rfl @@ -537,8 +537,10 @@ variable [Lattice α] [BoundedOrder α] [Lattice β] [BoundedOrder β] [Lattice bounded lattices. -/ @[simps!] protected def dual : BoundedLatticeHom α β ≃ BoundedLatticeHom αᵒᵈ βᵒᵈ where - toFun f := ⟨LatticeHom.dual f.toLatticeHom, f.map_bot', f.map_top'⟩ - invFun f := ⟨LatticeHom.dual.symm f.toLatticeHom, f.map_bot', f.map_top'⟩ + toFun f := ⟨LatticeHom.dual f.toLatticeHom, congrArg OrderDual.mk f.map_bot', + congrArg OrderDual.mk f.map_top'⟩ + invFun f := ⟨LatticeHom.dual.symm f.toLatticeHom, congrArg OrderDual.ofDual' f.map_bot', + congrArg OrderDual.ofDual' f.map_top'⟩ @[simp] theorem dual_id : BoundedLatticeHom.dual (BoundedLatticeHom.id α) = BoundedLatticeHom.id _ := diff --git a/mathlib4/Mathlib/Order/Hom/CompleteLattice.lean b/mathlib4/Mathlib/Order/Hom/CompleteLattice.lean index 07a05d6b3..8b7fca617 100644 --- a/mathlib4/Mathlib/Order/Hom/CompleteLattice.lean +++ b/mathlib4/Mathlib/Order/Hom/CompleteLattice.lean @@ -551,8 +551,10 @@ variable [SupSet α] [SupSet β] [SupSet γ] @[to_dual (attr := simps) /-- Reinterpret an `⨅`-homomorphism as a `⨆`-homomorphism between the dual orders. -/] protected def dual : sSupHom α β ≃ sInfHom αᵒᵈ βᵒᵈ where - toFun f := ⟨toDual ∘ f ∘ ofDual, f.map_sSup'⟩ - invFun f := ⟨ofDual ∘ f ∘ toDual, f.map_sInf'⟩ + toFun f := ⟨toDual ∘ f ∘ ofDual, by + unsealing_newtype OrderDual => exact f.map_sSup'⟩ + invFun f := ⟨ofDual ∘ f ∘ toDual, by + unsealing_newtype OrderDual => exact f.map_sInf'⟩ @[to_dual (attr := simp)] theorem dual_id : sSupHom.dual (sSupHom.id α) = sInfHom.id _ := @@ -582,8 +584,10 @@ variable [CompleteLattice α] [CompleteLattice β] [CompleteLattice γ] lattices. -/ @[simps!] protected def dual : CompleteLatticeHom α β ≃ CompleteLatticeHom αᵒᵈ βᵒᵈ where - toFun f := ⟨sSupHom.dual f.tosSupHom, fun s ↦ f.map_sInf' s⟩ - invFun f := ⟨sSupHom.dual f.tosSupHom, fun s ↦ f.map_sInf' s⟩ + toFun f := ⟨sSupHom.dual f.tosSupHom, fun s ↦ (sInfHom.dual f.tosInfHom).map_sSup' s⟩ + invFun f := ⟨sInfHom.dual.symm f.tosSupHom, fun s ↦ (sSupHom.dual.symm f.tosInfHom).map_sSup' s⟩ + left_inv _ := rfl + right_inv _ := rfl @[simp] theorem dual_id : CompleteLatticeHom.dual (CompleteLatticeHom.id α) = CompleteLatticeHom.id _ := diff --git a/mathlib4/Mathlib/Order/Hom/Lattice.lean b/mathlib4/Mathlib/Order/Hom/Lattice.lean index 8062a50ab..16faa3352 100644 --- a/mathlib4/Mathlib/Order/Hom/Lattice.lean +++ b/mathlib4/Mathlib/Order/Hom/Lattice.lean @@ -525,8 +525,11 @@ variable [Max α] [Max β] [Max γ] @[to_dual (attr := simps) /-- Reinterpret an infimum homomorphism as a supremum homomorphism between the dual lattices. -/] protected def dual : SupHom α β ≃ InfHom αᵒᵈ βᵒᵈ where - toFun f := ⟨f, f.map_sup'⟩ - invFun f := ⟨f, f.map_inf'⟩ + toFun f := ⟨fun a ↦ OrderDual.mk (f a.ofDual'), + fun a b ↦ congrArg OrderDual.mk (f.map_sup' a.ofDual' b.ofDual')⟩ + invFun f := ⟨fun a ↦ OrderDual.ofDual' (f (OrderDual.mk a)), + fun a b ↦ congrArg OrderDual.ofDual' + (f.map_inf' (OrderDual.mk a) (OrderDual.mk b))⟩ @[to_dual (attr := simp)] theorem dual_id : SupHom.dual (SupHom.id α) = InfHom.id _ := @@ -556,8 +559,10 @@ variable [Lattice α] [Lattice β] [Lattice γ] /-- Reinterpret a lattice homomorphism as a lattice homomorphism between the dual lattices. -/ @[simps!] protected def dual : LatticeHom α β ≃ LatticeHom αᵒᵈ βᵒᵈ where - toFun f := ⟨InfHom.dual f.toInfHom, f.map_sup'⟩ - invFun f := ⟨SupHom.dual.symm f.toInfHom, f.map_sup'⟩ + toFun f := ⟨InfHom.dual f.toInfHom, + fun a b ↦ congrArg OrderDual.mk (f.map_sup' a.ofDual' b.ofDual')⟩ + invFun f := ⟨SupHom.dual.symm f.toInfHom, fun a b ↦ congrArg OrderDual.ofDual' + (f.map_sup' (OrderDual.mk a) (OrderDual.mk b))⟩ @[simp] theorem dual_id : LatticeHom.dual (LatticeHom.id α) = LatticeHom.id _ := rfl diff --git a/mathlib4/Mathlib/Order/Hom/Set.lean b/mathlib4/Mathlib/Order/Hom/Set.lean index d71a3bf94..ae91db980 100644 --- a/mathlib4/Mathlib/Order/Hom/Set.lean +++ b/mathlib4/Mathlib/Order/Hom/Set.lean @@ -72,6 +72,15 @@ section LE variable [LE α] [LE β] +/-- Taking the order dual commutes with taking a subtype. -/ +@[simps! apply symm_apply] +def subtypeDual (p : α → Prop) : {x : αᵒᵈ // p (ofDual x)} ≃o {x : α // p x}ᵒᵈ where + toFun x := toDual ⟨ofDual x.1, x.2⟩ + invFun x := ⟨toDual (ofDual x).1, (ofDual x).2⟩ + left_inv _ := rfl + right_inv _ := rfl + map_rel_iff' := Iff.rfl + theorem range_eq (e : α ≃o β) : Set.range e = Set.univ := e.surjective.range_eq @@ -220,15 +229,13 @@ instance unique_of_wellFoundedLT [LinearOrder α] [WellFoundedLT α] : Unique ( instance subsingleton_of_wellFoundedGT [LinearOrder α] [WellFoundedGT α] [Preorder β] : Subsingleton (α ≃o β) := by - refine ⟨fun f g ↦ ?_⟩ - change f.dual.dual = g.dual.dual - rw [Subsingleton.elim f.dual] + refine ⟨fun f g ↦ DFunLike.ext _ _ fun x ↦ OrderDual.toDual_inj.1 <| + DFunLike.congr_fun (Subsingleton.elim f.dual g.dual) (OrderDual.toDual x)⟩ instance subsingleton_of_wellFoundedGT' [LinearOrder β] [WellFoundedGT β] [Preorder α] : Subsingleton (α ≃o β) := by - refine ⟨fun f g ↦ ?_⟩ - change f.dual.dual = g.dual.dual - rw [Subsingleton.elim f.dual] + refine ⟨fun f g ↦ DFunLike.ext _ _ fun x ↦ OrderDual.toDual_inj.1 <| + DFunLike.congr_fun (Subsingleton.elim f.dual g.dual) (OrderDual.toDual x)⟩ instance unique_of_wellFoundedGT [LinearOrder α] [WellFoundedGT α] : Unique (α ≃o α) := Unique.mk' _ diff --git a/mathlib4/Mathlib/Order/Interval/Basic.lean b/mathlib4/Mathlib/Order/Interval/Basic.lean index b47201fb7..616bd1b36 100644 --- a/mathlib4/Mathlib/Order/Interval/Basic.lean +++ b/mathlib4/Mathlib/Order/Interval/Basic.lean @@ -53,15 +53,16 @@ instance instCanLift : prf x hx := ⟨⟨x, hx⟩, rfl⟩ /-- The injection that induces the order on intervals. -/ -def toDualProd : NonemptyInterval α → αᵒᵈ × α := - toProd +def toDualProd (s : NonemptyInterval α) : αᵒᵈ × α := + (toDual s.fst, s.snd) @[simp] theorem toDualProd_apply (s : NonemptyInterval α) : s.toDualProd = (toDual s.fst, s.snd) := rfl -theorem toDualProd_injective : Injective (toDualProd : NonemptyInterval α → αᵒᵈ × α) := - toProd_injective +theorem toDualProd_injective : Injective (toDualProd : NonemptyInterval α → αᵒᵈ × α) := by + unsealing_newtype OrderDual => + exact toProd_injective instance [IsEmpty α] : IsEmpty (NonemptyInterval α) := ⟨fun s => isEmptyElim s.fst⟩ @@ -90,8 +91,10 @@ def toDualProdHom : NonemptyInterval α ↪o αᵒᵈ × α where /-- Turn an interval into an interval in the dual order. -/ def dual : NonemptyInterval α ≃ NonemptyInterval αᵒᵈ where - toFun s := ⟨s.toProd.swap, s.fst_le_snd⟩ - invFun s := ⟨s.toProd.swap, s.fst_le_snd⟩ + toFun s := ⟨(toDual s.snd, toDual s.fst), s.fst_le_snd⟩ + invFun s := ⟨(ofDual s.snd, ofDual s.fst), s.fst_le_snd⟩ + left_inv _ := rfl + right_inv _ := rfl @[simp] theorem fst_dual (s : NonemptyInterval α) : s.dual.fst = toDual s.snd := diff --git a/mathlib4/Mathlib/Order/Interval/Finset/Basic.lean b/mathlib4/Mathlib/Order/Interval/Finset/Basic.lean index b94b44cfe..043dbad1d 100644 --- a/mathlib4/Mathlib/Order/Interval/Finset/Basic.lean +++ b/mathlib4/Mathlib/Order/Interval/Finset/Basic.lean @@ -222,8 +222,8 @@ theorem Icc_subset_Ioo_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ioo a₂ b theorem Icc_subset_Ico_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ico a₂ b₂ ↔ a₂ ≤ a₁ ∧ b₁ < b₂ := by rw [← coe_subset, coe_Icc, coe_Ico, Set.Icc_subset_Ico_iff h₁] -theorem Icc_subset_Ioc_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ioc a₂ b₂ ↔ a₂ < a₁ ∧ b₁ ≤ b₂ := - (Icc_subset_Ico_iff h₁.dual).trans and_comm +theorem Icc_subset_Ioc_iff (h₁ : a₁ ≤ b₁) : Icc a₁ b₁ ⊆ Ioc a₂ b₂ ↔ a₂ < a₁ ∧ b₁ ≤ b₂ := by + rw [← coe_subset, coe_Icc, coe_Ioc, Set.Icc_subset_Ioc_iff h₁] --TODO: `Ico_subset_Ioo_iff`, `Ioc_subset_Ioo_iff` theorem Icc_ssubset_Icc_left (hI : a₂ ≤ b₂) (ha : a₂ < a₁) (hb : b₁ ≤ b₂) : @@ -394,7 +394,8 @@ section LocallyFiniteOrderBot variable [LocallyFiniteOrderBot α] @[simp] -theorem Iio_eq_empty : Iio a = ∅ ↔ IsMin a := Ioi_eq_empty (α := αᵒᵈ) +theorem Iio_eq_empty : Iio a = ∅ ↔ IsMin a := by + rw [← coe_eq_empty, coe_Iio, Set.Iio_eq_empty_iff] @[simp] alias ⟨_, _root_.IsMin.finsetIio_eq⟩ := Iio_eq_empty @@ -492,8 +493,9 @@ variable [LocallyFiniteOrderBot α] {a : α} theorem Iio_subset_Iic_self : Iio a ⊆ Iic a := by simpa [← coe_subset] using Set.Iio_subset_Iic_self -theorem _root_.BddAbove.finite {s : Set α} (hs : BddAbove s) : s.Finite := - hs.dual.finite +theorem _root_.BddAbove.finite {s : Set α} (hs : BddAbove s) : s.Finite := by + unsealing_newtype OrderDual => + exact hs.dual.finite theorem _root_.Set.Infinite.not_bddAbove {s : Set α} : s.Infinite → ¬BddAbove s := mt BddAbove.finite @@ -643,8 +645,11 @@ theorem card_Ico_eq_card_Icc_sub_one (a b : α) : #(Ico a b) = #(Icc a b) - 1 := exact (Nat.add_sub_cancel _ _).symm · rw [Ico_eq_empty fun h' => h h'.le, Icc_eq_empty h, card_empty, Nat.zero_sub] -theorem card_Ioc_eq_card_Icc_sub_one (a b : α) : #(Ioc a b) = #(Icc a b) - 1 := - @card_Ico_eq_card_Icc_sub_one αᵒᵈ _ _ _ _ +theorem card_Ioc_eq_card_Icc_sub_one (a b : α) : #(Ioc a b) = #(Icc a b) - 1 := by + by_cases h : a ≤ b + · rw [Icc_eq_cons_Ioc h, card_cons] + exact (Nat.add_sub_cancel _ _).symm + · rw [Ioc_eq_empty fun h' => h h'.le, Icc_eq_empty h, card_empty, Nat.zero_sub] theorem card_Ioo_eq_card_Ico_sub_one (a b : α) : #(Ioo a b) = #(Ico a b) - 1 := by by_cases h : a < b @@ -652,8 +657,11 @@ theorem card_Ioo_eq_card_Ico_sub_one (a b : α) : #(Ioo a b) = #(Ico a b) - 1 := exact (Nat.add_sub_cancel _ _).symm · rw [Ioo_eq_empty h, Ico_eq_empty h, card_empty, Nat.zero_sub] -theorem card_Ioo_eq_card_Ioc_sub_one (a b : α) : #(Ioo a b) = #(Ioc a b) - 1 := - @card_Ioo_eq_card_Ico_sub_one αᵒᵈ _ _ _ _ +theorem card_Ioo_eq_card_Ioc_sub_one (a b : α) : #(Ioo a b) = #(Ioc a b) - 1 := by + by_cases h : a < b + · rw [Ioc_eq_cons_Ioo h, card_cons] + exact (Nat.add_sub_cancel _ _).symm + · rw [Ioo_eq_empty h, Ioc_eq_empty h, card_empty, Nat.zero_sub] theorem card_Ioo_eq_card_Icc_sub_two (a b : α) : #(Ioo a b) = #(Icc a b) - 2 := by rw [card_Ioo_eq_card_Ico_sub_one, card_Ico_eq_card_Icc_sub_one] @@ -1160,19 +1168,22 @@ lemma strictMono_iff_forall_covBy [Preorder α] [LocallyFiniteOrder α] [Preorde /-- A function from a locally finite preorder is antitone if and only if it is antitone when restricted to pairs satisfying `a ⩿ b`. -/ lemma antitone_iff_forall_wcovBy [Preorder α] [LocallyFiniteOrder α] [Preorder β] - (f : α → β) : Antitone f ↔ ∀ a b : α, a ⩿ b → f b ≤ f a := - monotone_iff_forall_wcovBy (β := βᵒᵈ) f + (f : α → β) : Antitone f ↔ ∀ a b : α, a ⩿ b → f b ≤ f a := by + unsealing_newtype OrderDual => + exact monotone_iff_forall_wcovBy (β := βᵒᵈ) f /-- A function from a locally finite partial order is antitone if and only if it is antitone when restricted to pairs satisfying `a ⋖ b`. -/ lemma antitone_iff_forall_covBy [PartialOrder α] [LocallyFiniteOrder α] [Preorder β] - (f : α → β) : Antitone f ↔ ∀ a b : α, a ⋖ b → f b ≤ f a := - monotone_iff_forall_covBy (β := βᵒᵈ) f + (f : α → β) : Antitone f ↔ ∀ a b : α, a ⋖ b → f b ≤ f a := by + unsealing_newtype OrderDual => + exact monotone_iff_forall_covBy (β := βᵒᵈ) f /-- A function from a locally finite preorder is strictly antitone if and only if it is strictly antitone when restricted to pairs satisfying `a ⋖ b`. -/ lemma strictAnti_iff_forall_covBy [Preorder α] [LocallyFiniteOrder α] [Preorder β] - (f : α → β) : StrictAnti f ↔ ∀ a b : α, a ⋖ b → f b < f a := - strictMono_iff_forall_covBy (β := βᵒᵈ) f + (f : α → β) : StrictAnti f ↔ ∀ a b : α, a ⋖ b → f b < f a := by + unsealing_newtype OrderDual => + exact strictMono_iff_forall_covBy (β := βᵒᵈ) f end Cover diff --git a/mathlib4/Mathlib/Order/Interval/Finset/Defs.lean b/mathlib4/Mathlib/Order/Interval/Finset/Defs.lean index 03a818648..3e05c04f7 100644 --- a/mathlib4/Mathlib/Order/Interval/Finset/Defs.lean +++ b/mathlib4/Mathlib/Order/Interval/Finset/Defs.lean @@ -633,58 +633,59 @@ section LocallyFiniteOrder variable [LocallyFiniteOrder α] (a b : α) -/-- Note we define `Icc (toDual a) (toDual b)` as `Icc α _ _ b a` (which has type `Finset α` not -`Finset αᵒᵈ`!) instead of `(Icc b a).map toDual.toEmbedding` as this means the -following is defeq: -``` -lemma this : (Icc (toDual (toDual a)) (toDual (toDual b)) :) = (Icc a b :) := rfl -``` --/ +/-- Dual intervals transport their elements through `toDual`. +`Icc (toDual a) (toDual b)` equals `(Icc b a).map toDual.toEmbedding`; see `Finset.Icc_toDual`. -/ instance OrderDual.instLocallyFiniteOrder : LocallyFiniteOrder αᵒᵈ where - finsetIcc a b := @Icc α _ _ (ofDual b) (ofDual a) - finsetIco a b := @Ioc α _ _ (ofDual b) (ofDual a) - finsetIoc a b := @Ico α _ _ (ofDual b) (ofDual a) - finsetIoo a b := @Ioo α _ _ (ofDual b) (ofDual a) - finset_mem_Icc _ _ _ := (mem_Icc (α := α)).trans and_comm - finset_mem_Ico _ _ _ := (mem_Ioc (α := α)).trans and_comm - finset_mem_Ioc _ _ _ := (mem_Ico (α := α)).trans and_comm - finset_mem_Ioo _ _ _ := (mem_Ioo (α := α)).trans and_comm + finsetIcc a b := (@Icc α _ _ (ofDual b) (ofDual a)).map toDual.toEmbedding + finsetIco a b := (@Ioc α _ _ (ofDual b) (ofDual a)).map toDual.toEmbedding + finsetIoc a b := (@Ico α _ _ (ofDual b) (ofDual a)).map toDual.toEmbedding + finsetIoo a b := (@Ioo α _ _ (ofDual b) (ofDual a)).map toDual.toEmbedding + finset_mem_Icc _ _ _ := mem_map_equiv.trans <| (mem_Icc (α := α)).trans and_comm + finset_mem_Ico _ _ _ := mem_map_equiv.trans <| (mem_Ioc (α := α)).trans and_comm + finset_mem_Ioc _ _ _ := mem_map_equiv.trans <| (mem_Ico (α := α)).trans and_comm + finset_mem_Ioo _ _ _ := mem_map_equiv.trans <| (mem_Ioo (α := α)).trans and_comm @[to_dual self] lemma Finset.Icc_orderDual_def (a b : αᵒᵈ) : - Icc a b = (Icc (ofDual b) (ofDual a)).map toDual.toEmbedding := map_refl.symm + Icc a b = (Icc (ofDual b) (ofDual a)).map toDual.toEmbedding := rfl @[to_dual (reorder := a b)] lemma Finset.Ico_orderDual_def (a b : αᵒᵈ) : - Ico a b = (Ioc (ofDual b) (ofDual a)).map toDual.toEmbedding := map_refl.symm + Ico a b = (Ioc (ofDual b) (ofDual a)).map toDual.toEmbedding := rfl @[to_dual self] lemma Finset.Ioo_orderDual_def (a b : αᵒᵈ) : - Ioo a b = (Ioo (ofDual b) (ofDual a)).map toDual.toEmbedding := map_refl.symm + Ioo a b = (Ioo (ofDual b) (ofDual a)).map toDual.toEmbedding := rfl @[to_dual self] -lemma Finset.Icc_toDual : Icc (toDual a) (toDual b) = (Icc b a).map toDual.toEmbedding := - map_refl.symm +lemma Finset.Icc_toDual : Icc (toDual a) (toDual b) = (Icc b a).map toDual.toEmbedding := rfl @[to_dual (reorder := a b)] -lemma Finset.Ico_toDual : Ico (toDual a) (toDual b) = (Ioc b a).map toDual.toEmbedding := - map_refl.symm +lemma Finset.Ico_toDual : Ico (toDual a) (toDual b) = (Ioc b a).map toDual.toEmbedding := rfl @[to_dual self] -lemma Finset.Ioo_toDual : Ioo (toDual a) (toDual b) = (Ioo b a).map toDual.toEmbedding := - map_refl.symm +lemma Finset.Ioo_toDual : Ioo (toDual a) (toDual b) = (Ioo b a).map toDual.toEmbedding := rfl @[to_dual self] lemma Finset.Icc_ofDual (a b : αᵒᵈ) : - Icc (ofDual a) (ofDual b) = (Icc b a).map ofDual.toEmbedding := map_refl.symm + Icc (ofDual a) (ofDual b) = (Icc b a).map ofDual.toEmbedding := by + unsealing_newtype OrderDual => + rw [Finset.Icc_orderDual_def, Finset.map_map] + exact map_refl.symm @[to_dual (reorder := a b)] lemma Finset.Ico_ofDual (a b : αᵒᵈ) : - Ico (ofDual a) (ofDual b) = (Ioc b a).map ofDual.toEmbedding := map_refl.symm + Ico (ofDual a) (ofDual b) = (Ioc b a).map ofDual.toEmbedding := by + unsealing_newtype OrderDual => + rw [Finset.Ioc_orderDual_def, Finset.map_map] + exact map_refl.symm @[to_dual self] lemma Finset.Ioo_ofDual (a b : αᵒᵈ) : - Ioo (ofDual a) (ofDual b) = (Ioo b a).map ofDual.toEmbedding := map_refl.symm + Ioo (ofDual a) (ofDual b) = (Ioo b a).map ofDual.toEmbedding := by + unsealing_newtype OrderDual => + rw [Finset.Ioo_orderDual_def, Finset.map_map] + exact map_refl.symm end LocallyFiniteOrder @@ -692,46 +693,40 @@ section LocallyFiniteOrderTop variable [LocallyFiniteOrderTop α] -/-- Note we define `Iic (toDual a)` as `Ici a` (which has type `Finset α` not `Finset αᵒᵈ`!) -instead of `(Ici a).map toDual.toEmbedding` as this means the following is defeq: -``` -lemma this : (Iic (toDual (toDual a)) :) = (Iic a :) := rfl -``` --/ +/-- Dual intervals transport their elements through `toDual`. +`Iic (toDual a)` equals `(Ici a).map toDual.toEmbedding`; see `Finset.Iic_toDual`. -/ @[to_dual -/-- Note we define `Ici (toDual a)` as `Iic a` (which has type `Finset α` not `Finset αᵒᵈ`!) -instead of `(Iic a).map toDual.toEmbedding` as this means the following is defeq: -``` -lemma this : (Ici (toDual (toDual a)) :) = (Ici a :) := rfl -``` --/] +/-- Dual intervals transport their elements through `toDual`. +`Ici (toDual a)` equals `(Iic a).map toDual.toEmbedding`; see `Finset.Ici_toDual`. -/] instance OrderDual.instLocallyFiniteOrderBot : LocallyFiniteOrderBot αᵒᵈ where - finsetIic a := @Ici α _ _ (ofDual a) - finsetIio a := @Ioi α _ _ (ofDual a) - finset_mem_Iic _ _ := mem_Ici (α := α) - finset_mem_Iio _ _ := mem_Ioi (α := α) + finsetIic a := (@Ici α _ _ (ofDual a)).map toDual.toEmbedding + finsetIio a := (@Ioi α _ _ (ofDual a)).map toDual.toEmbedding + finset_mem_Iic _ _ := mem_map_equiv.trans <| mem_Ici (α := α) + finset_mem_Iio _ _ := mem_map_equiv.trans <| mem_Ioi (α := α) @[to_dual] -lemma Iic_orderDual_def (a : αᵒᵈ) : Iic a = (Ici (ofDual a)).map toDual.toEmbedding := map_refl.symm +lemma Iic_orderDual_def (a : αᵒᵈ) : Iic a = (Ici (ofDual a)).map toDual.toEmbedding := rfl @[to_dual] -lemma Iio_orderDual_def (a : αᵒᵈ) : Iio a = (Ioi (ofDual a)).map toDual.toEmbedding := map_refl.symm +lemma Iio_orderDual_def (a : αᵒᵈ) : Iio a = (Ioi (ofDual a)).map toDual.toEmbedding := rfl @[to_dual] -lemma Finset.Iic_toDual (a : α) : Iic (toDual a) = (Ici a).map toDual.toEmbedding := - map_refl.symm +lemma Finset.Iic_toDual (a : α) : Iic (toDual a) = (Ici a).map toDual.toEmbedding := rfl @[to_dual] -lemma Finset.Iio_toDual (a : α) : Iio (toDual a) = (Ioi a).map toDual.toEmbedding := - map_refl.symm +lemma Finset.Iio_toDual (a : α) : Iio (toDual a) = (Ioi a).map toDual.toEmbedding := rfl @[to_dual] -lemma Finset.Ici_ofDual (a : αᵒᵈ) : Ici (ofDual a) = (Iic a).map ofDual.toEmbedding := - map_refl.symm +lemma Finset.Ici_ofDual (a : αᵒᵈ) : Ici (ofDual a) = (Iic a).map ofDual.toEmbedding := by + unsealing_newtype OrderDual => + rw [Iic_orderDual_def, Finset.map_map] + exact map_refl.symm @[to_dual] -lemma Finset.Ioi_ofDual (a : αᵒᵈ) : Ioi (ofDual a) = (Iio a).map ofDual.toEmbedding := - map_refl.symm +lemma Finset.Ioi_ofDual (a : αᵒᵈ) : Ioi (ofDual a) = (Iio a).map ofDual.toEmbedding := by + unsealing_newtype OrderDual => + rw [Iio_orderDual_def, Finset.map_map] + exact map_refl.symm end LocallyFiniteOrderTop diff --git a/mathlib4/Mathlib/Order/Interval/Lex.lean b/mathlib4/Mathlib/Order/Interval/Lex.lean index bff42d5b1..f8bcc60c8 100644 --- a/mathlib4/Mathlib/Order/Interval/Lex.lean +++ b/mathlib4/Mathlib/Order/Interval/Lex.lean @@ -35,12 +35,14 @@ instance : LT (Lex (NonemptyInterval α)) where lt x y := toLex (ofLex x).toDualProd < toLex (ofLex y).toDualProd theorem toLex_le_toLex {x y : NonemptyInterval α} : - toLex x ≤ toLex y ↔ y.fst < x.fst ∨ x.fst = y.fst ∧ x.snd ≤ y.snd := - Prod.lex_def + toLex x ≤ toLex y ↔ y.fst < x.fst ∨ x.fst = y.fst ∧ x.snd ≤ y.snd := by + unsealing_newtype OrderDual => + exact Prod.lex_def theorem toLex_lt_toLex {x y : NonemptyInterval α} : - toLex x < toLex y ↔ y.fst < x.fst ∨ x.fst = y.fst ∧ x.snd < y.snd := - Prod.lex_def + toLex x < toLex y ↔ y.fst < x.fst ∨ x.fst = y.fst ∧ x.snd < y.snd := by + unsealing_newtype OrderDual => + exact Prod.lex_def instance [DecidableEq α] [DecidableLT α] [DecidableLE α] : DecidableLE (Lex (NonemptyInterval α)) := fun _ _ => decidable_of_iff' _ toLex_le_toLex @@ -75,10 +77,19 @@ instance [PartialOrder α] : PartialOrder (Lex (NonemptyInterval α)) := fast_in toLex.injective.comp <| toDualProd_injective.comp ofLex.injective instance [LinearOrder α] : LinearOrder (Lex (NonemptyInterval α)) := fast_instance% - { LinearOrder.lift' (fun x : Lex (NonemptyInterval α) => toLex (ofLex x).toDualProd) <| - toLex.injective.comp <| toDualProd_injective.comp ofLex.injective with + let base : LinearOrder (Lex (NonemptyInterval α)) := + LinearOrder.lift' (fun x : Lex (NonemptyInterval α) => toLex (ofLex x).toDualProd) <| + toLex.injective.comp <| toDualProd_injective.comp ofLex.injective + { base with toDecidableEq := inferInstance toDecidableLT := inferInstance - toDecidableLE := inferInstance } + toDecidableLE := inferInstance + min_def a b := (base.min_def a b).trans + (congrArg (fun d => @ite _ (a ≤ b) d a b) (Subsingleton.elim _ _)) + max_def a b := (base.max_def a b).trans + (congrArg (fun d => @ite _ (a ≤ b) d b a) (Subsingleton.elim _ _)) + compare_eq_compareOfLessAndEq a b := by + rw [base.compare_eq_compareOfLessAndEq] + congr 1 } end NonemptyInterval diff --git a/mathlib4/Mathlib/Order/Interval/Set/Disjoint.lean b/mathlib4/Mathlib/Order/Interval/Set/Disjoint.lean index c6c0c7c71..714baf744 100644 --- a/mathlib4/Mathlib/Order/Interval/Set/Disjoint.lean +++ b/mathlib4/Mathlib/Order/Interval/Set/Disjoint.lean @@ -122,8 +122,9 @@ theorem Ico_disjoint_Ico : Disjoint (Ico a₁ a₂) (Ico b₁ b₂) ↔ min a₂ @[simp] theorem Ioc_disjoint_Ioc : Disjoint (Ioc a₁ a₂) (Ioc b₁ b₂) ↔ min a₂ b₂ ≤ max a₁ b₁ := by - have h : _ ↔ min (toDual a₁) (toDual b₁) ≤ max (toDual a₂) (toDual b₂) := Ico_disjoint_Ico - simpa only [Ico_toDual] using! h + unsealing_newtype OrderDual => + have h : _ ↔ min (toDual a₁) (toDual b₁) ≤ max (toDual a₂) (toDual b₂) := Ico_disjoint_Ico + simpa only [Ico_toDual] using! h @[simp] theorem Ioo_disjoint_Ioo [DenselyOrdered α] : @@ -215,11 +216,13 @@ theorem IsGLB.biUnion_Ioi_eq (h : IsGLB s a) : ⋃ x ∈ s, Ioi x = Ioi a := by theorem IsGLB.iUnion_Ioi_eq (h : IsGLB (range f) a) : ⋃ x, Ioi (f x) = Ioi a := biUnion_range.symm.trans h.biUnion_Ioi_eq -theorem IsLUB.biUnion_Iio_eq (h : IsLUB s a) : ⋃ x ∈ s, Iio x = Iio a := - h.dual.biUnion_Ioi_eq +theorem IsLUB.biUnion_Iio_eq (h : IsLUB s a) : ⋃ x ∈ s, Iio x = Iio a := by + unsealing_newtype OrderDual => + exact h.dual.biUnion_Ioi_eq -theorem IsLUB.iUnion_Iio_eq (h : IsLUB (range f) a) : ⋃ x, Iio (f x) = Iio a := - h.dual.iUnion_Ioi_eq +theorem IsLUB.iUnion_Iio_eq (h : IsLUB (range f) a) : ⋃ x, Iio (f x) = Iio a := by + unsealing_newtype OrderDual => + exact h.dual.iUnion_Ioi_eq theorem iUnion_Ioi_eq_Ioi_iInf {R : Type*} [CompleteLinearOrder R] {f : ι → R} : ⋃ i : ι, Ioi (f i) = Ioi (⨅ i, f i) := @@ -238,8 +241,9 @@ theorem IsGLB.biUnion_Ici_eq_Ioi (a_glb : IsGLB s a) (a_notMem : a ∉ s) : exact ⟨y, hys, hyx.le⟩ theorem IsLUB.biUnion_Iic_eq_Iio (a_lub : IsLUB s a) (a_notMem : a ∉ s) : - ⋃ x ∈ s, Iic x = Iio a := - a_lub.dual.biUnion_Ici_eq_Ioi a_notMem + ⋃ x ∈ s, Iic x = Iio a := by + unsealing_newtype OrderDual => + exact a_lub.dual.biUnion_Ici_eq_Ioi a_notMem theorem iUnion_Ici_eq_Ioi_iInf {R : Type*} [CompleteLinearOrder R] {f : ι → R} (no_least_elem : ⨅ i, f i ∉ range f) : ⋃ i : ι, Ici (f i) = Ioi (⨅ i, f i) := by @@ -247,16 +251,18 @@ theorem iUnion_Ici_eq_Ioi_iInf {R : Type*} [CompleteLinearOrder R] {f : ι → R iUnion_exists, iUnion_iUnion_eq'] theorem iUnion_Iic_eq_Iio_iSup {R : Type*} [CompleteLinearOrder R] {f : ι → R} - (no_greatest_elem : (⨆ i, f i) ∉ range f) : ⋃ i : ι, Iic (f i) = Iio (⨆ i, f i) := - @iUnion_Ici_eq_Ioi_iInf ι (OrderDual R) _ f no_greatest_elem + (no_greatest_elem : (⨆ i, f i) ∉ range f) : ⋃ i : ι, Iic (f i) = Iio (⨆ i, f i) := by + unsealing_newtype OrderDual => + exact @iUnion_Ici_eq_Ioi_iInf ι (OrderDual R) _ f no_greatest_elem theorem iUnion_Ici_eq_Ici_iInf {R : Type*} [CompleteLattice R] {f : ι → R} (has_least_elem : (⨅ i, f i) ∈ range f) : ⋃ i : ι, Ici (f i) = Ici (⨅ i, f i) := by simp [← isGLB_iInf.isLeast has_least_elem |>.biUnion_Ici_eq_Ici] theorem iUnion_Iic_eq_Iic_iSup {R : Type*} [CompleteLattice R] {f : ι → R} - (has_greatest_elem : (⨆ i, f i) ∈ range f) : ⋃ i : ι, Iic (f i) = Iic (⨆ i, f i) := - @iUnion_Ici_eq_Ici_iInf ι (OrderDual R) _ f has_greatest_elem + (has_greatest_elem : (⨆ i, f i) ∈ range f) : ⋃ i : ι, Iic (f i) = Iic (⨆ i, f i) := by + unsealing_newtype OrderDual => + exact @iUnion_Ici_eq_Ici_iInf ι (OrderDual R) _ f has_greatest_elem theorem iUnion_Iio_eq_univ_iff : ⋃ i, Iio (f i) = univ ↔ (¬ BddAbove (range f)) := by simp [not_bddAbove_iff, Set.eq_univ_iff_forall] diff --git a/mathlib4/Mathlib/Order/Interval/Set/Image.lean b/mathlib4/Mathlib/Order/Interval/Set/Image.lean index ffc683e03..a74cfae31 100644 --- a/mathlib4/Mathlib/Order/Interval/Set/Image.lean +++ b/mathlib4/Mathlib/Order/Interval/Set/Image.lean @@ -323,12 +323,14 @@ lemma image_subtype_val_Iic_Ioi {a : α} (b : Iic a) : Subtype.val '' Ioi b = Io (Subtype.image_preimage_val (Iic a) (Ioi b)).trans <| inter_comm _ _ @[simp] -lemma image_subtype_val_Iic_Iic {a : α} (b : Iic a) : Subtype.val '' Iic b = Iic b.1 := - image_subtype_val_Ici_Ici (α := αᵒᵈ) _ +lemma image_subtype_val_Iic_Iic {a : α} (b : Iic a) : Subtype.val '' Iic b = Iic b.1 := by + unsealing_newtype OrderDual => + exact image_subtype_val_Ici_Ici (α := αᵒᵈ) _ @[simp] -lemma image_subtype_val_Iic_Iio {a : α} (b : Iic a) : Subtype.val '' Iio b = Iio b.1 := - image_subtype_val_Ici_Ioi (α := αᵒᵈ) _ +lemma image_subtype_val_Iic_Iio {a : α} (b : Iic a) : Subtype.val '' Iio b = Iio b.1 := by + unsealing_newtype OrderDual => + exact image_subtype_val_Ici_Ioi (α := αᵒᵈ) _ @[simp] lemma image_subtype_val_Ioi_Ici {a : α} (b : Ioi a) : Subtype.val '' Ici b = Ici b.1 := @@ -351,16 +353,18 @@ lemma image_subtype_val_Iio_Ici {a : α} (b : Iio a) : Subtype.val '' Ici b = Ic (Subtype.image_preimage_val (Iio a) (Ici b)).trans <| inter_comm _ _ @[simp] -lemma image_subtype_val_Iio_Iic {a : α} (b : Iio a) : Subtype.val '' Iic b = Iic b.1 := - image_subtype_val_Ioi_Ici (α := αᵒᵈ) _ +lemma image_subtype_val_Iio_Iic {a : α} (b : Iio a) : Subtype.val '' Iic b = Iic b.1 := by + unsealing_newtype OrderDual => + exact image_subtype_val_Ioi_Ici (α := αᵒᵈ) _ @[simp] lemma image_subtype_val_Iio_Ioi {a : α} (b : Iio a) : Subtype.val '' Ioi b = Ioo b.1 a := (Subtype.image_preimage_val (Iio a) (Ioi b)).trans <| inter_comm _ _ @[simp] -lemma image_subtype_val_Iio_Iio {a : α} (b : Iio a) : Subtype.val '' Iio b = Iio b.1 := - image_subtype_val_Ioi_Ioi (α := αᵒᵈ) _ +lemma image_subtype_val_Iio_Iio {a : α} (b : Iio a) : Subtype.val '' Iio b = Iio b.1 := by + unsealing_newtype OrderDual => + exact image_subtype_val_Ioi_Ioi (α := αᵒᵈ) _ @[simp] lemma image_subtype_val_Icc_Ici {a b : α} (c : Icc a b) : Subtype.val '' Ici c = Icc c.1 b := diff --git a/mathlib4/Mathlib/Order/Interval/Set/Infinite.lean b/mathlib4/Mathlib/Order/Interval/Set/Infinite.lean index 53b12688a..5e343c063 100644 --- a/mathlib4/Mathlib/Order/Interval/Set/Infinite.lean +++ b/mathlib4/Mathlib/Order/Interval/Set/Infinite.lean @@ -28,7 +28,7 @@ instance NoMaxOrder.infinite [Nonempty α] [NoMaxOrder α] : Infinite α := /-- A nonempty preorder with no minimal element is infinite. -/ instance NoMinOrder.infinite [Nonempty α] [NoMinOrder α] : Infinite α := - @NoMaxOrder.infinite αᵒᵈ _ _ _ + Infinite.of_injective (β := αᵒᵈ) OrderDual.ofDual' OrderDual.ofDual.injective namespace Set diff --git a/mathlib4/Mathlib/Order/Interval/Set/LinearOrder.lean b/mathlib4/Mathlib/Order/Interval/Set/LinearOrder.lean index 3f53bfb27..72c6e7f8a 100644 --- a/mathlib4/Mathlib/Order/Interval/Set/LinearOrder.lean +++ b/mathlib4/Mathlib/Order/Interval/Set/LinearOrder.lean @@ -75,7 +75,8 @@ theorem Ico_subset_Ico_iff (h₁ : a₁ < b₁) : Ico a₁ b₁ ⊆ Ico a₂ b fun ⟨h₁, h₂⟩ => Ico_subset_Ico h₁ h₂⟩ theorem Ioc_subset_Ioc_iff (h₁ : a₁ < b₁) : Ioc a₁ b₁ ⊆ Ioc a₂ b₂ ↔ b₁ ≤ b₂ ∧ a₂ ≤ a₁ := by - convert! @Ico_subset_Ico_iff αᵒᵈ _ b₁ b₂ a₁ a₂ h₁ using 2 <;> exact (@Ico_toDual α _ _ _).symm + unsealing_newtype OrderDual => + convert! @Ico_subset_Ico_iff αᵒᵈ _ b₁ b₂ a₁ a₂ h₁ using 2 <;> exact (@Ico_toDual α _ _ _).symm theorem Ico_eq_Ico_iff (h : a < b ∨ c < d) : Ico a b = Ico c d ↔ a = c ∧ b = d := by refine ⟨fun h ↦ ?_, by grind⟩ diff --git a/mathlib4/Mathlib/Order/Interval/Set/Monotone.lean b/mathlib4/Mathlib/Order/Interval/Set/Monotone.lean index 406941b6b..13dcfc6d3 100644 --- a/mathlib4/Mathlib/Order/Interval/Set/Monotone.lean +++ b/mathlib4/Mathlib/Order/Interval/Set/Monotone.lean @@ -174,16 +174,22 @@ theorem strictMonoOn_Iic_of_lt_succ [SuccOrder α] [IsSuccArchimedean α] {n : hψ _ <| (succ_le_iff_of_not_isMax ha').1 ha theorem strictAntiOn_Iic_of_succ_lt [SuccOrder α] [IsSuccArchimedean α] {n : α} - (hψ : ∀ m, m < n → ψ (succ m) < ψ m) : StrictAntiOn ψ (Set.Iic n) := fun i hi j hj hij => - @strictMonoOn_Iic_of_lt_succ α βᵒᵈ _ _ ψ _ _ n hψ i hi j hj hij + (hψ : ∀ m, m < n → ψ (succ m) < ψ m) : StrictAntiOn ψ (Set.Iic n) := by + unsealing_newtype OrderDual => + exact fun i hi j hj hij => + @strictMonoOn_Iic_of_lt_succ α βᵒᵈ _ _ ψ _ _ n hψ i hi j hj hij theorem strictMonoOn_Ici_of_pred_lt [PredOrder α] [IsPredArchimedean α] {n : α} - (hψ : ∀ m, n < m → ψ (pred m) < ψ m) : StrictMonoOn ψ (Set.Ici n) := fun i hi j hj hij => - @strictMonoOn_Iic_of_lt_succ αᵒᵈ βᵒᵈ _ _ ψ _ _ n hψ j hj i hi hij + (hψ : ∀ m, n < m → ψ (pred m) < ψ m) : StrictMonoOn ψ (Set.Ici n) := by + unsealing_newtype OrderDual => + exact fun i hi j hj hij => + @strictMonoOn_Iic_of_lt_succ αᵒᵈ βᵒᵈ _ _ ψ _ _ n hψ j hj i hi hij theorem strictAntiOn_Ici_of_lt_pred [PredOrder α] [IsPredArchimedean α] {n : α} - (hψ : ∀ m, n < m → ψ m < ψ (pred m)) : StrictAntiOn ψ (Set.Ici n) := fun i hi j hj hij => - @strictAntiOn_Iic_of_succ_lt αᵒᵈ βᵒᵈ _ _ ψ _ _ n hψ j hj i hi hij + (hψ : ∀ m, n < m → ψ m < ψ (pred m)) : StrictAntiOn ψ (Set.Ici n) := by + unsealing_newtype OrderDual => + exact fun i hi j hj hij => + @strictAntiOn_Iic_of_succ_lt αᵒᵈ βᵒᵈ _ _ ψ _ _ n hψ j hj i hi hij end SuccOrder @@ -211,7 +217,8 @@ theorem StrictMonoOn.Iic_id_le [SuccOrder α] [IsSuccArchimedean α] [OrderBot · exact ih (StrictMonoOn.mono hφ fun x hx => le_trans hx (le_succ _)) _ h theorem StrictMonoOn.Ici_le_id [PredOrder α] [IsPredArchimedean α] [OrderTop α] {n : α} {φ : α → α} - (hφ : StrictMonoOn φ (Set.Ici n)) : ∀ m, n ≤ m → φ m ≤ m := - StrictMonoOn.Iic_id_le (α := αᵒᵈ) fun _ hi _ hj hij => hφ hj hi hij + (hφ : StrictMonoOn φ (Set.Ici n)) : ∀ m, n ≤ m → φ m ≤ m := by + unsealing_newtype OrderDual => + exact StrictMonoOn.Iic_id_le (α := αᵒᵈ) fun _ hi _ hj hij => hφ hj hi hij end LinearOrder diff --git a/mathlib4/Mathlib/Order/Interval/Set/OrdConnected.lean b/mathlib4/Mathlib/Order/Interval/Set/OrdConnected.lean index c68e7fe02..ad45bb7b2 100644 --- a/mathlib4/Mathlib/Order/Interval/Set/OrdConnected.lean +++ b/mathlib4/Mathlib/Order/Interval/Set/OrdConnected.lean @@ -136,8 +136,9 @@ theorem dual_ordConnected {s : Set α} [OrdConnected s] : OrdConnected (ofDual .dual ‹OrdConnected s› @[simp] -theorem ordConnected_dual {s : Set α} : OrdConnected (OrderDual.ofDual ⁻¹' s) ↔ OrdConnected s := - ⟨fun h => by simpa only [ordConnected_def] using! h.dual, fun h => h.dual⟩ +theorem ordConnected_dual {s : Set α} : OrdConnected (OrderDual.ofDual ⁻¹' s) ↔ OrdConnected s := by + unsealing_newtype OrderDual => + exact ⟨fun h => by simpa only [ordConnected_def] using! h.dual, fun h => h.dual⟩ theorem ordConnected_sInter {S : Set (Set α)} (hS : ∀ s ∈ S, OrdConnected s) : OrdConnected (⋂₀ S) := diff --git a/mathlib4/Mathlib/Order/Interval/Set/OrdConnectedComponent.lean b/mathlib4/Mathlib/Order/Interval/Set/OrdConnectedComponent.lean index 2e36d4d06..092edbe3e 100644 --- a/mathlib4/Mathlib/Order/Interval/Set/OrdConnectedComponent.lean +++ b/mathlib4/Mathlib/Order/Interval/Set/OrdConnectedComponent.lean @@ -124,15 +124,6 @@ range of `Set.ordConnectedProj s`. -/ noncomputable def ordConnectedSection (s : Set α) : Set α := range <| ordConnectedProj s -theorem dual_ordConnectedSection (s : Set α) : - ordConnectedSection (ofDual ⁻¹' s) = ofDual ⁻¹' ordConnectedSection s := by - simp only [ordConnectedSection] - simp +unfoldPartialApp only [ordConnectedProj] - ext x - simp only [mem_range, Subtype.exists, mem_preimage, OrderDual.exists, dual_ordConnectedComponent, - ofDual_toDual] - tauto - theorem ordConnectedSection_subset : ordConnectedSection s ⊆ s := range_subset_iff.2 fun _ => ordConnectedComponent_subset <| Nonempty.some_mem _ diff --git a/mathlib4/Mathlib/Order/Interval/Set/SurjOn.lean b/mathlib4/Mathlib/Order/Interval/Set/SurjOn.lean index e8dba317e..8e9f565ad 100644 --- a/mathlib4/Mathlib/Order/Interval/Set/SurjOn.lean +++ b/mathlib4/Mathlib/Order/Interval/Set/SurjOn.lean @@ -46,7 +46,8 @@ theorem surjOn_Ico_of_monotone_surjective (h_mono : Monotone f) (h_surj : Functi theorem surjOn_Ioc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) (a b : α) : SurjOn f (Ioc a b) (Ioc (f a) (f b)) := by - simpa using! surjOn_Ico_of_monotone_surjective h_mono.dual h_surj (toDual b) (toDual a) + unsealing_newtype OrderDual => + simpa using! surjOn_Ico_of_monotone_surjective h_mono.dual h_surj (toDual b) (toDual a) -- to see that the hypothesis `a ≤ b` is necessary, consider a constant function theorem surjOn_Icc_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) @@ -65,8 +66,9 @@ theorem surjOn_Ioi_of_monotone_surjective (h_mono : Monotone f) (h_surj : Functi exact fun x hx => (h_mono hx).not_gt theorem surjOn_Iio_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) - (a : α) : SurjOn f (Iio a) (Iio (f a)) := - @surjOn_Ioi_of_monotone_surjective _ _ _ _ _ h_mono.dual h_surj a + (a : α) : SurjOn f (Iio a) (Iio (f a)) := by + unsealing_newtype OrderDual => + exact @surjOn_Ioi_of_monotone_surjective _ _ _ _ _ h_mono.dual h_surj a theorem surjOn_Ici_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) (a : α) : SurjOn f (Ici a) (Ici (f a)) := by @@ -76,5 +78,6 @@ theorem surjOn_Ici_of_monotone_surjective (h_mono : Monotone f) (h_surj : Functi (@image_singleton _ _ f a ▸ surjOn_image _ _) theorem surjOn_Iic_of_monotone_surjective (h_mono : Monotone f) (h_surj : Function.Surjective f) - (a : α) : SurjOn f (Iic a) (Iic (f a)) := - @surjOn_Ici_of_monotone_surjective _ _ _ _ _ h_mono.dual h_surj a + (a : α) : SurjOn f (Iic a) (Iic (f a)) := by + unsealing_newtype OrderDual => + exact @surjOn_Ici_of_monotone_surjective _ _ _ _ _ h_mono.dual h_surj a diff --git a/mathlib4/Mathlib/Order/Irreducible.lean b/mathlib4/Mathlib/Order/Irreducible.lean index bf95ed227..15140cb02 100644 --- a/mathlib4/Mathlib/Order/Irreducible.lean +++ b/mathlib4/Mathlib/Order/Irreducible.lean @@ -153,20 +153,24 @@ section SemilatticeSup variable [SemilatticeSup α] @[to_dual (attr := simp)] -theorem infIrred_toDual {a : α} : InfIrred (toDual a) ↔ SupIrred a := - Iff.rfl +theorem infIrred_toDual {a : α} : InfIrred (toDual a) ↔ SupIrred a := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual (attr := simp)] -theorem infPrime_toDual {a : α} : InfPrime (toDual a) ↔ SupPrime a := - Iff.rfl +theorem infPrime_toDual {a : α} : InfPrime (toDual a) ↔ SupPrime a := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual (attr := simp)] -theorem supIrred_ofDual {a : αᵒᵈ} : SupIrred (ofDual a) ↔ InfIrred a := - Iff.rfl +theorem supIrred_ofDual {a : αᵒᵈ} : SupIrred (ofDual a) ↔ InfIrred a := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual (attr := simp)] -theorem supPrime_ofDual {a : αᵒᵈ} : SupPrime (ofDual a) ↔ InfPrime a := - Iff.rfl +theorem supPrime_ofDual {a : αᵒᵈ} : SupPrime (ofDual a) ↔ InfPrime a := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual] alias ⟨_, SupIrred.dual⟩ := infIrred_toDual diff --git a/mathlib4/Mathlib/Order/Iterate.lean b/mathlib4/Mathlib/Order/Iterate.lean index 8676addad..c611c88f0 100644 --- a/mathlib4/Mathlib/Order/Iterate.lean +++ b/mathlib4/Mathlib/Order/Iterate.lean @@ -21,7 +21,7 @@ a circle homeomorphism. public section -open Function +open Function OrderDual open Function (Commute) @@ -65,8 +65,9 @@ theorem seq_pos_lt_seq_of_lt_of_le (hf : Monotone f) {n : ℕ} (hn : 0 < n) (h exact hk.trans n.succ.lt_succ_self theorem seq_pos_lt_seq_of_le_of_lt (hf : Monotone f) {n : ℕ} (hn : 0 < n) (h₀ : x 0 ≤ y 0) - (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) < y (k + 1)) : x n < y n := - hf.dual.seq_pos_lt_seq_of_lt_of_le hn h₀ hy hx + (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) < y (k + 1)) : x n < y n := by + unsealing_newtype OrderDual => + exact hf.dual.seq_pos_lt_seq_of_lt_of_le hn h₀ hy hx theorem seq_lt_seq_of_lt_of_le (hf : Monotone f) (n : ℕ) (h₀ : x 0 < y 0) (hx : ∀ k < n, x (k + 1) < f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n < y n := by @@ -74,8 +75,9 @@ theorem seq_lt_seq_of_lt_of_le (hf : Monotone f) (n : ℕ) (h₀ : x 0 < y 0) exacts [h₀, hf.seq_pos_lt_seq_of_lt_of_le (Nat.zero_lt_succ _) h₀.le hx hy] theorem seq_lt_seq_of_le_of_lt (hf : Monotone f) (n : ℕ) (h₀ : x 0 < y 0) - (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) < y (k + 1)) : x n < y n := - hf.dual.seq_lt_seq_of_lt_of_le n h₀ hy hx + (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) < y (k + 1)) : x n < y n := by + unsealing_newtype OrderDual => + exact hf.dual.seq_lt_seq_of_lt_of_le n h₀ hy hx /-! ### Iterates of two functions @@ -130,8 +132,10 @@ theorem monotone_iterate_of_id_le (h : id ≤ f) : Monotone fun m => f^[m] := rw [iterate_succ_apply'] exact h _ -theorem antitone_iterate_of_le_id (h : f ≤ id) : Antitone fun m => f^[m] := fun m n hmn => - @monotone_iterate_of_id_le αᵒᵈ _ f h m n hmn +theorem antitone_iterate_of_le_id (h : f ≤ id) : Antitone fun m => f^[m] := by + unsealing_newtype OrderDual => + exact fun m n hmn => + @monotone_iterate_of_id_le αᵒᵈ _ f h m n hmn end Preorder @@ -165,8 +169,9 @@ theorem iterate_pos_lt_of_map_lt (h : Commute f g) (hf : Monotone f) (hg : Stric · simp [h.iterate_right _ _, hg.iterate _ hx] theorem iterate_pos_lt_of_map_lt' (h : Commute f g) (hf : StrictMono f) (hg : Monotone g) {x} - (hx : f x < g x) {n} (hn : 0 < n) : f^[n] x < g^[n] x := - @iterate_pos_lt_of_map_lt αᵒᵈ _ g f h.symm hg.dual hf.dual x hx n hn + (hx : f x < g x) {n} (hn : 0 < n) : f^[n] x < g^[n] x := by + unsealing_newtype OrderDual => + exact @iterate_pos_lt_of_map_lt αᵒᵈ _ g f h.symm hg.dual hf.dual x hx n hn end Preorder @@ -180,8 +185,9 @@ theorem iterate_pos_lt_iff_map_lt (h : Commute f g) (hf : Monotone f) (hg : Stri · simp only [lt_asymm H, lt_asymm (h.symm.iterate_pos_lt_of_map_lt' hg hf H hn)] theorem iterate_pos_lt_iff_map_lt' (h : Commute f g) (hf : StrictMono f) (hg : Monotone g) {x n} - (hn : 0 < n) : f^[n] x < g^[n] x ↔ f x < g x := - @iterate_pos_lt_iff_map_lt αᵒᵈ _ _ _ h.symm hg.dual hf.dual x n hn + (hn : 0 < n) : f^[n] x < g^[n] x ↔ f x < g x := by + unsealing_newtype OrderDual => + exact @iterate_pos_lt_iff_map_lt αᵒᵈ _ _ _ h.symm hg.dual hf.dual x n hn theorem iterate_pos_le_iff_map_le (h : Commute f g) (hf : Monotone f) (hg : StrictMono g) {x n} (hn : 0 < n) : f^[n] x ≤ g^[n] x ↔ f x ≤ g x := by @@ -213,8 +219,10 @@ theorem monotone_iterate_of_le_map (hf : Monotone f) (hx : x ≤ f x) : Monotone /-- If `f` is a monotone map and `f x ≤ x` at some point `x`, then the iterates `f^[n] x` form an antitone sequence. -/ -theorem antitone_iterate_of_map_le (hf : Monotone f) (hx : f x ≤ x) : Antitone fun n => f^[n] x := - hf.dual.monotone_iterate_of_le_map hx +theorem antitone_iterate_of_map_le (hf : Monotone f) (hx : f x ≤ x) : + Antitone fun n => f^[n] x := by + unsealing_newtype OrderDual => + exact hf.dual.monotone_iterate_of_le_map hx end Monotone @@ -233,7 +241,8 @@ theorem strictMono_iterate_of_lt_map (hf : StrictMono f) (hx : x < f x) : /-- If `f` is a strictly antitone map and `f x < x` at some point `x`, then the iterates `f^[n] x` form a strictly antitone sequence. -/ theorem strictAnti_iterate_of_map_lt (hf : StrictMono f) (hx : f x < x) : - StrictAnti fun n => f^[n] x := - hf.dual.strictMono_iterate_of_lt_map hx + StrictAnti fun n => f^[n] x := by + unsealing_newtype OrderDual => + exact hf.dual.strictMono_iterate_of_lt_map hx end StrictMono diff --git a/mathlib4/Mathlib/Order/KrullDimension.lean b/mathlib4/Mathlib/Order/KrullDimension.lean index f616cfb9f..8e26e372f 100644 --- a/mathlib4/Mathlib/Order/KrullDimension.lean +++ b/mathlib4/Mathlib/Order/KrullDimension.lean @@ -99,7 +99,7 @@ The definition of `coheight` is via the `height` in the dual order, in order to theorems between `height` and `coheight`. See `coheight_eq` for the definition with a series ordered by `<` and beginning with `a`. -/ -noncomputable def coheight {α : Type*} [Preorder α] (a : α) : ℕ∞ := height (α := αᵒᵈ) a +noncomputable def coheight {α : Type*} [Preorder α] (a : α) : ℕ∞ := height (OrderDual.toDual a) end definitions @@ -114,8 +114,10 @@ variable {α β : Type*} variable [Preorder α] [Preorder β] @[simp] lemma height_toDual (x : α) : height (OrderDual.toDual x) = coheight x := rfl -@[simp] lemma height_ofDual (x : αᵒᵈ) : height (OrderDual.ofDual x) = coheight x := rfl -@[simp] lemma coheight_toDual (x : α) : coheight (OrderDual.toDual x) = height x := rfl +@[simp] lemma height_ofDual (x : αᵒᵈ) : height (OrderDual.ofDual x) = coheight x := by + unsealing_newtype OrderDual => rfl +@[simp] lemma coheight_toDual (x : α) : coheight (OrderDual.toDual x) = height x := by + unsealing_newtype OrderDual => rfl @[simp] lemma coheight_ofDual (x : αᵒᵈ) : coheight (OrderDual.ofDual x) = height x := rfl /-- @@ -127,9 +129,11 @@ dual order, in order to easily transfer theorems between `height` and `coheight` -/ lemma coheight_eq (a : α) : coheight a = ⨆ (p : LTSeries α) (_ : a ≤ p.head), (p.length : ℕ∞) := by - apply Equiv.iSup_congr ⟨RelSeries.reverse, RelSeries.reverse, fun _ ↦ RelSeries.reverse_reverse _, - fun _ ↦ RelSeries.reverse_reverse _⟩ - congr! 1 + unsealing_newtype OrderDual => + apply Equiv.iSup_congr + ⟨RelSeries.reverse, RelSeries.reverse, fun _ ↦ RelSeries.reverse_reverse _, + fun _ ↦ RelSeries.reverse_reverse _⟩ + congr! 1 lemma height_le_iff {a : α} {n : ℕ∞} : height a ≤ n ↔ ∀ ⦃p : LTSeries α⦄, p.last ≤ a → p.length ≤ n := by @@ -177,11 +181,13 @@ that begin at `a`. -/ lemma coheight_eq_iSup_head_eq (a : α) : coheight a = ⨆ (p : LTSeries α) (_ : p.head = a), ↑(p.length) := by - change height (α := αᵒᵈ) a = ⨆ (p : LTSeries α) (_ : p.head = a), ↑(p.length) - rw [height_eq_iSup_last_eq] - apply Equiv.iSup_congr ⟨RelSeries.reverse, RelSeries.reverse, fun _ ↦ RelSeries.reverse_reverse _, - fun _ ↦ RelSeries.reverse_reverse _⟩ - simp + unsealing_newtype OrderDual => + change height (α := αᵒᵈ) a = ⨆ (p : LTSeries α) (_ : p.head = a), ↑(p.length) + rw [height_eq_iSup_last_eq] + apply Equiv.iSup_congr + ⟨RelSeries.reverse, RelSeries.reverse, fun _ ↦ RelSeries.reverse_reverse _, + fun _ ↦ RelSeries.reverse_reverse _⟩ + simp /-- Variant of `coheight_le_iff` ranging only over those series that begin exactly on `a`. @@ -215,8 +221,9 @@ lemma length_le_height {p : LTSeries α} {x : α} (hlast : p.last ≤ x) : set_option backward.isDefEq.respectTransparency false in lemma length_le_coheight {x : α} {p : LTSeries α} (hhead : x ≤ p.head) : - p.length ≤ coheight x := - length_le_height (α := αᵒᵈ) (p := p.reverse) (by simpa) + p.length ≤ coheight x := by + unsealing_newtype OrderDual => + exact length_le_height (α := αᵒᵈ) (p := p.reverse) (by simpa) /-- The height of the last element in a series is larger or equal to the length of the series. @@ -240,7 +247,8 @@ lemma index_le_height (p : LTSeries α) (i : Fin (p.length + 1)) : i ≤ height The coheight of an element in a series is larger or equal to its reverse index in the series. -/ lemma rev_index_le_coheight (p : LTSeries α) (i : Fin (p.length + 1)) : i.rev ≤ coheight (p i) := by - simpa using! index_le_height (α := αᵒᵈ) p.reverse i.rev + unsealing_newtype OrderDual => + simpa using! index_le_height (α := αᵒᵈ) p.reverse i.rev /-- In a maximally long series, i.e one as long as the height of the last element, the height of each @@ -262,15 +270,18 @@ each element is its reverse index in the series. -/ lemma coheight_eq_index_of_length_eq_head_coheight {p : LTSeries α} (h : p.length = coheight p.head) (i : Fin (p.length + 1)) : coheight (p i) = i.rev := by - simpa using! height_eq_index_of_length_eq_height_last (α := αᵒᵈ) (p := p.reverse) (by simpa) i.rev + unsealing_newtype OrderDual => + simpa using! + height_eq_index_of_length_eq_height_last (α := αᵒᵈ) (p := p.reverse) (by simpa) i.rev @[gcongr] lemma height_mono : Monotone (α := α) height := fun _ _ hab ↦ biSup_mono (fun _ hla => hla.trans hab) @[gcongr] -lemma coheight_anti : Antitone (α := α) coheight := - (height_mono (α := αᵒᵈ)).dual_left +lemma coheight_anti : Antitone (α := α) coheight := by + unsealing_newtype OrderDual => + exact (height_mono (α := αᵒᵈ)).dual_left private lemma height_add_const (a : α) (n : ℕ∞) : height a + n = ⨆ (p : LTSeries α) (_ : p.last = a), p.length + n := by @@ -325,8 +336,9 @@ lemma height_le_height_apply_of_strictMono (f : α → β) (hf : StrictMono f) ( lemma coheight_le_coheight_apply_of_strictMono (f : α → β) (hf : StrictMono f) (x : α) : coheight x ≤ coheight (f x) := by - apply height_le_height_apply_of_strictMono (α := αᵒᵈ) - exact fun _ _ h ↦ hf h + unsealing_newtype OrderDual => + apply height_le_height_apply_of_strictMono (α := αᵒᵈ) + exact fun _ _ h ↦ hf h lemma coheight_eq_of_strictMono (f : α → β) (hf : StrictMono f) (h : ∀ a : α, ∀ b : β, f a < b → ∃ (a' : α), a < a' ∧ f a' = b) (a : α) : @@ -344,10 +356,11 @@ lemma coheight_eq_of_strictMono (f : α → β) (hf : StrictMono f) lemma height_eq_of_strictMono (f : α → β) (hf : StrictMono f) (h : ∀ a : α, ∀ b : β, b < f a → ∃ (a' : α), a' < a ∧ f a' = b) (a : α) : height a = height (f a) := by - have : coheight (OrderDual.toDual a) = coheight (OrderDual.toDual (f a)) := - coheight_eq_of_strictMono (α := αᵒᵈ) (β := βᵒᵈ) (f := OrderDual.toDual ∘ f ∘ OrderDual.toDual) - (strictMono_dual_iff.mp hf) (fun a b hab ↦ h a b hab) _ - simpa [Order.coheight_toDual] using this + unsealing_newtype OrderDual => + have : coheight (OrderDual.toDual a) = coheight (OrderDual.toDual (f a)) := + coheight_eq_of_strictMono (α := αᵒᵈ) (β := βᵒᵈ) (f := OrderDual.toDual ∘ f ∘ OrderDual.toDual) + (strictMono_dual_iff.mp hf) (fun a b hab ↦ h a b hab) _ + simpa [Order.coheight_toDual] using this @[simp] lemma height_orderIso (f : α ≃o β) (x : α) : height (f x) = height x := by @@ -355,8 +368,9 @@ lemma height_orderIso (f : α ≃o β) (x : α) : height (f x) = height x := by · simpa using height_le_height_apply_of_strictMono _ f.symm.strictMono (f x) · exact height_le_height_apply_of_strictMono _ f.strictMono x -lemma coheight_orderIso (f : α ≃o β) (x : α) : coheight (f x) = coheight x := - height_orderIso (α := αᵒᵈ) f.dual x +lemma coheight_orderIso (f : α ≃o β) (x : α) : coheight (f x) = coheight x := by + unsealing_newtype OrderDual => + exact height_orderIso (α := αᵒᵈ) f.dual x private lemma exists_eq_iSup_of_iSup_eq_coe {α : Type*} [Nonempty α] {f : α → ℕ∞} {n : ℕ} (h : (⨆ x, f x) = n) : ∃ x, f x = n := by @@ -390,8 +404,9 @@ lemma exists_series_of_le_height (a : α) {n : ℕ} (h : n ≤ height a) : lemma exists_series_of_le_coheight (a : α) {n : ℕ} (h : n ≤ coheight a) : ∃ p : LTSeries α, p.head = a ∧ p.length = n := by - obtain ⟨p, hp, hl⟩ := exists_series_of_le_height (α := αᵒᵈ) a h - exact ⟨p.reverse, by simpa, by simpa⟩ + unsealing_newtype OrderDual => + obtain ⟨p, hp, hl⟩ := exists_series_of_le_height (α := αᵒᵈ) a h + exact ⟨p.reverse, by simpa, by simpa⟩ /-- For an element of finite height there exists a series ending in that element of that height. -/ lemma exists_series_of_height_eq_coe (a : α) {n : ℕ} (h : height a = n) : @@ -422,8 +437,9 @@ lemma height_eq_iSup_lt_height (x : α) : height x = ⨆ y < x, height y + 1 := /-- Another characterization of coheight, based on the supremum of the coheights of elements above. -/ -lemma coheight_eq_iSup_gt_coheight (x : α) : coheight x = ⨆ y > x, coheight y + 1 := - height_eq_iSup_lt_height (α := αᵒᵈ) x +lemma coheight_eq_iSup_gt_coheight (x : α) : coheight x = ⨆ y > x, coheight y + 1 := by + unsealing_newtype OrderDual => + exact height_eq_iSup_lt_height (α := αᵒᵈ) x lemma height_le_coe_iff {x : α} {n : ℕ} : height x ≤ n ↔ ∀ y < x, height y < n := by conv_lhs => rw [height_eq_iSup_lt_height, iSup₂_le_iff] @@ -432,8 +448,9 @@ lemma height_le_coe_iff {x : α} {n : ℕ} : height x ≤ n ↔ ∀ y < x, heigh · simp · norm_cast -lemma coheight_le_coe_iff {x : α} {n : ℕ} : coheight x ≤ n ↔ ∀ y > x, coheight y < n := - height_le_coe_iff (α := αᵒᵈ) +lemma coheight_le_coe_iff {x : α} {n : ℕ} : coheight x ≤ n ↔ ∀ y > x, coheight y < n := by + unsealing_newtype OrderDual => + exact height_le_coe_iff (α := αᵒᵈ) /-- The height of an element is infinite iff there exist series of arbitrary length ending in that @@ -458,8 +475,9 @@ element. -/ lemma coheight_eq_top_iff {x : α} : coheight x = ⊤ ↔ ∀ n, ∃ p : LTSeries α, p.head = x ∧ p.length = n := by - convert! height_eq_top_iff (α := αᵒᵈ) (x := x) using 2 with n - constructor <;> (intro ⟨p, hp, hl⟩; use p.reverse; constructor <;> simpa) + unsealing_newtype OrderDual => + convert! height_eq_top_iff (α := αᵒᵈ) (x := x) using 2 with n + constructor <;> (intro ⟨p, hp, hl⟩; use p.reverse; constructor <;> simpa) /-- The elements of height zero are the minimal elements. -/ @[simp] lemma height_eq_zero {x : α} : height x = 0 ↔ IsMin x := by @@ -468,8 +486,9 @@ lemma coheight_eq_top_iff {x : α} : protected alias ⟨_, IsMin.height_eq_zero⟩ := height_eq_zero /-- The elements of coheight zero are the maximal elements. -/ -@[simp] lemma coheight_eq_zero {x : α} : coheight x = 0 ↔ IsMax x := - height_eq_zero (α := αᵒᵈ) +@[simp] lemma coheight_eq_zero {x : α} : coheight x = 0 ↔ IsMax x := by + unsealing_newtype OrderDual => + exact height_eq_zero (α := αᵒᵈ) protected alias ⟨_, IsMax.coheight_eq_zero⟩ := coheight_eq_zero @@ -511,8 +530,9 @@ lemma coe_lt_height_iff {x : α} {n : ℕ} (hfin : height x < ⊤) : hy ▸ height_strictMono hyx (lt_of_le_of_lt (height_mono hyx.le) hfin) lemma coe_lt_coheight_iff {x : α} {n : ℕ} (hfin : coheight x < ⊤) : - n < coheight x ↔ ∃ y > x, coheight y = n := - coe_lt_height_iff (α := αᵒᵈ) hfin + n < coheight x ↔ ∃ y > x, coheight y = n := by + unsealing_newtype OrderDual => + exact coe_lt_height_iff (α := αᵒᵈ) hfin lemma height_eq_coe_add_one_iff {x : α} {n : ℕ} : height x = n + 1 ↔ height x < ⊤ ∧ (∃ y < x, height y = n) ∧ (∀ y < x, height y ≤ n) := by @@ -528,8 +548,9 @@ lemma height_eq_coe_add_one_iff {x : α} {n : ℕ} : lemma coheight_eq_coe_add_one_iff {x : α} {n : ℕ} : coheight x = n + 1 ↔ - coheight x < ⊤ ∧ (∃ y > x, coheight y = n) ∧ (∀ y > x, coheight y ≤ n) := - height_eq_coe_add_one_iff (α := αᵒᵈ) + coheight x < ⊤ ∧ (∃ y > x, coheight y = n) ∧ (∀ y > x, coheight y ≤ n) := by + unsealing_newtype OrderDual => + exact height_eq_coe_add_one_iff (α := αᵒᵈ) lemma height_eq_coe_iff {x : α} {n : ℕ} : height x = n ↔ @@ -549,8 +570,9 @@ lemma height_eq_coe_iff {x : α} {n : ℕ} : lemma coheight_eq_coe_iff {x : α} {n : ℕ} : coheight x = n ↔ - coheight x < ⊤ ∧ (n = 0 ∨ ∃ y > x, coheight y = n - 1) ∧ (∀ y > x, coheight y < n) := - height_eq_coe_iff (α := αᵒᵈ) + coheight x < ⊤ ∧ (n = 0 ∨ ∃ y > x, coheight y = n - 1) ∧ (∀ y > x, coheight y < n) := by + unsealing_newtype OrderDual => + exact height_eq_coe_iff (α := αᵒᵈ) /-- The elements of finite height `n` are the minimal elements among those of height `≥ n`. -/ lemma height_eq_coe_iff_minimal_le_height {a : α} {n : ℕ} : @@ -569,8 +591,9 @@ lemma height_eq_coe_iff_minimal_le_height {a : α} {n : ℕ} : /-- The elements of finite coheight `n` are the maximal elements among those of coheight `≥ n`. -/ lemma coheight_eq_coe_iff_maximal_le_coheight {a : α} {n : ℕ} : - coheight a = n ↔ Maximal (fun y => n ≤ coheight y) a := - height_eq_coe_iff_minimal_le_height (α := αᵒᵈ) + coheight a = n ↔ Maximal (fun y => n ≤ coheight y) a := by + unsealing_newtype OrderDual => + exact height_eq_coe_iff_minimal_le_height (α := αᵒᵈ) lemma one_lt_height_iff {x : α} : 1 < Order.height x ↔ ∃ y z, z < y ∧ y < x := by rw [← ENat.add_one_le_iff ENat.one_ne_top, one_add_one_eq_two] @@ -762,9 +785,10 @@ lemma krullDim_eq_of_orderIso (f : α ≃o β) : krullDim α = krullDim β := le_antisymm (krullDim_le_of_strictMono _ f.strictMono) <| krullDim_le_of_strictMono _ f.symm.strictMono -@[simp] lemma krullDim_orderDual : krullDim αᵒᵈ = krullDim α := - le_antisymm (iSup_le fun i ↦ le_sSup ⟨i.reverse, rfl⟩) <| - iSup_le fun i ↦ le_sSup ⟨i.reverse, rfl⟩ +@[simp] lemma krullDim_orderDual : krullDim αᵒᵈ = krullDim α := by + unsealing_newtype OrderDual => + exact le_antisymm (iSup_le fun i ↦ le_sSup ⟨i.reverse, rfl⟩) <| + iSup_le fun i ↦ le_sSup ⟨i.reverse, rfl⟩ lemma height_le_krullDim (a : α) : height a ≤ krullDim α := by have : Nonempty α := ⟨a⟩ @@ -773,7 +797,8 @@ lemma height_le_krullDim (a : α) : height a ≤ krullDim α := by exact height_le fun p _ ↦ le_iSup_of_le p le_rfl lemma coheight_le_krullDim (a : α) : coheight a ≤ krullDim α := by - simpa using! height_le_krullDim (α := αᵒᵈ) a + unsealing_newtype OrderDual => + simpa using! height_le_krullDim (α := αᵒᵈ) a @[simp] lemma _root_.LTSeries.height_last_longestOf [FiniteDimensionalOrder α] : @@ -813,7 +838,8 @@ version, with the coercion under the supremum. -/ lemma krullDim_eq_iSup_coheight_of_nonempty [Nonempty α] : krullDim α = ↑(⨆ (a : α), coheight a) := by - simpa using! krullDim_eq_iSup_height_of_nonempty (α := αᵒᵈ) + unsealing_newtype OrderDual => + simpa using! krullDim_eq_iSup_height_of_nonempty (α := αᵒᵈ) /-- The Krull dimension is the supremum of the elements' height plus coheight. @@ -891,8 +917,9 @@ lemma height_eq_krullDim_Iic (x : α) : (height x : ℕ∞) = krullDim (Set.Iic lemma coheight_eq_krullDim_Ici {α : Type*} [Preorder α] (x : α) : (coheight x : ℕ∞) = krullDim (Set.Ici x) := by - rw [coheight, ← krullDim_orderDual, Order.krullDim_eq_of_orderIso (OrderIso.refl _)] - exact height_eq_krullDim_Iic _ + unsealing_newtype OrderDual => + rw [coheight, ← krullDim_orderDual, Order.krullDim_eq_of_orderIso (OrderIso.refl _)] + exact height_eq_krullDim_Iic _ end krullDim @@ -975,9 +1002,10 @@ variable {α : Type*} [Preorder α] apply hstrictmono lia -@[simp] lemma height_of_noMinOrder [NoMinOrder α] (a : α) : height a = ⊤ := - -- Implementation note: Here it's a bit easier to define the coheight variant first - coheight_of_noMaxOrder (α := αᵒᵈ) a +@[simp] lemma height_of_noMinOrder [NoMinOrder α] (a : α) : height a = ⊤ := by + -- Here it is easier to prove the coheight variant first. + unsealing_newtype OrderDual => + exact coheight_of_noMaxOrder (α := αᵒᵈ) a @[simp] lemma krullDim_of_noMaxOrder [Nonempty α] [NoMaxOrder α] : krullDim α = ⊤ := by simp [krullDim_eq_iSup_coheight, coheight_of_noMaxOrder] @@ -1142,9 +1170,10 @@ lemma height_le_of_krullDim_preimage_le (x : α) : include h in lemma coheight_le_of_krullDim_preimage_le (x : α) : Order.coheight x ≤ (m + 1) * Order.coheight (f x) + m := by - rw [Order.coheight, Order.coheight] - apply height_le_of_krullDim_preimage_le (f := f.dual) - exact fun x ↦ le_of_eq_of_le (krullDim_orderDual (α := f ⁻¹' {x})) (h x) + unsealing_newtype OrderDual => + rw [Order.coheight, Order.coheight] + apply height_le_of_krullDim_preimage_le (f := f.dual) + exact fun x ↦ le_of_eq_of_le (krullDim_orderDual (α := f ⁻¹' {x})) (h x) include f h in lemma krullDim_le_of_krullDim_preimage_le : diff --git a/mathlib4/Mathlib/Order/Lattice.lean b/mathlib4/Mathlib/Order/Lattice.lean index ff4c0a37c..9b374f77e 100644 --- a/mathlib4/Mathlib/Order/Lattice.lean +++ b/mathlib4/Mathlib/Order/Lattice.lean @@ -341,15 +341,17 @@ theorem SemilatticeSup.ext {α} {A B : SemilatticeSup α} @[to_dual] instance OrderDual.instSemilatticeSup (α) [h : SemilatticeInf α] : SemilatticeSup αᵒᵈ where - sup a b := h.inf a b - le_sup_left := h.inf_le_left - le_sup_right := h.inf_le_right - sup_le _ _ _ := h.le_inf _ _ _ + sup a b := OrderDual.mk (h.inf a.ofDual' b.ofDual') + le_sup_left a b := h.inf_le_left a.ofDual' b.ofDual' + le_sup_right a b := h.inf_le_right a.ofDual' b.ofDual' + sup_le _ _ _ hac hbc := h.le_inf _ _ _ hac hbc @[to_dual] theorem SemilatticeSup.dual_dual (α : Type*) [H : SemilatticeSup α] : - OrderDual.instSemilatticeSup αᵒᵈ = H := - SemilatticeSup.ext fun _ _ => Iff.rfl + (OrderDual.instSemilatticeSup αᵒᵈ).sup = fun a b ↦ + OrderDual.toDual (OrderDual.toDual + (H.sup (OrderDual.ofDual (OrderDual.ofDual a)) (OrderDual.ofDual (OrderDual.ofDual b)))) := + rfl end SemilatticeSup @@ -558,8 +560,11 @@ end DistribLattice @[to_dual existing mk] abbrev DistribLattice.ofInfSupLe [Lattice α] (inf_sup_le : ∀ a b c : α, a ⊓ (b ⊔ c) ≤ a ⊓ b ⊔ a ⊓ c) : DistribLattice α where - le_sup_inf := (@OrderDual.instDistribLattice αᵒᵈ { (inferInstance : Lattice αᵒᵈ) with - le_sup_inf := inf_sup_le }).le_sup_inf + le_sup_inf a b c := (@OrderDual.instDistribLattice αᵒᵈ { (inferInstance : Lattice αᵒᵈ) with + le_sup_inf := fun x y z ↦ + inf_sup_le (OrderDual.ofDual x) (OrderDual.ofDual y) (OrderDual.ofDual z) }).le_sup_inf + (OrderDual.toDual (OrderDual.toDual a)) (OrderDual.toDual (OrderDual.toDual b)) + (OrderDual.toDual (OrderDual.toDual c)) /-! ### Lattices derived from linear orders @@ -819,21 +824,24 @@ protected theorem max [Preorder α] [LinearOrder β] {f g : α → β} (hf : Ant @[to_dual le_map_inf] theorem map_sup_le [SemilatticeSup α] [SemilatticeInf β] {f : α → β} (h : Antitone f) (x y : α) : - f (x ⊔ y) ≤ f x ⊓ f y := - h.dual_right.le_map_sup x y + f (x ⊔ y) ≤ f x ⊓ f y := by + unsealing_newtype OrderDual => + exact h.dual_right.le_map_sup x y variable [LinearOrder α] @[to_dual] theorem map_sup [SemilatticeInf β] {f : α → β} (hf : Antitone f) (x y : α) : - f (x ⊔ y) = f x ⊓ f y := - hf.dual_right.map_sup x y + f (x ⊔ y) = f x ⊓ f y := by + unsealing_newtype OrderDual => + exact hf.dual_right.map_sup x y end Antitone theorem exists_le_and_iff_exists [SemilatticeInf α] {P : α → Prop} {x₀ : α} (hP : Antitone P) : - (∃ x, x ≤ x₀ ∧ P x) ↔ ∃ x, P x := - exists_ge_and_iff_exists <| hP.dual_left + (∃ x, x ≤ x₀ ∧ P x) ↔ ∃ x, P x := by + unsealing_newtype OrderDual => + exact exists_ge_and_iff_exists <| hP.dual_left theorem exists_and_iff_of_antitone [SemilatticeInf α] {P Q : α → Prop} (hP : Antitone P) (hQ : Antitone Q) : ((∃ x, P x) ∧ ∃ x, Q x) ↔ (∃ x, P x ∧ Q x) := diff --git a/mathlib4/Mathlib/Order/Lattice/Nat.lean b/mathlib4/Mathlib/Order/Lattice/Nat.lean index cee375896..a5efe7648 100644 --- a/mathlib4/Mathlib/Order/Lattice/Nat.lean +++ b/mathlib4/Mathlib/Order/Lattice/Nat.lean @@ -186,11 +186,13 @@ theorem iSup_lt_succ' (u : ℕ → α) (n : ℕ) : ⨆ k < n + 1, u k = u 0 ⊔ rw [← sup_iSup_nat_succ] simp -theorem iInf_lt_succ (u : ℕ → α) (n : ℕ) : ⨅ k < n + 1, u k = (⨅ k < n, u k) ⊓ u n := - @iSup_lt_succ αᵒᵈ _ _ _ +theorem iInf_lt_succ (u : ℕ → α) (n : ℕ) : ⨅ k < n + 1, u k = (⨅ k < n, u k) ⊓ u n := by + unsealing_newtype OrderDual => + exact @iSup_lt_succ αᵒᵈ _ _ _ -theorem iInf_lt_succ' (u : ℕ → α) (n : ℕ) : ⨅ k < n + 1, u k = u 0 ⊓ ⨅ k < n, u (k + 1) := - @iSup_lt_succ' αᵒᵈ _ _ _ +theorem iInf_lt_succ' (u : ℕ → α) (n : ℕ) : ⨅ k < n + 1, u k = u 0 ⊓ ⨅ k < n, u (k + 1) := by + unsealing_newtype OrderDual => + exact @iSup_lt_succ' αᵒᵈ _ _ _ theorem iSup_le_succ (u : ℕ → α) (n : ℕ) : ⨆ k ≤ n + 1, u k = (⨆ k ≤ n, u k) ⊔ u (n + 1) := by simp_rw [← Nat.lt_succ_iff, iSup_lt_succ] @@ -198,11 +200,13 @@ theorem iSup_le_succ (u : ℕ → α) (n : ℕ) : ⨆ k ≤ n + 1, u k = (⨆ k theorem iSup_le_succ' (u : ℕ → α) (n : ℕ) : ⨆ k ≤ n + 1, u k = u 0 ⊔ ⨆ k ≤ n, u (k + 1) := by simp_rw [← Nat.lt_succ_iff, iSup_lt_succ'] -theorem iInf_le_succ (u : ℕ → α) (n : ℕ) : ⨅ k ≤ n + 1, u k = (⨅ k ≤ n, u k) ⊓ u (n + 1) := - @iSup_le_succ αᵒᵈ _ _ _ +theorem iInf_le_succ (u : ℕ → α) (n : ℕ) : ⨅ k ≤ n + 1, u k = (⨅ k ≤ n, u k) ⊓ u (n + 1) := by + unsealing_newtype OrderDual => + exact @iSup_le_succ αᵒᵈ _ _ _ -theorem iInf_le_succ' (u : ℕ → α) (n : ℕ) : ⨅ k ≤ n + 1, u k = u 0 ⊓ ⨅ k ≤ n, u (k + 1) := - @iSup_le_succ' αᵒᵈ _ _ _ +theorem iInf_le_succ' (u : ℕ → α) (n : ℕ) : ⨅ k ≤ n + 1, u k = u 0 ⊓ ⨅ k ≤ n, u (k + 1) := by + unsealing_newtype OrderDual => + exact @iSup_le_succ' αᵒᵈ _ _ _ end diff --git a/mathlib4/Mathlib/Order/Max.lean b/mathlib4/Mathlib/Order/Max.lean index cb806198e..95feef99c 100644 --- a/mathlib4/Mathlib/Order/Max.lean +++ b/mathlib4/Mathlib/Order/Max.lean @@ -79,11 +79,11 @@ instance IsEmpty.toNoMinOrder [LT α] [IsEmpty α] : NoMinOrder α := ⟨isEmpty @[to_dual] instance OrderDual.noBotOrder [LE α] [NoTopOrder α] : NoBotOrder αᵒᵈ := - ⟨fun a => exists_not_le (α := α) a⟩ + ⟨fun a => let ⟨b, hb⟩ := exists_not_le (α := α) a.ofDual'; ⟨OrderDual.mk b, hb⟩⟩ @[to_dual] instance OrderDual.noMinOrder [LT α] [NoMaxOrder α] : NoMinOrder αᵒᵈ := - ⟨fun a => exists_gt (α := α) a⟩ + ⟨fun a => let ⟨b, hb⟩ := exists_gt (α := α) a.ofDual'; ⟨OrderDual.mk b, hb⟩⟩ -- See note [lower instance priority] @[to_dual] @@ -167,19 +167,19 @@ theorem IsBot.isMin_iff {α} [PartialOrder α] {i j : α} (h : IsBot i) : IsMin @[to_dual (attr := simp)] theorem isBot_toDual_iff : IsBot (toDual a) ↔ IsTop a := - Iff.rfl + OrderDual.forall @[to_dual (attr := simp)] theorem isMin_toDual_iff : IsMin (toDual a) ↔ IsMax a := - Iff.rfl + OrderDual.forall @[to_dual (attr := simp)] theorem isBot_ofDual_iff {a : αᵒᵈ} : IsBot (ofDual a) ↔ IsTop a := - Iff.rfl + (OrderDual.forall (p := (· ≤ a))).symm @[to_dual (attr := simp)] theorem isMin_ofDual_iff {a : αᵒᵈ} : IsMin (ofDual a) ↔ IsMax a := - Iff.rfl + (OrderDual.forall (p := fun b ↦ a ≤ b → b ≤ a)).symm @[to_dual] alias ⟨_, IsTop.toDual⟩ := isBot_toDual_iff diff --git a/mathlib4/Mathlib/Order/MinMax.lean b/mathlib4/Mathlib/Order/MinMax.lean index de014275e..0d71710af 100644 --- a/mathlib4/Mathlib/Order/MinMax.lean +++ b/mathlib4/Mathlib/Order/MinMax.lean @@ -128,7 +128,9 @@ theorem MonotoneOn.map_max (hf : MonotoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : @[to_dual] theorem AntitoneOn.map_max (hf : AntitoneOn f s) (ha : a ∈ s) (hb : b ∈ s) : f (max a b) = - min (f a) (f b) := hf.dual_right.map_max ha hb + min (f a) (f b) := by + unsealing_newtype OrderDual => + exact hf.dual_right.map_max ha hb @[to_dual] theorem Monotone.map_max (hf : Monotone f) : f (max a b) = max (f a) (f b) := by diff --git a/mathlib4/Mathlib/Order/Minimal.lean b/mathlib4/Mathlib/Order/Minimal.lean index e9bd64845..4e1c74a52 100644 --- a/mathlib4/Mathlib/Order/Minimal.lean +++ b/mathlib4/Mathlib/Order/Minimal.lean @@ -70,8 +70,9 @@ variable [LE α] lemma minimalFor_id : MinimalFor P id x ↔ Minimal P x := .rfl @[to_dual (attr := simp)] -theorem minimal_toDual : Minimal (fun x ↦ P (ofDual x)) (toDual x) ↔ Maximal P x := - Iff.rfl +theorem minimal_toDual : Minimal (fun x ↦ P (ofDual x)) (toDual x) ↔ Maximal P x := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual] alias ⟨Minimal.of_dual, Minimal.dual⟩ := minimal_toDual @@ -448,14 +449,16 @@ theorem minimal_mem_image_monotone_iff (ha : a ∈ s) @[to_dual (reorder := hf (x y, 3 4))] theorem minimal_mem_image_antitone (hf : ∀ ⦃x y⦄, x ∈ s → y ∈ s → (f x ≤ f y ↔ y ≤ x)) - (hx : Minimal (· ∈ s) x) : Maximal (· ∈ f '' s) (f x) := - minimal_mem_image_monotone (β := βᵒᵈ) (fun _ _ h h' ↦ hf h' h) hx + (hx : Minimal (· ∈ s) x) : Maximal (· ∈ f '' s) (f x) := by + unsealing_newtype OrderDual => + exact minimal_mem_image_monotone (β := βᵒᵈ) (fun _ _ h h' ↦ hf h' h) hx @[to_dual (reorder := hf (x y, 3 4))] theorem minimal_mem_image_antitone_iff (ha : a ∈ s) (hf : ∀ ⦃x y⦄, x ∈ s → y ∈ s → (f x ≤ f y ↔ y ≤ x)) : - Minimal (· ∈ f '' s) (f a) ↔ Maximal (· ∈ s) a := - maximal_mem_image_monotone_iff (β := βᵒᵈ) ha (fun _ _ h h' ↦ hf h' h) + Minimal (· ∈ f '' s) (f a) ↔ Maximal (· ∈ s) a := by + unsealing_newtype OrderDual => + exact maximal_mem_image_monotone_iff (β := βᵒᵈ) ha (fun _ _ h h' ↦ hf h' h) @[to_dual (reorder := hf (x y, 3 4))] theorem image_monotone_setOfPred_minimal (hf : ∀ ⦃x y⦄, P x → P y → (f x ≤ f y ↔ x ≤ y)) : @@ -474,8 +477,9 @@ alias image_monotone_setOf_maximal := image_monotone_setOfPred_maximal @[to_dual (reorder := hf (x y, 3 4))] theorem image_antitone_setOfPred_minimal (hf : ∀ ⦃x y⦄, P x → P y → (f x ≤ f y ↔ y ≤ x)) : - f '' {x | Minimal P x} = {x | Maximal (∃ x₀, P x₀ ∧ f x₀ = ·) x} := - image_monotone_setOfPred_minimal (β := βᵒᵈ) (fun _ _ hx hy ↦ hf hy hx) + f '' {x | Minimal P x} = {x | Maximal (∃ x₀, P x₀ ∧ f x₀ = ·) x} := by + unsealing_newtype OrderDual => + exact image_monotone_setOfPred_minimal (β := βᵒᵈ) (fun _ _ hx hy ↦ hf hy hx) @[deprecated (since := "2026-07-09")] alias image_antitone_setOf_minimal := image_antitone_setOfPred_minimal @@ -602,10 +606,21 @@ def mapSetOfPredMaximal (f : s ≃o t) : {x | Maximal (· ∈ s) x} ≃o {x | Ma @[to_dual /-- If two sets are antitonically order isomorphic, their maximals/minimals are too. -/] def setOfPredMinimalIsoSetOfPredMaximal (f : s ≃o tᵒᵈ) : {x | Minimal (· ∈ s) x} ≃o {x | Maximal (· ∈ t) (ofDual x)} where - toFun x := ⟨(f ⟨x.1, x.2.1⟩).1, ((show s ≃o ofDual ⁻¹' t from f).mapSetOfPredMinimal x).2⟩ - invFun x := ⟨(f.symm ⟨x.1, x.2.1⟩).1, - ((show ofDual ⁻¹' t ≃o s from f.symm).mapSetOfPredMinimal x).2⟩ - __ := (show s ≃o ofDual ⁻¹' t from f).mapSetOfPredMinimal + toFun x := ⟨toDual (ofDual (f ⟨x.1, x.2.1⟩)).1, by + unsealing_newtype OrderDual => + exact ((show s ≃o ofDual ⁻¹' t from f).mapSetOfPredMinimal x).2⟩ + invFun x := ⟨(f.symm (toDual ⟨ofDual x.1, x.2.1⟩)).1, by + unsealing_newtype OrderDual => + exact ((show ofDual ⁻¹' t ≃o s from f.symm).mapSetOfPredMinimal x).2⟩ + left_inv x := by + unsealing_newtype OrderDual => + exact (show s ≃o ofDual ⁻¹' t from f).mapSetOfPredMinimal.left_inv x + right_inv x := by + unsealing_newtype OrderDual => + exact (show s ≃o ofDual ⁻¹' t from f).mapSetOfPredMinimal.right_inv x + map_rel_iff' := by + unsealing_newtype OrderDual => + exact (show s ≃o ofDual ⁻¹' t from f).mapSetOfPredMinimal.map_rel_iff @[deprecated (since := "2026-07-09")] alias setOfMinimalIsoSetOfMaximal := setOfPredMinimalIsoSetOfPredMaximal diff --git a/mathlib4/Mathlib/Order/ModularLattice.lean b/mathlib4/Mathlib/Order/ModularLattice.lean index 3a2baebfc..0bcd721c2 100644 --- a/mathlib4/Mathlib/Order/ModularLattice.lean +++ b/mathlib4/Mathlib/Order/ModularLattice.lean @@ -170,11 +170,7 @@ theorem IsModularLattice.inf_sup_inf_assoc {x y z : α} : x ⊓ z ⊔ y ⊓ z = (sup_inf_assoc_of_le y inf_le_right).symm instance : IsModularLattice αᵒᵈ := - ⟨fun y z xz => - le_of_eq - (by - rw [inf_comm, sup_comm, eq_comm, inf_comm, sup_comm] - exact @sup_inf_assoc_of_le α _ _ _ y _ xz)⟩ + ⟨fun y _ xz => inf_sup_le_assoc_of_le (OrderDual.ofDual y) xz⟩ variable {x y z : α} @@ -216,9 +212,10 @@ theorem wellFounded_gt_exact_sequence {β γ : Type*} [Preorder β] [Preorder γ [WellFoundedGT β] [WellFoundedGT γ] (K : α) (f₁ : β → α) (f₂ : α → β) (g₁ : γ → α) (g₂ : α → γ) (gci : GaloisCoinsertion f₁ f₂) (gi : GaloisInsertion g₂ g₁) (hf : ∀ a, f₁ (f₂ a) = a ⊓ K) (hg : ∀ a, g₁ (g₂ a) = a ⊔ K) : - WellFoundedGT α := - wellFounded_lt_exact_sequence (α := αᵒᵈ) (β := γᵒᵈ) (γ := βᵒᵈ) - K g₁ g₂ f₁ f₂ gi.dual gci.dual hg hf + WellFoundedGT α := by + unsealing_newtype OrderDual => + exact wellFounded_lt_exact_sequence (α := αᵒᵈ) (β := γᵒᵈ) (γ := βᵒᵈ) + K g₁ g₂ f₁ f₂ gi.dual gci.dual hg hf set_option backward.isDefEq.respectTransparency false in /-- The diamond isomorphism between the closed intervals `[a ⊓ b, a]` and `[b, a ⊔ b]` -/ diff --git a/mathlib4/Mathlib/Order/Monotone/Basic.lean b/mathlib4/Mathlib/Order/Monotone/Basic.lean index 266fbb3b3..4b15a6a63 100644 --- a/mathlib4/Mathlib/Order/Monotone/Basic.lean +++ b/mathlib4/Mathlib/Order/Monotone/Basic.lean @@ -73,15 +73,17 @@ Often, you should not need the rewriting lemmas. Instead, you probably want to a section OrderDual -variable [Preorder α] [Preorder β] {f : α → β} {s : Set α} +variable [Preorder α] [Preorder β] {f : α → β} {s : Set α} {t : Set αᵒᵈ} @[simp] -theorem monotone_comp_ofDual_iff : Monotone (f ∘ ofDual) ↔ Antitone f := - forall_comm +theorem monotone_comp_ofDual_iff : Monotone (f ∘ ofDual) ↔ Antitone f := by + unsealing_newtype OrderDual => + exact forall_comm @[simp] -theorem antitone_comp_ofDual_iff : Antitone (f ∘ ofDual) ↔ Monotone f := - forall_comm +theorem antitone_comp_ofDual_iff : Antitone (f ∘ ofDual) ↔ Monotone f := by + unsealing_newtype OrderDual => + exact forall_comm @[simp] theorem monotone_toDual_comp_iff : Monotone (toDual ∘ f) ↔ Antitone f := @@ -92,12 +94,14 @@ theorem antitone_toDual_comp_iff : Antitone (toDual ∘ f) ↔ Monotone f := Iff.rfl @[simp] -theorem monotoneOn_comp_ofDual_iff : MonotoneOn (f ∘ ofDual) s ↔ AntitoneOn f s := - forall₂_comm +theorem monotoneOn_comp_ofDual_iff : MonotoneOn (f ∘ ofDual) t ↔ AntitoneOn f (⇑toDual ⁻¹' t) := by + unsealing_newtype OrderDual => + exact forall₂_comm @[simp] -theorem antitoneOn_comp_ofDual_iff : AntitoneOn (f ∘ ofDual) s ↔ MonotoneOn f s := - forall₂_comm +theorem antitoneOn_comp_ofDual_iff : AntitoneOn (f ∘ ofDual) t ↔ MonotoneOn f (⇑toDual ⁻¹' t) := by + unsealing_newtype OrderDual => + exact forall₂_comm @[simp] theorem monotoneOn_toDual_comp_iff : MonotoneOn (toDual ∘ f) s ↔ AntitoneOn f s := @@ -108,12 +112,14 @@ theorem antitoneOn_toDual_comp_iff : AntitoneOn (toDual ∘ f) s ↔ MonotoneOn Iff.rfl @[simp] -theorem strictMono_comp_ofDual_iff : StrictMono (f ∘ ofDual) ↔ StrictAnti f := - forall_comm +theorem strictMono_comp_ofDual_iff : StrictMono (f ∘ ofDual) ↔ StrictAnti f := by + unsealing_newtype OrderDual => + exact forall_comm @[simp] -theorem strictAnti_comp_ofDual_iff : StrictAnti (f ∘ ofDual) ↔ StrictMono f := - forall_comm +theorem strictAnti_comp_ofDual_iff : StrictAnti (f ∘ ofDual) ↔ StrictMono f := by + unsealing_newtype OrderDual => + exact forall_comm @[simp] theorem strictMono_toDual_comp_iff : StrictMono (toDual ∘ f : α → βᵒᵈ) ↔ StrictAnti f := @@ -124,12 +130,16 @@ theorem strictAnti_toDual_comp_iff : StrictAnti (toDual ∘ f : α → βᵒᵈ) Iff.rfl @[simp] -theorem strictMonoOn_comp_ofDual_iff : StrictMonoOn (f ∘ ofDual) s ↔ StrictAntiOn f s := - forall₂_comm +theorem strictMonoOn_comp_ofDual_iff : + StrictMonoOn (f ∘ ofDual) t ↔ StrictAntiOn f (⇑toDual ⁻¹' t) := by + unsealing_newtype OrderDual => + exact forall₂_comm @[simp] -theorem strictAntiOn_comp_ofDual_iff : StrictAntiOn (f ∘ ofDual) s ↔ StrictMonoOn f s := - forall₂_comm +theorem strictAntiOn_comp_ofDual_iff : + StrictAntiOn (f ∘ ofDual) t ↔ StrictMonoOn f (⇑toDual ⁻¹' t) := by + unsealing_newtype OrderDual => + exact forall₂_comm @[simp] theorem strictMonoOn_toDual_comp_iff : StrictMonoOn (toDual ∘ f : α → βᵒᵈ) s ↔ StrictAntiOn f s := @@ -145,12 +155,12 @@ theorem monotone_dual_iff : Monotone (toDual ∘ f ∘ ofDual : αᵒᵈ → β theorem antitone_dual_iff : Antitone (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) ↔ Antitone f := by rw [antitone_toDual_comp_iff, monotone_comp_ofDual_iff] -set_option backward.isDefEq.respectTransparency false in -theorem monotoneOn_dual_iff : MonotoneOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) s ↔ MonotoneOn f s := by +theorem monotoneOn_dual_iff : + MonotoneOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) t ↔ MonotoneOn f (⇑toDual ⁻¹' t) := by rw [monotoneOn_toDual_comp_iff, antitoneOn_comp_ofDual_iff] -set_option backward.isDefEq.respectTransparency false in -theorem antitoneOn_dual_iff : AntitoneOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) s ↔ AntitoneOn f s := by +theorem antitoneOn_dual_iff : + AntitoneOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) t ↔ AntitoneOn f (⇑toDual ⁻¹' t) := by rw [antitoneOn_toDual_comp_iff, monotoneOn_comp_ofDual_iff] theorem strictMono_dual_iff : StrictMono (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) ↔ StrictMono f := by @@ -159,14 +169,12 @@ theorem strictMono_dual_iff : StrictMono (toDual ∘ f ∘ ofDual : αᵒᵈ → theorem strictAnti_dual_iff : StrictAnti (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) ↔ StrictAnti f := by rw [strictAnti_toDual_comp_iff, strictMono_comp_ofDual_iff] -set_option backward.isDefEq.respectTransparency false in theorem strictMonoOn_dual_iff : - StrictMonoOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) s ↔ StrictMonoOn f s := by + StrictMonoOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) t ↔ StrictMonoOn f (⇑toDual ⁻¹' t) := by rw [strictMonoOn_toDual_comp_iff, strictAntiOn_comp_ofDual_iff] -set_option backward.isDefEq.respectTransparency false in theorem strictAntiOn_dual_iff : - StrictAntiOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) s ↔ StrictAntiOn f s := by + StrictAntiOn (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ) t ↔ StrictAntiOn f (⇑toDual ⁻¹' t) := by rw [strictAntiOn_toDual_comp_iff, strictMonoOn_comp_ofDual_iff] alias ⟨_, Monotone.dual_left⟩ := antitone_comp_ofDual_iff @@ -293,8 +301,9 @@ protected theorem StrictMono.ite (hf : StrictMono f) (hg : StrictMono g) {p : α protected theorem StrictAnti.ite' (hf : StrictAnti f) (hg : StrictAnti g) {p : α → Prop} [DecidablePred p] (hp : ∀ ⦃x y⦄, x < y → p y → p x) (hfg : ∀ ⦃x y⦄, p x → ¬p y → x < y → g y < f x) : - StrictAnti fun x ↦ if p x then f x else g x := - StrictMono.ite' hf.dual_right hg.dual_right hp hfg + StrictAnti fun x ↦ if p x then f x else g x := by + unsealing_newtype OrderDual => + exact StrictMono.ite' hf.dual_right hg.dual_right hp hfg protected theorem StrictAnti.ite (hf : StrictAnti f) (hg : StrictAnti g) {p : α → Prop} [DecidablePred p] (hp : ∀ ⦃x y⦄, x < y → p y → p x) (hfg : ∀ x, g x ≤ f x) : @@ -356,8 +365,9 @@ theorem StrictMonoOn.eq_iff_eq (hf : StrictMonoOn f s) {a b : α} (ha : a ∈ s) rfl⟩ theorem StrictAntiOn.eq_iff_eq (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) : - f a = f b ↔ b = a := - (hf.dual_right.eq_iff_eq ha hb).trans eq_comm + f a = f b ↔ b = a := by + unsealing_newtype OrderDual => + exact (hf.dual_right.eq_iff_eq ha hb).trans eq_comm @[to_dual self (reorder := a b, ha hb)] theorem StrictMonoOn.lt_iff_lt (hf : StrictMonoOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) : @@ -394,7 +404,7 @@ protected theorem StrictMonoOn.compares (hf : StrictMonoOn f s) {a b : α} (ha : protected theorem StrictAntiOn.compares (hf : StrictAntiOn f s) {a b : α} (ha : a ∈ s) (hb : b ∈ s) {o : Ordering} : o.Compares (f a) (f b) ↔ o.Compares b a := - toDual_compares_toDual.trans <| hf.dual_right.compares hb ha + toDual_compares_toDual.symm.trans <| hf.dual_right.compares hb ha protected theorem StrictMono.compares (hf : StrictMono f) {a b : α} {o : Ordering} : o.Compares (f a) (f b) ↔ o.Compares a b := @@ -413,7 +423,9 @@ theorem StrictAnti.injective (hf : StrictAnti f) : Injective f := lemma StrictMonoOn.injOn (hf : StrictMonoOn f s) : s.InjOn f := fun x hx y hy hxy ↦ show Ordering.eq.Compares x y from (hf.compares hx hy).1 hxy -lemma StrictAntiOn.injOn (hf : StrictAntiOn f s) : s.InjOn f := hf.dual_left.injOn +lemma StrictAntiOn.injOn (hf : StrictAntiOn f s) : s.InjOn f := by + unsealing_newtype OrderDual => + exact hf.dual_left.injOn @[to_dual] theorem StrictMono.maximal_of_maximal_image (hf : StrictMono f) {a} (hmax : ∀ p, p ≤ f a) (x : α) : @@ -550,28 +562,33 @@ theorem monotone_add_nat_iff_monotoneOn_nat_Ici {f : ℕ → α} {k : ℕ} : · rw [← Nat.add_le_add_iff_right] at hle exact h (Nat.le_add_left k x) (Nat.le_add_left k y) hle -theorem antitone_nat_of_succ_le {f : ℕ → α} (hf : ∀ n, f (n + 1) ≤ f n) : Antitone f := - @monotone_nat_of_le_succ αᵒᵈ _ _ hf +theorem antitone_nat_of_succ_le {f : ℕ → α} (hf : ∀ n, f (n + 1) ≤ f n) : Antitone f := by + unsealing_newtype OrderDual => + exact @monotone_nat_of_le_succ αᵒᵈ _ _ hf theorem antitone_add_nat_of_succ_le {f : ℕ → α} {k : ℕ} (hf : ∀ n ≥ k, f (n + 1) ≤ f n) : - Antitone (fun n ↦ f (n + k)) := - @monotone_add_nat_of_le_succ αᵒᵈ _ f k hf + Antitone (fun n ↦ f (n + k)) := by + unsealing_newtype OrderDual => + exact @monotone_add_nat_of_le_succ αᵒᵈ _ f k hf -- TODO replace `{ x | k ≤ x }` with `Set.Ici k` theorem antitoneOn_nat_Ici_of_succ_le {f : ℕ → α} {k : ℕ} (hf : ∀ n ≥ k, f (n + 1) ≤ f n) : - AntitoneOn f { x | k ≤ x } := - @monotoneOn_nat_Ici_of_le_succ αᵒᵈ _ f k hf + AntitoneOn f { x | k ≤ x } := by + unsealing_newtype OrderDual => + exact @monotoneOn_nat_Ici_of_le_succ αᵒᵈ _ f k hf -- TODO replace `{ x | k ≤ x }` with `Set.Ici k` theorem antitone_add_nat_iff_antitoneOn_nat_Ici {f : ℕ → α} {k : ℕ} : - Antitone (fun n ↦ f (n + k)) ↔ AntitoneOn f { x | k ≤ x } := - @monotone_add_nat_iff_monotoneOn_nat_Ici αᵒᵈ _ f k + Antitone (fun n ↦ f (n + k)) ↔ AntitoneOn f { x | k ≤ x } := by + unsealing_newtype OrderDual => + exact @monotone_add_nat_iff_monotoneOn_nat_Ici αᵒᵈ _ f k theorem strictMono_nat_of_lt_succ {f : ℕ → α} (hf : ∀ n, f n < f (n + 1)) : StrictMono f := Nat.rel_of_forall_rel_succ_of_lt (· < ·) hf -theorem strictAnti_nat_of_succ_lt {f : ℕ → α} (hf : ∀ n, f (n + 1) < f n) : StrictAnti f := - @strictMono_nat_of_lt_succ αᵒᵈ _ f hf +theorem strictAnti_nat_of_succ_lt {f : ℕ → α} (hf : ∀ n, f (n + 1) < f n) : StrictAnti f := by + unsealing_newtype OrderDual => + exact @strictMono_nat_of_lt_succ αᵒᵈ _ f hf namespace Nat @@ -583,8 +600,9 @@ theorem exists_strictMono' [NoMaxOrder α] (a : α) : ∃ f : ℕ → α, Strict /-- If `α` is a preorder with no maximal elements, then there exists a strictly antitone function `ℕ → α` with any prescribed value of `f 0`. -/ -theorem exists_strictAnti' [NoMinOrder α] (a : α) : ∃ f : ℕ → α, StrictAnti f ∧ f 0 = a := - exists_strictMono' (OrderDual.toDual a) +theorem exists_strictAnti' [NoMinOrder α] (a : α) : ∃ f : ℕ → α, StrictAnti f ∧ f 0 = a := by + unsealing_newtype OrderDual => + exact exists_strictMono' (OrderDual.toDual a) theorem exists_strictMono_subsequence {P : ℕ → Prop} (h : ∀ N, ∃ n > N, P n) : ∃ φ : ℕ → ℕ, StrictMono φ ∧ ∀ n, P (φ n) := by @@ -604,8 +622,9 @@ theorem exists_strictMono [Nonempty α] [NoMaxOrder α] : ∃ f : ℕ → α, St /-- If `α` is a nonempty preorder with no minimal elements, then there exists a strictly antitone function `ℕ → α`. -/ -theorem exists_strictAnti [Nonempty α] [NoMinOrder α] : ∃ f : ℕ → α, StrictAnti f := - exists_strictMono αᵒᵈ +theorem exists_strictAnti [Nonempty α] [NoMinOrder α] : ∃ f : ℕ → α, StrictAnti f := by + unsealing_newtype OrderDual => + exact exists_strictMono αᵒᵈ lemma pow_self_mono : Monotone fun n : ℕ ↦ n ^ n := by refine monotone_nat_of_le_succ fun n ↦ ?_ @@ -666,8 +685,9 @@ theorem exists_strictMono : ∃ f : ℤ → α, StrictMono f := by /-- If `α` is a nonempty preorder with no minimal or maximal elements, then there exists a strictly antitone function `f : ℤ → α`. -/ -theorem exists_strictAnti : ∃ f : ℤ → α, StrictAnti f := - exists_strictMono αᵒᵈ +theorem exists_strictAnti : ∃ f : ℤ → α, StrictAnti f := by + unsealing_newtype OrderDual => + exact exists_strictMono αᵒᵈ end Int diff --git a/mathlib4/Mathlib/Order/Monotone/Extension.lean b/mathlib4/Mathlib/Order/Monotone/Extension.lean index 422d0c3cf..30fbcd816 100644 --- a/mathlib4/Mathlib/Order/Monotone/Extension.lean +++ b/mathlib4/Mathlib/Order/Monotone/Extension.lean @@ -51,5 +51,6 @@ theorem MonotoneOn.exists_monotone_extension (h : MonotoneOn f s) (hl : BddBelow /-- If a function is antitone and is bounded on a set `s`, then it admits an antitone extension to the whole space. -/ theorem AntitoneOn.exists_antitone_extension (h : AntitoneOn f s) (hl : BddBelow (f '' s)) - (hu : BddAbove (f '' s)) : ∃ g : α → β, Antitone g ∧ EqOn f g s := - h.dual_right.exists_monotone_extension hu hl + (hu : BddAbove (f '' s)) : ∃ g : α → β, Antitone g ∧ EqOn f g s := by + unsealing_newtype OrderDual => + exact h.dual_right.exists_monotone_extension hu hl diff --git a/mathlib4/Mathlib/Order/Monotone/Odd.lean b/mathlib4/Mathlib/Order/Monotone/Odd.lean index 57229e6df..af57ea6ab 100644 --- a/mathlib4/Mathlib/Order/Monotone/Odd.lean +++ b/mathlib4/Mathlib/Order/Monotone/Odd.lean @@ -36,8 +36,9 @@ theorem strictMono_of_odd_strictMonoOn_nonneg {f : G → H} (h₁ : ∀ x, f (-x /-- An odd function on a linear ordered additive commutative group is strictly antitone on the whole group provided that it is strictly antitone on `Set.Ici 0`. -/ theorem strictAnti_of_odd_strictAntiOn_nonneg {f : G → H} (h₁ : ∀ x, f (-x) = -f x) - (h₂ : StrictAntiOn f (Ici 0)) : StrictAnti f := - strictMono_of_odd_strictMonoOn_nonneg (H := Hᵒᵈ) h₁ h₂ + (h₂ : StrictAntiOn f (Ici 0)) : StrictAnti f := by + unsealing_newtype OrderDual => + exact strictMono_of_odd_strictMonoOn_nonneg (H := Hᵒᵈ) h₁ h₂ /-- An odd function on a linear ordered additive commutative group is monotone on the whole group provided that it is monotone on `Set.Ici 0`. -/ @@ -50,5 +51,6 @@ theorem monotone_of_odd_of_monotoneOn_nonneg {f : G → H} (h₁ : ∀ x, f (-x) /-- An odd function on a linear ordered additive commutative group is antitone on the whole group provided that it is monotone on `Set.Ici 0`. -/ theorem antitone_of_odd_of_monotoneOn_nonneg {f : G → H} (h₁ : ∀ x, f (-x) = -f x) - (h₂ : AntitoneOn f (Ici 0)) : Antitone f := - monotone_of_odd_of_monotoneOn_nonneg (H := Hᵒᵈ) h₁ h₂ + (h₂ : AntitoneOn f (Ici 0)) : Antitone f := by + unsealing_newtype OrderDual => + exact monotone_of_odd_of_monotoneOn_nonneg (H := Hᵒᵈ) h₁ h₂ diff --git a/mathlib4/Mathlib/Order/OrdContinuous.lean b/mathlib4/Mathlib/Order/OrdContinuous.lean index 76e0dfd24..fceb2981d 100644 --- a/mathlib4/Mathlib/Order/OrdContinuous.lean +++ b/mathlib4/Mathlib/Order/OrdContinuous.lean @@ -58,8 +58,9 @@ variable {α} @[to_dual] protected theorem dual : - LeftOrdContinuous f → RightOrdContinuous (toDual ∘ f ∘ ofDual) := - id + LeftOrdContinuous f → RightOrdContinuous (toDual ∘ f ∘ ofDual) := by + unsealing_newtype OrderDual => + exact id @[deprecated (since := "2026-04-08")] alias rightOrdContinuous_dual := LeftOrdContinuous.dual diff --git a/mathlib4/Mathlib/Order/OrderDual.lean b/mathlib4/Mathlib/Order/OrderDual.lean index b54748e38..9803667f3 100644 --- a/mathlib4/Mathlib/Order/OrderDual.lean +++ b/mathlib4/Mathlib/Order/OrderDual.lean @@ -5,6 +5,8 @@ Authors: Jeremy Avigad, Mario Carneiro -/ module +public meta import Lean.Elab.NewType +public meta import Lean.Elab.Tactic.NewType public import Mathlib.Logic.Equiv.Defs public import Mathlib.Order.Basic @@ -20,9 +22,11 @@ with notation `αᵒᵈ`. ## Implementation notes -One should not abuse definitional equality between `α` and `αᵒᵈ`. Instead, explicit -coercions should be inserted: -* `OrderDual.toDual : α → αᵒᵈ` and `OrderDual.ofDual : αᵒᵈ → α` +The type and its constructor and projection are irreducible. Use the explicit equivalences: +* `OrderDual.toDual : α ≃ αᵒᵈ` and `OrderDual.ofDual : αᵒᵈ ≃ α` + +Constructor/projection round trips reduce definitionally. In proofs that transport compound +types, `unsealing_newtype OrderDual => ...` can locally unfold the type and these maps. -/ @[expose] public section @@ -33,32 +37,39 @@ variable {α : Type*} /-- Type synonym to equip a type with the dual order: `≤` means `≥` and `<` means `>`. `αᵒᵈ` is notation for `OrderDual α`. -/ -def OrderDual (α : Type*) : Type _ := - α +public newtype OrderDual (α : Type*) := α with ofDual' @[inherit_doc] notation:max α "ᵒᵈ" => OrderDual α namespace OrderDual +/-- `toDual` is the identity function to the `OrderDual` of a linear order. -/ +def toDual : α ≃ αᵒᵈ := + ⟨mk, ofDual', fun _ ↦ rfl, fun _ ↦ rfl⟩ + +/-- `ofDual` is the identity function from the `OrderDual` of a linear order. -/ +def ofDual : αᵒᵈ ≃ α := + toDual.symm + instance (α : Type*) [h : Nonempty α] : Nonempty αᵒᵈ := - h + h.map mk -instance (α : Type*) [h : Subsingleton α] : Subsingleton αᵒᵈ := - h +instance (α : Type*) [Subsingleton α] : Subsingleton αᵒᵈ := + ⟨fun a b ↦ congrArg mk (Subsingleton.elim a.ofDual' b.ofDual')⟩ instance (α : Type*) [h : LE α] : LE αᵒᵈ := - ⟨fun a b ↦ h.le b a⟩ + ⟨fun a b ↦ h.le b.ofDual' a.ofDual'⟩ instance (α : Type*) [h : LT α] : LT αᵒᵈ := - ⟨fun a b ↦ h.lt b a⟩ + ⟨fun a b ↦ h.lt b.ofDual' a.ofDual'⟩ instance (α : Type*) [h : Ord α] : Ord αᵒᵈ := - ⟨fun a b ↦ h.compare b a⟩ + ⟨fun a b ↦ h.compare b.ofDual' a.ofDual'⟩ @[to_dual] instance (α : Type*) [h : Min α] : Max αᵒᵈ := - ⟨fun a b ↦ h.min a b⟩ + ⟨fun a b ↦ mk (h.min a.ofDual' b.ofDual')⟩ instance [LE α] [T : IsTrans α LE.le] : IsTrans αᵒᵈ LE.le where trans _ _ _ hab hbc := T.trans _ _ _ hbc hab @@ -67,7 +78,7 @@ instance [LT α] [T : IsTrans α LT.lt] : IsTrans αᵒᵈ LT.lt where trans _ _ _ hab hbc := T.trans _ _ _ hbc hab instance [LT α] [T : @Std.Trichotomous α LT.lt] : @Std.Trichotomous αᵒᵈ LT.lt where - trichotomous a b := by rw [eq_comm]; exact T.trichotomous b a + trichotomous a b h₁ h₂ := congrArg mk (T.trichotomous b.ofDual' a.ofDual' h₁ h₂).symm instance (α : Type*) [Preorder α] : Preorder αᵒᵈ where le_refl _ := le_refl _ @@ -75,62 +86,65 @@ instance (α : Type*) [Preorder α] : Preorder αᵒᵈ where lt_iff_le_not_ge _ _ := lt_iff_le_not_ge instance (α : Type*) [PartialOrder α] : PartialOrder αᵒᵈ where - le_antisymm a b hab hba := @le_antisymm α _ a b hba hab + le_antisymm a b hab hba := congrArg mk (@le_antisymm α _ a.ofDual' b.ofDual' hba hab) -instance (α : Type*) [DecidableEq α] : DecidableEq αᵒᵈ := ‹DecidableEq α› +instance (α : Type*) [DecidableEq α] : DecidableEq αᵒᵈ := ofDual.decidableEq instance (α : Type*) [LT α] [h : DecidableLT α] : DecidableLT (αᵒᵈ) := - fun a b ↦ h b a + fun a b ↦ h b.ofDual' a.ofDual' instance (α : Type*) [LE α] [h : DecidableLE α] : DecidableLE (αᵒᵈ) := - fun a b ↦ h b a + fun a b ↦ h b.ofDual' a.ofDual' set_option backward.isDefEq.respectTransparency false in instance (α : Type*) [LinearOrder α] : LinearOrder αᵒᵈ where - le_total a b := le_total (α := α) b a - min_def := max_def' (α := α) - max_def := min_def' (α := α) + le_total a b := le_total (α := α) b.ofDual' a.ofDual' + min_def a b := by + change mk (max a.ofDual' b.ofDual') = _ + rw [max_def' (α := α), apply_ite mk] + rfl + max_def a b := by + change mk (min a.ofDual' b.ofDual') = _ + rw [min_def' (α := α), apply_ite mk] + rfl toDecidableLE := inferInstance toDecidableLT := inferInstance toDecidableEq := inferInstance compare_eq_compareOfLessAndEq a b := by - simp only [compare, LinearOrder.compare_eq_compareOfLessAndEq, compareOfLessAndEq, eq_comm] - rfl + unsealing_newtype OrderDual => + simp only [compare, LinearOrder.compare_eq_compareOfLessAndEq, compareOfLessAndEq, eq_comm] + rfl set_option linter.style.setOption false in set_option backward.inferInstanceAs.wrap.reuseSubInstances false in -- otherwise we get an identity! /-- The opposite linear order to a given linear order -/ @[instance_reducible, deprecated "This declaration shouldn't have existed" (since := "2026-04-08")] -def _root_.LinearOrder.swap (α : Type*) (_ : LinearOrder α) : LinearOrder α := - inferInstanceAs <| LinearOrder (OrderDual α) +def _root_.LinearOrder.swap (α : Type*) (h : LinearOrder α) : LinearOrder α := + @LinearOrder.lift α αᵒᵈ _ ⟨fun a b ↦ h.min a b⟩ ⟨fun a b ↦ h.max a b⟩ mk + (fun _ _ h ↦ congrArg ofDual' h) (fun _ _ ↦ rfl) fun _ _ ↦ rfl -instance [h : Inhabited α] : Inhabited αᵒᵈ := ⟨h.default⟩ +instance [h : Inhabited α] : Inhabited αᵒᵈ := ⟨mk h.default⟩ -theorem Ord.dual_dual (α : Type*) [H : Ord α] : OrderDual.instOrd αᵒᵈ = H := +theorem Ord.dual_dual (α : Type*) [H : Ord α] : + (OrderDual.instOrd αᵒᵈ).compare = fun a b ↦ H.compare (ofDual (ofDual a)) (ofDual (ofDual b)) := rfl -theorem Preorder.dual_dual (α : Type*) [H : Preorder α] : OrderDual.instPreorder αᵒᵈ = H := +theorem Preorder.dual_dual (α : Type*) [H : Preorder α] : + (OrderDual.instPreorder αᵒᵈ).le = fun a b ↦ H.le (ofDual (ofDual a)) (ofDual (ofDual b)) := rfl theorem instPartialOrder.dual_dual (α : Type*) [H : PartialOrder α] : - OrderDual.instPartialOrder αᵒᵈ = H := + (OrderDual.instPartialOrder αᵒᵈ).le = fun a b ↦ H.le (ofDual (ofDual a)) (ofDual (ofDual b)) := rfl theorem instLinearOrder.dual_dual (α : Type*) [H : LinearOrder α] : - OrderDual.instLinearOrder αᵒᵈ = H := + (OrderDual.instLinearOrder αᵒᵈ).le = fun a b ↦ H.le (ofDual (ofDual a)) (ofDual (ofDual b)) := rfl -instance [h : Nontrivial α] : Nontrivial αᵒᵈ := h +instance [h : Nontrivial α] : Nontrivial αᵒᵈ := toDual.symm.nontrivial instance [h : Unique α] : Unique αᵒᵈ where - uniq := h.uniq - -/-- `toDual` is the identity function to the `OrderDual` of a linear order. -/ -def toDual : α ≃ αᵒᵈ := - Equiv.refl _ - -/-- `ofDual` is the identity function from the `OrderDual` of a linear order. -/ -def ofDual : αᵒᵈ ≃ α := - Equiv.refl _ + default := mk h.default + uniq a := congrArg mk (h.uniq a.ofDual') @[simp] theorem toDual_symm_eq : (@toDual α).symm = ofDual := rfl @[simp] theorem ofDual_symm_eq : (@ofDual α).symm = toDual := rfl @@ -145,7 +159,9 @@ def ofDual : αᵒᵈ ≃ α := theorem toDual_inj {a b : α} : toDual a = toDual b ↔ a = b := by simp theorem ofDual_inj {a b : αᵒᵈ} : ofDual a = ofDual b ↔ a = b := by simp -@[ext] lemma ext {a b : αᵒᵈ} (h : ofDual a = ofDual b) : a = b := h +@[ext] lemma ext {a b : αᵒᵈ} (h : ofDual a = ofDual b) : a = b := by + unsealing_newtype OrderDual => + exact h @[to_dual self, simp] theorem toDual_le_toDual [LE α] {a b : α} : toDual a ≤ toDual b ↔ b ≤ a := .rfl @@ -165,13 +181,16 @@ theorem le_toDual [LE α] {a : αᵒᵈ} {b : α} : a ≤ toDual b ↔ b ≤ ofD @[to_dual toDual_lt] theorem lt_toDual [LT α] {a : αᵒᵈ} {b : α} : a < toDual b ↔ b < ofDual a := .rfl -/-- Recursor for `αᵒᵈ`. -/ -@[elab_as_elim] +/-- Recursion principle for `αᵒᵈ` phrased in terms of `OrderDual.toDual`, supported by `cases` +and `induction`. -/ +@[elab_as_elim, cases_eliminator, induction_eliminator] protected def rec {motive : αᵒᵈ → Sort*} (toDual : ∀ a : α, motive (toDual a)) : - ∀ a : αᵒᵈ, motive a := toDual + ∀ a : αᵒᵈ, motive a := fun a ↦ toDual (ofDual a) -@[simp] protected theorem «forall» {p : αᵒᵈ → Prop} : (∀ a, p a) ↔ ∀ a, p (toDual a) := .rfl -@[simp] protected theorem «exists» {p : αᵒᵈ → Prop} : (∃ a, p a) ↔ ∃ a, p (toDual a) := .rfl +@[simp] protected theorem «forall» {p : αᵒᵈ → Prop} : (∀ a, p a) ↔ ∀ a, p (toDual a) := by + unsealing_newtype OrderDual => rfl +@[simp] protected theorem «exists» {p : αᵒᵈ → Prop} : (∃ a, p a) ↔ ∃ a, p (toDual a) := by + unsealing_newtype OrderDual => rfl @[to_dual self] alias ⟨_, _root_.LE.le.dual⟩ := toDual_le_toDual @[to_dual self] alias ⟨_, _root_.LT.lt.dual⟩ := toDual_lt_toDual @@ -184,11 +203,14 @@ end OrderDual instance OrderDual.denselyOrdered (α : Type*) [LT α] [h : DenselyOrdered α] : DenselyOrdered αᵒᵈ := - ⟨fun _ _ ha ↦ (@exists_between α _ h _ _ ha).imp fun _ ↦ And.symm⟩ + ⟨fun a b hab ↦ + let ⟨c, hc⟩ := @exists_between α _ h b.ofDual' a.ofDual' hab + ⟨OrderDual.mk c, hc.2, hc.1⟩⟩ @[simp] -theorem denselyOrdered_orderDual [LT α] : DenselyOrdered αᵒᵈ ↔ DenselyOrdered α := - ⟨by convert! @OrderDual.denselyOrdered αᵒᵈ _, @OrderDual.denselyOrdered α _⟩ +theorem denselyOrdered_orderDual [LT α] : DenselyOrdered αᵒᵈ ↔ DenselyOrdered α := by + unsealing_newtype OrderDual => + exact ⟨by convert! @OrderDual.denselyOrdered αᵒᵈ _, @OrderDual.denselyOrdered α _⟩ /-! ### Pushing order definitions through `Equiv` -/ diff --git a/mathlib4/Mathlib/Order/OrderIsoNat.lean b/mathlib4/Mathlib/Order/OrderIsoNat.lean index 150549fb0..2c9dc1ad4 100644 --- a/mathlib4/Mathlib/Order/OrderIsoNat.lean +++ b/mathlib4/Mathlib/Order/OrderIsoNat.lean @@ -87,8 +87,9 @@ theorem not_strictAnti_of_wellFoundedLT [Preorder α] [WellFoundedLT α] (f : (RelEmbedding.natGT f (fun n ↦ hf (by simp))).not_wellFounded wellFounded_lt theorem not_strictMono_of_wellFoundedGT [Preorder α] [WellFoundedGT α] (f : ℕ → α) : - ¬ StrictMono f := - not_strictAnti_of_wellFoundedLT (α := αᵒᵈ) f + ¬ StrictMono f := by + unsealing_newtype OrderDual => + exact not_strictAnti_of_wellFoundedLT (α := αᵒᵈ) f namespace Nat @@ -263,8 +264,9 @@ well-founded `<` is eventually constant. This is the dual of `WellFoundedGT.monotone_chain_condition`. It is provided for convenience, since it unbundles the antitone property from the order homomorphism. -/ theorem WellFoundedLT.antitone_chain_condition [PartialOrder α] [WellFoundedLT α] - {f : ℕ → α} (hf : Antitone f) : ∃ n, ∀ m, n ≤ m → f n = f m := - WellFoundedGT.monotone_chain_condition ⟨OrderDual.toDual ∘ f, hf⟩ + {f : ℕ → α} (hf : Antitone f) : ∃ n, ∀ m, n ≤ m → f n = f m := by + unsealing_newtype OrderDual => + exact WellFoundedGT.monotone_chain_condition ⟨OrderDual.toDual ∘ f, hf⟩ /-- Given an eventually-constant monotone sequence `a₀ ≤ a₁ ≤ a₂ ≤ ...` in a partially-ordered type, `monotonicSequenceLimitIndex a` is the least natural number `n` for which `aₙ` reaches the diff --git a/mathlib4/Mathlib/Order/PFilter.lean b/mathlib4/Mathlib/Order/PFilter.lean index 31bc5e22d..1feafb51b 100644 --- a/mathlib4/Mathlib/Order/PFilter.lean +++ b/mathlib4/Mathlib/Order/PFilter.lean @@ -53,8 +53,9 @@ def IsPFilter [Preorder P] (F : Set P) : Prop := theorem IsPFilter.of_def [Preorder P] {F : Set P} (nonempty : F.Nonempty) (directed : DirectedOn (· ≥ ·) F) (mem_of_le : ∀ {x y : P}, x ≤ y → x ∈ F → y ∈ F) : - IsPFilter F := - ⟨fun _ _ _ _ => mem_of_le ‹_› ‹_›, nonempty, directed⟩ + IsPFilter F := by + unsealing_newtype OrderDual => + exact ⟨fun _ _ _ _ => mem_of_le ‹_› ‹_›, nonempty, directed⟩ /-- Create an element of type `Order.PFilter` from a set satisfying the predicate `Order.IsPFilter`. -/ @@ -72,15 +73,19 @@ instance [Inhabited P] : Inhabited (PFilter P) := ⟨⟨default⟩⟩ /-- A filter on `P` is a subset of `P`. -/ instance : SetLike (PFilter P) P where coe F := toDual ⁻¹' F.dual.carrier - coe_injective := fun ⟨_⟩ ⟨_⟩ h => congr_arg mk <| Ideal.ext h + coe_injective := fun ⟨_⟩ ⟨_⟩ h => congr_arg mk <| Ideal.ext <| congrArg (⇑ofDual ⁻¹' ·) h instance : PartialOrder (PFilter P) := .ofSetLike (PFilter P) P theorem isPFilter : IsPFilter (F : Set P) := F.dual.isIdeal -protected theorem nonempty : (F : Set P).Nonempty := F.dual.nonempty +protected theorem nonempty : (F : Set P).Nonempty := by + unsealing_newtype OrderDual => + exact F.dual.nonempty -theorem directed : DirectedOn (· ≥ ·) (F : Set P) := F.dual.directed +theorem directed : DirectedOn (· ≥ ·) (F : Set P) := by + unsealing_newtype OrderDual => + exact F.dual.directed theorem mem_of_le {F : PFilter P} : x ≤ y → x ∈ F → y ∈ F := fun h => F.dual.lower h @@ -101,8 +106,9 @@ theorem mem_mk (x : P) (I : Ideal Pᵒᵈ) : x ∈ (⟨I⟩ : PFilter P) ↔ toD Iff.rfl @[simp] -theorem principal_le_iff {F : PFilter P} : principal x ≤ F ↔ x ∈ F := - Ideal.principal_le_iff (x := toDual x) +theorem principal_le_iff {F : PFilter P} : principal x ≤ F ↔ x ∈ F := by + unsealing_newtype OrderDual => + exact Ideal.principal_le_iff (x := toDual x) @[simp] theorem mem_principal : x ∈ principal y ↔ y ≤ x := Iff.rfl @@ -124,14 +130,14 @@ variable [Preorder P] [OrderTop P] {F : PFilter P} /-- There is a bottom filter when `P` has a top element. -/ instance : OrderBot (PFilter P) where bot := ⟨⊥⟩ - bot_le F := (bot_le : ⊥ ≤ F.dual) + bot_le _ _ hx := (bot_le : (⊥ : Ideal Pᵒᵈ) ≤ _) hx end OrderTop /-- There is a top filter when `P` has a bottom element. -/ instance {P} [Preorder P] [OrderBot P] : OrderTop (PFilter P) where top := ⟨⊤⟩ - le_top F := (le_top : F.dual ≤ ⊤) + le_top F _ hx := (le_top : F.dual ≤ (⊤ : Ideal Pᵒᵈ)) hx section SemilatticeInf diff --git a/mathlib4/Mathlib/Order/PartialSups.lean b/mathlib4/Mathlib/Order/PartialSups.lean index d989ae872..810ef8617 100644 --- a/mathlib4/Mathlib/Order/PartialSups.lean +++ b/mathlib4/Mathlib/Order/PartialSups.lean @@ -64,12 +64,13 @@ lemma partialSups_apply (f : ι → α) (i : ι) : lemma partialSups_iff_forall {f : ι → α} (p : α → Prop) (hp : ∀ {a b}, p (a ⊔ b) ↔ p a ∧ p b) {i : ι} : p (partialSups f i) ↔ ∀ j ≤ i, p (f j) := by - rw [partialSups_apply, apply_sup'_eq_sup'_comp (γ := Propᵒᵈ) _ p, sup'_eq_sup] - · change (Iic i).inf (p ∘ f) ↔ _ - simp [Finset.inf_eq_iInf] - · intro x y - rw [hp] - rfl + unsealing_newtype OrderDual => + rw [partialSups_apply, apply_sup'_eq_sup'_comp (γ := Propᵒᵈ) _ p, sup'_eq_sup] + · change (Iic i).inf (p ∘ f) ↔ _ + simp [Finset.inf_eq_iInf] + · intro x y + rw [hp] + rfl @[simp] lemma partialSups_le_iff {f : ι → α} {i : ι} {a : α} : diff --git a/mathlib4/Mathlib/Order/PiLex.lean b/mathlib4/Mathlib/Order/PiLex.lean index c5fd5b089..572b05c35 100644 --- a/mathlib4/Mathlib/Order/PiLex.lean +++ b/mathlib4/Mathlib/Order/PiLex.lean @@ -121,8 +121,9 @@ instance Lex.isStrictOrder [LinearOrder ι] [∀ a, PartialOrder (β a)] : set_option backward.isDefEq.respectTransparency.types false in instance Colex.isStrictOrder [LinearOrder ι] [∀ a, PartialOrder (β a)] : - IsStrictOrder (Colex (∀ i, β i)) (· < ·) := - Lex.isStrictOrder (ι := ιᵒᵈ) + IsStrictOrder (Colex (∀ i, β i)) (· < ·) := by + unsealing_newtype OrderDual => + exact Lex.isStrictOrder (ι := ιᵒᵈ) instance [LinearOrder ι] [∀ a, PartialOrder (β a)] : PartialOrder (Lex (∀ i, β i)) := partialOrderOfSO (· < ·) @@ -136,11 +137,11 @@ noncomputable instance Lex.linearOrder [LinearOrder ι] [WellFoundedLT ι] @linearOrderOfSTO (Πₗ i, β i) (· < ·) { trichotomous := (trichotomous_lex _ _ IsWellFounded.wf).1 } (Classical.decRel _) -set_option backward.isDefEq.respectTransparency.types false in /-- `Colex (∀ i, α i)` is a linear order if the original order has well-founded `>`. -/ noncomputable instance Colex.linearOrder [LinearOrder ι] [WellFoundedGT ι] [∀ a, LinearOrder (β a)] : LinearOrder (Colex (∀ i, β i)) := - Lex.linearOrder (ι := ιᵒᵈ) + @linearOrderOfSTO (Colex (∀ i, β i)) (· < ·) + { trichotomous := (trichotomous_lex _ _ IsWellFounded.wf).1 } (Classical.decRel _) set_option backward.isDefEq.respectTransparency false in theorem lex_le_iff_of_unique [Unique ι] [LinearOrder ι] [∀ i, PartialOrder (β i)] @@ -215,32 +216,38 @@ section Colex variable [WellFoundedGT ι] set_option backward.isDefEq.respectTransparency.types false in -theorem toColex_monotone : Monotone (@toColex (∀ i, β i)) := - toLex_monotone (ι := ιᵒᵈ) +theorem toColex_monotone : Monotone (@toColex (∀ i, β i)) := by + unsealing_newtype OrderDual => + exact toLex_monotone (ι := ιᵒᵈ) set_option backward.isDefEq.respectTransparency.types false in -theorem toColex_strictMono : StrictMono (@toColex (∀ i, β i)) := - toLex_strictMono (ι := ιᵒᵈ) +theorem toColex_strictMono : StrictMono (@toColex (∀ i, β i)) := by + unsealing_newtype OrderDual => + exact toLex_strictMono (ι := ιᵒᵈ) set_option backward.isDefEq.respectTransparency.types false in @[simp] -theorem lt_toColex_update_self_iff : toColex x < toColex (update x i a) ↔ x i < a := - lt_toLex_update_self_iff (ι := ιᵒᵈ) +theorem lt_toColex_update_self_iff : toColex x < toColex (update x i a) ↔ x i < a := by + unsealing_newtype OrderDual => + exact lt_toLex_update_self_iff (ι := ιᵒᵈ) set_option backward.isDefEq.respectTransparency.types false in @[simp] -theorem toColex_update_lt_self_iff : toColex (update x i a) < toColex x ↔ a < x i := - toLex_update_lt_self_iff (ι := ιᵒᵈ) +theorem toColex_update_lt_self_iff : toColex (update x i a) < toColex x ↔ a < x i := by + unsealing_newtype OrderDual => + exact toLex_update_lt_self_iff (ι := ιᵒᵈ) -set_option backward.isDefEq.respectTransparency.types false in +set_option backward.isDefEq.respectTransparency false in @[simp] -theorem le_toColex_update_self_iff : toColex x ≤ toColex (update x i a) ↔ x i ≤ a := - le_toLex_update_self_iff (ι := ιᵒᵈ) +theorem le_toColex_update_self_iff : toColex x ≤ toColex (update x i a) ↔ x i ≤ a := by + unsealing_newtype OrderDual => + exact le_toLex_update_self_iff (ι := ιᵒᵈ) -set_option backward.isDefEq.respectTransparency.types false in +set_option backward.isDefEq.respectTransparency false in @[simp] -theorem toColex_update_le_self_iff : toColex (update x i a) ≤ toColex x ↔ a ≤ x i := - toLex_update_le_self_iff (ι := ιᵒᵈ) +theorem toColex_update_le_self_iff : toColex (update x i a) ≤ toColex x ↔ a ≤ x i := by + unsealing_newtype OrderDual => + exact toLex_update_le_self_iff (ι := ιᵒᵈ) end Colex @@ -314,8 +321,9 @@ instance [Preorder ι] [∀ i, LT (β i)] [∀ i, DenselyOrdered (β i)] : set_option backward.isDefEq.respectTransparency.types false in instance [Preorder ι] [∀ i, LT (β i)] [∀ i, DenselyOrdered (β i)] : - DenselyOrdered (Colex (∀ i, β i)) := - inferInstanceAs (DenselyOrdered (Lex (∀ i : ιᵒᵈ, β (OrderDual.toDual i)))) + DenselyOrdered (Colex (∀ i, β i)) := by + unsealing_newtype OrderDual => + exact inferInstanceAs (DenselyOrdered (Lex (∀ i : ιᵒᵈ, β (OrderDual.toDual i)))) set_option backward.isDefEq.respectTransparency.types false in theorem Lex.noMaxOrder' [Preorder ι] [∀ i, LT (β i)] (i : ι) [NoMaxOrder (β i)] : @@ -328,8 +336,9 @@ theorem Lex.noMaxOrder' [Preorder ι] [∀ i, LT (β i)] (i : ι) [NoMaxOrder ( set_option backward.isDefEq.respectTransparency.types false in theorem Colex.noMaxOrder' [Preorder ι] [∀ i, LT (β i)] (i : ι) [NoMaxOrder (β i)] : - NoMaxOrder (Colex (∀ i, β i)) := - Lex.noMaxOrder' (ι := ιᵒᵈ) i + NoMaxOrder (Colex (∀ i, β i)) := by + unsealing_newtype OrderDual => + exact Lex.noMaxOrder' (ι := ιᵒᵈ) i instance [LinearOrder ι] [WellFoundedLT ι] [Nonempty ι] [∀ i, PartialOrder (β i)] [∀ i, NoMaxOrder (β i)] : NoMaxOrder (Lex (∀ i, β i)) := @@ -337,10 +346,11 @@ instance [LinearOrder ι] [WellFoundedLT ι] [Nonempty ι] [∀ i, PartialOrder let ⟨_, hb⟩ := exists_gt (ofLex a) ⟨_, toLex_strictMono hb⟩⟩ -set_option backward.isDefEq.respectTransparency.types false in instance [LinearOrder ι] [WellFoundedGT ι] [Nonempty ι] [∀ i, PartialOrder (β i)] [∀ i, NoMaxOrder (β i)] : NoMaxOrder (Colex (∀ i, β i)) := - inferInstanceAs (NoMaxOrder (Lex (∀ i : ιᵒᵈ, β (OrderDual.toDual i)))) + ⟨fun a => + let ⟨_, hb⟩ := exists_gt (ofColex a) + ⟨_, toColex_strictMono hb⟩⟩ instance [LinearOrder ι] [WellFoundedLT ι] [Nonempty ι] [∀ i, PartialOrder (β i)] [∀ i, NoMinOrder (β i)] : NoMinOrder (Lex (∀ i, β i)) := @@ -348,10 +358,11 @@ instance [LinearOrder ι] [WellFoundedLT ι] [Nonempty ι] [∀ i, PartialOrder let ⟨_, hb⟩ := exists_lt (ofLex a) ⟨_, toLex_strictMono hb⟩⟩ -set_option backward.isDefEq.respectTransparency.types false in instance [LinearOrder ι] [WellFoundedGT ι] [Nonempty ι] [∀ i, PartialOrder (β i)] [∀ i, NoMinOrder (β i)] : NoMinOrder (Colex (∀ i, β i)) := - inferInstanceAs (NoMinOrder (Lex (∀ i : ιᵒᵈ, β (OrderDual.toDual i)))) + ⟨fun a => + let ⟨_, hb⟩ := exists_lt (ofColex a) + ⟨_, toColex_strictMono hb⟩⟩ /-- If we swap two strictly decreasing values in a function, then the result is lexicographically smaller than the original function. -/ @@ -364,7 +375,8 @@ theorem lex_desc {α} [Preorder ι] [DecidableEq ι] [LT α] {f : ι → α} {i smaller than the original function. -/ theorem colex_asc {α} [Preorder ι] [DecidableEq ι] [LT α] {f : ι → α} {i j : ι} (h₁ : i ≤ j) (h₂ : f i < f j) : toColex (f ∘ Equiv.swap i j) < toColex f := by - rw [Equiv.swap_comm] - exact lex_desc (ι := ιᵒᵈ) h₁ h₂ + unsealing_newtype OrderDual => + rw [Equiv.swap_comm] + exact lex_desc (ι := ιᵒᵈ) h₁ h₂ end Pi diff --git a/mathlib4/Mathlib/Order/Preorder/Chain.lean b/mathlib4/Mathlib/Order/Preorder/Chain.lean index 7ea92e0d9..735b3ff27 100644 --- a/mathlib4/Mathlib/Order/Preorder/Chain.lean +++ b/mathlib4/Mathlib/Order/Preorder/Chain.lean @@ -121,12 +121,14 @@ theorem Monotone.isChain_range [LinearOrder α] [Preorder β] {f : α → β} (h exact hf.isChain_image (isChain_of_trichotomous _) lemma Antitone.isChain_image [Preorder α] [Preorder β] {s : Set α} {f : α → β} - (hf : Antitone f) (hs : IsChain (· ≤ ·) s) : IsChain (· ≤ ·) (f '' s) := - hf.dual_left.isChain_image hs.symm + (hf : Antitone f) (hs : IsChain (· ≤ ·) s) : IsChain (· ≤ ·) (f '' s) := by + unsealing_newtype OrderDual => + exact hf.dual_left.isChain_image hs.symm theorem Antitone.isChain_range [LinearOrder α] [Preorder β] {f : α → β} (hf : Antitone f) : - IsChain (· ≤ ·) (range f) := - hf.dual_left.isChain_range + IsChain (· ≤ ·) (range f) := by + unsealing_newtype OrderDual => + exact hf.dual_left.isChain_range theorem IsChain.lt_of_le [PartialOrder α] {s : Set α} (h : IsChain (· ≤ ·) s) : IsChain (· < ·) s := fun _a ha _b hb hne ↦ diff --git a/mathlib4/Mathlib/Order/Preorder/Finite.lean b/mathlib4/Mathlib/Order/Preorder/Finite.lean index 04d245be8..7f7596113 100644 --- a/mathlib4/Mathlib/Order/Preorder/Finite.lean +++ b/mathlib4/Mathlib/Order/Preorder/Finite.lean @@ -99,8 +99,9 @@ lemma infinite_of_forall_exists_gt (h : ∀ a, ∃ b ∈ s, a < b) : s.Infinite (strictMono_nat_of_lt_succ fun n => (h _).choose_spec.2).injective hf @[to_dual existing infinite_of_forall_exists_gt] -lemma infinite_of_forall_exists_lt (h : ∀ a, ∃ b ∈ s, b < a) : s.Infinite := - infinite_of_forall_exists_gt (α := αᵒᵈ) h +lemma infinite_of_forall_exists_lt (h : ∀ a, ∃ b ∈ s, b < a) : s.Infinite := by + unsealing_newtype OrderDual => + exact infinite_of_forall_exists_gt (α := αᵒᵈ) h end Preorder diff --git a/mathlib4/Mathlib/Order/PropInstances.lean b/mathlib4/Mathlib/Order/PropInstances.lean index a7e3fa5ad..263002b1d 100644 --- a/mathlib4/Mathlib/Order/PropInstances.lean +++ b/mathlib4/Mathlib/Order/PropInstances.lean @@ -79,8 +79,9 @@ theorem disjoint_iff [∀ i, OrderBot (α' i)] {f g : ∀ i, α' i} : apply h i (hf i) (hg i) theorem codisjoint_iff [∀ i, OrderTop (α' i)] {f g : ∀ i, α' i} : - Codisjoint f g ↔ ∀ i, Codisjoint (f i) (g i) := - @disjoint_iff _ (fun i => (α' i)ᵒᵈ) _ _ _ _ + Codisjoint f g ↔ ∀ i, Codisjoint (f i) (g i) := by + unsealing_newtype OrderDual => + exact @disjoint_iff _ (fun i => (α' i)ᵒᵈ) _ _ _ _ theorem isCompl_iff [∀ i, BoundedOrder (α' i)] {f g : ∀ i, α' i} : IsCompl f g ↔ ∀ i, IsCompl (f i) (g i) := by diff --git a/mathlib4/Mathlib/Order/Rel/GaloisConnection.lean b/mathlib4/Mathlib/Order/Rel/GaloisConnection.lean index a21eabf8a..e756bde80 100644 --- a/mathlib4/Mathlib/Order/Rel/GaloisConnection.lean +++ b/mathlib4/Mathlib/Order/Rel/GaloisConnection.lean @@ -53,8 +53,9 @@ of elements `a` of type `α` such that `a ~[R] b` for every element `b` of `I`. def rightDual (I : Set β) : Set α := {a : α | ∀ ⦃b⦄, b ∈ I → a ~[R] b} /-- The pair of functions `toDual ∘ leftDual` and `rightDual ∘ ofDual` forms a Galois connection. -/ -theorem gc_leftDual_rightDual : GaloisConnection (toDual ∘ R.leftDual) (R.rightDual ∘ ofDual) := - fun _ _ ↦ ⟨fun h _ ha _ hb ↦ h (by simpa) ha, fun h _ hb _ ha ↦ h (by simpa) hb⟩ +theorem gc_leftDual_rightDual : GaloisConnection (toDual ∘ R.leftDual) (R.rightDual ∘ ofDual) := by + unsealing_newtype OrderDual => + exact fun _ _ ↦ ⟨fun h _ ha _ hb ↦ h (by simpa) ha, fun h _ hb _ ha ↦ h (by simpa) hb⟩ /-! ### Induced equivalences between fixed points -/ @@ -69,15 +70,17 @@ open GaloisConnection /-- `leftDual` maps every element `J` to `rightFixedPoints`. -/ theorem leftDual_mem_rightFixedPoint (J : Set α) : R.leftDual J ∈ R.rightFixedPoints := by - apply le_antisymm - · apply R.gc_leftDual_rightDual.monotone_l; exact R.gc_leftDual_rightDual.le_u_l J - · exact R.gc_leftDual_rightDual.l_u_le (R.leftDual J) + unsealing_newtype OrderDual => + apply le_antisymm + · apply R.gc_leftDual_rightDual.monotone_l; exact R.gc_leftDual_rightDual.le_u_l J + · exact R.gc_leftDual_rightDual.l_u_le (R.leftDual J) /-- `rightDual` maps every element `I` to `leftFixedPoints`. -/ theorem rightDual_mem_leftFixedPoint (I : Set β) : R.rightDual I ∈ R.leftFixedPoints := by - apply le_antisymm - · apply R.gc_leftDual_rightDual.monotone_u; exact R.gc_leftDual_rightDual.l_u_le I - · exact R.gc_leftDual_rightDual.le_u_l (R.rightDual I) + unsealing_newtype OrderDual => + apply le_antisymm + · apply R.gc_leftDual_rightDual.monotone_u; exact R.gc_leftDual_rightDual.l_u_le I + · exact R.gc_leftDual_rightDual.le_u_l (R.rightDual I) /-- The maps `leftDual` and `rightDual` induce inverse bijections between the sets of fixed points. -/ @@ -89,16 +92,18 @@ def equivFixedPoints : R.leftFixedPoints ≃ R.rightFixedPoints where theorem rightDual_leftDual_le_of_le {J J' : Set α} (h : J' ∈ R.leftFixedPoints) (h₁ : J ≤ J') : R.rightDual (R.leftDual J) ≤ J' := by - rw [← h] - apply R.gc_leftDual_rightDual.monotone_u - apply R.gc_leftDual_rightDual.monotone_l - exact h₁ + unsealing_newtype OrderDual => + rw [← h] + apply R.gc_leftDual_rightDual.monotone_u + apply R.gc_leftDual_rightDual.monotone_l + exact h₁ theorem leftDual_rightDual_le_of_le {I I' : Set β} (h : I' ∈ R.rightFixedPoints) (h₁ : I ≤ I') : R.leftDual (R.rightDual I) ≤ I' := by - rw [← h] - apply R.gc_leftDual_rightDual.monotone_l - apply R.gc_leftDual_rightDual.monotone_u - exact h₁ + unsealing_newtype OrderDual => + rw [← h] + apply R.gc_leftDual_rightDual.monotone_l + apply R.gc_leftDual_rightDual.monotone_u + exact h₁ end SetRel diff --git a/mathlib4/Mathlib/Order/RelClasses.lean b/mathlib4/Mathlib/Order/RelClasses.lean index ad0d12451..30849cd5c 100644 --- a/mathlib4/Mathlib/Order/RelClasses.lean +++ b/mathlib4/Mathlib/Order/RelClasses.lean @@ -252,11 +252,12 @@ lemma wellFounded_lt [LT α] [WellFoundedLT α] : @WellFounded α (· < ·) := I -- See note [lower instance priority] @[to_dual] instance (priority := 100) (α : Type*) [LT α] [h : WellFoundedLT α] : WellFoundedGT αᵒᵈ := - h + ⟨InvImage.wf OrderDual.ofDual' h.wf⟩ @[to_dual] -theorem wellFoundedGT_dual_iff (α : Type*) [LT α] : WellFoundedGT αᵒᵈ ↔ WellFoundedLT α := - ⟨fun h => ⟨h.wf⟩, fun h => ⟨h.wf⟩⟩ +theorem wellFoundedGT_dual_iff (α : Type*) [LT α] : WellFoundedGT αᵒᵈ ↔ WellFoundedLT α := by + unsealing_newtype OrderDual => + exact ⟨fun h => ⟨h.wf⟩, fun h => ⟨h.wf⟩⟩ /-- A well order is a well-founded linear order. -/ @[wikidata Q659746] @@ -624,7 +625,7 @@ theorem isTrans_lt [Preorder α] : IsTrans α LT.lt := @[to_dual total_ge] instance OrderDual.total_le [LE α] [h : @Std.Total α (· ≤ ·)] : @Std.Total αᵒᵈ (· ≤ ·) := - inferInstanceAs <| @Std.Total α <| swap (· ≤ ·) + ⟨fun a b ↦ h.total b.ofDual' a.ofDual'⟩ instance : WellFoundedLT ℕ := ⟨Nat.lt_wfRel.wf⟩ diff --git a/mathlib4/Mathlib/Order/RelIso/Set.lean b/mathlib4/Mathlib/Order/RelIso/Set.lean index 69aea6ed9..b70d0573b 100644 --- a/mathlib4/Mathlib/Order/RelIso/Set.lean +++ b/mathlib4/Mathlib/Order/RelIso/Set.lean @@ -37,8 +37,9 @@ theorem map_inf [SemilatticeInf α] [LinearOrder β] [FunLike F β α] theorem map_sup [SemilatticeSup α] [LinearOrder β] [FunLike F β α] [RelHomClass F (· > ·) (· > ·)] (a : F) (m n : β) : - a (m ⊔ n) = a m ⊔ a n := - map_inf (α := αᵒᵈ) (β := βᵒᵈ) _ _ _ + a (m ⊔ n) = a m ⊔ a n := by + unsealing_newtype OrderDual => + exact map_inf (α := αᵒᵈ) (β := βᵒᵈ) _ _ _ theorem directed [FunLike F α β] [RelHomClass F r s] {ι : Sort*} {a : ι → α} {f : F} (ha : Directed r a) : Directed s (f ∘ a) := diff --git a/mathlib4/Mathlib/Order/Sublocale.lean b/mathlib4/Mathlib/Order/Sublocale.lean index b61995cf3..020cd85b9 100644 --- a/mathlib4/Mathlib/Order/Sublocale.lean +++ b/mathlib4/Mathlib/Order/Sublocale.lean @@ -223,15 +223,16 @@ def nucleusIsoSublocale : (Nucleus X)ᵒᵈ ≃o Sublocale X where right_inv S := by ext x; simpa using ⟨by simp +contextual [eq_comm], fun hx ↦ ⟨x, by simp [hx]⟩⟩ map_rel_iff' := by simp -lemma nucleusIsoSublocale.eq_toSublocale : Nucleus.toSublocale = @nucleusIsoSublocale X _ := rfl -lemma nucleusIsoSublocale.symm_eq_toNucleus : - Sublocale.toNucleus = (@nucleusIsoSublocale X _).symm := rfl +lemma nucleusIsoSublocale.eq_toSublocale (n : Nucleus X) : + nucleusIsoSublocale (OrderDual.toDual n) = n.toSublocale := rfl + +lemma nucleusIsoSublocale.symm_eq_toNucleus (S : Sublocale X) : + OrderDual.ofDual (nucleusIsoSublocale.symm S) = S.toNucleus := rfl instance Sublocale.instCompleteLattice : CompleteLattice (Sublocale X) := nucleusIsoSublocale.toGaloisInsertion.liftCompleteLattice -set_option backward.isDefEq.respectTransparency false in instance Sublocale.instCoframe : Order.Coframe (Sublocale X) := .ofMinimalAxioms { - iInf_sup_le_sup_sInf a s := by simp [← toNucleus_le_toNucleus, - nucleusIsoSublocale.symm_eq_toNucleus, nucleusIsoSublocale.symm.map_sup, - nucleusIsoSublocale.symm.map_sInf, sup_iInf_eq, nucleusIsoSublocale.symm.map_iInf] } + iInf_sup_le_sup_sInf a s := by + rw [← nucleusIsoSublocale.symm.le_iff_le] + simp only [map_iInf, map_sup, map_sInf, sup_sInf_eq, iInf_image, le_refl] } diff --git a/mathlib4/Mathlib/Order/SuccPred/Archimedean.lean b/mathlib4/Mathlib/Order/SuccPred/Archimedean.lean index a3ff37adb..46ddd5a45 100644 --- a/mathlib4/Mathlib/Order/SuccPred/Archimedean.lean +++ b/mathlib4/Mathlib/Order/SuccPred/Archimedean.lean @@ -43,12 +43,14 @@ section Preorder variable [Preorder α] -- `to_dual` cannot yet reorder arguments of arguments -instance [SuccOrder α] [IsSuccArchimedean α] : IsPredArchimedean αᵒᵈ := - ⟨fun {a b} h => by convert! exists_succ_iterate_of_le h.ofDual⟩ +instance [SuccOrder α] [IsSuccArchimedean α] : IsPredArchimedean αᵒᵈ := by + unsealing_newtype OrderDual => + exact ⟨fun {a b} h => by convert! exists_succ_iterate_of_le h.ofDual⟩ @[to_dual existing] -instance [PredOrder α] [IsPredArchimedean α] : IsSuccArchimedean αᵒᵈ := - ⟨fun {a b} h => by convert! exists_pred_iterate_of_le h.ofDual⟩ +instance [PredOrder α] [IsPredArchimedean α] : IsSuccArchimedean αᵒᵈ := by + unsealing_newtype OrderDual => + exact ⟨fun {a b} h => by convert! exists_pred_iterate_of_le h.ofDual⟩ section SuccOrder @@ -137,9 +139,13 @@ This isn't an instance due to a loop with `LinearOrder`. @[to_dual existing] abbrev IsPredArchimedean.linearOrder [PredOrder α] [IsPredArchimedean α] [DecidableEq α] [DecidableLE α] [DecidableLT α] - [IsDirectedOrder α] : LinearOrder α := - letI : LinearOrder αᵒᵈ := IsSuccArchimedean.linearOrder - inferInstanceAs (LinearOrder αᵒᵈᵒᵈ) + [IsDirectedOrder α] : LinearOrder α where + le_total a b := + have ⟨c, ha, hb⟩ := directed_of (· ≤ ·) a b + le_total_of_directed hb ha + toDecidableEq := inferInstance + toDecidableLE := inferInstance + toDecidableLT := inferInstance end PartialOrder @@ -177,8 +183,9 @@ lemma StrictMono.not_bddAbove_range_of_isSuccArchimedean [NoMaxOrder α] [SuccOr @[to_dual] lemma StrictAnti.not_bddAbove_range_of_isSuccArchimedean [NoMinOrder α] [SuccOrder β] - [IsSuccArchimedean β] (hf : StrictAnti f) : ¬ BddAbove (Set.range f) := - hf.dual_right.not_bddBelow_range_of_isPredArchimedean + [IsSuccArchimedean β] (hf : StrictAnti f) : ¬ BddAbove (Set.range f) := by + unsealing_newtype OrderDual => + exact hf.dual_right.not_bddBelow_range_of_isPredArchimedean end bdd_range @@ -204,9 +211,10 @@ instance (priority := 100) WellFoundedLT.toIsPredArchimedean [h : WellFoundedLT @[to_dual existing] instance (priority := 100) WellFoundedGT.toIsSuccArchimedean [h : WellFoundedGT α] - [SuccOrder α] : IsSuccArchimedean α := - let h : IsPredArchimedean αᵒᵈ := by infer_instance - ⟨h.1⟩ + [SuccOrder α] : IsSuccArchimedean α := by + unsealing_newtype OrderDual => + let h : IsPredArchimedean αᵒᵈ := by infer_instance + exact ⟨h.1⟩ end IsWellFounded @@ -325,9 +333,10 @@ instance Set.OrdConnected.isPredArchimedean [PredOrder α] [IsPredArchimedean α · exact this instance Set.OrdConnected.isSuccArchimedean [SuccOrder α] [IsSuccArchimedean α] - (s : Set α) [s.OrdConnected] : IsSuccArchimedean s := - letI : IsPredArchimedean sᵒᵈ := inferInstanceAs (IsPredArchimedean (OrderDual.ofDual ⁻¹' s)) - inferInstanceAs (IsSuccArchimedean sᵒᵈᵒᵈ) + (s : Set α) [s.OrdConnected] : IsSuccArchimedean s := by + unsealing_newtype OrderDual => + let : IsPredArchimedean sᵒᵈ := inferInstanceAs (IsPredArchimedean (OrderDual.ofDual ⁻¹' s)) + exact inferInstanceAs (IsSuccArchimedean sᵒᵈᵒᵈ) end OrdConnected diff --git a/mathlib4/Mathlib/Order/SuccPred/Basic.lean b/mathlib4/Mathlib/Order/SuccPred/Basic.lean index 579dab7a4..3473c0ffb 100644 --- a/mathlib4/Mathlib/Order/SuccPred/Basic.lean +++ b/mathlib4/Mathlib/Order/SuccPred/Basic.lean @@ -73,7 +73,7 @@ class PredOrder (α : Type*) [Preorder α] where instance [Preorder α] [SuccOrder α] : PredOrder αᵒᵈ where pred := toDual ∘ SuccOrder.succ ∘ ofDual pred_le := by simp [SuccOrder.le_succ] - min_of_le_pred h := by apply SuccOrder.max_of_succ_le h + min_of_le_pred h := (SuccOrder.max_of_succ_le h).toDual le_pred_of_lt {a b} h := SuccOrder.succ_le_of_lt h section Preorder @@ -633,13 +633,15 @@ variable [Preorder α] [PredOrder α] {a : α} @[to_dual existing] theorem isMin_iterate_pred_of_eq_of_lt {n m : ℕ} (h_eq : pred^[n] a = pred^[m] a) - (h_lt : n < m) : IsMin (pred^[n] a) := - @isMax_iterate_succ_of_eq_of_lt αᵒᵈ _ _ _ _ _ h_eq h_lt + (h_lt : n < m) : IsMin (pred^[n] a) := by + unsealing_newtype OrderDual => + exact @isMax_iterate_succ_of_eq_of_lt αᵒᵈ _ _ _ _ _ h_eq h_lt @[to_dual existing] theorem isMin_iterate_pred_of_eq_of_ne {n m : ℕ} (h_eq : pred^[n] a = pred^[m] a) - (h_ne : n ≠ m) : IsMin (pred^[n] a) := - @isMax_iterate_succ_of_eq_of_ne αᵒᵈ _ _ _ _ _ h_eq h_ne + (h_ne : n ≠ m) : IsMin (pred^[n] a) := by + unsealing_newtype OrderDual => + exact @isMax_iterate_succ_of_eq_of_ne αᵒᵈ _ _ _ _ _ h_eq h_ne end Preorder @@ -889,24 +891,28 @@ lemma pred_notMem_iff_isMin [PredOrder α] [NoMinOrder α] {a : s} : rw [coe_pred_of_mem nh] at h simp at h -noncomputable instance Set.OrdConnected.succOrder [SuccOrder α] : - SuccOrder s := - letI : PredOrder sᵒᵈ := inferInstanceAs (PredOrder (OrderDual.ofDual ⁻¹' s)) - inferInstanceAs (SuccOrder sᵒᵈᵒᵈ) -set_option backward.isDefEq.respectTransparency false in +open scoped Classical in +noncomputable instance Set.OrdConnected.succOrder [SuccOrder α] : SuccOrder s where + succ x := if h : Order.succ x.1 ∈ s then ⟨Order.succ x.1, h⟩ else x + le_succ := fun ⟨x, hx⟩ ↦ by dsimp; split <;> simp_all [Order.le_succ] + max_of_succ_le := by + unsealing_newtype OrderDual => + exact (Set.OrdConnected.predOrder (α := αᵒᵈ) (s := OrderDual.ofDual ⁻¹' s)).min_of_le_pred + succ_le_of_lt := by + unsealing_newtype OrderDual => + exact (Set.OrdConnected.predOrder (α := αᵒᵈ) (s := OrderDual.ofDual ⁻¹' s)).le_pred_of_lt + @[simp, norm_cast] lemma coe_succ_of_mem [SuccOrder α] {a : s} (h : succ ↑a ∈ s) : (succ a).1 = succ ↑a := by classical change Subtype.val (dite ..) = _ - split_ifs <;> trivial + simp [h] -set_option backward.isDefEq.respectTransparency false in -lemma isMax_of_succ_notMem [SuccOrder α] {a : s} (h : succ ↑a ∉ s) : IsMax a := by - classical +lemma isMax_of_succ_notMem [SuccOrder α] {a : s} (h : succ ↑a ∉ s) : IsMax a := by classical rw [← succ_eq_iff_isMax] change dite .. = _ - split_ifs <;> trivial + simp [h] lemma succ_notMem_iff_isMax [SuccOrder α] [NoMaxOrder α] {a : s} : succ ↑a ∉ s ↔ IsMax a where diff --git a/mathlib4/Mathlib/Order/SuccPred/IntervalSucc.lean b/mathlib4/Mathlib/Order/SuccPred/IntervalSucc.lean index 46455ca7b..4cd84394f 100644 --- a/mathlib4/Mathlib/Order/SuccPred/IntervalSucc.lean +++ b/mathlib4/Mathlib/Order/SuccPred/IntervalSucc.lean @@ -113,19 +113,22 @@ theorem pairwise_disjoint_on_Ioo_succ [SuccOrder α] [Preorder β] {f : α → the intervals `Set.Ioc (f Order.pred n) (f n)` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ioc_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Monotone f) : Pairwise (Disjoint on fun n => Ioc (f (pred n)) (f n)) := by - simpa using! hf.dual.pairwise_disjoint_on_Ico_succ + unsealing_newtype OrderDual => + simpa using! hf.dual.pairwise_disjoint_on_Ico_succ /-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is a monotone function, then the intervals `Set.Ico (f Order.pred n) (f n)` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ico_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Monotone f) : Pairwise (Disjoint on fun n => Ico (f (pred n)) (f n)) := by - simpa using! hf.dual.pairwise_disjoint_on_Ioc_succ + unsealing_newtype OrderDual => + simpa using! hf.dual.pairwise_disjoint_on_Ioc_succ /-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is a monotone function, then the intervals `Set.Ioo (f Order.pred n) (f n)` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ioo_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Monotone f) : Pairwise (Disjoint on fun n => Ioo (f (pred n)) (f n)) := by - simpa using! hf.dual.pairwise_disjoint_on_Ioo_succ + unsealing_newtype OrderDual => + simpa using! hf.dual.pairwise_disjoint_on_Ioo_succ end Monotone @@ -136,37 +139,43 @@ open scoped Function -- required for scoped `on` notation /-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is an antitone function, then the intervals `Set.Ioc (f (Order.succ n)) (f n)` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ioc_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Antitone f) : - Pairwise (Disjoint on fun n => Ioc (f (succ n)) (f n)) := - hf.dual_left.pairwise_disjoint_on_Ioc_pred + Pairwise (Disjoint on fun n => Ioc (f (succ n)) (f n)) := by + unsealing_newtype OrderDual => + exact hf.dual_left.pairwise_disjoint_on_Ioc_pred /-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is an antitone function, then the intervals `Set.Ico (f (Order.succ n)) (f n)` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ico_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Antitone f) : - Pairwise (Disjoint on fun n => Ico (f (succ n)) (f n)) := - hf.dual_left.pairwise_disjoint_on_Ico_pred + Pairwise (Disjoint on fun n => Ico (f (succ n)) (f n)) := by + unsealing_newtype OrderDual => + exact hf.dual_left.pairwise_disjoint_on_Ico_pred /-- If `α` is a linear succ order, `β` is a preorder, and `f : α → β` is an antitone function, then the intervals `Set.Ioo (f (Order.succ n)) (f n)` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ioo_succ [SuccOrder α] [Preorder β] {f : α → β} (hf : Antitone f) : - Pairwise (Disjoint on fun n => Ioo (f (succ n)) (f n)) := - hf.dual_left.pairwise_disjoint_on_Ioo_pred + Pairwise (Disjoint on fun n => Ioo (f (succ n)) (f n)) := by + unsealing_newtype OrderDual => + exact hf.dual_left.pairwise_disjoint_on_Ioo_pred /-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is an antitone function, then the intervals `Set.Ioc (f n) (f (Order.pred n))` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ioc_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Antitone f) : - Pairwise (Disjoint on fun n => Ioc (f n) (f (pred n))) := - hf.dual_left.pairwise_disjoint_on_Ioc_succ + Pairwise (Disjoint on fun n => Ioc (f n) (f (pred n))) := by + unsealing_newtype OrderDual => + exact hf.dual_left.pairwise_disjoint_on_Ioc_succ /-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is an antitone function, then the intervals `Set.Ico (f n) (f (Order.pred n))` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ico_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Antitone f) : - Pairwise (Disjoint on fun n => Ico (f n) (f (pred n))) := - hf.dual_left.pairwise_disjoint_on_Ico_succ + Pairwise (Disjoint on fun n => Ico (f n) (f (pred n))) := by + unsealing_newtype OrderDual => + exact hf.dual_left.pairwise_disjoint_on_Ico_succ /-- If `α` is a linear pred order, `β` is a preorder, and `f : α → β` is an antitone function, then the intervals `Set.Ioo (f n) (f (Order.pred n))` are pairwise disjoint. -/ theorem pairwise_disjoint_on_Ioo_pred [PredOrder α] [Preorder β] {f : α → β} (hf : Antitone f) : - Pairwise (Disjoint on fun n => Ioo (f n) (f (pred n))) := - hf.dual_left.pairwise_disjoint_on_Ioo_succ + Pairwise (Disjoint on fun n => Ioo (f n) (f (pred n))) := by + unsealing_newtype OrderDual => + exact hf.dual_left.pairwise_disjoint_on_Ioo_succ end Antitone diff --git a/mathlib4/Mathlib/Order/SuccPred/LinearLocallyFinite.lean b/mathlib4/Mathlib/Order/SuccPred/LinearLocallyFinite.lean index c46459239..b4d78cfc0 100644 --- a/mathlib4/Mathlib/Order/SuccPred/LinearLocallyFinite.lean +++ b/mathlib4/Mathlib/Order/SuccPred/LinearLocallyFinite.lean @@ -85,8 +85,9 @@ instance (priority := 100) isPredArchimedean_of_isSuccArchimedean [IsSuccArchime · rw [hn_eq] exact hn_lt_ne _ (Nat.lt_succ_self n) -instance isSuccArchimedean_of_isPredArchimedean [IsPredArchimedean ι] : IsSuccArchimedean ι := - inferInstanceAs (IsSuccArchimedean ιᵒᵈᵒᵈ) +instance isSuccArchimedean_of_isPredArchimedean [IsPredArchimedean ι] : IsSuccArchimedean ι := by + unsealing_newtype OrderDual => + exact inferInstanceAs (IsSuccArchimedean ιᵒᵈᵒᵈ) /-- In a linear `SuccOrder` that's also a `PredOrder`, `IsSuccArchimedean` and `IsPredArchimedean` are equivalent. -/ @@ -160,9 +161,11 @@ variable (ι) in This is not an instance, because its `succ` field conflicts with computable `PredOrder` structures on `ℕ` and `ℤ`. -/ @[instance_reducible] -noncomputable def predOrder [LocallyFiniteOrder ι] : PredOrder ι := - letI := succOrder (ι := ιᵒᵈ) - inferInstanceAs (PredOrder ιᵒᵈᵒᵈ) +noncomputable def predOrder [LocallyFiniteOrder ι] : PredOrder ι where + pred i := OrderDual.ofDual (succFn (OrderDual.toDual i)) + pred_le i := le_succFn (ι := ιᵒᵈ) (OrderDual.toDual i) + min_of_le_pred {_} h := isMax_toDual_iff.1 (isMax_of_succFn_le (ι := ιᵒᵈ) _ h) + le_pred_of_lt {_ _} h := succFn_le_of_lt (ι := ιᵒᵈ) _ _ h instance (priority := 100) [LocallyFiniteOrder ι] [SuccOrder ι] : IsSuccArchimedean ι where exists_succ_iterate_of_le := by @@ -194,7 +197,8 @@ instance (priority := 100) [LocallyFiniteOrder ι] [SuccOrder ι] : IsSuccArchim exact not_le.mpr (h_lt n) (h_max (h_lt n).le) instance (priority := 100) [LocallyFiniteOrder ι] [PredOrder ι] : IsPredArchimedean ι := - inferInstanceAs (IsPredArchimedean ιᵒᵈᵒᵈ) + letI := succOrder ι + LinearOrder.isPredArchimedean_of_isSuccArchimedean end LinearLocallyFiniteOrder diff --git a/mathlib4/Mathlib/Order/SuccPred/Relation.lean b/mathlib4/Mathlib/Order/SuccPred/Relation.lean index aa90d44df..e11f17046 100644 --- a/mathlib4/Mathlib/Order/SuccPred/Relation.lean +++ b/mathlib4/Mathlib/Order/SuccPred/Relation.lean @@ -93,26 +93,30 @@ variable {α : Type*} [PartialOrder α] [PredOrder α] [IsPredArchimedean α] /-- For `m ≤ n`, `(n, m)` is in the reflexive-transitive closure of `~` if `i ~ pred i` for all `i` between `n` and `m`. -/ theorem reflTransGen_of_pred_of_ge (r : α → α → Prop) {n m : α} (h : ∀ i ∈ Ioc m n, r i (pred i)) - (hnm : m ≤ n) : ReflTransGen r n m := - reflTransGen_of_succ_of_le (α := αᵒᵈ) r (fun x hx => h x ⟨hx.2, hx.1⟩) hnm + (hnm : m ≤ n) : ReflTransGen r n m := by + unsealing_newtype OrderDual => + exact reflTransGen_of_succ_of_le (α := αᵒᵈ) r (fun x hx => h x ⟨hx.2, hx.1⟩) hnm /-- For `n ≤ m`, `(n, m)` is in the reflexive-transitive closure of `~` if `pred i ~ i` for all `i` between `n` and `m`. -/ theorem reflTransGen_of_pred_of_le (r : α → α → Prop) {n m : α} (h : ∀ i ∈ Ioc n m, r (pred i) i) - (hmn : n ≤ m) : ReflTransGen r n m := - reflTransGen_of_succ_of_ge (α := αᵒᵈ) r (fun x hx => h x ⟨hx.2, hx.1⟩) hmn + (hmn : n ≤ m) : ReflTransGen r n m := by + unsealing_newtype OrderDual => + exact reflTransGen_of_succ_of_ge (α := αᵒᵈ) r (fun x hx => h x ⟨hx.2, hx.1⟩) hmn /-- For `m < n`, `(n, m)` is in the transitive closure of a relation `~` for `n ≠ m` if `i ~ pred i` for all `i` between `n` and `m`. -/ theorem transGen_of_pred_of_gt (r : α → α → Prop) {n m : α} (h : ∀ i ∈ Ioc m n, r i (pred i)) - (hnm : m < n) : TransGen r n m := - transGen_of_succ_of_lt (α := αᵒᵈ) r (fun x hx => h x ⟨hx.2, hx.1⟩) hnm + (hnm : m < n) : TransGen r n m := by + unsealing_newtype OrderDual => + exact transGen_of_succ_of_lt (α := αᵒᵈ) r (fun x hx => h x ⟨hx.2, hx.1⟩) hnm /-- For `n < m`, `(n, m)` is in the transitive closure of a relation `~` for `n ≠ m` if `pred i ~ i` for all `i` between `n` and `m`. -/ theorem transGen_of_pred_of_lt (r : α → α → Prop) {n m : α} (h : ∀ i ∈ Ioc n m, r (pred i) i) - (hmn : n < m) : TransGen r n m := - transGen_of_succ_of_gt (α := αᵒᵈ) r (fun x hx => h x ⟨hx.2, hx.1⟩) hmn + (hmn : n < m) : TransGen r n m := by + unsealing_newtype OrderDual => + exact transGen_of_succ_of_gt (α := αᵒᵈ) r (fun x hx => h x ⟨hx.2, hx.1⟩) hmn end PartialPred @@ -123,23 +127,26 @@ variable {α : Type*} [LinearOrder α] [PredOrder α] [IsPredArchimedean α] /-- `(n, m)` is in the reflexive-transitive closure of `~` if `i ~ pred i` and `pred i ~ i` for all `i` between `n` and `m`. -/ theorem reflTransGen_of_pred (r : α → α → Prop) {n m : α} (h1 : ∀ i ∈ Ioc m n, r i (pred i)) - (h2 : ∀ i ∈ Ioc n m, r (pred i) i) : ReflTransGen r n m := - reflTransGen_of_succ (α := αᵒᵈ) r (fun x hx => h1 x ⟨hx.2, hx.1⟩) fun x hx => - h2 x ⟨hx.2, hx.1⟩ + (h2 : ∀ i ∈ Ioc n m, r (pred i) i) : ReflTransGen r n m := by + unsealing_newtype OrderDual => + exact reflTransGen_of_succ (α := αᵒᵈ) r (fun x hx => h1 x ⟨hx.2, hx.1⟩) fun x hx => + h2 x ⟨hx.2, hx.1⟩ /-- For `n ≠ m`, `(n, m)` is in the transitive closure of a relation `~` if `i ~ pred i` and `pred i ~ i` for all `i` between `n` and `m`. -/ theorem transGen_of_pred_of_ne (r : α → α → Prop) {n m : α} (h1 : ∀ i ∈ Ioc m n, r i (pred i)) - (h2 : ∀ i ∈ Ioc n m, r (pred i) i) (hnm : n ≠ m) : TransGen r n m := - transGen_of_succ_of_ne (α := αᵒᵈ) r (fun x hx => h1 x ⟨hx.2, hx.1⟩) - (fun x hx => h2 x ⟨hx.2, hx.1⟩) hnm + (h2 : ∀ i ∈ Ioc n m, r (pred i) i) (hnm : n ≠ m) : TransGen r n m := by + unsealing_newtype OrderDual => + exact transGen_of_succ_of_ne (α := αᵒᵈ) r (fun x hx => h1 x ⟨hx.2, hx.1⟩) + (fun x hx => h2 x ⟨hx.2, hx.1⟩) hnm /-- `(n, m)` is in the transitive closure of a reflexive relation `~` if `i ~ pred i` and `pred i ~ i` for all `i` between `n` and `m`. -/ theorem transGen_of_pred_of_refl (r : α → α → Prop) {n m : α} [Std.Refl r] - (h1 : ∀ i ∈ Ioc m n, r i (pred i)) (h2 : ∀ i ∈ Ioc n m, r (pred i) i) : TransGen r n m := - @transGen_of_succ_of_refl αᵒᵈ _ _ _ r _ _ ‹_› (fun x hx ↦ h1 x ⟨hx.2, hx.1⟩) - fun x hx ↦ h2 x ⟨hx.2, hx.1⟩ + (h1 : ∀ i ∈ Ioc m n, r i (pred i)) (h2 : ∀ i ∈ Ioc n m, r (pred i) i) : TransGen r n m := by + unsealing_newtype OrderDual => + exact @transGen_of_succ_of_refl αᵒᵈ _ _ _ r _ _ ‹_› (fun x hx ↦ h1 x ⟨hx.2, hx.1⟩) + fun x hx ↦ h2 x ⟨hx.2, hx.1⟩ @[deprecated (since := "2026-03-27")] alias transGen_of_pred_of_reflexive := transGen_of_pred_of_refl diff --git a/mathlib4/Mathlib/Order/SupClosed.lean b/mathlib4/Mathlib/Order/SupClosed.lean index 2bee61b66..cb4974167 100644 --- a/mathlib4/Mathlib/Order/SupClosed.lean +++ b/mathlib4/Mathlib/Order/SupClosed.lean @@ -190,16 +190,24 @@ lemma isSublattice_pi {ι : Type*} {α : ι → Type*} [∀ i, Lattice (α i)] { ⟨supClosed_pi fun _i hi ↦ (ht _ hi).1, infClosed_pi fun _i hi ↦ (ht _ hi).2⟩ @[to_dual (attr := simp)] lemma supClosed_preimage_toDual {s : Set αᵒᵈ} : - SupClosed (toDual ⁻¹' s) ↔ InfClosed s := Iff.rfl + SupClosed (toDual ⁻¹' s) ↔ InfClosed s := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual (attr := simp)] lemma supClosed_preimage_ofDual {s : Set α} : - SupClosed (ofDual ⁻¹' s) ↔ InfClosed s := Iff.rfl + SupClosed (ofDual ⁻¹' s) ↔ InfClosed s := by + unsealing_newtype OrderDual => + exact Iff.rfl @[simp] lemma isSublattice_preimage_toDual {s : Set αᵒᵈ} : - IsSublattice (toDual ⁻¹' s) ↔ IsSublattice s := ⟨fun h ↦ ⟨h.2, h.1⟩, fun h ↦ ⟨h.2, h.1⟩⟩ + IsSublattice (toDual ⁻¹' s) ↔ IsSublattice s := by + unsealing_newtype OrderDual => + exact ⟨fun h ↦ ⟨h.2, h.1⟩, fun h ↦ ⟨h.2, h.1⟩⟩ @[simp] lemma isSublattice_preimage_ofDual : - IsSublattice (ofDual ⁻¹' s) ↔ IsSublattice s := ⟨fun h ↦ ⟨h.2, h.1⟩, fun h ↦ ⟨h.2, h.1⟩⟩ + IsSublattice (ofDual ⁻¹' s) ↔ IsSublattice s := by + unsealing_newtype OrderDual => + exact ⟨fun h ↦ ⟨h.2, h.1⟩, fun h ↦ ⟨h.2, h.1⟩⟩ @[to_dual] alias ⟨_, InfClosed.dual⟩ := supClosed_preimage_ofDual alias ⟨_, IsSublattice.dual⟩ := isSublattice_preimage_ofDual @@ -379,8 +387,9 @@ lemma ofDual_preimage_latticeClosure (s : Set α) : lemma image_latticeClosure' (s : Set α) (f : α → β) (map_sup : ∀ a b, f (a ⊔ b) = f a ⊓ f b) (map_inf : ∀ a b, f (a ⊓ b) = f a ⊔ f b) : f '' latticeClosure s = latticeClosure (f '' s) := by - simpa only [Set.image_comp, Equiv.image_symm_eq_preimage, ← ofDual_preimage_latticeClosure] - using! image_latticeClosure s (ofDual.symm ∘ f) map_sup map_inf + unsealing_newtype OrderDual => + simpa only [Set.image_comp, Equiv.image_symm_eq_preimage, ← ofDual_preimage_latticeClosure] + using! image_latticeClosure s (ofDual.symm ∘ f) map_sup map_inf end Lattice diff --git a/mathlib4/Mathlib/Order/SymmDiff.lean b/mathlib4/Mathlib/Order/SymmDiff.lean index c5d81d84e..a446ca1dd 100644 --- a/mathlib4/Mathlib/Order/SymmDiff.lean +++ b/mathlib4/Mathlib/Order/SymmDiff.lean @@ -391,42 +391,52 @@ the `GeneralizedBooleanAlgebra` ones -/ section CogeneralizedBooleanAlgebra @[simp] -theorem inf_himp_bihimp : a ⇔ b ⇨ a ⊓ b = a ⊔ b := - @sup_sdiff_symmDiff αᵒᵈ _ _ _ +theorem inf_himp_bihimp : a ⇔ b ⇨ a ⊓ b = a ⊔ b := by + unsealing_newtype OrderDual => + exact @sup_sdiff_symmDiff αᵒᵈ _ _ _ -theorem codisjoint_bihimp_sup : Codisjoint (a ⇔ b) (a ⊔ b) := - @disjoint_symmDiff_inf αᵒᵈ _ _ _ +theorem codisjoint_bihimp_sup : Codisjoint (a ⇔ b) (a ⊔ b) := by + unsealing_newtype OrderDual => + exact @disjoint_symmDiff_inf αᵒᵈ _ _ _ @[simp] -theorem himp_bihimp_left : a ⇨ a ⇔ b = a ⇨ b := - @symmDiff_sdiff_left αᵒᵈ _ _ _ +theorem himp_bihimp_left : a ⇨ a ⇔ b = a ⇨ b := by + unsealing_newtype OrderDual => + exact @symmDiff_sdiff_left αᵒᵈ _ _ _ @[simp] -theorem himp_bihimp_right : b ⇨ a ⇔ b = b ⇨ a := - @symmDiff_sdiff_right αᵒᵈ _ _ _ +theorem himp_bihimp_right : b ⇨ a ⇔ b = b ⇨ a := by + unsealing_newtype OrderDual => + exact @symmDiff_sdiff_right αᵒᵈ _ _ _ @[simp] -theorem bihimp_himp_left : a ⇔ b ⇨ a = a ⊔ b := - @sdiff_symmDiff_left αᵒᵈ _ _ _ +theorem bihimp_himp_left : a ⇔ b ⇨ a = a ⊔ b := by + unsealing_newtype OrderDual => + exact @sdiff_symmDiff_left αᵒᵈ _ _ _ @[simp] -theorem bihimp_himp_right : a ⇔ b ⇨ b = a ⊔ b := - @sdiff_symmDiff_right αᵒᵈ _ _ _ +theorem bihimp_himp_right : a ⇔ b ⇨ b = a ⊔ b := by + unsealing_newtype OrderDual => + exact @sdiff_symmDiff_right αᵒᵈ _ _ _ @[simp] -theorem bihimp_eq_inf : a ⇔ b = a ⊓ b ↔ Codisjoint a b := - @symmDiff_eq_sup αᵒᵈ _ _ _ +theorem bihimp_eq_inf : a ⇔ b = a ⊓ b ↔ Codisjoint a b := by + unsealing_newtype OrderDual => + exact @symmDiff_eq_sup αᵒᵈ _ _ _ @[simp] -theorem bihimp_le_iff_left : a ⇔ b ≤ a ↔ Codisjoint a b := - @le_symmDiff_iff_left αᵒᵈ _ _ _ +theorem bihimp_le_iff_left : a ⇔ b ≤ a ↔ Codisjoint a b := by + unsealing_newtype OrderDual => + exact @le_symmDiff_iff_left αᵒᵈ _ _ _ @[simp] -theorem bihimp_le_iff_right : a ⇔ b ≤ b ↔ Codisjoint a b := - @le_symmDiff_iff_right αᵒᵈ _ _ _ +theorem bihimp_le_iff_right : a ⇔ b ≤ b ↔ Codisjoint a b := by + unsealing_newtype OrderDual => + exact @le_symmDiff_iff_right αᵒᵈ _ _ _ -theorem bihimp_assoc : a ⇔ b ⇔ c = a ⇔ (b ⇔ c) := - @symmDiff_assoc αᵒᵈ _ _ _ _ +theorem bihimp_assoc : a ⇔ b ⇔ c = a ⇔ (b ⇔ c) := by + unsealing_newtype OrderDual => + exact @symmDiff_assoc αᵒᵈ _ _ _ _ instance bihimp_isAssociative : Std.Associative (α := α) (· ⇔ ·) := ⟨bihimp_assoc⟩ @@ -453,17 +463,21 @@ theorem bihimp_left_involutive (a : α) : Involutive (· ⇔ a) := theorem bihimp_right_involutive (a : α) : Involutive (a ⇔ ·) := bihimp_bihimp_cancel_left _ -theorem bihimp_left_injective (a : α) : Injective (· ⇔ a) := - @symmDiff_left_injective αᵒᵈ _ _ +theorem bihimp_left_injective (a : α) : Injective (· ⇔ a) := by + unsealing_newtype OrderDual => + exact @symmDiff_left_injective αᵒᵈ _ _ -theorem bihimp_right_injective (a : α) : Injective (a ⇔ ·) := - @symmDiff_right_injective αᵒᵈ _ _ +theorem bihimp_right_injective (a : α) : Injective (a ⇔ ·) := by + unsealing_newtype OrderDual => + exact @symmDiff_right_injective αᵒᵈ _ _ -theorem bihimp_left_surjective (a : α) : Surjective (· ⇔ a) := - @symmDiff_left_surjective αᵒᵈ _ _ +theorem bihimp_left_surjective (a : α) : Surjective (· ⇔ a) := by + unsealing_newtype OrderDual => + exact @symmDiff_left_surjective αᵒᵈ _ _ -theorem bihimp_right_surjective (a : α) : Surjective (a ⇔ ·) := - @symmDiff_right_surjective αᵒᵈ _ _ +theorem bihimp_right_surjective (a : α) : Surjective (a ⇔ ·) := by + unsealing_newtype OrderDual => + exact @symmDiff_right_surjective αᵒᵈ _ _ variable {a b c} @@ -476,12 +490,14 @@ theorem bihimp_right_inj : a ⇔ b = a ⇔ c ↔ b = c := (bihimp_right_injective _).eq_iff @[simp] -theorem bihimp_eq_left : a ⇔ b = a ↔ b = ⊤ := - @symmDiff_eq_left αᵒᵈ _ _ _ +theorem bihimp_eq_left : a ⇔ b = a ↔ b = ⊤ := by + unsealing_newtype OrderDual => + exact @symmDiff_eq_left αᵒᵈ _ _ _ @[simp] -theorem bihimp_eq_right : a ⇔ b = b ↔ a = ⊤ := - @symmDiff_eq_right αᵒᵈ _ _ _ +theorem bihimp_eq_right : a ⇔ b = b ↔ a = ⊤ := by + unsealing_newtype OrderDual => + exact @symmDiff_eq_right αᵒᵈ _ _ _ protected theorem Codisjoint.bihimp_left (ha : Codisjoint a c) (hb : Codisjoint b c) : Codisjoint (a ⇔ b) c := @@ -500,24 +516,27 @@ theorem bihimp_eq : a ⇔ b = (a ⊔ bᶜ) ⊓ (b ⊔ aᶜ) := by simp only [(· theorem symmDiff_eq' : a ∆ b = (a ⊔ b) ⊓ (aᶜ ⊔ bᶜ) := by rw [symmDiff_eq_sup_sdiff_inf, sdiff_eq, compl_inf] -theorem bihimp_eq' : a ⇔ b = a ⊓ b ⊔ aᶜ ⊓ bᶜ := - @symmDiff_eq' αᵒᵈ _ _ _ +theorem bihimp_eq' : a ⇔ b = a ⊓ b ⊔ aᶜ ⊓ bᶜ := by + unsealing_newtype OrderDual => + exact @symmDiff_eq' αᵒᵈ _ _ _ @[simp] theorem compl_symmDiff : (a ∆ b)ᶜ = a ⇔ b := by simp_rw [symmDiff, compl_sup_distrib, compl_sdiff, bihimp, inf_comm] @[simp] -theorem compl_bihimp : (a ⇔ b)ᶜ = a ∆ b := - @compl_symmDiff αᵒᵈ _ _ _ +theorem compl_bihimp : (a ⇔ b)ᶜ = a ∆ b := by + unsealing_newtype OrderDual => + exact @compl_symmDiff αᵒᵈ _ _ _ @[simp] theorem compl_symmDiff_compl : aᶜ ∆ bᶜ = a ∆ b := (sup_comm _ _).trans <| by simp_rw [compl_sdiff_compl, sdiff_eq, symmDiff_eq] @[simp] -theorem compl_bihimp_compl : aᶜ ⇔ bᶜ = a ⇔ b := - @compl_symmDiff_compl αᵒᵈ _ _ _ +theorem compl_bihimp_compl : aᶜ ⇔ bᶜ = a ⇔ b := by + unsealing_newtype OrderDual => + exact @compl_symmDiff_compl αᵒᵈ _ _ _ @[simp] theorem symmDiff_eq_top : a ∆ b = ⊤ ↔ IsCompl a b := by diff --git a/mathlib4/Mathlib/Order/UpperLower/Basic.lean b/mathlib4/Mathlib/Order/UpperLower/Basic.lean index 7eac592db..ffc7f6262 100644 --- a/mathlib4/Mathlib/Order/UpperLower/Basic.lean +++ b/mathlib4/Mathlib/Order/UpperLower/Basic.lean @@ -85,12 +85,15 @@ theorem isUpperSet_iInter₂ {f : ∀ i, κ i → Set α} (hf : ∀ i j, IsUpper isUpperSet_iInter fun i => isUpperSet_iInter <| hf i @[to_dual (attr := simp)] -theorem isUpperSet_preimage_ofDual_iff : IsUpperSet (ofDual ⁻¹' s) ↔ IsLowerSet s := - Iff.rfl +theorem isUpperSet_preimage_ofDual_iff : IsUpperSet (ofDual ⁻¹' s) ↔ IsLowerSet s := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual (attr := simp)] -theorem isUpperSet_preimage_toDual_iff {s : Set αᵒᵈ} : IsUpperSet (toDual ⁻¹' s) ↔ IsLowerSet s := - Iff.rfl +theorem isUpperSet_preimage_toDual_iff {s : Set αᵒᵈ} : + IsUpperSet (toDual ⁻¹' s) ↔ IsLowerSet s := by + unsealing_newtype OrderDual => + exact Iff.rfl @[to_dual] alias ⟨_, IsUpperSet.toDual⟩ := isLowerSet_preimage_ofDual_iff @[to_dual] alias ⟨_, IsUpperSet.ofDual⟩ := isLowerSet_preimage_toDual_iff diff --git a/mathlib4/Mathlib/Order/UpperLower/Closure.lean b/mathlib4/Mathlib/Order/UpperLower/Closure.lean index 7f860e316..1577e77ed 100644 --- a/mathlib4/Mathlib/Order/UpperLower/Closure.lean +++ b/mathlib4/Mathlib/Order/UpperLower/Closure.lean @@ -128,15 +128,19 @@ theorem upperClosure_singleton (a : α) : upperClosure ({a} : Set α) = UpperSet theorem upperClosure_univ : upperClosure (univ : Set α) = ⊥ := bot_unique subset_upperClosure -theorem upperClosure_union (s t : Set α) : upperClosure (s ∪ t) = upperClosure s ⊓ upperClosure t := - (@gc_upperClosure_coe α _).l_sup +theorem upperClosure_union (s t : Set α) : + upperClosure (s ∪ t) = upperClosure s ⊓ upperClosure t := by + unsealing_newtype OrderDual => + exact (@gc_upperClosure_coe α _).l_sup @[to_dual existing (attr := simp)] theorem lowerClosure_union (s t : Set α) : lowerClosure (s ∪ t) = lowerClosure s ⊔ lowerClosure t := (@gc_lowerClosure_coe α _).l_sup -theorem upperClosure_iUnion (f : ι → Set α) : upperClosure (⋃ i, f i) = ⨅ i, upperClosure (f i) := - (@gc_upperClosure_coe α _).l_iSup +theorem upperClosure_iUnion (f : ι → Set α) : + upperClosure (⋃ i, f i) = ⨅ i, upperClosure (f i) := by + unsealing_newtype OrderDual => + exact (@gc_upperClosure_coe α _).l_iSup @[to_dual existing (attr := simp)] theorem lowerClosure_iUnion (f : ι → Set α) : lowerClosure (⋃ i, f i) = ⨆ i, lowerClosure (f i) := @@ -200,8 +204,9 @@ lemma IsAntichain.minimal_mem_upperClosure_iff_mem (hs : IsAntichain (· ≤ ·) rwa [← hs.eq has h (hab.trans hbx)] lemma IsAntichain.maximal_mem_lowerClosure_iff_mem (hs : IsAntichain (· ≤ ·) s) : - Maximal (· ∈ lowerClosure s) x ↔ x ∈ s := - hs.to_dual.minimal_mem_upperClosure_iff_mem + Maximal (· ∈ lowerClosure s) x ↔ x ∈ s := by + unsealing_newtype OrderDual => + exact hs.to_dual.minimal_mem_upperClosure_iff_mem end PartialOrder diff --git a/mathlib4/Mathlib/Order/UpperLower/CompleteLattice.lean b/mathlib4/Mathlib/Order/UpperLower/CompleteLattice.lean index 677249267..672be5b12 100644 --- a/mathlib4/Mathlib/Order/UpperLower/CompleteLattice.lean +++ b/mathlib4/Mathlib/Order/UpperLower/CompleteLattice.lean @@ -93,12 +93,15 @@ instance : PartialOrder (UpperSet α) := instance completeLattice : CompleteLattice (UpperSet α) := (toDual.injective.comp SetLike.coe_injective).completeLattice _ - .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) (fun _ ↦ rfl) (fun _ ↦ rfl) rfl rfl + .rfl .rfl (fun _ _ ↦ rfl) (fun _ _ ↦ rfl) + (fun _ ↦ by simp [← OrderDual.ofDual_inj, ofDual_iSup]; rfl) + (fun _ ↦ by simp [← OrderDual.ofDual_inj, ofDual_iInf]; rfl) rfl rfl instance completelyDistribLattice : CompletelyDistribLattice (UpperSet α) := .ofMinimalAxioms <| (toDual.injective.comp SetLike.coe_injective).completelyDistribLatticeMinimalAxioms .of _ - (fun _ ↦ rfl) (fun _ ↦ rfl) + (fun _ ↦ by simp [← OrderDual.ofDual_inj, ofDual_iSup]; rfl) + (fun _ ↦ by simp [← OrderDual.ofDual_inj, ofDual_iInf]; rfl) @[to_dual existing] instance _root_.LowerSet.instPartialOrder : PartialOrder (LowerSet α) := diff --git a/mathlib4/Mathlib/Order/UpperLower/Fibration.lean b/mathlib4/Mathlib/Order/UpperLower/Fibration.lean index 9167f1197..25dbf222f 100644 --- a/mathlib4/Mathlib/Order/UpperLower/Fibration.lean +++ b/mathlib4/Mathlib/Order/UpperLower/Fibration.lean @@ -41,21 +41,25 @@ lemma fibration_iff_image_Iic [Preorder α] [Preorder β] (hf : Monotone f) : fun H ↦ fibration_iff_isLowerSet_image_Iic.mpr (fun x ↦ (H x).symm ▸ isLowerSet_Iic (f x))⟩ lemma Fibration.isUpperSet_image [LE α] [LE β] (hf : Fibration (· ≥ ·) (· ≥ ·) f) - {s : Set α} (hs : IsUpperSet s) : IsUpperSet (f '' s) := - @Fibration.isLowerSet_image αᵒᵈ βᵒᵈ _ _ _ hf s hs + {s : Set α} (hs : IsUpperSet s) : IsUpperSet (f '' s) := by + unsealing_newtype OrderDual => + exact @Fibration.isLowerSet_image αᵒᵈ βᵒᵈ _ _ _ hf s hs alias _root_.IsUpperSet.image_fibration := Fibration.isUpperSet_image lemma fibration_iff_isUpperSet_image_Ici [Preorder α] [LE β] : - Fibration (· ≥ ·) (· ≥ ·) f ↔ ∀ x, IsUpperSet (f '' Ici x) := - @fibration_iff_isLowerSet_image_Iic αᵒᵈ βᵒᵈ _ _ _ + Fibration (· ≥ ·) (· ≥ ·) f ↔ ∀ x, IsUpperSet (f '' Ici x) := by + unsealing_newtype OrderDual => + exact @fibration_iff_isLowerSet_image_Iic αᵒᵈ βᵒᵈ _ _ _ lemma fibration_iff_isUpperSet_image [Preorder α] [LE β] : - Fibration (· ≥ ·) (· ≥ ·) f ↔ ∀ s, IsUpperSet s → IsUpperSet (f '' s) := - @fibration_iff_isLowerSet_image αᵒᵈ βᵒᵈ _ _ _ + Fibration (· ≥ ·) (· ≥ ·) f ↔ ∀ s, IsUpperSet s → IsUpperSet (f '' s) := by + unsealing_newtype OrderDual => + exact @fibration_iff_isLowerSet_image αᵒᵈ βᵒᵈ _ _ _ lemma fibration_iff_image_Ici [Preorder α] [Preorder β] (hf : Monotone f) : - Fibration (· ≥ ·) (· ≥ ·) f ↔ ∀ x, f '' Ici x = Ici (f x) := - fibration_iff_image_Iic hf.dual + Fibration (· ≥ ·) (· ≥ ·) f ↔ ∀ x, f '' Ici x = Ici (f x) := by + unsealing_newtype OrderDual => + exact fibration_iff_image_Iic hf.dual end Relation diff --git a/mathlib4/Mathlib/Order/UpperLower/Principal.lean b/mathlib4/Mathlib/Order/UpperLower/Principal.lean index d36281e9d..6d6420ec0 100644 --- a/mathlib4/Mathlib/Order/UpperLower/Principal.lean +++ b/mathlib4/Mathlib/Order/UpperLower/Principal.lean @@ -92,7 +92,9 @@ lemma Ici_ne_top : Ici a ≠ ⊤ := SetLike.coe_ne_coe.1 nonempty_Ici.ne_empty lemma Ici_lt_top : Ici a < ⊤ := lt_top_iff_ne_top.2 Ici_ne_top @[to_dual (attr := simp) Iic_le] -lemma le_Ici : s ≤ Ici a ↔ a ∈ s := ⟨fun h ↦ h le_rfl, fun ha ↦ s.upper.Ici_subset ha⟩ +lemma le_Ici : s ≤ Ici a ↔ a ∈ s := by + unsealing_newtype OrderDual => + exact ⟨fun h ↦ h le_rfl, fun ha ↦ s.upper.Ici_subset ha⟩ variable (α) in @[to_dual] diff --git a/mathlib4/Mathlib/Order/WellFounded.lean b/mathlib4/Mathlib/Order/WellFounded.lean index 6e07bf93c..cb9a8a0af 100644 --- a/mathlib4/Mathlib/Order/WellFounded.lean +++ b/mathlib4/Mathlib/Order/WellFounded.lean @@ -238,8 +238,9 @@ alias Set.range_injOn_strictMono := Set.range_injOn_strictMono_of_wellFoundedLT @[to_dual] theorem Set.range_injOn_strictAnti_of_wellFoundedGT [WellFoundedGT β] : - Set.InjOn Set.range { f : β → γ | StrictAnti f } := - fun _ hf _ hg ↦ Set.range_injOn_strictMono_of_wellFoundedLT (β := βᵒᵈ) hf.dual hg.dual + Set.InjOn Set.range { f : β → γ | StrictAnti f } := by + unsealing_newtype OrderDual => + exact fun _ hf _ hg ↦ Set.range_injOn_strictMono_of_wellFoundedLT (β := βᵒᵈ) hf.dual hg.dual @[deprecated (since := "2026-08-13")] alias Set.range_injOn_strictAnti := Set.range_injOn_strictAnti_of_wellFoundedGT diff --git a/mathlib4/Mathlib/Order/WellFoundedSet.lean b/mathlib4/Mathlib/Order/WellFoundedSet.lean index b12fe240e..c4cd44b8e 100644 --- a/mathlib4/Mathlib/Order/WellFoundedSet.lean +++ b/mathlib4/Mathlib/Order/WellFoundedSet.lean @@ -180,10 +180,11 @@ theorem wellFoundedOn_iff_no_descending_seq : theorem WellFoundedOn.union (hs : s.WellFoundedOn r) (ht : t.WellFoundedOn r) : (s ∪ t).WellFoundedOn r := by - rw [wellFoundedOn_iff_no_descending_seq] at * - rintro f hf - rcases Nat.exists_subseq_of_forall_mem_union f hf with ⟨g, hg | hg⟩ - exacts [hs (g.dual.ltEmbedding.trans f) hg, ht (g.dual.ltEmbedding.trans f) hg] + unsealing_newtype OrderDual => + rw [wellFoundedOn_iff_no_descending_seq] at * + rintro f hf + rcases Nat.exists_subseq_of_forall_mem_union f hf with ⟨g, hg | hg⟩ + exacts [hs (g.dual.ltEmbedding.trans f) hg, ht (g.dual.ltEmbedding.trans f) hg] @[simp] theorem wellFoundedOn_union : (s ∪ t).WellFoundedOn r ↔ s.WellFoundedOn r ∧ t.WellFoundedOn r := @@ -735,8 +736,9 @@ theorem BddBelow.wellFoundedOn_lt : BddBelow s → s.WellFoundedOn (· < ·) := ⟨ha <| hf _, antitone_iff_forall_lt.2 (fun a b hab => (f.map_rel_iff.2 hab).le) <| Nat.zero_le _⟩ -theorem BddAbove.wellFoundedOn_gt : BddAbove s → s.WellFoundedOn (· > ·) := - fun h => h.dual.wellFoundedOn_lt +theorem BddAbove.wellFoundedOn_gt : BddAbove s → s.WellFoundedOn (· > ·) := by + unsealing_newtype OrderDual => + exact fun h => h.dual.wellFoundedOn_lt theorem BddBelow.isWF : BddBelow s → IsWF s := BddBelow.wellFoundedOn_lt diff --git a/mathlib4/Mathlib/Order/WithBot.lean b/mathlib4/Mathlib/Order/WithBot.lean index ea24709e2..34c574fce 100644 --- a/mathlib4/Mathlib/Order/WithBot.lean +++ b/mathlib4/Mathlib/Order/WithBot.lean @@ -902,8 +902,11 @@ See `WithBot.toDualTopEquiv` for the related order-iso. -/ @[to_dual /-- `WithTop.toDual` is the equivalence sending `⊤` to `⊥` and any `a : α` to `toDual a : αᵒᵈ`. See `WithTop.toDualBotEquiv` for the related order-iso. -/] -protected def toDual : WithBot α ≃ WithTop αᵒᵈ := - Equiv.refl _ +protected def toDual : WithBot α ≃ WithTop αᵒᵈ where + toFun x := x.map OrderDual.mk + invFun x := x.map OrderDual.ofDual' + left_inv x := by cases x <;> rfl + right_inv x := by cases x <;> rfl /-- `WithBot.ofDual` is the equivalence sending `⊥` to `⊤` and any `a : αᵒᵈ` to `ofDual a : α`. See `WithBot.ofDualTopEquiv` for the related order-iso. @@ -911,8 +914,11 @@ See `WithBot.ofDualTopEquiv` for the related order-iso. @[to_dual /-- `WithTop.ofDual` is the equivalence sending `⊤` to `⊥` and any `a : αᵒᵈ` to `ofDual a : α`. See `WithTop.toDualBotEquiv` for the related order-iso. -/] -protected def ofDual : WithBot αᵒᵈ ≃ WithTop α := - Equiv.refl _ +protected def ofDual : WithBot αᵒᵈ ≃ WithTop α where + toFun x := x.map OrderDual.ofDual' + invFun x := x.map OrderDual.mk + left_inv x := by cases x <;> rfl + right_inv x := by cases x <;> rfl @[to_dual (attr := simp)] theorem toDual_symm : WithBot.toDual.symm = WithTop.ofDual (α := α) := rfl @@ -936,23 +942,23 @@ theorem ofDual_apply_coe (a : αᵒᵈ) : WithBot.ofDual (a : WithBot αᵒᵈ) @[to_dual] theorem map_toDual (f : αᵒᵈ → βᵒᵈ) (a : WithBot α) : - map f (WithBot.toDual a) = a.map (toDual ∘ f) := - rfl + map f (WithBot.toDual a) = a.map (f ∘ ⇑toDual) := by + cases a <;> rfl @[to_dual] theorem map_ofDual (f : α → β) (a : WithBot αᵒᵈ) : - map f (WithBot.ofDual a) = a.map (ofDual ∘ f) := - rfl + map f (WithBot.ofDual a) = a.map (f ∘ ⇑ofDual) := by + cases a <;> rfl @[to_dual] theorem toDual_map (f : α → β) (a : WithBot α) : - WithBot.toDual (map f a) = WithTop.map (toDual ∘ f ∘ ofDual) (WithBot.toDual a) := - rfl + WithBot.toDual (map f a) = WithTop.map (⇑toDual ∘ f ∘ ⇑ofDual) (WithBot.toDual a) := by + cases a <;> rfl @[to_dual] theorem ofDual_map (f : αᵒᵈ → βᵒᵈ) (a : WithBot αᵒᵈ) : - WithBot.ofDual (map f a) = WithTop.map (ofDual ∘ f ∘ toDual) (WithBot.ofDual a) := - rfl + WithBot.ofDual (map f a) = WithTop.map (⇑ofDual ∘ f ∘ ⇑toDual) (WithBot.ofDual a) := by + cases a <;> rfl section LE variable [LE α] diff --git a/mathlib4/Mathlib/Order/Zorn.lean b/mathlib4/Mathlib/Order/Zorn.lean index 13576090e..543469afd 100644 --- a/mathlib4/Mathlib/Order/Zorn.lean +++ b/mathlib4/Mathlib/Order/Zorn.lean @@ -155,13 +155,15 @@ theorem zorn_subset_nonempty (S : Set (Set α)) zorn_le_nonempty₀ _ (fun _ cS hc y yc => H _ cS hc ⟨y, yc⟩) _ hx theorem zorn_superset (S : Set (Set α)) - (h : ∀ c ⊆ S, IsChain (· ⊆ ·) c → ∃ lb ∈ S, ∀ s ∈ c, lb ⊆ s) : ∃ m, Minimal (· ∈ S) m := - (@zorn_le₀ (Set α)ᵒᵈ _ S) fun c cS hc => h c cS hc.symm + (h : ∀ c ⊆ S, IsChain (· ⊆ ·) c → ∃ lb ∈ S, ∀ s ∈ c, lb ⊆ s) : ∃ m, Minimal (· ∈ S) m := by + unsealing_newtype OrderDual => + exact (@zorn_le₀ (Set α)ᵒᵈ _ S) fun c cS hc => h c cS hc.symm theorem zorn_superset_nonempty (S : Set (Set α)) (H : ∀ c ⊆ S, IsChain (· ⊆ ·) c → c.Nonempty → ∃ lb ∈ S, ∀ s ∈ c, lb ⊆ s) (x) (hx : x ∈ S) : - ∃ m, m ⊆ x ∧ Minimal (· ∈ S) m := - @zorn_le_nonempty₀ (Set α)ᵒᵈ _ S (fun _ cS hc y yc => H _ cS hc.symm ⟨y, yc⟩) _ hx + ∃ m, m ⊆ x ∧ Minimal (· ∈ S) m := by + unsealing_newtype OrderDual => + exact @zorn_le_nonempty₀ (Set α)ᵒᵈ _ S (fun _ cS hc y yc => H _ cS hc.symm ⟨y, yc⟩) _ hx /-- Every chain is contained in a maximal chain. This generalizes Hausdorff's maximality principle. -/ diff --git a/mathlib4/Mathlib/Order/ZornAtoms.lean b/mathlib4/Mathlib/Order/ZornAtoms.lean index 1d5210273..86532f6e7 100644 --- a/mathlib4/Mathlib/Order/ZornAtoms.lean +++ b/mathlib4/Mathlib/Order/ZornAtoms.lean @@ -40,5 +40,6 @@ theorem IsAtomic.of_isChain_bounded {α : Type*} [PartialOrder α] [OrderBot α] (h : ∀ c : Set α, IsChain (· ≤ ·) c → c.Nonempty → ⊥ ∉ c → ∃ x ≠ ⊥, x ∈ lowerBounds c) : - IsAtomic α := - isCoatomic_dual_iff_isAtomic.mp <| IsCoatomic.of_isChain_bounded fun c hc => h c hc.symm + IsAtomic α := by + unsealing_newtype OrderDual => + exact isCoatomic_dual_iff_isAtomic.mp <| IsCoatomic.of_isChain_bounded fun c hc => h c hc.symm diff --git a/mathlib4/Mathlib/RingTheory/Artinian/Module.lean b/mathlib4/Mathlib/RingTheory/Artinian/Module.lean index 3bcfb7221..0f3a86670 100644 --- a/mathlib4/Mathlib/RingTheory/Artinian/Module.lean +++ b/mathlib4/Mathlib/RingTheory/Artinian/Module.lean @@ -143,8 +143,9 @@ theorem IsArtinian.set_has_minimal [IsArtinian R M] (a : Set <| Submodule R M) ( /-- A module is Artinian iff every decreasing chain of submodules stabilizes. -/ theorem monotone_stabilizes_iff_artinian : - (∀ f : ℕ →o (Submodule R M)ᵒᵈ, ∃ n, ∀ m, n ≤ m → f n = f m) ↔ IsArtinian R M := - wellFoundedGT_iff_monotone_chain_condition.symm + (∀ f : ℕ →o (Submodule R M)ᵒᵈ, ∃ n, ∀ m, n ≤ m → f n = f m) ↔ IsArtinian R M := by + unsealing_newtype OrderDual => + exact wellFoundedGT_iff_monotone_chain_condition.symm namespace IsArtinian @@ -180,16 +181,17 @@ is eventually ⊤. -/ theorem disjoint_partial_infs_eventually_top (f : ℕ → Submodule R M) (h : ∀ n, Disjoint (partialSups (OrderDual.toDual ∘ f) n) (OrderDual.toDual (f (n + 1)))) : ∃ n : ℕ, ∀ m, n ≤ m → f m = ⊤ := by - -- A little off-by-one cleanup first: - rsuffices ⟨n, w⟩ : ∃ n : ℕ, ∀ m, n ≤ m → OrderDual.toDual f (m + 1) = ⊤ - · use n + 1 - rintro (_ | m) p - · cases p - · apply w - exact Nat.succ_le_succ_iff.mp p - obtain ⟨n, w⟩ := monotone_stabilizes (partialSups (OrderDual.toDual ∘ f)) - refine ⟨n, fun m p ↦ (h m).eq_bot_of_ge <| sup_eq_left.mp ?_⟩ - simpa only [partialSups_add_one] using! (w (m + 1) <| le_add_right p).symm.trans <| w m p + unsealing_newtype OrderDual => + -- A little off-by-one cleanup first: + rsuffices ⟨n, w⟩ : ∃ n : ℕ, ∀ m, n ≤ m → OrderDual.toDual f (m + 1) = ⊤ + · use n + 1 + rintro (_ | m) p + · cases p + · apply w + exact Nat.succ_le_succ_iff.mp p + obtain ⟨n, w⟩ := monotone_stabilizes (partialSups (OrderDual.toDual ∘ f)) + refine ⟨n, fun m p ↦ (h m).eq_bot_of_ge <| sup_eq_left.mp ?_⟩ + simpa only [partialSups_add_one] using! (w (m + 1) <| le_add_right p).symm.trans <| w m p end IsArtinian @@ -206,12 +208,13 @@ variable [IsArtinian R M] lemma eventually_iInf_range_pow_eq (f : Module.End R M) : ∀ᶠ n in atTop, ⨅ m, LinearMap.range (f ^ m) = LinearMap.range (f ^ n) := by - obtain ⟨n, hn : ∀ m, n ≤ m → LinearMap.range (f ^ n) = LinearMap.range (f ^ m)⟩ := - IsArtinian.monotone_stabilizes f.iterateRange - refine eventually_atTop.mpr ⟨n, fun l hl ↦ le_antisymm (iInf_le _ _) (le_iInf fun m ↦ ?_)⟩ - rcases le_or_gt l m with h | h - · rw [← hn _ (hl.trans h), hn _ hl] - · exact f.iterateRange.monotone h.le + unsealing_newtype OrderDual => + obtain ⟨n, hn : ∀ m, n ≤ m → LinearMap.range (f ^ n) = LinearMap.range (f ^ m)⟩ := + IsArtinian.monotone_stabilizes f.iterateRange + refine eventually_atTop.mpr ⟨n, fun l hl ↦ le_antisymm (iInf_le _ _) (le_iInf fun m ↦ ?_)⟩ + rcases le_or_gt l m with h | h + · rw [← hn _ (hl.trans h), hn _ hl] + · exact f.iterateRange.monotone h.le end LinearMap @@ -300,17 +303,19 @@ variable [IsArtinian R M] and range. -/ theorem eventually_codisjoint_ker_pow_range_pow (f : Module.End R M) : ∀ᶠ n in atTop, Codisjoint (LinearMap.ker (f ^ n)) (LinearMap.range (f ^ n)) := by - obtain ⟨n, hn : ∀ m, n ≤ m → LinearMap.range (f ^ n) = LinearMap.range (f ^ m)⟩ := - IsArtinian.monotone_stabilizes f.iterateRange - refine eventually_atTop.mpr ⟨n, fun m hm ↦ codisjoint_iff.mpr ?_⟩ - simp_rw [← hn _ hm, Submodule.eq_top_iff', Submodule.mem_sup] - intro x - rsuffices ⟨y, hy⟩ : ∃ y, (f ^ m) ((f ^ n) y) = (f ^ m) x - · exact ⟨x - (f ^ n) y, by simp [hy], (f ^ n) y, by simp⟩ - -- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to change `mem_range` into `mem_range (f := _)` - simp_rw [f.pow_apply n, f.pow_apply m, ← iterate_add_apply, ← f.pow_apply (m + n), - ← f.pow_apply m, ← mem_range (f := _), ← hn _ (n.le_add_left m), hn _ hm] - exact LinearMap.mem_range_self (f ^ m) x + unsealing_newtype OrderDual => + obtain ⟨n, hn : ∀ m, n ≤ m → LinearMap.range (f ^ n) = LinearMap.range (f ^ m)⟩ := + IsArtinian.monotone_stabilizes f.iterateRange + refine eventually_atTop.mpr ⟨n, fun m hm ↦ codisjoint_iff.mpr ?_⟩ + simp_rw [← hn _ hm, Submodule.eq_top_iff', Submodule.mem_sup] + intro x + rsuffices ⟨y, hy⟩ : ∃ y, (f ^ m) ((f ^ n) y) = (f ^ m) x + · exact ⟨x - (f ^ n) y, by simp [hy], (f ^ n) y, by simp⟩ + -- Note: https://github.com/leanprover-community/mathlib4/pull/8386 + -- had to change `mem_range` into `mem_range (f := _)` + simp_rw [f.pow_apply n, f.pow_apply m, ← iterate_add_apply, ← f.pow_apply (m + n), + ← f.pow_apply m, ← mem_range (f := _), ← hn _ (n.le_add_left m), hn _ hm] + exact LinearMap.mem_range_self (f ^ m) x /-- This is the Fitting decomposition of the module `M` with respect to the endomorphism `f`. @@ -344,12 +349,13 @@ namespace IsArtinian theorem range_smul_pow_stabilizes (r : R) : ∃ n : ℕ, ∀ m, n ≤ m → LinearMap.range (r ^ n • LinearMap.id : M →ₗ[R] M) = - LinearMap.range (r ^ m • LinearMap.id : M →ₗ[R] M) := - monotone_stabilizes - ⟨fun n => LinearMap.range (r ^ n • LinearMap.id : M →ₗ[R] M), fun n m h x ⟨y, hy⟩ => - ⟨r ^ (m - n) • y, by - dsimp at hy ⊢ - rw [← smul_assoc, smul_eq_mul, ← pow_add, ← hy, add_tsub_cancel_of_le h]⟩⟩ + LinearMap.range (r ^ m • LinearMap.id : M →ₗ[R] M) := by + unsealing_newtype OrderDual => + exact monotone_stabilizes + ⟨fun n => LinearMap.range (r ^ n • LinearMap.id : M →ₗ[R] M), fun n m h x ⟨y, hy⟩ => + ⟨r ^ (m - n) • y, by + dsimp at hy ⊢ + rw [← smul_assoc, smul_eq_mul, ← pow_add, ← hy, add_tsub_cancel_of_le h]⟩⟩ variable {M} @@ -656,9 +662,11 @@ instance : IsSemiprimaryRing R where IsArtinianRing.isSemisimpleRing_iff_jacobson.mpr (Ring.jacobson_quotient_jacobson R) isNilpotent := by let Jac := Ring.jacobson R - have ⟨n, hn⟩ := IsArtinian.monotone_stabilizes ⟨(Jac ^ ·), @Ideal.pow_le_pow_right _ _ _⟩ + have ⟨n, hn⟩ := IsArtinian.monotone_stabilizes + ⟨fun n ↦ OrderDual.toDual (Jac ^ n), fun _ _ h ↦ Ideal.pow_le_pow_right h⟩ have hn : Jac * Jac ^ n = Jac ^ n := by - rw [← Ideal.IsTwoSided.pow_succ]; exact (hn _ n.le_succ).symm + rw [← Ideal.IsTwoSided.pow_succ] + exact (congrArg OrderDual.ofDual (hn _ n.le_succ)).symm use n; by_contra ne have ⟨N, ⟨eq, ne⟩, min⟩ := wellFounded_lt.has_min {N | Jac * N = N ∧ N ≠ ⊥} ⟨_, hn, ne⟩ have : Jac ^ n * N = N := n.rec (by rw [Jac.pow_zero, N.one_mul]) diff --git a/mathlib4/Mathlib/RingTheory/Ideal/KrullsHeightTheorem.lean b/mathlib4/Mathlib/RingTheory/Ideal/KrullsHeightTheorem.lean index 1fa404f1e..f7f38fed6 100644 --- a/mathlib4/Mathlib/RingTheory/Ideal/KrullsHeightTheorem.lean +++ b/mathlib4/Mathlib/RingTheory/Ideal/KrullsHeightTheorem.lean @@ -61,46 +61,47 @@ lemma Ideal.height_le_one_of_isPrincipal_of_mem_minimalPrimes_of_isLocalRing [IsLocalRing R] (I : Ideal R) [I.IsPrincipal] (hp : (IsLocalRing.maximalIdeal R) ∈ I.minimalPrimes) : (IsLocalRing.maximalIdeal R).height ≤ 1 := by - refine Ideal.height_le_iff.mpr fun q h₁ h₂ ↦ ?_ - suffices q.height = 0 by rw [this]; exact zero_lt_one - rw [← WithBot.coe_inj, - ← IsLocalization.AtPrime.ringKrullDim_eq_height q (Localization.AtPrime q), - WithBot.coe_zero, ← ringKrullDimZero_iff_ringKrullDim_eq_zero, - ← isArtinianRing_iff_krullDimLE_zero, isArtinianRing_iff_isNilpotent_maximalIdeal, - ← Localization.AtPrime.map_eq_maximalIdeal] - have : IsArtinianRing (R ⧸ I) := - IsLocalRing.quotient_artinian_of_mem_minimalPrimes_of_isLocalRing I hp - let f := algebraMap R (Localization.AtPrime q) - let qs : ℕ →o (Ideal (R ⧸ I))ᵒᵈ := - { toFun n := ((q.map f ^ n).comap f).map (Ideal.Quotient.mk I) - monotone' i j e := Ideal.map_mono (Ideal.comap_mono (Ideal.pow_le_pow_right e)) } - obtain ⟨n, hn⟩ := IsArtinian.monotone_stabilizes qs - refine ⟨n, ?_⟩ - apply Submodule.eq_bot_of_le_smul_of_le_jacobson_bot (q.map f) _ (IsNoetherian.noetherian _) - rotate_left - · rw [IsLocalRing.jacobson_eq_maximalIdeal, Localization.AtPrime.map_eq_maximalIdeal] - exact bot_ne_top - rw [smul_eq_mul, ← pow_succ', - ← (IsLocalization.orderEmbedding q.primeCompl (Localization.AtPrime q)).map_rel_iff] - refine Submodule.le_of_le_smul_of_le_jacobson_bot (I := I) (IsNoetherian.noetherian _) ?_ ?_ - · rw [IsLocalRing.jacobson_eq_maximalIdeal] - exacts [hp.le, bot_ne_top] - · replace hn := congr(Ideal.comap (Ideal.Quotient.mk I) $(hn _ n.le_succ)) - simp only [qs, OrderHom.coe_mk, ← RingHom.ker_eq_comap_bot, Ideal.mk_ker, - Ideal.comap_map_of_surjective _ Ideal.Quotient.mk_surjective] at hn - intro x hx - obtain ⟨y, hy, z, hz, rfl⟩ := Submodule.mem_sup.mp (hn.le (Ideal.mem_sup_left hx)) - refine Submodule.add_mem_sup hy ?_ - obtain ⟨z, rfl⟩ := (Submodule.IsPrincipal.mem_iff_eq_smul_generator I).mp hz - rw [smul_eq_mul, smul_eq_mul, mul_comm] - refine Ideal.mul_mem_mul ?_ (Submodule.IsPrincipal.generator_mem _) - dsimp [IsLocalization.orderEmbedding] at hx - rwa [Ideal.mem_comap, f.map_add, f.map_mul, Ideal.add_mem_iff_right _ - (Ideal.pow_le_pow_right n.le_succ hy), mul_comm, Ideal.unit_mul_mem_iff_mem] at hx - refine IsLocalization.map_units (M := q.primeCompl) _ ⟨_, ?_⟩ - change Submodule.IsPrincipal.generator I ∉ (↑q : Set R) - rw [← Set.singleton_subset_iff, ← Ideal.span_le, Ideal.span_singleton_generator] - exact fun e ↦ h₂.not_ge (hp.2 ⟨h₁, e⟩ h₂.le) + unsealing_newtype OrderDual => + refine Ideal.height_le_iff.mpr fun q h₁ h₂ ↦ ?_ + suffices q.height = 0 by rw [this]; exact zero_lt_one + rw [← WithBot.coe_inj, + ← IsLocalization.AtPrime.ringKrullDim_eq_height q (Localization.AtPrime q), + WithBot.coe_zero, ← ringKrullDimZero_iff_ringKrullDim_eq_zero, + ← isArtinianRing_iff_krullDimLE_zero, isArtinianRing_iff_isNilpotent_maximalIdeal, + ← Localization.AtPrime.map_eq_maximalIdeal] + have : IsArtinianRing (R ⧸ I) := + IsLocalRing.quotient_artinian_of_mem_minimalPrimes_of_isLocalRing I hp + let f := algebraMap R (Localization.AtPrime q) + let qs : ℕ →o (Ideal (R ⧸ I))ᵒᵈ := + { toFun n := ((q.map f ^ n).comap f).map (Ideal.Quotient.mk I) + monotone' i j e := Ideal.map_mono (Ideal.comap_mono (Ideal.pow_le_pow_right e)) } + obtain ⟨n, hn⟩ := IsArtinian.monotone_stabilizes qs + refine ⟨n, ?_⟩ + apply Submodule.eq_bot_of_le_smul_of_le_jacobson_bot (q.map f) _ (IsNoetherian.noetherian _) + rotate_left + · rw [IsLocalRing.jacobson_eq_maximalIdeal, Localization.AtPrime.map_eq_maximalIdeal] + exact bot_ne_top + rw [smul_eq_mul, ← pow_succ', + ← (IsLocalization.orderEmbedding q.primeCompl (Localization.AtPrime q)).map_rel_iff] + refine Submodule.le_of_le_smul_of_le_jacobson_bot (I := I) (IsNoetherian.noetherian _) ?_ ?_ + · rw [IsLocalRing.jacobson_eq_maximalIdeal] + exacts [hp.le, bot_ne_top] + · replace hn := congr(Ideal.comap (Ideal.Quotient.mk I) $(hn _ n.le_succ)) + simp only [qs, OrderHom.coe_mk, ← RingHom.ker_eq_comap_bot, Ideal.mk_ker, + Ideal.comap_map_of_surjective _ Ideal.Quotient.mk_surjective] at hn + intro x hx + obtain ⟨y, hy, z, hz, rfl⟩ := Submodule.mem_sup.mp (hn.le (Ideal.mem_sup_left hx)) + refine Submodule.add_mem_sup hy ?_ + obtain ⟨z, rfl⟩ := (Submodule.IsPrincipal.mem_iff_eq_smul_generator I).mp hz + rw [smul_eq_mul, smul_eq_mul, mul_comm] + refine Ideal.mul_mem_mul ?_ (Submodule.IsPrincipal.generator_mem _) + dsimp [IsLocalization.orderEmbedding] at hx + rwa [Ideal.mem_comap, f.map_add, f.map_mul, Ideal.add_mem_iff_right _ + (Ideal.pow_le_pow_right n.le_succ hy), mul_comm, Ideal.unit_mul_mem_iff_mem] at hx + refine IsLocalization.map_units (M := q.primeCompl) _ ⟨_, ?_⟩ + change Submodule.IsPrincipal.generator I ∉ (↑q : Set R) + rw [← Set.singleton_subset_iff, ← Ideal.span_le, Ideal.span_singleton_generator] + exact fun e ↦ h₂.not_ge (hp.2 ⟨h₁, e⟩ h₂.le) /-- **Krull's principal ideal theorem** (also known as **Krullscher Hauptidealsatz**) : In a commutative Noetherian ring `R`, any prime ideal that is minimal over a principal ideal diff --git a/mathlib4/Mathlib/RingTheory/Ideal/MinimalPrime/Basic.lean b/mathlib4/Mathlib/RingTheory/Ideal/MinimalPrime/Basic.lean index 46939e4ed..16b083fb3 100644 --- a/mathlib4/Mathlib/RingTheory/Ideal/MinimalPrime/Basic.lean +++ b/mathlib4/Mathlib/RingTheory/Ideal/MinimalPrime/Basic.lean @@ -73,22 +73,23 @@ theorem Ideal.minimalPrimes_isPrime {p : Ideal R} (h : p ∈ minimalPrimes R) : h.1.1 theorem Ideal.exists_minimalPrimes_le [J.IsPrime] (e : I ≤ J) : ∃ p ∈ I.minimalPrimes, p ≤ J := by - set S := { p : (Ideal R)ᵒᵈ | Ideal.IsPrime p ∧ I ≤ OrderDual.ofDual p } - suffices h : ∃ m, OrderDual.toDual J ≤ m ∧ Maximal (· ∈ S) m by - obtain ⟨p, hJp, hp⟩ := h - exact ⟨p, ⟨hp.prop, fun q hq hle ↦ hp.le_of_ge hq hle⟩, hJp⟩ - apply zorn_le_nonempty₀ - swap - · refine ⟨show J.IsPrime by infer_instance, e⟩ - rintro (c : Set (Ideal R)) hc hc' J' hJ' - refine - ⟨OrderDual.toDual (sInf c), - ⟨Ideal.sInf_isPrime_of_isChain ⟨J', hJ'⟩ hc'.symm fun x hx => (hc hx).1, ?_⟩, ?_⟩ - · rw [OrderDual.ofDual_toDual, le_sInf_iff] - exact fun _ hx => (hc hx).2 - · rintro z hz - rw [OrderDual.le_toDual] - exact sInf_le hz + unsealing_newtype OrderDual => + set S := { p : (Ideal R)ᵒᵈ | Ideal.IsPrime p ∧ I ≤ OrderDual.ofDual p } + suffices h : ∃ m, OrderDual.toDual J ≤ m ∧ Maximal (· ∈ S) m by + obtain ⟨p, hJp, hp⟩ := h + exact ⟨p, ⟨hp.prop, fun q hq hle ↦ hp.le_of_ge hq hle⟩, hJp⟩ + apply zorn_le_nonempty₀ + swap + · refine ⟨show J.IsPrime by infer_instance, e⟩ + rintro (c : Set (Ideal R)) hc hc' J' hJ' + refine + ⟨OrderDual.toDual (sInf c), + ⟨Ideal.sInf_isPrime_of_isChain ⟨J', hJ'⟩ hc'.symm fun x hx => (hc hx).1, ?_⟩, ?_⟩ + · rw [OrderDual.ofDual_toDual, le_sInf_iff] + exact fun _ hx => (hc hx).2 + · rintro z hz + rw [OrderDual.le_toDual] + exact sInf_le hz theorem Ideal.nonempty_minimalPrimes (h : I ≠ ⊤) : Nonempty I.minimalPrimes := by obtain ⟨m, hm, hle⟩ := Ideal.exists_le_maximal I h diff --git a/mathlib4/Mathlib/RingTheory/Localization/Submodule.lean b/mathlib4/Mathlib/RingTheory/Localization/Submodule.lean index 688c6c5d6..fe52ecda4 100644 --- a/mathlib4/Mathlib/RingTheory/Localization/Submodule.lean +++ b/mathlib4/Mathlib/RingTheory/Localization/Submodule.lean @@ -80,8 +80,9 @@ variable [IsLocalization M S] include M in theorem isNoetherianRing (h : IsNoetherianRing R) : IsNoetherianRing S := by - rw [isNoetherianRing_iff, isNoetherian_iff] at h ⊢ - exact OrderEmbedding.wellFounded (IsLocalization.orderEmbedding M S).dual h + unsealing_newtype OrderDual => + rw [isNoetherianRing_iff, isNoetherian_iff] at h ⊢ + exact OrderEmbedding.wellFounded (IsLocalization.orderEmbedding M S).dual h instance {R} [CommRing R] [IsNoetherianRing R] (S : Submonoid R) : IsNoetherianRing (Localization S) := diff --git a/mathlib4/Mathlib/RingTheory/Noetherian/Basic.lean b/mathlib4/Mathlib/RingTheory/Noetherian/Basic.lean index 5f62a5128..be66a1d3b 100644 --- a/mathlib4/Mathlib/RingTheory/Noetherian/Basic.lean +++ b/mathlib4/Mathlib/RingTheory/Noetherian/Basic.lean @@ -312,14 +312,17 @@ instance (priority := 100) isNoetherian_of_subsingleton (R M) [Subsingleton R] [ isNoetherian_of_finite R M theorem isNoetherian_of_submodule_of_noetherian (R M) [Semiring R] [AddCommMonoid M] [Module R M] - (N : Submodule R M) (h : IsNoetherian R M) : IsNoetherian R N := - isNoetherian_mk ⟨OrderEmbedding.wellFounded (Submodule.MapSubtype.orderEmbedding N).dual h.wf⟩ + (N : Submodule R M) (h : IsNoetherian R M) : IsNoetherian R N := by + unsealing_newtype OrderDual => + exact isNoetherian_mk + ⟨OrderEmbedding.wellFounded (Submodule.MapSubtype.orderEmbedding N).dual h.wf⟩ /-- If `M / S / R` is a scalar tower, and `M / R` is Noetherian, then `M / S` is also Noetherian. -/ theorem isNoetherian_of_tower (R) {S M} [Semiring R] [Semiring S] [AddCommMonoid M] [SMul R S] - [Module S M] [Module R M] [IsScalarTower R S M] (h : IsNoetherian R M) : IsNoetherian S M := - isNoetherian_mk ⟨(Submodule.restrictScalarsEmbedding R S M).dual.wellFounded h.wf⟩ + [Module S M] [Module R M] [IsScalarTower R S M] (h : IsNoetherian R M) : IsNoetherian S M := by + unsealing_newtype OrderDual => + exact isNoetherian_mk ⟨(Submodule.restrictScalarsEmbedding R S M).dual.wellFounded h.wf⟩ instance isNoetherian_of_isNoetherianRing_of_finite (R M : Type*) [Ring R] [AddCommGroup M] [Module R M] [IsNoetherianRing R] [Module.Finite R M] : @@ -342,8 +345,10 @@ theorem IsNoetherianRing.of_finite (R S) [Ring R] [Ring S] [Module R S] [IsScala isNoetherian_of_tower R inferInstance theorem isNoetherianRing_of_surjective (R) [Semiring R] (S) [Semiring S] (f : R →+* S) - (hf : Function.Surjective f) [H : IsNoetherianRing R] : IsNoetherianRing S := - isNoetherian_mk ⟨OrderEmbedding.wellFounded (Ideal.orderEmbeddingOfSurjective f hf).dual H.wf⟩ + (hf : Function.Surjective f) [H : IsNoetherianRing R] : IsNoetherianRing S := by + unsealing_newtype OrderDual => + exact isNoetherian_mk + ⟨OrderEmbedding.wellFounded (Ideal.orderEmbeddingOfSurjective f hf).dual H.wf⟩ instance isNoetherianRing_rangeS {R} [Semiring R] {S} [Semiring S] (f : R →+* S) [IsNoetherianRing R] : IsNoetherianRing f.rangeS := diff --git a/mathlib4/Mathlib/RingTheory/Noetherian/Defs.lean b/mathlib4/Mathlib/RingTheory/Noetherian/Defs.lean index b7f258dc8..148906c75 100644 --- a/mathlib4/Mathlib/RingTheory/Noetherian/Defs.lean +++ b/mathlib4/Mathlib/RingTheory/Noetherian/Defs.lean @@ -130,25 +130,26 @@ instance wellFoundedGT [h : IsNoetherian R M] : WellFoundedGT (Submodule R M) := theorem isNoetherian_iff_fg_wellFounded : IsNoetherian R M ↔ WellFoundedGT { N : Submodule R M // N.FG } := by - let α := { N : Submodule R M // N.FG } - constructor - · intro H - let f : α ↪o Submodule R M := OrderEmbedding.subtype _ - exact OrderEmbedding.wellFoundedLT f.dual - · intro H + unsealing_newtype OrderDual => + let α := { N : Submodule R M // N.FG } constructor - intro N - obtain ⟨⟨N₀, h₁⟩, e : N₀ ≤ N, h₂⟩ := - WellFounded.has_min H.wf { N' : α | N'.1 ≤ N } ⟨⟨⊥, Submodule.fg_bot⟩, @bot_le _ _ _ N⟩ - convert! h₁ - refine (e.antisymm ?_).symm - by_contra h₃ - obtain ⟨x, hx₁ : x ∈ N, hx₂ : x ∉ N₀⟩ := Set.not_subset.mp h₃ - apply hx₂ - rw [eq_of_le_of_not_lt (le_sup_right : N₀ ≤ _) (h₂ - ⟨_, Submodule.FG.sup ⟨{x}, by rw [Finset.coe_singleton]⟩ h₁⟩ <| - sup_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hx₁) e)] - exact (le_sup_left : R ∙ x ≤ _) (Submodule.mem_span_singleton_self _) + · intro H + let f : α ↪o Submodule R M := OrderEmbedding.subtype _ + exact OrderEmbedding.wellFoundedLT f.dual + · intro H + constructor + intro N + obtain ⟨⟨N₀, h₁⟩, e : N₀ ≤ N, h₂⟩ := + WellFounded.has_min H.wf { N' : α | N'.1 ≤ N } ⟨⟨⊥, Submodule.fg_bot⟩, @bot_le _ _ _ N⟩ + convert! h₁ + refine (e.antisymm ?_).symm + by_contra h₃ + obtain ⟨x, hx₁ : x ∈ N, hx₂ : x ∉ N₀⟩ := Set.not_subset.mp h₃ + apply hx₂ + rw [eq_of_le_of_not_lt (le_sup_right : N₀ ≤ _) (h₂ + ⟨_, Submodule.FG.sup ⟨{x}, by rw [Finset.coe_singleton]⟩ h₁⟩ <| + sup_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hx₁) e)] + exact (le_sup_left : R ∙ x ≤ _) (Submodule.mem_span_singleton_self _) /-- A module is Noetherian iff every nonempty set of submodules has a maximal submodule among them. -/ diff --git a/mathlib4/Mathlib/RingTheory/Nullstellensatz.lean b/mathlib4/Mathlib/RingTheory/Nullstellensatz.lean index 34fd73c57..8ea74e3c4 100644 --- a/mathlib4/Mathlib/RingTheory/Nullstellensatz.lean +++ b/mathlib4/Mathlib/RingTheory/Nullstellensatz.lean @@ -85,13 +85,16 @@ theorem zeroLocus_vanishingIdeal_le (V : Set (σ → K)) : V ≤ zeroLocus K (va theorem zeroLocus_vanishingIdeal_galoisConnection : @GaloisConnection (Ideal (MvPolynomial σ k)) (Set (σ → K))ᵒᵈ _ _ - (zeroLocus K) (vanishingIdeal k) := - GaloisConnection.monotone_intro (fun _ _ ↦ vanishingIdeal_anti_mono) - (fun _ _ ↦ zeroLocus_anti_mono) le_vanishingIdeal_zeroLocus zeroLocus_vanishingIdeal_le + (fun I ↦ OrderDual.toDual (zeroLocus K I)) (fun V ↦ + vanishingIdeal k (OrderDual.ofDual V)) := by + unsealing_newtype OrderDual => + exact GaloisConnection.monotone_intro (fun _ _ ↦ vanishingIdeal_anti_mono) + (fun _ _ ↦ zeroLocus_anti_mono) le_vanishingIdeal_zeroLocus zeroLocus_vanishingIdeal_le theorem le_zeroLocus_iff_le_vanishingIdeal {V : Set (σ → K)} {I : Ideal (MvPolynomial σ k)} : - V ≤ zeroLocus K I ↔ I ≤ vanishingIdeal k V := - zeroLocus_vanishingIdeal_galoisConnection.le_iff_le + V ≤ zeroLocus K I ↔ I ≤ vanishingIdeal k V := by + unsealing_newtype OrderDual => + exact zeroLocus_vanishingIdeal_galoisConnection.le_iff_le theorem zeroLocus_span (S : Set (MvPolynomial σ k)) : zeroLocus K (Ideal.span S) = { x | ∀ p ∈ S, aeval x p = 0 } := diff --git a/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Basic.lean b/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Basic.lean index bb032d6c3..e648c854e 100644 --- a/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Basic.lean +++ b/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Basic.lean @@ -183,29 +183,35 @@ variable (R) /-- `zeroLocus` and `vanishingIdeal` form a Galois connection. -/ theorem gc : - @GaloisConnection (Ideal R) (Set (PrimeSpectrum R))ᵒᵈ _ _ (fun I => zeroLocus I) fun t => - vanishingIdeal t := - fun I t => subset_zeroLocus_iff_le_vanishingIdeal t I + @GaloisConnection (Ideal R) (Set (PrimeSpectrum R))ᵒᵈ _ _ + (fun I => OrderDual.toDual (zeroLocus I)) fun t => + vanishingIdeal (OrderDual.ofDual t) := by + unsealing_newtype OrderDual => + exact fun I t => subset_zeroLocus_iff_le_vanishingIdeal t I set_option backward.isDefEq.respectTransparency false in /-- `zeroLocus` and `vanishingIdeal` form a Galois connection. -/ theorem gc_set : - @GaloisConnection (Set R) (Set (PrimeSpectrum R))ᵒᵈ _ _ (fun s => zeroLocus s) fun t => - vanishingIdeal t := by + @GaloisConnection (Set R) (Set (PrimeSpectrum R))ᵒᵈ _ _ + (fun s => OrderDual.toDual (zeroLocus s)) fun t => + vanishingIdeal (OrderDual.ofDual t) := by have ideal_gc : GaloisConnection Ideal.span _ := (Submodule.gi R R).gc simpa [zeroLocus_span, Function.comp_def] using ideal_gc.compose (gc R) theorem subset_zeroLocus_iff_subset_vanishingIdeal (t : Set (PrimeSpectrum R)) (s : Set R) : - t ⊆ zeroLocus s ↔ s ⊆ vanishingIdeal t := - (gc_set R) s t + t ⊆ zeroLocus s ↔ s ⊆ vanishingIdeal t := by + unsealing_newtype OrderDual => + exact (gc_set R) s t end Gc -theorem subset_vanishingIdeal_zeroLocus (s : Set R) : s ⊆ vanishingIdeal (zeroLocus s) := - (gc_set R).le_u_l s +theorem subset_vanishingIdeal_zeroLocus (s : Set R) : s ⊆ vanishingIdeal (zeroLocus s) := by + unsealing_newtype OrderDual => + exact (gc_set R).le_u_l s -theorem le_vanishingIdeal_zeroLocus (I : Ideal R) : I ≤ vanishingIdeal (zeroLocus I) := - (gc R).le_u_l I +theorem le_vanishingIdeal_zeroLocus (I : Ideal R) : I ≤ vanishingIdeal (zeroLocus I) := by + unsealing_newtype OrderDual => + exact (gc R).le_u_l I @[simp] theorem vanishingIdeal_zeroLocus_eq_radical (I : Ideal R) : @@ -221,12 +227,14 @@ theorem nilradical_eq_iInf : nilradical R = iInf asIdeal := by rw [vanishingIdeal, iInf_univ, nilradical_eq_iInf] @[simp] -theorem zeroLocus_radical (I : Ideal R) : zeroLocus (I.radical : Set R) = zeroLocus I := - vanishingIdeal_zeroLocus_eq_radical I ▸ (gc R).l_u_l_eq_l I +theorem zeroLocus_radical (I : Ideal R) : zeroLocus (I.radical : Set R) = zeroLocus I := by + unsealing_newtype OrderDual => + exact vanishingIdeal_zeroLocus_eq_radical I ▸ (gc R).l_u_l_eq_l I theorem subset_zeroLocus_vanishingIdeal (t : Set (PrimeSpectrum R)) : - t ⊆ zeroLocus (vanishingIdeal t) := - (gc R).l_u_le t + t ⊆ zeroLocus (vanishingIdeal t) := by + unsealing_newtype OrderDual => + exact (gc R).l_u_le t theorem zeroLocus_anti_mono {s t : Set R} (h : s ⊆ t) : zeroLocus t ⊆ zeroLocus s := (gc_set R).monotone_l h @@ -236,8 +244,9 @@ theorem zeroLocus_anti_mono_ideal {s t : Ideal R} (h : s ≤ t) : (gc R).monotone_l h theorem vanishingIdeal_anti_mono {s t : Set (PrimeSpectrum R)} (h : s ⊆ t) : - vanishingIdeal t ≤ vanishingIdeal s := - (gc R).monotone_u h + vanishingIdeal t ≤ vanishingIdeal s := by + unsealing_newtype OrderDual => + exact (gc R).monotone_u h theorem zeroLocus_subset_zeroLocus_iff (I J : Ideal R) : zeroLocus (I : Set R) ⊆ zeroLocus (J : Set R) ↔ J ≤ I.radical := by @@ -248,8 +257,9 @@ theorem zeroLocus_subset_zeroLocus_singleton_iff (f g : R) : rw [← zeroLocus_span {f}, ← zeroLocus_span {g}, zeroLocus_subset_zeroLocus_iff, Ideal.span_le, Set.singleton_subset_iff, SetLike.mem_coe] -theorem zeroLocus_bot : zeroLocus ((⊥ : Ideal R) : Set R) = Set.univ := - (gc R).l_bot +theorem zeroLocus_bot : zeroLocus ((⊥ : Ideal R) : Set R) = Set.univ := by + unsealing_newtype OrderDual => + exact (gc R).l_bot @[simp] lemma zeroLocus_nilradical : zeroLocus (nilradical R : Set R) = Set.univ := by @@ -260,8 +270,9 @@ theorem zeroLocus_singleton_zero : zeroLocus ({0} : Set R) = Set.univ := zeroLocus_bot @[simp] -theorem zeroLocus_empty : zeroLocus (∅ : Set R) = Set.univ := - (gc_set R).l_bot +theorem zeroLocus_empty : zeroLocus (∅ : Set R) = Set.univ := by + unsealing_newtype OrderDual => + exact (gc_set R).l_bot @[simp] theorem vanishingIdeal_empty : vanishingIdeal (∅ : Set (PrimeSpectrum R)) = ⊤ := by @@ -304,34 +315,41 @@ theorem zeroLocus_eq_univ_iff (s : Set R) : rw [← Set.univ_subset_iff, subset_zeroLocus_iff_subset_vanishingIdeal, vanishingIdeal_univ] theorem zeroLocus_sup (I J : Ideal R) : - zeroLocus ((I ⊔ J : Ideal R) : Set R) = zeroLocus I ∩ zeroLocus J := - (gc R).l_sup + zeroLocus ((I ⊔ J : Ideal R) : Set R) = zeroLocus I ∩ zeroLocus J := by + unsealing_newtype OrderDual => + exact (gc R).l_sup -theorem zeroLocus_union (s s' : Set R) : zeroLocus (s ∪ s') = zeroLocus s ∩ zeroLocus s' := - (gc_set R).l_sup +theorem zeroLocus_union (s s' : Set R) : zeroLocus (s ∪ s') = zeroLocus s ∩ zeroLocus s' := by + unsealing_newtype OrderDual => + exact (gc_set R).l_sup theorem vanishingIdeal_union (t t' : Set (PrimeSpectrum R)) : - vanishingIdeal (t ∪ t') = vanishingIdeal t ⊓ vanishingIdeal t' := - (gc R).u_inf + vanishingIdeal (t ∪ t') = vanishingIdeal t ⊓ vanishingIdeal t' := by + unsealing_newtype OrderDual => + exact (gc R).u_inf theorem zeroLocus_iSup {ι : Sort*} (I : ι → Ideal R) : - zeroLocus ((⨆ i, I i : Ideal R) : Set R) = ⋂ i, zeroLocus (I i) := - (gc R).l_iSup + zeroLocus ((⨆ i, I i : Ideal R) : Set R) = ⋂ i, zeroLocus (I i) := by + unsealing_newtype OrderDual => + exact (gc R).l_iSup theorem zeroLocus_iUnion {ι : Sort*} (s : ι → Set R) : - zeroLocus (⋃ i, s i) = ⋂ i, zeroLocus (s i) := - (gc_set R).l_iSup + zeroLocus (⋃ i, s i) = ⋂ i, zeroLocus (s i) := by + unsealing_newtype OrderDual => + exact (gc_set R).l_iSup theorem zeroLocus_iUnion₂ {ι : Sort*} {κ : (i : ι) → Sort*} (s : ∀ i, κ i → Set R) : zeroLocus (⋃ (i) (j), s i j) = ⋂ (i) (j), zeroLocus (s i j) := - (gc_set R).l_iSup₂ + by + simp only [zeroLocus_iUnion] theorem zeroLocus_bUnion (s : Set (Set R)) : zeroLocus (⋃ s' ∈ s, s' : Set R) = ⋂ s' ∈ s, zeroLocus s' := by simp only [zeroLocus_iUnion] theorem vanishingIdeal_iUnion {ι : Sort*} (t : ι → Set (PrimeSpectrum R)) : - vanishingIdeal (⋃ i, t i) = ⨅ i, vanishingIdeal (t i) := - (gc R).u_iInf + vanishingIdeal (⋃ i, t i) = ⨅ i, vanishingIdeal (t i) := by + unsealing_newtype OrderDual => + exact (gc R).u_iInf theorem zeroLocus_inf (I J : Ideal R) : zeroLocus ((I ⊓ J : Ideal R) : Set R) = zeroLocus I ∪ zeroLocus J := diff --git a/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Noetherian.lean b/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Noetherian.lean index d64802163..eb3634c32 100644 --- a/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Noetherian.lean +++ b/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Noetherian.lean @@ -30,7 +30,8 @@ section IsNoetherianRing variable (R : Type u) [CommSemiring R] [IsNoetherianRing R] instance : NoetherianSpace (PrimeSpectrum R) := - ((noetherianSpace_TFAE <| PrimeSpectrum R).out 1 2).mpr (closedsEmbedding R).dual.wellFoundedLT + ((noetherianSpace_TFAE <| PrimeSpectrum R).out 1 2).mpr + ((wellFoundedGT_dual_iff _).1 (closedsEmbedding R).wellFoundedGT) lemma finite_setOfPred_isMin : {x : PrimeSpectrum R | IsMin x}.Finite := by diff --git a/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Topology.lean b/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Topology.lean index 3f333b85f..812353aeb 100644 --- a/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Topology.lean +++ b/mathlib4/Mathlib/RingTheory/Spectrum/Prime/Topology.lean @@ -161,14 +161,18 @@ set_option backward.isDefEq.respectTransparency.types false in theorem zeroLocus_vanishingIdeal_eq_closure (t : Set (PrimeSpectrum R)) : zeroLocus (vanishingIdeal t : Set R) = closure t := by rcases isClosed_iff_zeroLocus (closure t) |>.mp isClosed_closure with ⟨I, hI⟩ + have key : ∀ u : Set (PrimeSpectrum R), + vanishingIdeal (zeroLocus (vanishingIdeal u : Set R)) = vanishingIdeal u := + fun u ↦ (gc R).u_l_u_eq_u (OrderDual.toDual u) rw [subset_antisymm_iff, (isClosed_zeroLocus _).closure_subset_iff, hI, - subset_zeroLocus_iff_subset_vanishingIdeal, (gc R).u_l_u_eq_u, + subset_zeroLocus_iff_subset_vanishingIdeal, key, ← subset_zeroLocus_iff_subset_vanishingIdeal, ← hI] exact ⟨subset_closure, subset_zeroLocus_vanishingIdeal t⟩ theorem vanishingIdeal_closure (t : Set (PrimeSpectrum R)) : - vanishingIdeal (closure t) = vanishingIdeal t := - zeroLocus_vanishingIdeal_eq_closure t ▸ (gc R).u_l_u_eq_u t + vanishingIdeal (closure t) = vanishingIdeal t := by + unsealing_newtype OrderDual => + exact zeroLocus_vanishingIdeal_eq_closure t ▸ (gc R).u_l_u_eq_u t theorem closure_singleton (x) : closure ({x} : Set (PrimeSpectrum R)) = zeroLocus x.asIdeal := by rw [← zeroLocus_vanishingIdeal_eq_closure, vanishingIdeal_singleton] @@ -208,7 +212,7 @@ theorem vanishingIdeal_strict_anti_mono_iff {s t : Set (PrimeSpectrum R)} (hs : def closedsEmbedding (R : Type*) [CommSemiring R] : (TopologicalSpace.Closeds <| PrimeSpectrum R)ᵒᵈ ↪o Ideal R := OrderEmbedding.ofMapLEIff (fun s => vanishingIdeal ↑(OrderDual.ofDual s)) fun s _ => - (vanishingIdeal_anti_mono_iff s.2).symm + (vanishingIdeal_anti_mono_iff (OrderDual.ofDual s).2).symm theorem t1Space_iff_isField [IsDomain R] : T1Space (PrimeSpectrum R) ↔ IsField R := by refine ⟨?_, fun h => ?_⟩ @@ -1237,9 +1241,10 @@ protected def _root_.Ideal.minimalPrimes.equivIrreducibleComponents (I : Ideal R let e : {p : Ideal R | p.IsPrime ∧ I ≤ p} ≃o zeroLocus (I : Set R) := ⟨⟨fun x ↦ ⟨⟨x.1, x.2.1⟩, x.2.2⟩, fun x ↦ ⟨x.1.1, x.1.2, x.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩, .rfl⟩ rw [irreducibleComponents_eq_maximals_closed] - exact OrderIso.setOfPredMinimalIsoSetOfPredMaximal + refine (OrderIso.setOfPredMinimalIsoSetOfPredMaximal (e.trans ((PrimeSpectrum.zeroLocusEquivIrreducibleCloseds (I : Set R)).trans - (TopologicalSpace.IrreducibleCloseds.orderIsoSubtype' (zeroLocus (I : Set R))).dual)) + (TopologicalSpace.IrreducibleCloseds.orderIsoSubtype' (zeroLocus (I : Set R))).dual))).trans ?_ + exact OrderIso.subtypeDual (fun s => Maximal (fun s => IsClosed s ∧ IsIrreducible s) s) variable (R) @@ -1251,9 +1256,10 @@ protected def _root_.minimalPrimes.equivIrreducibleComponents : let e : {p : Ideal R | p.IsPrime ∧ ⊥ ≤ p} ≃o PrimeSpectrum R := ⟨⟨fun x ↦ ⟨x.1, x.2.1⟩, fun x ↦ ⟨x.1, x.2, bot_le⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩, Iff.rfl⟩ rw [irreducibleComponents_eq_maximals_closed] - exact OrderIso.setOfPredMinimalIsoSetOfPredMaximal + refine (OrderIso.setOfPredMinimalIsoSetOfPredMaximal (e.trans ((PrimeSpectrum.pointsEquivIrreducibleCloseds R).trans - (TopologicalSpace.IrreducibleCloseds.orderIsoSubtype' (PrimeSpectrum R)).dual)) + (TopologicalSpace.IrreducibleCloseds.orderIsoSubtype' (PrimeSpectrum R)).dual))).trans ?_ + exact OrderIso.subtypeDual (fun s => Maximal (fun s => IsClosed s ∧ IsIrreducible s) s) lemma vanishingIdeal_irreducibleComponents : vanishingIdeal '' (irreducibleComponents <| PrimeSpectrum R) = minimalPrimes R := by diff --git a/mathlib4/Mathlib/RingTheory/Valuation/Basic.lean b/mathlib4/Mathlib/RingTheory/Valuation/Basic.lean index ed8b787f1..38b74abb8 100644 --- a/mathlib4/Mathlib/RingTheory/Valuation/Basic.lean +++ b/mathlib4/Mathlib/RingTheory/Valuation/Basic.lean @@ -1084,14 +1084,26 @@ namespace AddValuation variable {Γ₀ : Type*} {Γ'₀ : Type*} +/-- Unwrap an equality between multiplicative valuation values. -/ +private lemma val_congr {Γ : Type*} {a b : Multiplicative Γᵒᵈ} (h : a = b) : + OrderDual.ofDual (Multiplicative.toAdd a) = OrderDual.ofDual (Multiplicative.toAdd b) := + congrArg _ h + section Basic section Monoid variable [Ring R] [LinearOrderedAddCommMonoidWithTop Γ₀] [LinearOrderedAddCommMonoidWithTop Γ'₀] (v : AddValuation R Γ₀) -instance : FunLike (AddValuation R Γ₀) R Γ₀ := - inferInstanceAs <| FunLike (Valuation R <| Multiplicative Γ₀ᵒᵈ) R <| Multiplicative Γ₀ᵒᵈ +/-- Evaluate an additive valuation by unwrapping its underlying multiplicative valuation. +The conversion gives `toValuation v r = Multiplicative.ofAdd (OrderDual.toDual (v r))` +by definitional equality. -/ +instance : FunLike (AddValuation R Γ₀) R Γ₀ where + coe v r := OrderDual.ofDual (Multiplicative.toAdd + (DFunLike.coe (F := Valuation R (Multiplicative Γ₀ᵒᵈ)) v r)) + coe_injective _ _ h := + DFunLike.coe_injective (F := Valuation R (Multiplicative Γ₀ᵒᵈ)) + (funext fun r ↦ congrArg (fun x ↦ Multiplicative.ofAdd (OrderDual.toDual x)) (congrFun h r)) section @@ -1100,11 +1112,11 @@ variable (hadd : ∀ x y, min (f x) (f y) ≤ f (x + y)) (hmul : ∀ x y, f (x * /-- An alternate constructor of `AddValuation`, that doesn't reference `Multiplicative Γ₀ᵒᵈ` -/ def of : AddValuation R Γ₀ where - toFun := f - map_one' := h1 - map_zero' := h0 + toFun r := Multiplicative.ofAdd (OrderDual.toDual (f r)) + map_one' := by unsealing_newtype OrderDual => exact h1 + map_zero' := by unsealing_newtype OrderDual => exact h0 map_add_le_max' := hadd - map_mul' := hmul + map_mul' := by unsealing_newtype OrderDual => exact hmul variable {h0} {h1} {hadd} {hmul} {r : R} @@ -1147,16 +1159,18 @@ theorem ofValuation_apply (v : Valuation R (Multiplicative Γ₀ᵒᵈ)) (r : R) end @[simp] -theorem map_zero : v 0 = (⊤ : Γ₀) := - Valuation.map_zero v +theorem map_zero : v 0 = (⊤ : Γ₀) := by + unsealing_newtype OrderDual => + exact Valuation.map_zero v @[simp] -theorem map_one : v 1 = (0 : Γ₀) := - Valuation.map_one v +theorem map_one : v 1 = (0 : Γ₀) := by + unsealing_newtype OrderDual => + exact Valuation.map_one v @[simp] -theorem map_mul : ∀ (x y : R), v (x * y) = v x + v y := - Valuation.map_mul v +theorem map_mul (x y : R) : v (x * y) = v x + v y := + val_congr (Valuation.map_mul v x y) -- `simp`-normal form is `map_add'` theorem map_add : ∀ (x y : R), min (v x) (v y) ≤ v (x + y) := @@ -1179,20 +1193,22 @@ theorem map_le_sum {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hf : v.map_sum_le hf theorem map_lt_sum {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hg : g ≠ ⊤) - (hf : ∀ i ∈ s, g < v (f i)) : g < v (∑ i ∈ s, f i) := - v.map_sum_lt hg hf + (hf : ∀ i ∈ s, g < v (f i)) : g < v (∑ i ∈ s, f i) := by + unsealing_newtype OrderDual => + exact v.map_sum_lt hg hf theorem map_lt_sum' {ι : Type*} {s : Finset ι} {f : ι → R} {g : Γ₀} (hg : g < ⊤) (hf : ∀ i ∈ s, g < v (f i)) : g < v (∑ i ∈ s, f i) := v.map_sum_lt' hg hf @[simp] -theorem map_pow : ∀ (x : R) (n : ℕ), v (x ^ n) = n • (v x) := - Valuation.map_pow v +theorem map_pow (x : R) (n : ℕ) : v (x ^ n) = n • (v x) := + val_congr (Valuation.map_pow v x n) @[ext] -theorem ext {v₁ v₂ : AddValuation R Γ₀} (h : ∀ r, v₁ r = v₂ r) : v₁ = v₂ := - Valuation.ext h +theorem ext {v₁ v₂ : AddValuation R Γ₀} (h : ∀ r, v₁ r = v₂ r) : v₁ = v₂ := by + unsealing_newtype OrderDual => + exact Valuation.ext h -- The following definition is not an instance, because we have more than one `v` on a given `R`. -- In addition, type class inference would not be able to infer `v`. @@ -1203,11 +1219,12 @@ def toPreorder : Preorder R := /-- If `v` is an additive valuation on a division ring then `v(x) = ⊤` iff `x = 0`. -/ @[simp] -theorem top_iff [Nontrivial Γ₀] (v : AddValuation K Γ₀) {x : K} : v x = (⊤ : Γ₀) ↔ x = 0 := - v.zero_iff +theorem top_iff [Nontrivial Γ₀] (v : AddValuation K Γ₀) {x : K} : v x = (⊤ : Γ₀) ↔ x = 0 := by + unsealing_newtype OrderDual => + exact v.zero_iff theorem ne_top_iff [Nontrivial Γ₀] (v : AddValuation K Γ₀) {x : K} : v x ≠ (⊤ : Γ₀) ↔ x ≠ 0 := - v.ne_zero_iff + not_congr (top_iff v) /-- A ring homomorphism `S → R` induces a map `AddValuation R Γ₀ → AddValuation S Γ₀`. -/ def comap {S : Type*} [Ring S] (f : S →+* R) (v : AddValuation R Γ₀) : AddValuation S Γ₀ := @@ -1226,11 +1243,10 @@ theorem comap_comp {S₁ : Type*} {S₂ : Type*} [Ring S₁] [Ring S₂] (f : S -/ def map (f : Γ₀ →+ Γ'₀) (ht : f ⊤ = ⊤) (hf : Monotone f) (v : AddValuation R Γ₀) : AddValuation R Γ'₀ := - @Valuation.map R (Multiplicative Γ₀ᵒᵈ) (Multiplicative Γ'₀ᵒᵈ) _ _ _ - { toFun := f - map_mul' := f.map_add - map_one' := f.map_zero - map_zero' := ht } (fun _ _ h => hf h) v + of (fun r => f (v r)) + (by rw [v.map_zero, ht]) (by rw [v.map_one, f.map_zero]) + (fun x y => hf.map_min.symm.trans_le (hf (v.map_add x y))) + (fun x y => by rw [v.map_mul, f.map_add]) @[simp] lemma map_apply (f : Γ₀ →+ Γ'₀) (ht : f ⊤ = ⊤) (hf : Monotone f) (v : AddValuation R Γ₀) (r : R) : @@ -1242,11 +1258,13 @@ def IsEquiv (v₁ : AddValuation R Γ₀) (v₂ : AddValuation R Γ'₀) : Prop Valuation.IsEquiv v₁ v₂ @[simp] -theorem map_neg (x : R) : v (-x) = v x := - Valuation.map_neg v x +theorem map_neg (x : R) : v (-x) = v x := by + unsealing_newtype OrderDual => + exact Valuation.map_neg v x -theorem map_sub_swap (x y : R) : v (x - y) = v (y - x) := - Valuation.map_sub_swap v x y +theorem map_sub_swap (x y : R) : v (x - y) = v (y - x) := by + unsealing_newtype OrderDual => + exact Valuation.map_sub_swap v x y theorem map_sub (x y : R) : min (v x) (v y) ≤ v (x - y) := Valuation.map_sub v x y @@ -1256,8 +1274,9 @@ theorem map_le_sub {x y : R} {g : Γ₀} (hx : g ≤ v x) (hy : g ≤ v y) : g variable {x y : R} -theorem map_add_of_distinct_val (h : v x ≠ v y) : v (x + y) = @Min.min Γ₀ _ (v x) (v y) := - Valuation.map_add_of_distinct_val v h +theorem map_add_of_distinct_val (h : v x ≠ v y) : v (x + y) = @Min.min Γ₀ _ (v x) (v y) := by + unsealing_newtype OrderDual => + exact Valuation.map_add_of_distinct_val v h theorem map_add_eq_of_lt_left {x y : R} (h : v x < v y) : v (x + y) = v x := by @@ -1275,8 +1294,9 @@ theorem map_sub_eq_of_lt_left {x y : R} (hx : v x < v y) : theorem map_sub_eq_of_lt_right {x y : R} (hx : v y < v x) : v (x - y) = v y := map_sub_swap v x y ▸ map_sub_eq_of_lt_left v hx -theorem map_eq_of_lt_sub (h : v x < v (y - x)) : v y = v x := - Valuation.map_eq_of_sub_lt v h +theorem map_eq_of_lt_sub (h : v x < v (y - x)) : v y = v x := by + unsealing_newtype OrderDual => + exact Valuation.map_eq_of_sub_lt v h end Monoid @@ -1285,12 +1305,14 @@ section Group variable [LinearOrderedAddCommGroupWithTop Γ₀] [Ring R] (v : AddValuation R Γ₀) {x y : R} @[simp] -theorem map_inv (v : AddValuation K Γ₀) {x : K} : v x⁻¹ = -(v x) := - map_inv₀ (toValuation v) x +theorem map_inv (v : AddValuation K Γ₀) {x : K} : v x⁻¹ = -(v x) := by + unsealing_newtype OrderDual => + exact map_inv₀ (toValuation v) x @[simp] -theorem map_div (v : AddValuation K Γ₀) {x y : K} : v (x / y) = v x - v y := - map_div₀ (toValuation v) x y +theorem map_div (v : AddValuation K Γ₀) {x y : K} : v (x / y) = v x - v y := by + unsealing_newtype OrderDual => + exact map_div₀ (toValuation v) x y end Group @@ -1320,23 +1342,26 @@ theorem of_eq {v' : AddValuation R Γ₀} (h : v = v') : v.IsEquiv v' := Valuation.IsEquiv.of_eq h theorem map {v' : AddValuation R Γ₀} (f : Γ₀ →+ Γ'₀) (ht : f ⊤ = ⊤) (hf : Monotone f) - (inf : Injective f) (h : v.IsEquiv v') : (v.map f ht hf).IsEquiv (v'.map f ht hf) := - @Valuation.IsEquiv.map R (Multiplicative Γ₀ᵒᵈ) (Multiplicative Γ'₀ᵒᵈ) _ _ _ _ _ - { toFun := f - map_mul' := f.map_add - map_one' := f.map_zero - map_zero' := ht } (fun _x _y h => hf h) inf h + (inf : Injective f) (h : v.IsEquiv v') : (v.map f ht hf).IsEquiv (v'.map f ht hf) := by + unsealing_newtype OrderDual => + exact @Valuation.IsEquiv.map R (Multiplicative Γ₀ᵒᵈ) (Multiplicative Γ'₀ᵒᵈ) _ _ _ _ _ + { toFun := f + map_mul' := f.map_add + map_one' := f.map_zero + map_zero' := ht } (fun _x _y h => hf h) inf h /-- `comap` preserves equivalence. -/ theorem comap {S : Type*} [Ring S] (f : S →+* R) (h : v₁.IsEquiv v₂) : (v₁.comap f).IsEquiv (v₂.comap f) := Valuation.IsEquiv.comap f h -theorem val_eq (h : v₁.IsEquiv v₂) {r s : R} : v₁ r = v₁ s ↔ v₂ r = v₂ s := - Valuation.IsEquiv.eq_iff h +theorem val_eq (h : v₁.IsEquiv v₂) {r s : R} : v₁ r = v₁ s ↔ v₂ r = v₂ s := by + unsealing_newtype OrderDual => + exact Valuation.IsEquiv.eq_iff h -theorem ne_top (h : v₁.IsEquiv v₂) {r : R} : v₁ r ≠ (⊤ : Γ₀) ↔ v₂ r ≠ (⊤ : Γ'₀) := - (Valuation.IsEquiv.eq_zero h).ne +theorem ne_top (h : v₁.IsEquiv v₂) {r : R} : v₁ r ≠ (⊤ : Γ₀) ↔ v₂ r ≠ (⊤ : Γ'₀) := by + unsealing_newtype OrderDual => + exact (Valuation.IsEquiv.eq_zero h).ne end IsEquiv @@ -1349,11 +1374,13 @@ def supp : Ideal R := Valuation.supp v @[simp] -theorem mem_supp_iff (x : R) : x ∈ supp v ↔ v x = (⊤ : Γ₀) := - Valuation.mem_supp_iff v x +theorem mem_supp_iff (x : R) : x ∈ supp v ↔ v x = (⊤ : Γ₀) := by + unsealing_newtype OrderDual => + exact Valuation.mem_supp_iff v x -theorem map_add_supp (a : R) {s : R} (h : s ∈ supp v) : v (a + s) = v a := - Valuation.map_add_supp v a h +theorem map_add_supp (a : R) {s : R} (h : s ∈ supp v) : v (a + s) = v a := by + unsealing_newtype OrderDual => + exact Valuation.map_add_supp v a h end Supp diff --git a/mathlib4/Mathlib/RingTheory/Valuation/Quotient.lean b/mathlib4/Mathlib/RingTheory/Valuation/Quotient.lean index 5c4364f0e..2cf8267d9 100644 --- a/mathlib4/Mathlib/RingTheory/Valuation/Quotient.lean +++ b/mathlib4/Mathlib/RingTheory/Valuation/Quotient.lean @@ -85,7 +85,7 @@ variable (v : AddValuation R Γ₀) /-- If `hJ : J ⊆ supp v` then `onQuotVal hJ` is the induced function on `R / J` as a function. Note: it's just the function; the valuation is `onQuot hJ`. -/ def onQuotVal {J : Ideal R} (hJ : J ≤ supp v) : R ⧸ J → Γ₀ := - Valuation.onQuotVal v hJ + fun x ↦ OrderDual.ofDual (Multiplicative.toAdd (Valuation.onQuotVal v hJ x)) /-- The extension of valuation `v` on `R` to valuation on `R / J` if `J ⊆ supp v`. -/ def onQuot {J : Ideal R} (hJ : J ≤ supp v) : AddValuation (R ⧸ J) Γ₀ := diff --git a/mathlib4/Mathlib/RingTheory/Valuation/ValuationSubring.lean b/mathlib4/Mathlib/RingTheory/Valuation/ValuationSubring.lean index 4a1dc16d0..c4748f97b 100644 --- a/mathlib4/Mathlib/RingTheory/Valuation/ValuationSubring.lean +++ b/mathlib4/Mathlib/RingTheory/Valuation/ValuationSubring.lean @@ -590,8 +590,8 @@ theorem nonunits_inj {A B : ValuationSubring K} : A.nonunits = B.nonunits ↔ A /-- The map on valuation subrings to their nonunits is a dual order embedding. -/ def nonunitsOrderEmbedding : ValuationSubring K ↪o (NonUnitalSubring K)ᵒᵈ where - toFun A := A.nonunits - inj' := nonunits_injective + toFun A := OrderDual.toDual A.nonunits + inj' _ _ h := nonunits_injective (OrderDual.toDual_inj.1 h) map_rel_iff' {_A _B} := nonunits_le_nonunits variable {A} @@ -682,8 +682,8 @@ theorem eq_iff_principalUnitGroup {A B : ValuationSubring K} : /-- The map on valuation subrings to their principal unit groups is an order embedding. -/ def principalUnitGroupOrderEmbedding : ValuationSubring K ↪o (Subgroup Kˣ)ᵒᵈ where - toFun A := A.principalUnitGroup - inj' := principalUnitGroup_injective + toFun A := OrderDual.toDual A.principalUnitGroup + inj' _ _ h := principalUnitGroup_injective (OrderDual.toDual_inj.1 h) map_rel_iff' {_A _B} := principalUnitGroup_le_principalUnitGroup theorem coe_mem_principalUnitGroup_iff {x : A.unitGroup} : diff --git a/mathlib4/Mathlib/SetTheory/Cardinal/Arithmetic.lean b/mathlib4/Mathlib/SetTheory/Cardinal/Arithmetic.lean index 3e980f7da..3d8c2a060 100644 --- a/mathlib4/Mathlib/SetTheory/Cardinal/Arithmetic.lean +++ b/mathlib4/Mathlib/SetTheory/Cardinal/Arithmetic.lean @@ -329,8 +329,9 @@ theorem mk_Iic_lt {α : Type*} [LinearOrder α] [WellFoundedLT α] (i : α) exact add_one_lt_of_lt hα (mk_Iio_lt i h) theorem mk_Ici_lt {α : Type*} [LinearOrder α] [WellFoundedGT α] (i : α) - (h : ord #α = typeLT αᵒᵈ) (hα : ℵ₀ ≤ #α) : #(Ici i) < #α := - mk_Iic_lt (OrderDual.toDual i) h hα + (h : ord #α = typeLT αᵒᵈ) (hα : ℵ₀ ≤ #α) : #(Ici i) < #α := by + unsealing_newtype OrderDual => + exact mk_Iic_lt (OrderDual.toDual i) h hα protected theorem eq_of_add_eq_add_left {a b c : Cardinal} (h : a + b = a + c) (ha : a < ℵ₀) : b = c := by diff --git a/mathlib4/Mathlib/SetTheory/Cardinal/EventuallyConst.lean b/mathlib4/Mathlib/SetTheory/Cardinal/EventuallyConst.lean index 402831ca5..a7ae31332 100644 --- a/mathlib4/Mathlib/SetTheory/Cardinal/EventuallyConst.lean +++ b/mathlib4/Mathlib/SetTheory/Cardinal/EventuallyConst.lean @@ -44,8 +44,9 @@ theorem of_monotone_of_lt_cof (hf : Monotone f) (hα : lift.{u} #β < lift.{v} ( exact (cof_le_cardinalMk _).trans (mk_set_le _) theorem of_antitone_of_lt_cof (hf : Antitone f) (hα : lift.{u} #β < lift.{v} (cof α)) : - atTop.EventuallyConst f := - .of_monotone_of_lt_cof (β := βᵒᵈ) hf.dual_right hα + atTop.EventuallyConst f := by + unsealing_newtype OrderDual => + exact .of_monotone_of_lt_cof (β := βᵒᵈ) hf.dual_right hα end Filter.EventuallyConst @@ -56,8 +57,9 @@ theorem eventuallyConst_of_monotone (hf : Monotone f) : atTop.EventuallyConst f refine .of_monotone_of_lt_cof hf ?_ simpa [← small_iff_lift_mk_lt_univ] -theorem eventuallyConst_of_antitone (hf : Antitone f) : atTop.EventuallyConst f := - eventuallyConst_of_monotone (β := βᵒᵈ) hf +theorem eventuallyConst_of_antitone (hf : Antitone f) : atTop.EventuallyConst f := by + unsealing_newtype OrderDual => + exact eventuallyConst_of_monotone (β := βᵒᵈ) hf end Cardinal @@ -68,7 +70,8 @@ theorem eventuallyConst_of_monotone (hf : Monotone f) : atTop.EventuallyConst f refine .of_monotone_of_lt_cof hf ?_ simpa [← small_iff_lift_mk_lt_univ] -theorem eventuallyConst_of_antitone (hf : Antitone f) : atTop.EventuallyConst f := - eventuallyConst_of_monotone (β := βᵒᵈ) hf +theorem eventuallyConst_of_antitone (hf : Antitone f) : atTop.EventuallyConst f := by + unsealing_newtype OrderDual => + exact eventuallyConst_of_monotone (β := βᵒᵈ) hf end Ordinal diff --git a/mathlib4/Mathlib/SetTheory/Ordinal/Basic.lean b/mathlib4/Mathlib/SetTheory/Ordinal/Basic.lean index 135786181..d45a15b67 100644 --- a/mathlib4/Mathlib/SetTheory/Ordinal/Basic.lean +++ b/mathlib4/Mathlib/SetTheory/Ordinal/Basic.lean @@ -1150,8 +1150,9 @@ theorem mk_Iio_lt [LinearOrder α] [WellFoundedLT α] (i : α) (h : ord #α = ty card_typein_lt (r := LT.lt) i h theorem mk_Ioi_lt {α : Type*} [LinearOrder α] [WellFoundedGT α] (i : α) (h : ord #α = typeLT αᵒᵈ) : - #(Ioi i) < #α := - mk_Iio_lt (OrderDual.toDual i) h + #(Ioi i) < #α := by + unsealing_newtype OrderDual => + exact mk_Iio_lt (OrderDual.toDual i) h @[deprecated mk_Iio_lt +typeChanged (since := "2026-04-12")] theorem mk_Iio_toType_ord_lt {c : Cardinal} (i : c.ord.ToType) : #(Iio i) < c := by diff --git a/mathlib4/Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean b/mathlib4/Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean index ca301d27e..2d403e72c 100644 --- a/mathlib4/Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean +++ b/mathlib4/Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean @@ -257,93 +257,111 @@ def gfpApprox (a : Ordinal.{u}) : α := termination_by a -- By unsealing these recursive definitions we can relate them --- by definitional equality unseal gfpApprox lfpApprox theorem gfpApprox_zero : gfpApprox f x 0 = x := by - exact lfpApprox_zero f.dual + unsealing_newtype OrderDual => + exact lfpApprox_zero f.dual -theorem gfpApprox_anti_right : Antitone (gfpApprox f x) := - lfpApprox_mono_right f.dual +theorem gfpApprox_anti_right : Antitone (gfpApprox f x) := by + unsealing_newtype OrderDual => + exact lfpApprox_mono_right f.dual @[deprecated (since := "2026-03-30")] alias gfpApprox_antitone := gfpApprox_anti_right -theorem gfpApprox_le {a : Ordinal} : gfpApprox f x a ≤ x := - le_lfpApprox f.dual +theorem gfpApprox_le {a : Ordinal} : gfpApprox f x a ≤ x := by + unsealing_newtype OrderDual => + exact le_lfpApprox f.dual theorem gfpApprox_add_one (hx : f x ≤ x) (a : Ordinal) : - gfpApprox f x (a + 1) = f (gfpApprox f x a) := - lfpApprox_add_one f.dual hx a + gfpApprox f x (a + 1) = f (gfpApprox f x a) := by + unsealing_newtype OrderDual => + exact lfpApprox_add_one f.dual hx a theorem gfpApprox_le_apply_gfpApprox_of_lt {a b : Ordinal} (h : a < b) : - gfpApprox f x b ≤ f (gfpApprox f x a) := - apply_lfpApprox_le_lfpApprox_of_lt f.dual h + gfpApprox f x b ≤ f (gfpApprox f x a) := by + unsealing_newtype OrderDual => + exact apply_lfpApprox_le_lfpApprox_of_lt f.dual h theorem gfpApprox_of_isSuccLimit {a : Ordinal} (ha : Order.IsSuccLimit a) : - gfpApprox f x a = ⨅ b : Set.Iio a, gfpApprox f x b := - lfpApprox_of_isSuccLimit f.dual ha + gfpApprox f x a = ⨅ b : Set.Iio a, gfpApprox f x b := by + unsealing_newtype OrderDual => + exact lfpApprox_of_isSuccLimit f.dual ha theorem gfpApprox_mono_left : Monotone (gfpApprox : (α →o α) → _) := by - intro f g h - have : g.dual ≤ f.dual := h - exact lfpApprox_mono_left this + unsealing_newtype OrderDual => + intro f g h + have : g.dual ≤ f.dual := h + exact lfpApprox_mono_left this -theorem gfpApprox_mono_mid : Monotone (gfpApprox f) := - fun _ _ h => lfpApprox_mono_mid f.dual h +theorem gfpApprox_mono_mid : Monotone (gfpApprox f) := by + unsealing_newtype OrderDual => + exact fun _ _ h => lfpApprox_mono_mid f.dual h /-- The approximations of the greatest fixed point stabilize at a fixed point of `f` -/ theorem gfpApprox_eq_of_mem_fixedPoints {a b : Ordinal} (h_ab : a ≤ b) - (h : gfpApprox f x a ∈ fixedPoints f) : gfpApprox f x b = gfpApprox f x a := - lfpApprox_eq_of_mem_fixedPoints f.dual h_ab h + (h : gfpApprox f x a ∈ fixedPoints f) : gfpApprox f x b = gfpApprox f x a := by + unsealing_newtype OrderDual => + exact lfpApprox_eq_of_mem_fixedPoints f.dual h_ab h theorem gfpApprox_eq_all_of_fixedPoint (hx : f x ≤ x) : - (∀ o, gfpApprox f x o = x) ↔ f x = x := - lfpApprox_eq_all_of_fixedPoint f.dual hx + (∀ o, gfpApprox f x o = x) ↔ f x = x := by + unsealing_newtype OrderDual => + exact lfpApprox_eq_all_of_fixedPoint f.dual hx lemma gfpApprox_mem_fixedPoints_of_eq (hx : f x ≤ x) (hab : a < b) (hac : a ≤ c) - (hf : gfpApprox f x a = gfpApprox f x b) : gfpApprox f x c ∈ fixedPoints f := - lfpApprox_mem_fixedPoints_of_eq f.dual hx hab hac hf + (hf : gfpApprox f x a = gfpApprox f x b) : gfpApprox f x c ∈ fixedPoints f := by + unsealing_newtype OrderDual => + exact lfpApprox_mem_fixedPoints_of_eq f.dual hx hab hac hf theorem gfpApprox_eq_of_fixedPoint_or_zero (hx : f x ≤ x) (o : Ordinal) : - gfpApprox f x o = x ↔ f x = x ∨ o = 0 := - lfpApprox_eq_of_fixedPoint_or_zero f.dual hx o + gfpApprox f x o = x ↔ f x = x ∨ o = 0 := by + unsealing_newtype OrderDual => + exact lfpApprox_eq_of_fixedPoint_or_zero f.dual hx o /-- There are distinct indices smaller than the successor of the domain's cardinality yielding the same value -/ theorem exists_gfpApprox_eq_gfpApprox : ∃ a < ord <| succ #α, ∃ b < ord <| succ #α, - a ≠ b ∧ gfpApprox f x a = gfpApprox f x b := - exists_lfpApprox_eq_lfpApprox f.dual x + a ≠ b ∧ gfpApprox f x a = gfpApprox f x b := by + unsealing_newtype OrderDual => + exact exists_lfpApprox_eq_lfpApprox f.dual x /-- The approximation at the index of the successor of the domain's cardinality is a fixed point -/ lemma gfpApprox_ord_mem_fixedPoint (hx : f x ≤ x) : - gfpApprox f x (ord <| succ #α) ∈ fixedPoints f := - lfpApprox_ord_mem_fixedPoint f.dual hx + gfpApprox f x (ord <| succ #α) ∈ fixedPoints f := by + unsealing_newtype OrderDual => + exact lfpApprox_ord_mem_fixedPoint f.dual hx /-- Every value of the approximation is greater or equal than every fixed point of `f` less or equal than the initial value -/ lemma le_gfpApprox_of_mem_fixedPoints {a : α} - (ha : a ∈ fixedPoints f) (hax : a ≤ x) (i : Ordinal) : a ≤ gfpApprox f x i := - lfpApprox_le_of_mem_fixedPoints f.dual ha hax i + (ha : a ∈ fixedPoints f) (hax : a ≤ x) (i : Ordinal) : a ≤ gfpApprox f x i := by + unsealing_newtype OrderDual => + exact lfpApprox_le_of_mem_fixedPoints f.dual ha hax i /-- The approximation sequence converges at the successor of the domain's cardinality to the greatest fixed point if starting from `⊥` -/ -theorem gfpApprox_ord_eq_gfp : gfpApprox f ⊤ (ord <| succ #α) = f.gfp := - lfpApprox_ord_eq_lfp f.dual +theorem gfpApprox_ord_eq_gfp : gfpApprox f ⊤ (ord <| succ #α) = f.gfp := by + unsealing_newtype OrderDual => + exact lfpApprox_ord_eq_lfp f.dual /-- Some approximation of the least fixed point starting from `⊤` is the greatest fixed point. -/ -theorem gfp_mem_range_gfpApprox : f.gfp ∈ Set.range (gfpApprox f ⊤) := - lfp_mem_range_lfpApprox f.dual +theorem gfp_mem_range_gfpApprox : f.gfp ∈ Set.range (gfpApprox f ⊤) := by + unsealing_newtype OrderDual => + exact lfp_mem_range_lfpApprox f.dual /-- If `gfpApprox f x a` is a fixed point, then the infimum of the whole ordinal-indexed sequence equals the value at `a`. -/ lemma iInf_gfpApprox_eq_of_mem_fixedPoints (hf : gfpApprox f x a ∈ fixedPoints f) : - ⨅ i : Ordinal, gfpApprox f x i = gfpApprox f x a := - iSup_lfpApprox_eq_of_mem_fixedPoints f.dual hf + ⨅ i : Ordinal, gfpApprox f x i = gfpApprox f x a := by + unsealing_newtype OrderDual => + exact iSup_lfpApprox_eq_of_mem_fixedPoints f.dual hf /-- The ordinal-indexed infimum of `gfpApprox` equals `prevFixed`: the greatest fixed point less than or equal to `x`. -/ theorem prevFixed_eq_iInf_gfpApprox (hx : f x ≤ x) : - (f.prevFixed x hx).val = ⨅ a : Ordinal, gfpApprox f x a := - nextFixed_eq_iSup_lfpApprox f.dual hx + (f.prevFixed x hx).val = ⨅ a : Ordinal, gfpApprox f x a := by + unsealing_newtype OrderDual => + exact nextFixed_eq_iSup_lfpApprox f.dual hx end OrdinalApprox diff --git a/mathlib4/Mathlib/Topology/Algebra/ConstMulAction.lean b/mathlib4/Mathlib/Topology/Algebra/ConstMulAction.lean index 8b197e82f..cda48b2c7 100644 --- a/mathlib4/Mathlib/Topology/Algebra/ConstMulAction.lean +++ b/mathlib4/Mathlib/Topology/Algebra/ConstMulAction.lean @@ -122,11 +122,12 @@ instance MulOpposite.continuousConstSMul : ContinuousConstSMul M αᵐᵒᵖ := ⟨fun c => MulOpposite.continuous_op.comp <| MulOpposite.continuous_unop.const_smul c⟩ @[to_additive] -instance : ContinuousConstSMul M αᵒᵈ := ‹ContinuousConstSMul M α› +instance : ContinuousConstSMul M αᵒᵈ := + ⟨fun c ↦ continuous_toDual.comp ((continuous_const_smul c).comp continuous_ofDual)⟩ @[to_additive] instance OrderDual.continuousConstSMul' : ContinuousConstSMul Mᵒᵈ α := - ‹ContinuousConstSMul M α› + ⟨fun c ↦ continuous_const_smul (OrderDual.ofDual c)⟩ @[to_additive] instance Prod.continuousConstSMul [SMul M β] [ContinuousConstSMul M β] : diff --git a/mathlib4/Mathlib/Topology/Algebra/Group/ContinuousInv.lean b/mathlib4/Mathlib/Topology/Algebra/Group/ContinuousInv.lean index 1c585d2a6..fec26f5b1 100644 --- a/mathlib4/Mathlib/Topology/Algebra/Group/ContinuousInv.lean +++ b/mathlib4/Mathlib/Topology/Algebra/Group/ContinuousInv.lean @@ -78,7 +78,8 @@ theorem tendsto_inv (a : G) : Tendsto Inv.inv (𝓝 a) (𝓝 a⁻¹) := continuousAt_inv @[to_additive] -instance OrderDual.instContinuousInv : ContinuousInv Gᵒᵈ := ‹ContinuousInv G› +instance OrderDual.instContinuousInv : ContinuousInv Gᵒᵈ := + ⟨continuous_toDual.comp (continuous_inv.comp continuous_ofDual)⟩ @[to_additive] instance Prod.continuousInv [TopologicalSpace H] [Inv H] [ContinuousInv H] : diff --git a/mathlib4/Mathlib/Topology/Algebra/Monoid.lean b/mathlib4/Mathlib/Topology/Algebra/Monoid.lean index a2db03b14..f45ee96b9 100644 --- a/mathlib4/Mathlib/Topology/Algebra/Monoid.lean +++ b/mathlib4/Mathlib/Topology/Algebra/Monoid.lean @@ -56,8 +56,13 @@ section SeparatelyContinuousMul variable [TopologicalSpace M] [Mul M] [SeparatelyContinuousMul M] @[to_additive] -instance : SeparatelyContinuousMul Mᵒᵈ := - ‹SeparatelyContinuousMul M› +instance : SeparatelyContinuousMul Mᵒᵈ where + continuous_const_mul {a} := continuous_toDual.comp + ((SeparatelyContinuousMul.continuous_const_mul (a := OrderDual.ofDual a)).comp + continuous_ofDual) + continuous_mul_const {a} := continuous_toDual.comp + ((SeparatelyContinuousMul.continuous_mul_const (a := OrderDual.ofDual a)).comp + continuous_ofDual) @[to_additive] instance : SeparatelyContinuousMul (ULift.{u} M) := @@ -79,7 +84,8 @@ variable [TopologicalSpace M] [Mul M] [ContinuousMul M] @[to_additive] instance : ContinuousMul Mᵒᵈ := - ‹ContinuousMul M› + ⟨continuous_toDual.comp + (continuous_mul.comp (continuous_ofDual.prodMap continuous_ofDual))⟩ @[to_additive] instance : ContinuousMul (ULift.{u} M) := ⟨continuous_uliftUp.comp (by fun_prop)⟩ diff --git a/mathlib4/Mathlib/Topology/Algebra/MulAction.lean b/mathlib4/Mathlib/Topology/Algebra/MulAction.lean index fbac7d983..9466fc360 100644 --- a/mathlib4/Mathlib/Topology/Algebra/MulAction.lean +++ b/mathlib4/Mathlib/Topology/Algebra/MulAction.lean @@ -85,11 +85,13 @@ instance : ContinuousSMul (ULift M) X := @[to_additive] instance OrderDual.instContinuousSMul_right : ContinuousSMul M Xᵒᵈ where - continuous_smul := continuous_smul (M := M) (X := X) + continuous_smul := continuous_toDual.comp + ((continuous_smul (M := M) (X := X)).comp (continuous_id.prodMap continuous_ofDual)) @[to_additive] instance OrderDual.instContinuousSMul_left : ContinuousSMul Mᵒᵈ X where - continuous_smul := continuous_smul (M := M) (X := X) + continuous_smul := (continuous_smul (M := M) (X := X)).comp + (continuous_ofDual.prodMap continuous_id) @[to_additive] instance (priority := 100) ContinuousSMul.continuousConstSMul : ContinuousConstSMul M X where diff --git a/mathlib4/Mathlib/Topology/Algebra/Order/UpperLower.lean b/mathlib4/Mathlib/Topology/Algebra/Order/UpperLower.lean index b3cd26574..cc069c6ea 100644 --- a/mathlib4/Mathlib/Topology/Algebra/Order/UpperLower.lean +++ b/mathlib4/Mathlib/Topology/Algebra/Order/UpperLower.lean @@ -73,11 +73,10 @@ protected theorem IsOpen.upperClosure : IsOpen s → IsOpen (upperClosure s : Se protected theorem IsOpen.lowerClosure : IsOpen s → IsOpen (lowerClosure s : Set α) := HasUpperLowerClosure.isOpen_lowerClosure _ -instance : HasUpperLowerClosure αᵒᵈ where - isUpperSet_closure := @IsLowerSet.closure α _ _ _ - isLowerSet_closure := @IsUpperSet.closure α _ _ _ - isOpen_upperClosure := @IsOpen.lowerClosure α _ _ _ - isOpen_lowerClosure := @IsOpen.upperClosure α _ _ _ +instance : HasUpperLowerClosure αᵒᵈ := by + unsealing_newtype OrderDual => + exact ⟨@IsLowerSet.closure α _ _ _, @IsUpperSet.closure α _ _ _, + @IsOpen.lowerClosure α _ _ _, @IsOpen.upperClosure α _ _ _⟩ /- Note: `s.OrdConnected` does not imply `(closure s).OrdConnected`, as we can see by taking @@ -97,8 +96,9 @@ protected theorem IsUpperSet.interior (h : IsUpperSet s) : IsUpperSet (interior rw [← isLowerSet_compl, ← closure_compl] exact h.compl.closure -protected theorem IsLowerSet.interior (h : IsLowerSet s) : IsLowerSet (interior s) := - h.toDual.interior +protected theorem IsLowerSet.interior (h : IsLowerSet s) : IsLowerSet (interior s) := by + unsealing_newtype OrderDual => + exact h.toDual.interior protected theorem Set.OrdConnected.interior (h : s.OrdConnected) : (interior s).OrdConnected := by rw [← h.upperClosure_inter_lowerClosure, interior_inter] diff --git a/mathlib4/Mathlib/Topology/Algebra/Ring/Real.lean b/mathlib4/Mathlib/Topology/Algebra/Ring/Real.lean index 8881aa518..d1a71a3f2 100644 --- a/mathlib4/Mathlib/Topology/Algebra/Ring/Real.lean +++ b/mathlib4/Mathlib/Topology/Algebra/Ring/Real.lean @@ -62,7 +62,7 @@ instance : IsTopologicalDivisionRing ℝ := inferInstance namespace EReal -instance : ContinuousNeg EReal := ⟨negOrderIso.continuous⟩ +instance : ContinuousNeg EReal := ⟨continuous_ofDual.comp negOrderIso.continuous⟩ end EReal @@ -124,6 +124,6 @@ instance : ContinuousAdd ℝ≥0∞ := by simp only [ContinuousAt, some_eq_coe, nhds_coe_coe, ← coe_add, tendsto_map'_iff, Function.comp_def, tendsto_coe, tendsto_add] -instance : ContinuousInv ℝ≥0∞ := ⟨OrderIso.invENNReal.continuous⟩ +instance : ContinuousInv ℝ≥0∞ := ⟨continuous_ofDual.comp OrderIso.invENNReal.continuous⟩ end ENNReal diff --git a/mathlib4/Mathlib/Topology/Bornology/Basic.lean b/mathlib4/Mathlib/Topology/Bornology/Basic.lean index 4b142e1d6..bc027a218 100644 --- a/mathlib4/Mathlib/Topology/Bornology/Basic.lean +++ b/mathlib4/Mathlib/Topology/Bornology/Basic.lean @@ -316,7 +316,11 @@ end Bornology namespace OrderDual variable [Bornology α] -instance instBornology : Bornology αᵒᵈ := ‹Bornology α› +-- Transport the bornology along `toDual`. +instance instBornology : Bornology αᵒᵈ where + cobounded := (Bornology.cobounded α).map toDual + le_cofinite := + (map_mono (Bornology.le_cofinite α)).trans toDual.injective.tendsto_cofinite @[simp] lemma isCobounded_preimage_ofDual {s : Set α} : IsCobounded (ofDual ⁻¹' s) ↔ IsCobounded s := Iff.rfl diff --git a/mathlib4/Mathlib/Topology/Bornology/Constructions.lean b/mathlib4/Mathlib/Topology/Bornology/Constructions.lean index 8097fab3d..fe3315460 100644 --- a/mathlib4/Mathlib/Topology/Bornology/Constructions.lean +++ b/mathlib4/Mathlib/Topology/Bornology/Constructions.lean @@ -186,12 +186,12 @@ instance [BoundedSpace α] : BoundedSpace (Multiplicative α) := /-! ### Order dual -The bornology on this type synonym is inherited without change. +The bornology on `αᵒᵈ` is transported from `α` along `toDual`. +The instance is defined in `Mathlib/Topology/Bornology/Basic.lean`. -/ -instance : Bornology αᵒᵈ := - ‹Bornology α› - -instance [BoundedSpace α] : BoundedSpace αᵒᵈ := - ‹BoundedSpace α› +instance [BoundedSpace α] : BoundedSpace αᵒᵈ where + bounded_univ := by + rw [← Set.preimage_univ (f := OrderDual.ofDual)] + exact OrderDual.isBounded_preimage_ofDual.2 BoundedSpace.bounded_univ diff --git a/mathlib4/Mathlib/Topology/Constructions.lean b/mathlib4/Mathlib/Topology/Constructions.lean index 91a7136cc..213c004eb 100644 --- a/mathlib4/Mathlib/Topology/Constructions.lean +++ b/mathlib4/Mathlib/Topology/Constructions.lean @@ -139,7 +139,8 @@ end /-! ### Order dual -The topology on this type synonym is inherited without change. +The topology on `Xᵒᵈ` is coinduced by `toDual`. +A set is open exactly when its preimage under `toDual` is open in `X`. -/ @@ -149,29 +150,64 @@ variable [TopologicalSpace X] open OrderDual -instance OrderDual.instTopologicalSpace : TopologicalSpace Xᵒᵈ := ‹_› -instance OrderDual.instDiscreteTopology [DiscreteTopology X] : DiscreteTopology Xᵒᵈ := ‹_› +instance OrderDual.instTopologicalSpace : TopologicalSpace Xᵒᵈ := .coinduced toDual ‹_› -theorem continuous_toDual : Continuous (toDual : X → Xᵒᵈ) := continuous_id +@[simp] theorem OrderDual.isOpen_preimage_toDual {s : Set Xᵒᵈ} : + IsOpen (toDual ⁻¹' s) ↔ IsOpen s := Iff.rfl -theorem continuous_ofDual : Continuous (ofDual : Xᵒᵈ → X) := continuous_id +@[simp] theorem OrderDual.isClosed_preimage_toDual {s : Set Xᵒᵈ} : + IsClosed (toDual ⁻¹' s) ↔ IsClosed s := + ⟨fun h ↦ ⟨h.isOpen_compl⟩, fun h ↦ ⟨h.isOpen_compl⟩⟩ -theorem isOpenMap_toDual : IsOpenMap (toDual : X → Xᵒᵈ) := IsOpenMap.id +instance OrderDual.instDiscreteTopology [DiscreteTopology X] : DiscreteTopology Xᵒᵈ := + discreteTopology_iff_forall_isOpen.2 fun s ↦ isOpen_discrete (⇑toDual ⁻¹' s) -theorem isOpenMap_ofDual : IsOpenMap (ofDual : Xᵒᵈ → X) := IsOpenMap.id +theorem continuous_toDual : Continuous (toDual : X → Xᵒᵈ) := continuous_coinduced_rng -theorem isClosedMap_toDual : IsClosedMap (toDual : X → Xᵒᵈ) := IsClosedMap.id +theorem continuous_ofDual : Continuous (ofDual : Xᵒᵈ → X) := by + unsealing_newtype OrderDual => + exact continuous_id -theorem isClosedMap_ofDual : IsClosedMap (ofDual : Xᵒᵈ → X) := IsClosedMap.id +theorem isOpenMap_toDual : IsOpenMap (toDual : X → Xᵒᵈ) := by + unsealing_newtype OrderDual => + exact IsOpenMap.id -theorem nhds_toDual (x : X) : 𝓝 (toDual x) = map toDual (𝓝 x) := rfl +theorem isOpenMap_ofDual : IsOpenMap (ofDual : Xᵒᵈ → X) := by + unsealing_newtype OrderDual => + exact IsOpenMap.id -theorem nhds_ofDual (x : X) : 𝓝 (ofDual x) = map ofDual (𝓝 x) := rfl +theorem isClosedMap_toDual : IsClosedMap (toDual : X → Xᵒᵈ) := by + unsealing_newtype OrderDual => + exact IsClosedMap.id + +theorem isClosedMap_ofDual : IsClosedMap (ofDual : Xᵒᵈ → X) := by + unsealing_newtype OrderDual => + exact IsClosedMap.id + +theorem nhds_toDual (x : X) : 𝓝 (toDual x) = map toDual (𝓝 x) := by + unsealing_newtype OrderDual => rfl + +theorem nhds_ofDual (x : Xᵒᵈ) : 𝓝 (ofDual x) = map ofDual (𝓝 x) := by + have h := nhds_toDual (OrderDual.ofDual x) + rw [OrderDual.toDual_ofDual] at h + rw [h, Filter.map_map] + simp only [Function.comp_def, OrderDual.ofDual_toDual, Filter.map_id'] variable [Preorder X] {x : X} -instance OrderDual.instNeBotNhdsWithinIoi [(𝓝[<] x).NeBot] : (𝓝[>] toDual x).NeBot := ‹_› -instance OrderDual.instNeBotNhdsWithinIio [(𝓝[>] x).NeBot] : (𝓝[<] toDual x).NeBot := ‹_› +instance OrderDual.instNeBotNhdsWithinIoi [h : (𝓝[<] x).NeBot] : (𝓝[>] toDual x).NeBot := by + have : 𝓝[>] toDual x = map toDual (𝓝[<] x) := by + rw [nhdsWithin, nhdsWithin, nhds_toDual, Filter.map_inf toDual.injective, + Filter.map_principal, Equiv.image_eq_preimage_symm, OrderDual.toDual_symm_eq, Set.Ioi_toDual] + rw [this] + exact h.map _ + +instance OrderDual.instNeBotNhdsWithinIio [h : (𝓝[>] x).NeBot] : (𝓝[<] toDual x).NeBot := by + have : 𝓝[<] toDual x = map toDual (𝓝[>] x) := by + rw [nhdsWithin, nhdsWithin, nhds_toDual, Filter.map_inf toDual.injective, + Filter.map_principal, Equiv.image_eq_preimage_symm, OrderDual.toDual_symm_eq, Set.Iio_toDual] + rw [this] + exact h.map _ end diff --git a/mathlib4/Mathlib/Topology/EMetricSpace/BoundedVariation.lean b/mathlib4/Mathlib/Topology/EMetricSpace/BoundedVariation.lean index 148048a49..b71b94bdc 100644 --- a/mathlib4/Mathlib/Topology/EMetricSpace/BoundedVariation.lean +++ b/mathlib4/Mathlib/Topology/EMetricSpace/BoundedVariation.lean @@ -71,6 +71,29 @@ endpoints in `s`, then the function has finite variation on `s ∩ [a, b]`. -/ def LocallyBoundedVariationOn (f : α → E) (s : Set α) := ∀ a b, a ∈ s → b ∈ s → BoundedVariationOn f (s ∩ Icc a b) +section DualBridge + +private theorem nhdsWithin_toDual {X : Type*} [TopologicalSpace X] (t : Set X) (a : X) : + 𝓝[⇑ofDual ⁻¹' t] (toDual a) = Filter.map toDual (𝓝[t] a) := by + rw [nhdsWithin, nhdsWithin, nhds_toDual, Filter.map_inf toDual.injective, Filter.map_principal, + Equiv.image_eq_preimage_symm, OrderDual.toDual_symm_eq] + +private theorem neBot_nhdsWithin_toDual {X : Type*} [TopologicalSpace X] {t : Set X} {a : X} + (h : (𝓝[t] a).NeBot) : (𝓝[⇑ofDual ⁻¹' t] (toDual a)).NeBot := by + rw [nhdsWithin_toDual] + exact h.map _ + +/-- Transport a limit statement along the identification of `α` with `αᵒᵈ`. Stated in this +direction so that the function is determined by the hypothesis: the reverse direction is done +by rewriting with `nhdsWithin_toDual` and `Filter.tendsto_map'_iff`, which stays first-order. -/ +private theorem tendsto_comp_ofDual {X Y : Type*} [TopologicalSpace X] {f : X → Y} + {t : Set X} {a : X} {l : Filter Y} (h : Tendsto f (𝓝[t] a) l) : + Tendsto (f ∘ ⇑ofDual) (𝓝[⇑ofDual ⁻¹' t] (toDual a)) l := by + rw [nhdsWithin_toDual, Filter.tendsto_map'_iff] + exact h + +end DualBridge + /-! ### Basic computations of variation -/ namespace eVariationOn @@ -577,8 +600,9 @@ protected lemma _root_.BoundedVariationOn.ofDual simpa [BoundedVariationOn] using hf @[simp] lemma boundedVariation_ofDual {f : α → E} {s : Set α} : - BoundedVariationOn (f ∘ ofDual) (ofDual ⁻¹' s) ↔ BoundedVariationOn f s := - ⟨fun h ↦ h.ofDual, fun h ↦ h.ofDual⟩ + BoundedVariationOn (f ∘ ofDual) (ofDual ⁻¹' s) ↔ BoundedVariationOn f s := by + unsealing_newtype OrderDual => + exact ⟨fun h ↦ h.ofDual, fun h ↦ h.ofDual⟩ protected lemma _root_.LocallyBoundedVariationOn.ofDual {f : α → E} {s : Set α} (hf : LocallyBoundedVariationOn f s) : @@ -588,8 +612,9 @@ protected lemma _root_.LocallyBoundedVariationOn.ofDual {f : α → E} {s : Set apply BoundedVariationOn.ofDual (hf (ofDual y) (ofDual x) hy hx) @[simp] lemma locallyBoundedVariation_ofDual {f : α → E} {s : Set α} : - LocallyBoundedVariationOn (f ∘ ofDual) (ofDual ⁻¹' s) ↔ LocallyBoundedVariationOn f s := - ⟨fun h ↦ h.ofDual, fun h ↦ h.ofDual⟩ + LocallyBoundedVariationOn (f ∘ ofDual) (ofDual ⁻¹' s) ↔ LocallyBoundedVariationOn f s := by + unsealing_newtype OrderDual => + exact ⟨fun h ↦ h.ofDual, fun h ↦ h.ofDual⟩ end Monotone @@ -670,7 +695,8 @@ theorem eVariationOn_on_inter_Ici_eq_Ioi_add_edist (h'f : Tendsto f (𝓝[s ∩ Ioi a] a) (𝓝 l)) : eVariationOn f (s ∩ Ici a) = eVariationOn f (s ∩ Ioi a) + edist (f a) l := by rw [← comp_ofDual f, ← comp_ofDual f] - exact eVariationOn_on_inter_Iic_eq_Iio_add_edist h ha h'f + exact eVariationOn_on_inter_Iic_eq_Iio_add_edist (neBot_nhdsWithin_toDual h) ha + (tendsto_comp_ofDual (t := s ∩ Ioi a) h'f) /-- If a function is continuous on the left at a point `a`, then its variations on `Iio a` and on `Iic a` coincide. We give a version relative to a set `s`. -/ @@ -691,7 +717,8 @@ lemma eVariationOn_inter_Ioi_eq_inter_Ici_of_continuousWithinAt (h : (𝓝[s ∩ Ioi a] a).NeBot) (h' : ContinuousWithinAt f (s ∩ Ici a) a) : eVariationOn f (s ∩ Ioi a) = eVariationOn f (s ∩ Ici a) := by rw [← comp_ofDual f, ← comp_ofDual f] - exact eVariationOn_inter_Iio_eq_inter_Iic_of_continuousWithinAt h h' + exact eVariationOn_inter_Iio_eq_inter_Iic_of_continuousWithinAt (neBot_nhdsWithin_toDual h) + (tendsto_comp_ofDual (t := s ∩ Ici a) h') lemma eVariationOn_Ioc_eq_Icc_of_continuousWithinAt' [TopologicalSpace α] [OrderTopology α] {f : α → M} {a b : α} @@ -719,14 +746,14 @@ lemma eVariationOn_Ico_eq_Icc_of_continuousWithinAt' [h : (𝓝[<] a).NeBot] (h' : ContinuousWithinAt f (Iic a) a) : eVariationOn f (Ico b a) = eVariationOn f (Icc b a) := by rw [← comp_ofDual f, ← comp_ofDual f, ← Ioc_toDual, ← Icc_toDual] - exact eVariationOn_Ioc_eq_Icc_of_continuousWithinAt' h' + exact eVariationOn_Ioc_eq_Icc_of_continuousWithinAt' (tendsto_comp_ofDual (t := Iic a) h') lemma eVariationOn_Ico_eq_Icc_of_continuousWithinAt [TopologicalSpace α] [OrderTopology α] [DenselyOrdered α] {f : α → M} {a b : α} (h' : ContinuousWithinAt f (Iic a) a) : eVariationOn f (Ico b a) = eVariationOn f (Icc b a) := by rw [← comp_ofDual f, ← comp_ofDual f, ← Ioc_toDual, ← Icc_toDual] - exact eVariationOn_Ioc_eq_Icc_of_continuousWithinAt h' + exact eVariationOn_Ioc_eq_Icc_of_continuousWithinAt (tendsto_comp_ofDual (t := Iic a) h') lemma exists_lt_eVariationOn_inter_Icc {f : α → E} {ε : ℝ≥0∞} {s : Set α} (h : ε < eVariationOn f s) : ∃ a ∈ s, ∃ b ∈ s, a < b ∧ ε < eVariationOn f (s ∩ Icc a b) := by @@ -848,12 +875,13 @@ intervals to the right of any point tends to `0`. -/ theorem _root_.BoundedVariationOn.tendsto_eVariationOn_Ioc_zero [TopologicalSpace α] [OrderTopology α] {f : α → E} {s : Set α} (hf : BoundedVariationOn f s) (x : α) : Tendsto (fun y ↦ eVariationOn f (s ∩ Ioc x y)) (𝓝[s] x) (𝓝 0) := by - have : (fun y ↦ eVariationOn f (s ∩ Ioc x y)) = - (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Ico (toDual y) (toDual x))) := by - ext y - rw [Ico_toDual, ← preimage_inter, comp_ofDual] - rw [this] - exact hf.ofDual.tendsto_eVariationOn_Ico_zero (toDual x) + unsealing_newtype OrderDual => + have : (fun y ↦ eVariationOn f (s ∩ Ioc x y)) = + (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Ico (toDual y) (toDual x))) := by + ext y + rw [Ico_toDual, ← preimage_inter, comp_ofDual] + rw [this] + exact hf.ofDual.tendsto_eVariationOn_Ico_zero (toDual x) /-- A bounded variation function has a limit on its left within a set. -/ theorem _root_.BoundedVariationOn.exists_tendsto_left [CompleteSpace M] [TopologicalSpace α] @@ -868,8 +896,9 @@ theorem _root_.BoundedVariationOn.exists_tendsto_left [CompleteSpace M] [Topolog /-- A bounded variation function has a limit on its right within a set. -/ theorem _root_.BoundedVariationOn.exists_tendsto_right [CompleteSpace M] [TopologicalSpace α] [OrderTopology α] {f : α → M} {s : Set α} (hf : BoundedVariationOn f s) (x : α) : - ∃ l, Tendsto f (𝓝[s ∩ Ioi x] x) (𝓝 l) := - hf.ofDual.exists_tendsto_left (toDual x) + ∃ l, Tendsto f (𝓝[s ∩ Ioi x] x) (𝓝 l) := by + unsealing_newtype OrderDual => + exact hf.ofDual.exists_tendsto_left (toDual x) /-- A bounded variation function tends to its left-limit on its left. -/ theorem _root_.BoundedVariationOn.tendsto_leftLim [CompleteSpace M] [TopologicalSpace α] @@ -882,8 +911,9 @@ theorem _root_.BoundedVariationOn.tendsto_leftLim [CompleteSpace M] [Topological /-- A bounded variation function tends to its right-limit on its right. -/ theorem _root_.BoundedVariationOn.tendsto_rightLim [CompleteSpace M] [TopologicalSpace α] [OrderTopology α] {f : α → M} (hf : BoundedVariationOn f univ) (x : α) : - Tendsto f (𝓝[>] x) (𝓝 (f.rightLim x)) := - hf.ofDual.tendsto_leftLim x + Tendsto f (𝓝[>] x) (𝓝 (f.rightLim x)) := by + unsealing_newtype OrderDual => + exact hf.ofDual.tendsto_leftLim x theorem _root_.BoundedVariationOn.eVariationOn_Iic_eq_Iio_add_edist [CompleteSpace M] [DenselyOrdered α] {f : α → M} {a : α} (hf : BoundedVariationOn f univ) : @@ -940,12 +970,13 @@ theorem _root_.BoundedVariationOn.tendsto_eVariationOn_Icc_right [TopologicalSpace α] [OrderTopology α] {f : α → M} {s : Set α} {l : M} (hf : BoundedVariationOn f s) {x : α} (h'f : Tendsto f (𝓝[s ∩ Ioi x] x) (𝓝 l)) (hx : x ∈ s) : Tendsto (fun y ↦ eVariationOn f (s ∩ Icc x y)) (𝓝[s ∩ Ioi x] x) (𝓝 (edist (f x) l)) := by - have : (fun y ↦ eVariationOn f (s ∩ Icc x y)) = - (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Icc (toDual y) (toDual x))) := by - ext y - rw [Icc_toDual, ← preimage_inter, comp_ofDual] - rw [this] - exact hf.ofDual.tendsto_eVariationOn_Icc_left h'f hx + unsealing_newtype OrderDual => + have : (fun y ↦ eVariationOn f (s ∩ Icc x y)) = + (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Icc (toDual y) (toDual x))) := by + ext y + rw [Icc_toDual, ← preimage_inter, comp_ofDual] + rw [this] + exact hf.ofDual.tendsto_eVariationOn_Icc_left h'f hx /-- If a function has locally bounded variation, then the variation on small closed intervals to the left of this point tends to the contribution of the point, i.e., @@ -976,12 +1007,13 @@ theorem _root_.LocallyBoundedVariationOn.tendsto_eVariationOn_Icc_right (hf : LocallyBoundedVariationOn f s) {x : α} (h'f : Tendsto f (𝓝[s ∩ Ioi x] x) (𝓝 l)) (hx : x ∈ s) : Tendsto (fun y ↦ eVariationOn f (s ∩ Icc x y)) (𝓝[s ∩ Ioi x] x) (𝓝 (edist (f x) l)) := by - have : (fun y ↦ eVariationOn f (s ∩ Icc x y)) = - (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Icc (toDual y) (toDual x))) := by - ext y - rw [Icc_toDual, ← preimage_inter, comp_ofDual] - rw [this] - exact hf.ofDual.tendsto_eVariationOn_Icc_left h'f hx + unsealing_newtype OrderDual => + have : (fun y ↦ eVariationOn f (s ∩ Icc x y)) = + (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Icc (toDual y) (toDual x))) := by + ext y + rw [Icc_toDual, ← preimage_inter, comp_ofDual] + rw [this] + exact hf.ofDual.tendsto_eVariationOn_Icc_left h'f hx /-- If a function has bounded variation and is left-continuous at a point, then the variation on small closed intervals to the left of this point tends to `0`. -/ @@ -1014,12 +1046,13 @@ theorem _root_.BoundedVariationOn.tendsto_eVariationOn_Icc_zero_right [TopologicalSpace α] [OrderTopology α] {f : α → M} {s : Set α} (hf : BoundedVariationOn f s) {x : α} (h : ContinuousWithinAt f (s ∩ Ici x) x) : Tendsto (fun y ↦ eVariationOn f (s ∩ Icc x y)) (𝓝[s] x) (𝓝 0) := by - have : (fun y ↦ eVariationOn f (s ∩ Icc x y)) = - (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Icc (toDual y) (toDual x))) := by - ext y - rw [Icc_toDual, ← preimage_inter, comp_ofDual] - rw [this] - exact hf.ofDual.tendsto_eVariationOn_Icc_zero_left h + unsealing_newtype OrderDual => + have : (fun y ↦ eVariationOn f (s ∩ Icc x y)) = + (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Icc (toDual y) (toDual x))) := by + ext y + rw [Icc_toDual, ← preimage_inter, comp_ofDual] + rw [this] + exact hf.ofDual.tendsto_eVariationOn_Icc_zero_left h /-- If a function `g` is at each point `x` a limit of `f` to the left or to the right (or more generally a cluster point of the values of `f` around `x`) then the variation of `g` is bounded @@ -1105,8 +1138,9 @@ lemma _root_.BoundedVariationOn.continuousWithinAt_leftLim [TopologicalSpace α] lemma _root_.BoundedVariationOn.continuousWithinAt_rightLim [TopologicalSpace α] [OrderTopology α] [CompleteSpace M] [T3Space M] {f : α → M} (hf : BoundedVariationOn f univ) {x : α} : - ContinuousWithinAt f.rightLim (Ici x) x := - BoundedVariationOn.continuousWithinAt_leftLim hf.ofDual + ContinuousWithinAt f.rightLim (Ici x) x := by + unsealing_newtype OrderDual => + exact BoundedVariationOn.continuousWithinAt_leftLim hf.ofDual /-! ### Limits of bounded variation functions as `± ∞` -/ @@ -1123,12 +1157,13 @@ intervals tends to `0` at `-∞`. -/ theorem _root_.BoundedVariationOn.tendsto_eVariationOn_Iic_zero {f : α → E} {s : Set α} (hf : BoundedVariationOn f s) : Tendsto (fun y ↦ eVariationOn f (s ∩ Iic y)) (𝓟 s ⊓ atBot) (𝓝 0) := by - have : (fun y ↦ eVariationOn f (s ∩ Iic y)) = - (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Ici (toDual y))) := by - ext y - rw [Ici_toDual, ← preimage_inter, comp_ofDual] - rw [this] - exact hf.ofDual.tendsto_eVariationOn_Ici_zero + unsealing_newtype OrderDual => + have : (fun y ↦ eVariationOn f (s ∩ Iic y)) = + (fun y ↦ eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s ∩ Ici (toDual y))) := by + ext y + rw [Ici_toDual, ← preimage_inter, comp_ofDual] + rw [this] + exact hf.ofDual.tendsto_eVariationOn_Ici_zero /-- A bounded variation function has a limit at `+∞`. -/ theorem _root_.BoundedVariationOn.exists_tendsto_atTop [CompleteSpace M] [hM : Nonempty M] @@ -1142,8 +1177,9 @@ theorem _root_.BoundedVariationOn.exists_tendsto_atTop [CompleteSpace M] [hM : N /-- A bounded variation function has a limit at `-∞`. -/ theorem _root_.BoundedVariationOn.exists_tendsto_atBot [CompleteSpace M] [hM : Nonempty M] {f : α → M} {s : Set α} (hf : BoundedVariationOn f s) : - ∃ l, Tendsto f (𝓟 s ⊓ atBot) (𝓝 l) := - hf.ofDual.exists_tendsto_atTop + ∃ l, Tendsto f (𝓟 s ⊓ atBot) (𝓝 l) := by + unsealing_newtype OrderDual => + exact hf.ofDual.exists_tendsto_atTop theorem _root_.BoundedVariationOn.tendsto_atTop_limUnder [CompleteSpace M] [hM : Nonempty M] {f : α → M} (hf : BoundedVariationOn f univ) : diff --git a/mathlib4/Mathlib/Topology/EMetricSpace/Defs.lean b/mathlib4/Mathlib/Topology/EMetricSpace/Defs.lean index 9e1adc511..ff85cf665 100644 --- a/mathlib4/Mathlib/Topology/EMetricSpace/Defs.lean +++ b/mathlib4/Mathlib/Topology/EMetricSpace/Defs.lean @@ -948,7 +948,7 @@ section variable [EDist X] -instance : EDist Xᵒᵈ := ‹EDist X› +instance : EDist Xᵒᵈ := ⟨fun a b ↦ edist (ofDual a) (ofDual b)⟩ @[simp] theorem edist_toDual (a b : X) : edist (toDual a) (toDual b) = edist a b := @@ -978,11 +978,17 @@ instance {α : Type*} {p : α → Prop} [TopologicalSpace α] [WeakEMetricSpace end -instance [TopologicalSpace X] [WeakPseudoEMetricSpace X] : WeakPseudoEMetricSpace Xᵒᵈ := - ‹WeakPseudoEMetricSpace X› +instance OrderDual.instWeakPseudoEMetricSpace [TopologicalSpace X] [WeakPseudoEMetricSpace X] : + WeakPseudoEMetricSpace Xᵒᵈ := + WeakPseudoEMetricSpace.IsInducing (f := ofDual) + ⟨by + refine TopologicalSpace.ext_iff.2 fun s ↦ ⟨fun hs ↦ ⟨_, hs, rfl⟩, ?_⟩ + rintro ⟨u, hu, rfl⟩ + exact hu⟩ ‹_› instance [TopologicalSpace X] [WeakEMetricSpace X] : WeakEMetricSpace Xᵒᵈ := - ‹WeakEMetricSpace X› + { OrderDual.instWeakPseudoEMetricSpace with + eq_of_edist_eq_zero := fun h ↦ congrArg toDual (eq_of_edist_eq_zero h) } instance [PseudoEMetricSpace X] : PseudoEMetricSpace Xᵒᵈ := - ‹PseudoEMetricSpace X› + (PseudoEMetricSpace.induced ofDual ‹_›).replaceUniformity (by rfl) instance [EMetricSpace X] : EMetricSpace Xᵒᵈ := - ‹EMetricSpace X› + (EMetricSpace.induced ofDual (fun _ _ h ↦ congrArg toDual h) ‹_›).replaceUniformity (by rfl) diff --git a/mathlib4/Mathlib/Topology/Filter.lean b/mathlib4/Mathlib/Topology/Filter.lean index e77483920..3e637877a 100644 --- a/mathlib4/Mathlib/Topology/Filter.lean +++ b/mathlib4/Mathlib/Topology/Filter.lean @@ -176,12 +176,14 @@ protected theorem tendsto_nhds_atTop_iff [Preorder β] {l : Filter α} {f : α Tendsto f l (𝓝 atTop) ↔ ∀ y, ∀ᶠ a in l, Ici y ∈ f a := by simp only [nhds_atTop, tendsto_iInf, tendsto_principal, mem_Iic, le_principal_iff] -theorem nhds_atBot [Preorder α] : 𝓝 atBot = ⨅ x : α, 𝓟 (Iic (𝓟 (Iic x))) := - @nhds_atTop αᵒᵈ _ +theorem nhds_atBot [Preorder α] : 𝓝 atBot = ⨅ x : α, 𝓟 (Iic (𝓟 (Iic x))) := by + unsealing_newtype OrderDual => + exact @nhds_atTop αᵒᵈ _ protected theorem tendsto_nhds_atBot_iff [Preorder β] {l : Filter α} {f : α → Filter β} : - Tendsto f l (𝓝 atBot) ↔ ∀ y, ∀ᶠ a in l, Iic y ∈ f a := - @Filter.tendsto_nhds_atTop_iff α βᵒᵈ _ _ _ + Tendsto f l (𝓝 atBot) ↔ ∀ y, ∀ᶠ a in l, Iic y ∈ f a := by + unsealing_newtype OrderDual => + exact @Filter.tendsto_nhds_atTop_iff α βᵒᵈ _ _ _ variable [TopologicalSpace X] diff --git a/mathlib4/Mathlib/Topology/Instances/ENNReal/Lemmas.lean b/mathlib4/Mathlib/Topology/Instances/ENNReal/Lemmas.lean index 7ee5707ee..14a5f3ce9 100644 --- a/mathlib4/Mathlib/Topology/Instances/ENNReal/Lemmas.lean +++ b/mathlib4/Mathlib/Topology/Instances/ENNReal/Lemmas.lean @@ -454,12 +454,14 @@ theorem le_of_forall_lt_one_mul_le {x y : ℝ≥0∞} (h : ∀ a < 1, a * x ≤ exact le_of_tendsto this (eventually_nhdsWithin_iff.2 <| Eventually.of_forall h) theorem inv_limsup {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} : - (limsup x l)⁻¹ = liminf (fun i => (x i)⁻¹) l := - OrderIso.invENNReal.limsup_apply + (limsup x l)⁻¹ = liminf (fun i => (x i)⁻¹) l := by + unsealing_newtype OrderDual => + exact OrderIso.invENNReal.limsup_apply theorem inv_liminf {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} : - (liminf x l)⁻¹ = limsup (fun i => (x i)⁻¹) l := - OrderIso.invENNReal.liminf_apply + (liminf x l)⁻¹ = limsup (fun i => (x i)⁻¹) l := by + unsealing_newtype OrderDual => + exact OrderIso.invENNReal.liminf_apply @[fun_prop] protected theorem continuous_zpow : ∀ n : ℤ, Continuous (· ^ n : ℝ≥0∞ → ℝ≥0∞) diff --git a/mathlib4/Mathlib/Topology/Instances/EReal/Lemmas.lean b/mathlib4/Mathlib/Topology/Instances/EReal/Lemmas.lean index c05325f9a..9ea673d7b 100644 --- a/mathlib4/Mathlib/Topology/Instances/EReal/Lemmas.lean +++ b/mathlib4/Mathlib/Topology/Instances/EReal/Lemmas.lean @@ -251,11 +251,13 @@ section LimInfSup variable {α : Type*} {f : Filter α} {u v : α → EReal} -lemma liminf_neg : liminf (-v) f = -limsup v f := - EReal.negOrderIso.limsup_apply.symm +lemma liminf_neg : liminf (-v) f = -limsup v f := by + unsealing_newtype OrderDual => + exact EReal.negOrderIso.limsup_apply.symm -lemma limsup_neg : limsup (-v) f = -liminf v f := - EReal.negOrderIso.liminf_apply.symm +lemma limsup_neg : limsup (-v) f = -liminf v f := by + unsealing_newtype OrderDual => + exact EReal.negOrderIso.liminf_apply.symm lemma le_liminf_add : (liminf u f) + (liminf v f) ≤ liminf (u + v) f := by refine add_le_of_forall_lt fun a a_u b b_v ↦ (le_liminf_iff).2 fun c c_ab ↦ ?_ diff --git a/mathlib4/Mathlib/Topology/MetricSpace/Algebra.lean b/mathlib4/Mathlib/Topology/MetricSpace/Algebra.lean index 7064d1688..97a24b16f 100644 --- a/mathlib4/Mathlib/Topology/MetricSpace/Algebra.lean +++ b/mathlib4/Mathlib/Topology/MetricSpace/Algebra.lean @@ -277,7 +277,8 @@ instance [AddMonoid α] [LipschitzAdd α] : LipschitzMul (Multiplicative α) := @[to_additive] instance [Monoid α] [LipschitzMul α] : LipschitzMul αᵒᵈ := - ‹LipschitzMul α› + ⟨LipschitzMul.C α, fun x y ↦ lipschitzWith_lipschitz_const_mul_edist (β := α) + (OrderDual.ofDual x.1, OrderDual.ofDual x.2) (OrderDual.ofDual y.1, OrderDual.ofDual y.2)⟩ variable {ι : Type*} [Fintype ι] diff --git a/mathlib4/Mathlib/Topology/MetricSpace/Bounded.lean b/mathlib4/Mathlib/Topology/MetricSpace/Bounded.lean index b47b2b389..215e6ed76 100644 --- a/mathlib4/Mathlib/Topology/MetricSpace/Bounded.lean +++ b/mathlib4/Mathlib/Topology/MetricSpace/Bounded.lean @@ -662,7 +662,8 @@ This is a convenient combination of `Continuous.exists_forall_ge'` and theorem exists_forall_ge_of_isBounded {f : β → α} (hf : Continuous f) (x₀ : β) (h : Bornology.IsBounded {x : β | f x₀ ≤ f x}) : ∃ x, ∀ y, f y ≤ f x := - hf.exists_forall_le_of_isBounded (α := αᵒᵈ) x₀ h + Continuous.exists_forall_le_of_isBounded (α := αᵒᵈ) + (continuous_toDual.comp hf) x₀ h end Continuous diff --git a/mathlib4/Mathlib/Topology/MetricSpace/Defs.lean b/mathlib4/Mathlib/Topology/MetricSpace/Defs.lean index 10910c95e..dd633f018 100644 --- a/mathlib4/Mathlib/Topology/MetricSpace/Defs.lean +++ b/mathlib4/Mathlib/Topology/MetricSpace/Defs.lean @@ -252,7 +252,7 @@ section variable [Dist X] -instance : Dist Xᵒᵈ := ‹Dist X› +instance : Dist Xᵒᵈ := ⟨fun a b ↦ dist (ofDual a) (ofDual b)⟩ @[simp] theorem dist_toDual (a b : X) : dist (toDual a) (toDual b) = dist a b := rfl @@ -260,4 +260,6 @@ instance : Dist Xᵒᵈ := ‹Dist X› end -instance [MetricSpace X] : MetricSpace Xᵒᵈ := ‹MetricSpace X› +instance [MetricSpace X] : MetricSpace Xᵒᵈ where + toPseudoMetricSpace := inferInstance + eq_of_dist_eq_zero h := congrArg toDual (eq_of_dist_eq_zero h) diff --git a/mathlib4/Mathlib/Topology/MetricSpace/ProperSpace.lean b/mathlib4/Mathlib/Topology/MetricSpace/ProperSpace.lean index 98fc4a762..612c055b8 100644 --- a/mathlib4/Mathlib/Topology/MetricSpace/ProperSpace.lean +++ b/mathlib4/Mathlib/Topology/MetricSpace/ProperSpace.lean @@ -148,4 +148,9 @@ end ProperSpace instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace (Additive X) := ‹ProperSpace X› instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace (Multiplicative X) := ‹ProperSpace X› -instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace Xᵒᵈ := ‹ProperSpace X› +instance [PseudoMetricSpace X] [ProperSpace X] : ProperSpace Xᵒᵈ := + ⟨fun x r ↦ by + have h : Metric.closedBall x r = OrderDual.toDual '' Metric.closedBall (OrderDual.ofDual x) r := + by rw [Equiv.image_eq_preimage_symm, OrderDual.toDual_symm_eq]; rfl + rw [h] + exact (isCompact_closedBall _ _).image continuous_toDual⟩ diff --git a/mathlib4/Mathlib/Topology/MetricSpace/Pseudo/Defs.lean b/mathlib4/Mathlib/Topology/MetricSpace/Pseudo/Defs.lean index 912bc4643..58d685c68 100644 --- a/mathlib4/Mathlib/Topology/MetricSpace/Pseudo/Defs.lean +++ b/mathlib4/Mathlib/Topology/MetricSpace/Pseudo/Defs.lean @@ -1271,7 +1271,18 @@ end open OrderDual -instance : PseudoMetricSpace αᵒᵈ := ‹_› +instance : PseudoMetricSpace αᵒᵈ where + dist x y := dist (ofDual x) (ofDual y) + dist_self _ := dist_self _ + dist_comm _ _ := dist_comm _ _ + dist_triangle _ _ _ := dist_triangle _ _ _ + edist x y := edist (ofDual x) (ofDual y) + edist_dist _ _ := edist_dist _ _ + toUniformSpace := inferInstance + uniformity_dist := (Metric.uniformity_basis_dist.comap _).eq_biInf + toBornology := inferInstance + cobounded_sets := by + unsealing_newtype OrderDual => exact PseudoMetricSpace.cobounded_sets (α := α) section diff --git a/mathlib4/Mathlib/Topology/MetricSpace/Thickening.lean b/mathlib4/Mathlib/Topology/MetricSpace/Thickening.lean index 81cf52111..f35cad422 100644 --- a/mathlib4/Mathlib/Topology/MetricSpace/Thickening.lean +++ b/mathlib4/Mathlib/Topology/MetricSpace/Thickening.lean @@ -86,8 +86,8 @@ theorem thickening_of_nonpos (hδ : δ ≤ 0) (s : Set α) : thickening δ s = the thickening radius `δ`. -/ @[gcongr] theorem thickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) : - thickening δ₁ E ⊆ thickening δ₂ E := - preimage_mono (Iio_subset_Iio (ENNReal.ofReal_le_ofReal hle)) + thickening δ₁ E ⊆ thickening δ₂ E := fun _ hx ↦ + hx.trans_le (ENNReal.ofReal_le_ofReal hle) /-- The (open) thickening `Metric.thickening δ E` with a fixed thickening radius `δ` is an increasing function of the subset `E`. -/ @@ -232,8 +232,8 @@ theorem cthickening_max_zero (δ : ℝ) (E : Set α) : cthickening (max 0 δ) E /-- The closed thickening `Metric.cthickening δ E` of a fixed subset `E` is an increasing function of the thickening radius `δ`. -/ theorem cthickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) : - cthickening δ₁ E ⊆ cthickening δ₂ E := - preimage_mono (Iic_subset_Iic.mpr (ENNReal.ofReal_le_ofReal hle)) + cthickening δ₁ E ⊆ cthickening δ₂ E := fun _ hx ↦ + hx.trans (ENNReal.ofReal_le_ofReal hle) @[simp] theorem cthickening_singleton {α : Type*} [PseudoMetricSpace α] (x : α) {δ : ℝ} (hδ : 0 ≤ δ) : diff --git a/mathlib4/Mathlib/Topology/Neighborhoods.lean b/mathlib4/Mathlib/Topology/Neighborhoods.lean index 8bfc6cc6c..6f613fdf9 100644 --- a/mathlib4/Mathlib/Topology/Neighborhoods.lean +++ b/mathlib4/Mathlib/Topology/Neighborhoods.lean @@ -197,8 +197,9 @@ theorem tendsto_atTop_of_eventually_const {ι : Type*} [Preorder ι] Tendsto.congr' (EventuallyEq.symm ((eventually_ge_atTop i₀).mono h)) tendsto_const_nhds theorem tendsto_atBot_of_eventually_const {ι : Type*} [Preorder ι] - {u : ι → X} {i₀ : ι} (h : ∀ i ≤ i₀, u i = x) : Tendsto u atBot (𝓝 x) := - tendsto_atTop_of_eventually_const (ι := ιᵒᵈ) h + {u : ι → X} {i₀ : ι} (h : ∀ i ≤ i₀, u i = x) : Tendsto u atBot (𝓝 x) := by + unsealing_newtype OrderDual => + exact tendsto_atTop_of_eventually_const (ι := ιᵒᵈ) h theorem pure_le_nhds : pure ≤ (𝓝 : X → Filter X) := fun _ _ hs => mem_pure.2 <| mem_of_mem_nhds hs diff --git a/mathlib4/Mathlib/Topology/NhdsWithin.lean b/mathlib4/Mathlib/Topology/NhdsWithin.lean index bc09a0ae9..6157c011d 100644 --- a/mathlib4/Mathlib/Topology/NhdsWithin.lean +++ b/mathlib4/Mathlib/Topology/NhdsWithin.lean @@ -368,7 +368,8 @@ instance Pi.instNeBotNhdsWithinIio [Nonempty ι] [∀ i, Preorder (X i)] {x : instance Pi.instNeBotNhdsWithinIoi [Nonempty ι] [∀ i, Preorder (X i)] {x : ∀ i, X i} [∀ i, (𝓝[>] x i).NeBot] : (𝓝[>] x).NeBot := - Pi.instNeBotNhdsWithinIio (X := fun i ↦ (X i)ᵒᵈ) (x := fun i ↦ OrderDual.toDual (x i)) + have : (𝓝[pi univ fun i ↦ Ioi (x i)] x).NeBot := inferInstance + this.mono <| nhdsWithin_mono _ fun _y hy ↦ lt_of_strongLT fun i ↦ hy i trivial end Pi diff --git a/mathlib4/Mathlib/Topology/Order.lean b/mathlib4/Mathlib/Topology/Order.lean index b8acdd3ae..60f65b70e 100644 --- a/mathlib4/Mathlib/Topology/Order.lean +++ b/mathlib4/Mathlib/Topology/Order.lean @@ -146,7 +146,8 @@ variable {α : Type u} /-- The ordering on topologies on the type `α`. `t ≤ s` if every set open in `s` is also open in `t` (`t` is finer than `s`). -/ instance : PartialOrder (TopologicalSpace α) := - { PartialOrder.lift (fun t => OrderDual.toDual IsOpen[t]) (fun _ _ => TopologicalSpace.ext) with + { PartialOrder.lift (fun t => OrderDual.toDual IsOpen[t]) + (fun _ _ h => TopologicalSpace.ext (congrArg OrderDual.ofDual h)) with le := fun s t => ∀ U, IsOpen[t] U → IsOpen[s] U } protected theorem le_def {α} {t s : TopologicalSpace α} : t ≤ s ↔ IsOpen[s] ≤ IsOpen[t] := @@ -184,7 +185,7 @@ def gciGenerateFrom (α : Type*) : (generateFrom ∘ OrderDual.ofDual) where gc := gc_generateFrom α u_l_le _ s hs := TopologicalSpace.GenerateOpen.basic s hs - choice g hg := TopologicalSpace.mkOfClosure g + choice g hg := TopologicalSpace.mkOfClosure (OrderDual.ofDual g) (Subset.antisymm hg <| le_generateFrom_iff_subset_isOpen.1 <| le_rfl) choice_eq _ _ := mkOfClosure_sets @@ -210,11 +211,14 @@ theorem leftInverse_generateFrom : LeftInverse generateFrom fun t : TopologicalSpace α => { s | IsOpen[t] s } := (gciGenerateFrom α).leftInverse_u_l -theorem generateFrom_surjective : Surjective (generateFrom : Set (Set α) → TopologicalSpace α) := - (gciGenerateFrom α).u_surjective +theorem generateFrom_surjective : Surjective (generateFrom : Set (Set α) → TopologicalSpace α) := by + unsealing_newtype OrderDual => + exact (gciGenerateFrom α).u_surjective -theorem setOfPred_isOpen_injective : Injective fun t : TopologicalSpace α => { s | IsOpen[t] s } := - (gciGenerateFrom α).l_injective +theorem setOfPred_isOpen_injective : Injective fun t : + TopologicalSpace α => { s | IsOpen[t] s } := by + unsealing_newtype OrderDual => + exact (gciGenerateFrom α).l_injective @[deprecated (since := "2026-07-09")] alias setOf_isOpen_injective := setOfPred_isOpen_injective @@ -991,22 +995,26 @@ theorem setOfPred_isOpen_sup (t₁ t₂ : TopologicalSpace α) : @[deprecated (since := "2026-07-09")] alias setOf_isOpen_sup := setOfPred_isOpen_sup theorem generateFrom_iUnion {f : ι → Set (Set α)} : - generateFrom (⋃ i, f i) = ⨅ i, generateFrom (f i) := - (gc_generateFrom α).u_iInf + generateFrom (⋃ i, f i) = ⨅ i, generateFrom (f i) := by + unsealing_newtype OrderDual => + exact (gc_generateFrom α).u_iInf theorem setOfPred_isOpen_iSup {t : ι → TopologicalSpace α} : - { s | IsOpen[⨆ i, t i] s } = ⋂ i, { s | IsOpen[t i] s } := - (gc_generateFrom α).l_iSup + { s | IsOpen[⨆ i, t i] s } = ⋂ i, { s | IsOpen[t i] s } := by + unsealing_newtype OrderDual => + exact (gc_generateFrom α).l_iSup @[deprecated (since := "2026-07-09")] alias setOf_isOpen_iSup := setOfPred_isOpen_iSup theorem generateFrom_sUnion {S : Set (Set (Set α))} : - generateFrom (⋃₀ S) = ⨅ s ∈ S, generateFrom s := - (gc_generateFrom α).u_sInf + generateFrom (⋃₀ S) = ⨅ s ∈ S, generateFrom s := by + unsealing_newtype OrderDual => + exact (gc_generateFrom α).u_sInf theorem setOfPred_isOpen_sSup {T : Set (TopologicalSpace α)} : - { s | IsOpen[sSup T] s } = ⋂ t ∈ T, { s | IsOpen[t] s } := - (gc_generateFrom α).l_sSup + { s | IsOpen[sSup T] s } = ⋂ t ∈ T, { s | IsOpen[t] s } := by + unsealing_newtype OrderDual => + exact (gc_generateFrom α).l_sSup @[deprecated (since := "2026-07-09")] alias setOf_isOpen_sSup := setOfPred_isOpen_sSup @@ -1015,21 +1023,24 @@ theorem generateFrom_union_isOpen (a b : TopologicalSpace α) : (gciGenerateFrom α).u_inf_l _ _ theorem generateFrom_iUnion_isOpen (f : ι → TopologicalSpace α) : - generateFrom (⋃ i, { s | IsOpen[f i] s }) = ⨅ i, f i := - (gciGenerateFrom α).u_iInf_l _ + generateFrom (⋃ i, { s | IsOpen[f i] s }) = ⨅ i, f i := by + unsealing_newtype OrderDual => + exact (gciGenerateFrom α).u_iInf_l _ theorem generateFrom_inter (a b : TopologicalSpace α) : generateFrom ({ s | IsOpen[a] s } ∩ { s | IsOpen[b] s }) = a ⊔ b := (gciGenerateFrom α).u_sup_l _ _ theorem generateFrom_iInter (f : ι → TopologicalSpace α) : - generateFrom (⋂ i, { s | IsOpen[f i] s }) = ⨆ i, f i := - (gciGenerateFrom α).u_iSup_l _ + generateFrom (⋂ i, { s | IsOpen[f i] s }) = ⨆ i, f i := by + unsealing_newtype OrderDual => + exact (gciGenerateFrom α).u_iSup_l _ theorem generateFrom_iInter_of_generateFrom_eq_self (f : ι → Set (Set α)) (hf : ∀ i, { s | IsOpen[generateFrom (f i)] s } = f i) : - generateFrom (⋂ i, f i) = ⨆ i, generateFrom (f i) := - (gciGenerateFrom α).u_iSup_of_l_u_eq_self f hf + generateFrom (⋂ i, f i) = ⨆ i, generateFrom (f i) := by + unsealing_newtype OrderDual => + exact (gciGenerateFrom α).u_iSup_of_l_u_eq_self f hf variable {t : ι → TopologicalSpace α} diff --git a/mathlib4/Mathlib/Topology/Order/AtTopBotIxx.lean b/mathlib4/Mathlib/Topology/Order/AtTopBotIxx.lean index 328dd8234..c6874314d 100644 --- a/mathlib4/Mathlib/Topology/Order/AtTopBotIxx.lean +++ b/mathlib4/Mathlib/Topology/Order/AtTopBotIxx.lean @@ -73,9 +73,10 @@ theorem comap_coe_nhdsLT_eq_atTop_iff : theorem comap_coe_nhdsGT_eq_atBot_iff : comap ((↑) : s → X) (𝓝[>] b) = atBot ↔ s ⊆ Ioi b ∧ (s.Nonempty → ∀ a > b, (s ∩ Ioo b a).Nonempty) := by - refine comap_coe_nhdsLT_eq_atTop_iff (s := OrderDual.ofDual ⁻¹' s) (b := OrderDual.toDual b) - |>.trans ?_ - simp [← preimage_inter, ofDual.surjective] + unsealing_newtype OrderDual => + refine comap_coe_nhdsLT_eq_atTop_iff (s := OrderDual.ofDual ⁻¹' s) (b := OrderDual.toDual b) + |>.trans ?_ + simp [← preimage_inter, ofDual.surjective] theorem comap_coe_nhdsLT_of_Ioo_subset (hsb : s ⊆ Iio b) (hs : s.Nonempty → ∃ a < b, Ioo a b ⊆ s) (hb : IsSuccPrelimit b := by exact .of_dense _) : @@ -90,8 +91,9 @@ theorem comap_coe_nhdsLT_of_Ioo_subset (hsb : s ⊆ Iio b) (hs : s.Nonempty → theorem comap_coe_nhdsGT_of_Ioo_subset (hsa : s ⊆ Ioi a) (hs : s.Nonempty → ∃ b > a, Ioo a b ⊆ s) (ha : IsPredPrelimit a := by exact .of_dense _) : comap ((↑) : s → X) (𝓝[>] a) = atBot := by - refine comap_coe_nhdsLT_of_Ioo_subset (show ofDual ⁻¹' s ⊆ Iio (toDual a) from hsa) ?_ ha.dual - simpa only [OrderDual.exists, Ioo_toDual] + unsealing_newtype OrderDual => + refine comap_coe_nhdsLT_of_Ioo_subset (show ofDual ⁻¹' s ⊆ Iio (toDual a) from hsa) ?_ ha.dual + simpa only [OrderDual.exists, Ioo_toDual] theorem map_coe_atTop_of_Ioo_subset (hsb : s ⊆ Iio b) (hs : ∀ a' < b, ∃ a < b, Ioo a b ⊆ s) (hb : IsSuccPrelimit b := by exact .of_dense _) : @@ -106,9 +108,10 @@ theorem map_coe_atTop_of_Ioo_subset (hsb : s ⊆ Iio b) (hs : ∀ a' < b, ∃ a theorem map_coe_atBot_of_Ioo_subset (hsa : s ⊆ Ioi a) (hs : ∀ b' > a, ∃ b > a, Ioo a b ⊆ s) (ha : IsPredPrelimit a := by exact .of_dense _) : map ((↑) : s → X) atBot = 𝓝[>] a := by - refine map_coe_atTop_of_Ioo_subset (s := ofDual ⁻¹' s) (b := toDual a) hsa ?_ ha.dual - intro b' hb' - simpa [OrderDual.exists] using hs (ofDual b') hb' + unsealing_newtype OrderDual => + refine map_coe_atTop_of_Ioo_subset (s := ofDual ⁻¹' s) (b := toDual a) hsa ?_ ha.dual + intro b' hb' + simpa [OrderDual.exists] using hs (ofDual b') hb' /-- The `atTop` filter for an open interval `Ioo a b` comes from the left-neighbourhoods filter at the right endpoint in the ambient order. -/ @@ -133,8 +136,9 @@ theorem comap_coe_Ioi_nhdsGT (a : X) (ha : IsPredPrelimit a := by exact .of_dens @[simp] theorem comap_coe_Iio_nhdsLT (a : X) (ha : IsSuccPrelimit a := by exact .of_dense _) : - comap ((↑) : Iio a → X) (𝓝[<] a) = atTop := - comap_coe_Ioi_nhdsGT (toDual a) ha.dual + comap ((↑) : Iio a → X) (𝓝[<] a) = atTop := by + unsealing_newtype OrderDual => + exact comap_coe_Ioi_nhdsGT (toDual a) ha.dual @[simp] theorem map_coe_Ioo_atTop (h : a < b) (hb : IsSuccPrelimit b := by exact .of_dense _) : @@ -153,8 +157,9 @@ theorem map_coe_Ioi_atBot (a : X) (ha : IsPredPrelimit a := by exact .of_dense _ @[simp] theorem map_coe_Iio_atTop (a : X) (ha : IsSuccPrelimit a := by exact .of_dense _) : - map ((↑) : Iio a → X) atTop = 𝓝[<] a := - map_coe_Ioi_atBot (toDual a) ha.dual + map ((↑) : Iio a → X) atTop = 𝓝[<] a := by + unsealing_newtype OrderDual => + exact map_coe_Ioi_atBot (toDual a) ha.dual variable {α : Type*} {l : Filter α} {f : X → α} diff --git a/mathlib4/Mathlib/Topology/Order/Basic.lean b/mathlib4/Mathlib/Topology/Order/Basic.lean index 5c275cd75..6e4019867 100644 --- a/mathlib4/Mathlib/Topology/Order/Basic.lean +++ b/mathlib4/Mathlib/Topology/Order/Basic.lean @@ -91,10 +91,11 @@ instance (priority := 100) [OrderTopology α] [Countable α] : · exact OrderTopology.topology_eq_generate_intervals instance [t : OrderTopology α] : OrderTopology αᵒᵈ := by - constructor - rcases t.topology_eq_generate_intervals with rfl - simp_rw [Preorder.topology, or_comm] - rfl + unsealing_newtype OrderDual => + constructor + rcases t.topology_eq_generate_intervals with rfl + simp_rw [Preorder.topology, or_comm] + rfl @[to_dual none] protected theorem OrderTopology.continuous_iff [OrderTopology α] [TopologicalSpace β] {f : β → α} : @@ -693,8 +694,9 @@ which the image under `f` of `(-∞, x)` is separated above from `f x` is counta here a version relative to a set `t`. -/] theorem countable_image_gt_image_Ioi_within [LinearOrder β] [SecondCountableTopology α] (t : Set β) (f : β → α) : - Set.Countable {x ∈ t | ∃ z, z < f x ∧ ∀ y ∈ t, x < y → f y ≤ z} := - countable_image_lt_image_Ioi_within (α := αᵒᵈ) t f + Set.Countable {x ∈ t | ∃ z, z < f x ∧ ∀ y ∈ t, x < y → f y ≤ z} := by + unsealing_newtype OrderDual => + exact countable_image_lt_image_Ioi_within (α := αᵒᵈ) t f /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(x, ∞)` is separated below from `f x` is countable. -/ @@ -702,8 +704,9 @@ which the image under `f` of `(x, ∞)` is separated below from `f x` is countab /-- For a function taking values in a second countable space, the set of points `x` for which the image under `f` of `(-∞, x)` is separated above from `f x` is countable. -/] theorem countable_image_gt_image_Ioi [LinearOrder β] (f : β → α) - [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := - countable_image_lt_image_Ioi (α := αᵒᵈ) f + [SecondCountableTopology α] : Set.Countable {x | ∃ z, z < f x ∧ ∀ y, x < y → f y ≤ z} := by + unsealing_newtype OrderDual => + exact countable_image_lt_image_Ioi (α := αᵒᵈ) f @[to_dual] instance instIsCountablyGenerated_atTop [SeparableSpace α] : @@ -814,7 +817,9 @@ lemma LeftOrdContinuous.continuousWithinAt_Iic (hf : LeftOrdContinuous f) : the function is between conditionally complete linear orders with order topologies. -/ @[to_dual existing] lemma RightOrdContinuous.continuousWithinAt_Ici (hf : RightOrdContinuous f) : - ContinuousWithinAt f (Ici x) x := hf.dual.continuousWithinAt_Iic + ContinuousWithinAt f (Ici x) x := by + unsealing_newtype OrderDual => + exact hf.dual.continuousWithinAt_Iic /-- A function that is order-theoretically both left- and right-continuous is continuous, assuming the function is between conditionally complete linear orders with order topologies. -/ diff --git a/mathlib4/Mathlib/Topology/Order/Bornology.lean b/mathlib4/Mathlib/Topology/Order/Bornology.lean index 0789f5caa..219724baa 100644 --- a/mathlib4/Mathlib/Topology/Order/Bornology.lean +++ b/mathlib4/Mathlib/Topology/Order/Bornology.lean @@ -105,8 +105,8 @@ lemma Nonempty.of_isOrderBornology : Nonempty α := Bornology.isBounded_empty.bd instance IsOrderBornology.neBot_cobounded_of_noBotOrder [NoBotOrder α] : (cobounded α).NeBot := by simp [Filter.neBot_iff, cobounded_eq_bot_iff, ← isBounded_univ, isBounded_iff_bddBelow_bddAbove] -instance IsOrderBornology.neBot_cobounded_of_noTopOrder [NoTopOrder α] : (cobounded α).NeBot := - neBot_cobounded_of_noBotOrder (α := αᵒᵈ) +instance IsOrderBornology.neBot_cobounded_of_noTopOrder [NoTopOrder α] : (cobounded α).NeBot := by + simp [Filter.neBot_iff, cobounded_eq_bot_iff, ← isBounded_univ, isBounded_iff_bddBelow_bddAbove] lemma IsOrderBornology.atTop_le_cobounded [NoMaxOrder α] : .atTop ≤ Bornology.cobounded α := by intro s hs @@ -119,8 +119,9 @@ lemma IsOrderBornology.atTop_le_cobounded [NoMaxOrder α] : .atTop ≤ Bornology -- TODO (khw): Generate this in the future with `to_dual` -- See https://github.com/leanprover-community/mathlib4/pull/37738 -lemma IsOrderBornology.atBot_le_cobounded [NoMinOrder α] : .atBot ≤ Bornology.cobounded α := - atTop_le_cobounded (α := αᵒᵈ) +lemma IsOrderBornology.atBot_le_cobounded [NoMinOrder α] : .atBot ≤ Bornology.cobounded α := by + unsealing_newtype OrderDual => + exact atTop_le_cobounded (α := αᵒᵈ) end Preorder @@ -157,7 +158,9 @@ lemma IsOrderBornology.cobounded_eq_atTop [NoMaxOrder α] [OrderBot α] : -- See https://github.com/leanprover-community/mathlib4/pull/37738 @[to_dual existing] lemma IsOrderBornology.cobounded_eq_atBot [NoMinOrder α] [OrderTop α] : - Bornology.cobounded α = .atBot := cobounded_eq_atTop (α := αᵒᵈ) + Bornology.cobounded α = .atBot := by + unsealing_newtype OrderDual => + exact cobounded_eq_atTop (α := αᵒᵈ) end LinearOrder diff --git a/mathlib4/Mathlib/Topology/Order/Compact.lean b/mathlib4/Mathlib/Topology/Order/Compact.lean index 8e1982cb6..894ad224e 100644 --- a/mathlib4/Mathlib/Topology/Order/Compact.lean +++ b/mathlib4/Mathlib/Topology/Order/Compact.lean @@ -33,6 +33,20 @@ open Filter OrderDual TopologicalSpace Function Set open scoped Filter Topology +section DualBridge + +/-- The image of `s` under `toDual`, spelled as a preimage so that it stays a `Set αᵒᵈ`. -/ +private lemma Set.Nonempty.preimage_ofDual {α : Type*} {s : Set α} (hs : s.Nonempty) : + (⇑ofDual ⁻¹' s).Nonempty := + ⟨toDual hs.some, hs.some_mem⟩ + +private lemma IsCompact.preimage_ofDual {α : Type*} [TopologicalSpace α] {s : Set α} + (hs : IsCompact s) : IsCompact (⇑ofDual ⁻¹' s) := by + have h := hs.image (continuous_toDual (X := α)) + rwa [Equiv.image_eq_preimage_symm, OrderDual.toDual_symm_eq] at h + +end DualBridge + /-! ### Compactness of a closed interval @@ -68,10 +82,11 @@ lemma CompactIccSpace.mk'' [TopologicalSpace α] [PartialOrder α] .mk' fun hab => hab.eq_or_lt.elim (by rintro rfl; simp) h instance [TopologicalSpace α] [Preorder α] [CompactIccSpace α] : CompactIccSpace (αᵒᵈ) where - isCompact_Icc := by - intro a b - convert! isCompact_Icc (α := α) (a := b) (b := a) using 1 - exact Icc_toDual (α := α) + isCompact_Icc {a b} := by + have h : Icc a b = ⇑ofDual ⁻¹' Icc (ofDual b) (ofDual a) := + Icc_toDual (a := ofDual a) (b := ofDual b) + rw [h] + exact (isCompact_Icc (α := α)).preimage_ofDual /-- A closed interval in a conditionally complete linear order is compact. -/ instance (priority := 100) ConditionallyCompleteLinearOrder.toCompactIccSpace (α : Type*) @@ -156,16 +171,18 @@ theorem IsCompact.exists_isLeast [ClosedIicTopology α] {s : Set α} (hs : IsCom exact disjoint_left.mp hx x.2 le_rfl theorem IsCompact.exists_isGreatest [ClosedIciTopology α] {s : Set α} (hs : IsCompact s) - (ne_s : s.Nonempty) : ∃ x, IsGreatest s x := - IsCompact.exists_isLeast (α := αᵒᵈ) hs ne_s + (ne_s : s.Nonempty) : ∃ x, IsGreatest s x := by + unsealing_newtype OrderDual => + exact IsCompact.exists_isLeast (α := αᵒᵈ) hs ne_s theorem IsCompact.exists_isGLB [ClosedIicTopology α] {s : Set α} (hs : IsCompact s) (ne_s : s.Nonempty) : ∃ x ∈ s, IsGLB s x := (hs.exists_isLeast ne_s).imp (fun x (hx : IsLeast s x) => ⟨hx.1, hx.isGLB⟩) theorem IsCompact.exists_isLUB [ClosedIciTopology α] {s : Set α} (hs : IsCompact s) - (ne_s : s.Nonempty) : ∃ x ∈ s, IsLUB s x := - IsCompact.exists_isGLB (α := αᵒᵈ) hs ne_s + (ne_s : s.Nonempty) : ∃ x ∈ s, IsLUB s x := by + unsealing_newtype OrderDual => + exact IsCompact.exists_isGLB (α := αᵒᵈ) hs ne_s theorem cocompact_le_atBot_atTop [CompactIccSpace α] : cocompact α ≤ atBot ⊔ atTop := by @@ -185,8 +202,9 @@ theorem cocompact_le_atBot [OrderTop α] [CompactIccSpace α] : exact (not_and_or.mp hx).casesOn (fun h ↦ ht _ (le_of_not_ge h)) (fun h ↦ (h le_top).elim) theorem cocompact_le_atTop [OrderBot α] [CompactIccSpace α] : - cocompact α ≤ atTop := - cocompact_le_atBot (α := αᵒᵈ) + cocompact α ≤ atTop := by + unsealing_newtype OrderDual => + exact cocompact_le_atBot (α := αᵒᵈ) theorem atBot_le_cocompact [NoMinOrder α] [ClosedIicTopology α] : atBot ≤ cocompact α := by @@ -202,8 +220,9 @@ theorem atBot_le_cocompact [NoMinOrder α] [ClosedIicTopology α] : fun hc ↦ LT.lt.false <| hb'.trans_lt <| hb.trans_le <| ha.2 (not_notMem.mp hc)⟩ theorem atTop_le_cocompact [NoMaxOrder α] [ClosedIciTopology α] : - atTop ≤ cocompact α := - atBot_le_cocompact (α := αᵒᵈ) + atTop ≤ cocompact α := by + unsealing_newtype OrderDual => + exact atBot_le_cocompact (α := αᵒᵈ) theorem atBot_atTop_le_cocompact [NoMinOrder α] [NoMaxOrder α] [OrderClosedTopology α] : atBot ⊔ atTop ≤ cocompact α := @@ -244,8 +263,9 @@ theorem IsCompact.exists_forall_le' [ClosedIicTopology α] [NoMaxOrder α] {f : /-- The **extreme value theorem**: a continuous function realizes its maximum on a compact set. -/ theorem IsCompact.exists_isMaxOn [ClosedIciTopology α] {s : Set β} (hs : IsCompact s) - (ne_s : s.Nonempty) {f : β → α} (hf : ContinuousOn f s) : ∃ x ∈ s, IsMaxOn f s x := - IsCompact.exists_isMinOn (α := αᵒᵈ) hs ne_s hf + (ne_s : s.Nonempty) {f : β → α} (hf : ContinuousOn f s) : ∃ x ∈ s, IsMaxOn f s x := by + unsealing_newtype OrderDual => + exact IsCompact.exists_isMinOn (α := αᵒᵈ) hs ne_s hf /-- The **extreme value theorem**: if a function `f` is continuous on a closed set `s` and it is larger than a value in its image away from compact sets, then it has a minimum on this set. -/ @@ -264,8 +284,9 @@ theorem ContinuousOn.exists_isMinOn' [ClosedIicTopology α] {s : Set β} {f : β smaller than a value in its image away from compact sets, then it has a maximum on this set. -/ theorem ContinuousOn.exists_isMaxOn' [ClosedIciTopology α] {s : Set β} {f : β → α} (hf : ContinuousOn f s) (hsc : IsClosed s) {x₀ : β} (h₀ : x₀ ∈ s) - (hc : ∀ᶠ x in cocompact β ⊓ 𝓟 s, f x ≤ f x₀) : ∃ x ∈ s, IsMaxOn f s x := - ContinuousOn.exists_isMinOn' (α := αᵒᵈ) hf hsc h₀ hc + (hc : ∀ᶠ x in cocompact β ⊓ 𝓟 s, f x ≤ f x₀) : ∃ x ∈ s, IsMaxOn f s x := by + unsealing_newtype OrderDual => + exact ContinuousOn.exists_isMinOn' (α := αᵒᵈ) hf hsc h₀ hc /-- The **extreme value theorem**: if a continuous function `f` is larger than a value in its range away from compact sets, then it has a global minimum. -/ @@ -278,8 +299,9 @@ theorem Continuous.exists_forall_le' [ClosedIicTopology α] {f : β → α} (hf /-- The **extreme value theorem**: if a continuous function `f` is smaller than a value in its range away from compact sets, then it has a global maximum. -/ theorem Continuous.exists_forall_ge' [ClosedIciTopology α] {f : β → α} (hf : Continuous f) - (x₀ : β) (h : ∀ᶠ x in cocompact β, f x ≤ f x₀) : ∃ x : β, ∀ y : β, f y ≤ f x := - Continuous.exists_forall_le' (α := αᵒᵈ) hf x₀ h + (x₀ : β) (h : ∀ᶠ x in cocompact β, f x ≤ f x₀) : ∃ x : β, ∀ y : β, f y ≤ f x := by + unsealing_newtype OrderDual => + exact Continuous.exists_forall_le' (α := αᵒᵈ) hf x₀ h /-- The **extreme value theorem**: if a continuous function `f` tends to infinity away from compact sets, then it has a global minimum. -/ @@ -291,8 +313,9 @@ theorem Continuous.exists_forall_le [ClosedIicTopology α] [Nonempty β] {f : β /-- The **extreme value theorem**: if a continuous function `f` tends to negative infinity away from compact sets, then it has a global maximum. -/ theorem Continuous.exists_forall_ge [ClosedIciTopology α] [Nonempty β] {f : β → α} - (hf : Continuous f) (hlim : Tendsto f (cocompact β) atBot) : ∃ x, ∀ y, f y ≤ f x := - Continuous.exists_forall_le (α := αᵒᵈ) hf hlim + (hf : Continuous f) (hlim : Tendsto f (cocompact β) atBot) : ∃ x, ∀ y, f y ≤ f x := by + unsealing_newtype OrderDual => + exact Continuous.exists_forall_le (α := αᵒᵈ) hf hlim /-- A continuous function with compact support has a global minimum. -/ @[to_additive /-- A continuous function with compact support has a global minimum. -/] @@ -307,8 +330,9 @@ theorem Continuous.exists_forall_le_of_hasCompactMulSupport [ClosedIicTopology @[to_additive /-- A continuous function with compact support has a global maximum. -/] theorem Continuous.exists_forall_ge_of_hasCompactMulSupport [ClosedIciTopology α] [Nonempty β] [One α] {f : β → α} (hf : Continuous f) (h : HasCompactMulSupport f) : - ∃ x : β, ∀ y : β, f y ≤ f x := - Continuous.exists_forall_le_of_hasCompactMulSupport (α := αᵒᵈ) hf h + ∃ x : β, ∀ y : β, f y ≤ f x := by + unsealing_newtype OrderDual => + exact Continuous.exists_forall_le_of_hasCompactMulSupport (α := αᵒᵈ) hf h /-- A compact set is bounded below -/ theorem IsCompact.bddBelow [ClosedIicTopology α] [Nonempty α] {s : Set α} (hs : IsCompact s) : @@ -320,8 +344,9 @@ theorem IsCompact.bddBelow [ClosedIicTopology α] [Nonempty α] {s : Set α} (hs /-- A compact set is bounded above -/ theorem IsCompact.bddAbove [ClosedIciTopology α] [Nonempty α] {s : Set α} (hs : IsCompact s) : - BddAbove s := - IsCompact.bddBelow (α := αᵒᵈ) hs + BddAbove s := by + unsealing_newtype OrderDual => + exact IsCompact.bddBelow (α := αᵒᵈ) hs /-- A continuous function is bounded below on a compact set. -/ theorem IsCompact.bddBelow_image [ClosedIicTopology α] [Nonempty α] {f : β → α} {K : Set β} @@ -331,7 +356,7 @@ theorem IsCompact.bddBelow_image [ClosedIicTopology α] [Nonempty α] {f : β /-- A continuous function is bounded above on a compact set. -/ theorem IsCompact.bddAbove_image [ClosedIciTopology α] [Nonempty α] {f : β → α} {K : Set β} (hK : IsCompact K) (hf : ContinuousOn f K) : BddAbove (f '' K) := - IsCompact.bddBelow_image (α := αᵒᵈ) hK hf + (hK.image_of_continuousOn hf).bddAbove /-- A continuous function with compact support is bounded below. -/ @[to_additive /-- A continuous function with compact support is bounded below. -/] @@ -343,7 +368,7 @@ theorem Continuous.bddBelow_range_of_hasCompactMulSupport [ClosedIicTopology α] @[to_additive /-- A continuous function with compact support is bounded above. -/] theorem Continuous.bddAbove_range_of_hasCompactMulSupport [ClosedIciTopology α] [One α] {f : β → α} (hf : Continuous f) (h : HasCompactMulSupport f) : BddAbove (range f) := - Continuous.bddBelow_range_of_hasCompactMulSupport (α := αᵒᵈ) hf h + (h.isCompact_range hf).bddAbove end LinearOrder @@ -363,8 +388,10 @@ theorem IsCompact.sSup_lt_iff_of_continuous [ClosedIciTopology α] {f : β → theorem IsCompact.lt_sInf_iff_of_continuous [ClosedIicTopology α] {f : β → α} {K : Set β} (hK : IsCompact K) (h0K : K.Nonempty) (hf : ContinuousOn f K) (y : α) : - y < sInf (f '' K) ↔ ∀ x ∈ K, y < f x := - IsCompact.sSup_lt_iff_of_continuous (α := αᵒᵈ) hK h0K hf y + y < sInf (f '' K) ↔ ∀ x ∈ K, y < f x := by + unsealing_newtype OrderDual => + exact IsCompact.sSup_lt_iff_of_continuous (α := αᵒᵈ) + hK h0K (continuous_toDual.comp_continuousOn hf) y end ConditionallyCompleteLinearOrder @@ -383,24 +410,27 @@ theorem IsCompact.sInf_mem [ClosedIicTopology α] {s : Set α} (hs : IsCompact s ha.csInf_mem theorem IsCompact.sSup_mem [ClosedIciTopology α] {s : Set α} (hs : IsCompact s) - (ne_s : s.Nonempty) : sSup s ∈ s := - IsCompact.sInf_mem (α := αᵒᵈ) hs ne_s + (ne_s : s.Nonempty) : sSup s ∈ s := by + unsealing_newtype OrderDual => + exact IsCompact.sInf_mem (α := αᵒᵈ) hs ne_s theorem IsCompact.isGLB_sInf [ClosedIicTopology α] {s : Set α} (hs : IsCompact s) (ne_s : s.Nonempty) : IsGLB s (sInf s) := isGLB_csInf ne_s hs.bddBelow theorem IsCompact.isLUB_sSup [ClosedIciTopology α] {s : Set α} (hs : IsCompact s) - (ne_s : s.Nonempty) : IsLUB s (sSup s) := - IsCompact.isGLB_sInf (α := αᵒᵈ) hs ne_s + (ne_s : s.Nonempty) : IsLUB s (sSup s) := by + unsealing_newtype OrderDual => + exact IsCompact.isGLB_sInf (α := αᵒᵈ) hs ne_s theorem IsCompact.isLeast_sInf [ClosedIicTopology α] {s : Set α} (hs : IsCompact s) (ne_s : s.Nonempty) : IsLeast s (sInf s) := ⟨hs.sInf_mem ne_s, (hs.isGLB_sInf ne_s).1⟩ theorem IsCompact.isGreatest_sSup [ClosedIciTopology α] {s : Set α} (hs : IsCompact s) - (ne_s : s.Nonempty) : IsGreatest s (sSup s) := - IsCompact.isLeast_sInf (α := αᵒᵈ) hs ne_s + (ne_s : s.Nonempty) : IsGreatest s (sSup s) := by + unsealing_newtype OrderDual => + exact IsCompact.isLeast_sInf (α := αᵒᵈ) hs ne_s theorem IsCompact.exists_sInf_image_eq_and_le [ClosedIicTopology α] {s : Set β} (hs : IsCompact s) (ne_s : s.Nonempty) {f : β → α} (hf : ContinuousOn f s) : @@ -411,8 +441,9 @@ theorem IsCompact.exists_sInf_image_eq_and_le [ClosedIicTopology α] {s : Set β theorem IsCompact.exists_sSup_image_eq_and_ge [ClosedIciTopology α] {s : Set β} (hs : IsCompact s) (ne_s : s.Nonempty) {f : β → α} (hf : ContinuousOn f s) : - ∃ x ∈ s, sSup (f '' s) = f x ∧ ∀ y ∈ s, f y ≤ f x := - IsCompact.exists_sInf_image_eq_and_le (α := αᵒᵈ) hs ne_s hf + ∃ x ∈ s, sSup (f '' s) = f x ∧ ∀ y ∈ s, f y ≤ f x := by + unsealing_newtype OrderDual => + exact IsCompact.exists_sInf_image_eq_and_le (α := αᵒᵈ) hs ne_s hf theorem IsCompact.exists_sInf_image_eq [ClosedIicTopology α] {s : Set β} (hs : IsCompact s) (ne_s : s.Nonempty) {f : β → α} (hf : ContinuousOn f s) : ∃ x ∈ s, sInf (f '' s) = f x := @@ -420,8 +451,9 @@ theorem IsCompact.exists_sInf_image_eq [ClosedIicTopology α] {s : Set β} (hs : ⟨x, hxs, hx⟩ theorem IsCompact.exists_sSup_image_eq [ClosedIciTopology α] {s : Set β} (hs : IsCompact s) - (ne_s : s.Nonempty) : ∀ {f : β → α}, ContinuousOn f s → ∃ x ∈ s, sSup (f '' s) = f x := - IsCompact.exists_sInf_image_eq (α := αᵒᵈ) hs ne_s + (ne_s : s.Nonempty) : ∀ {f : β → α}, ContinuousOn f s → ∃ x ∈ s, sSup (f '' s) = f x := by + unsealing_newtype OrderDual => + exact IsCompact.exists_sInf_image_eq (α := αᵒᵈ) hs ne_s end InfSup @@ -502,8 +534,9 @@ theorem IsCompact.continuous_sSup {f : γ → β → α} {K : Set β} (hK : IsCo exact fun y' hy' => huv (mk_mem_prod hx' (hKv hy')) theorem IsCompact.continuous_sInf {f : γ → β → α} {K : Set β} (hK : IsCompact K) - (hf : Continuous ↿f) : Continuous fun x => sInf (f x '' K) := - IsCompact.continuous_sSup (α := αᵒᵈ) hK hf + (hf : Continuous ↿f) : Continuous fun x => sInf (f x '' K) := by + unsealing_newtype OrderDual => + exact IsCompact.continuous_sSup (α := αᵒᵈ) hK hf namespace ContinuousOn diff --git a/mathlib4/Mathlib/Topology/Order/CountableSeparating.lean b/mathlib4/Mathlib/Topology/Order/CountableSeparating.lean index 0f4097292..ce50bb12a 100644 --- a/mathlib4/Mathlib/Topology/Order/CountableSeparating.lean +++ b/mathlib4/Mathlib/Topology/Order/CountableSeparating.lean @@ -48,16 +48,18 @@ instance range_Iio : HasCountableSeparatingOn X (· ∈ range Iio) s := by rcases hsd.inter_open_nonempty _ isOpen_Ioo hne with ⟨z, ⟨hxz, hzy⟩, hzs⟩ simpa [hxz, hzy.not_gt] using h (Iio z) (mem_image_of_mem _ (.inl hzs)) -instance range_Ioi : HasCountableSeparatingOn X (· ∈ range Ioi) s := - .range_Iio (X := Xᵒᵈ) +instance range_Ioi : HasCountableSeparatingOn X (· ∈ range Ioi) s := by + unsealing_newtype OrderDual => + exact .range_Iio (X := Xᵒᵈ) instance range_Iic : HasCountableSeparatingOn X (· ∈ range Iic) s := let ⟨t, htc, ht_sub, ht⟩ := (range_Ioi (X := X) (s := s)).1 ⟨compl '' t, htc.image _, by simpa [← compl_inj_iff (x := Ioi _)] using ht_sub, by simpa [not_iff_not]⟩ -instance range_Ici : HasCountableSeparatingOn X (· ∈ range Ici) s := - range_Iic (X := Xᵒᵈ) +instance range_Ici : HasCountableSeparatingOn X (· ∈ range Ici) s := by + unsealing_newtype OrderDual => + exact range_Iic (X := Xᵒᵈ) end HasCountableSeparatingOn @@ -71,10 +73,12 @@ lemma of_forall_eventually_lt_iff (h : ∀ x, ∀ᶠ a in l, f a < x ↔ g a < x lemma of_forall_eventually_le_iff (h : ∀ x, ∀ᶠ a in l, f a ≤ x ↔ g a ≤ x) : f =ᶠ[l] g := of_forall_separating_preimage (· ∈ range Iic) <| forall_mem_range.2 <| fun x ↦ .set_eq (h x) -lemma of_forall_eventually_gt_iff (h : ∀ x, ∀ᶠ a in l, x < f a ↔ x < g a) : f =ᶠ[l] g := - of_forall_eventually_lt_iff (X := Xᵒᵈ) h +lemma of_forall_eventually_gt_iff (h : ∀ x, ∀ᶠ a in l, x < f a ↔ x < g a) : f =ᶠ[l] g := by + unsealing_newtype OrderDual => + exact of_forall_eventually_lt_iff (X := Xᵒᵈ) h -lemma of_forall_eventually_ge_iff (h : ∀ x, ∀ᶠ a in l, x ≤ f a ↔ x ≤ g a) : f =ᶠ[l] g := - of_forall_eventually_le_iff (X := Xᵒᵈ) h +lemma of_forall_eventually_ge_iff (h : ∀ x, ∀ᶠ a in l, x ≤ f a ↔ x ≤ g a) : f =ᶠ[l] g := by + unsealing_newtype OrderDual => + exact of_forall_eventually_le_iff (X := Xᵒᵈ) h end Filter.EventuallyEq diff --git a/mathlib4/Mathlib/Topology/Order/DenselyOrdered.lean b/mathlib4/Mathlib/Topology/Order/DenselyOrdered.lean index 6158d1cc8..008ca9c97 100644 --- a/mathlib4/Mathlib/Topology/Order/DenselyOrdered.lean +++ b/mathlib4/Mathlib/Topology/Order/DenselyOrdered.lean @@ -41,8 +41,9 @@ theorem closure_Ioi (a : α) [NoMaxOrder α] : closure (Ioi a) = Ici a := /-- The closure of the interval `(-∞, a)` is the closed interval `(-∞, a]`, unless `a` is a bottom element. -/ -theorem closure_Iio' (h : (Iio a).Nonempty) : closure (Iio a) = Iic a := - closure_Ioi' (α := αᵒᵈ) h +theorem closure_Iio' (h : (Iio a).Nonempty) : closure (Iio a) = Iic a := by + unsealing_newtype OrderDual => + exact closure_Ioi' (α := αᵒᵈ) h /-- The closure of the interval `(-∞, a)` is the interval `(-∞, a]`. -/ @[simp] @@ -56,8 +57,9 @@ theorem IsMax.of_disjoint_nhds_Ioi {x : α} {u : Set α} (hu : u ∈ nhds x) (disjoint_iff.mp hd) theorem IsMin.of_disjoint_nhds_Iio {x : α} {u : Set α} (hu : u ∈ nhds x) - (hd : Disjoint u (Set.Iio x)) : IsMin x := - IsMax.of_disjoint_nhds_Ioi (α := αᵒᵈ) hu hd + (hd : Disjoint u (Set.Iio x)) : IsMin x := by + unsealing_newtype OrderDual => + exact IsMax.of_disjoint_nhds_Ioi (α := αᵒᵈ) hu hd theorem nonempty_nhds_inter_Ioi {x : α} {u : Set α} (hu : u ∈ nhds x) (hx : ¬IsMax x) : (u ∩ Set.Ioi x).Nonempty := by @@ -66,8 +68,9 @@ theorem nonempty_nhds_inter_Ioi {x : α} {u : Set α} (hu : u ∈ nhds x) (hx : (Set.not_nonempty_iff_eq_empty.mp h))) theorem nonempty_nhds_inter_Iio {x : α} {u : Set α} (hu : u ∈ nhds x) (hx : ¬IsMin x) : - (u ∩ Set.Iio x).Nonempty := - nonempty_nhds_inter_Ioi (α := αᵒᵈ) hu hx + (u ∩ Set.Iio x).Nonempty := by + unsealing_newtype OrderDual => + exact nonempty_nhds_inter_Ioi (α := αᵒᵈ) hu hx /-- The closure of the open interval `(a, b)` is the closed interval `[a, b]`. -/ @[simp] @@ -114,8 +117,9 @@ theorem interior_Ici [NoMinOrder α] {a : α} : interior (Ici a) = Ioi a := interior_Ici' nonempty_Iio @[simp] -theorem interior_Iic' {a : α} (ha : (Ioi a).Nonempty) : interior (Iic a) = Iio a := - interior_Ici' (α := αᵒᵈ) ha +theorem interior_Iic' {a : α} (ha : (Ioi a).Nonempty) : interior (Iic a) = Iio a := by + unsealing_newtype OrderDual => + exact interior_Ici' (α := αᵒᵈ) ha theorem interior_Iic [NoMaxOrder α] {a : α} : interior (Iic a) = Iio a := interior_Iic' nonempty_Ioi @@ -162,8 +166,9 @@ theorem Ioc_subset_closure_interior (a b : α) : Ioc a b ⊆ closure (interior ( closure_mono (interior_maximal Ioo_subset_Ioc_self isOpen_Ioo) theorem Ico_subset_closure_interior (a b : α) : Ico a b ⊆ closure (interior (Ico a b)) := by - simpa only [Ioc_toDual] using! - Ioc_subset_closure_interior (OrderDual.toDual b) (OrderDual.toDual a) + unsealing_newtype OrderDual => + simpa only [Ioc_toDual] using! + Ioc_subset_closure_interior (OrderDual.toDual b) (OrderDual.toDual a) @[simp] theorem frontier_Ici' {a : α} (ha : (Iio a).Nonempty) : frontier (Ici a) = {a} := by diff --git a/mathlib4/Mathlib/Topology/Order/ExtendFrom.lean b/mathlib4/Mathlib/Topology/Order/ExtendFrom.lean index 14d7107cf..6881c512e 100644 --- a/mathlib4/Mathlib/Topology/Order/ExtendFrom.lean +++ b/mathlib4/Mathlib/Topology/Order/ExtendFrom.lean @@ -69,10 +69,11 @@ theorem continuousOn_Ico_extendFrom_Ioo theorem continuousOn_Ioc_extendFrom_Ioo (hf : ContinuousOn f (Ioo a b)) (hb : Tendsto f (𝓝[<] b) (𝓝 lb)) : ContinuousOn (extendFrom (Ioo a b) f) (Ioc a b) := by - have := continuousOn_Ico_extendFrom_Ioo (f := f ∘ OrderDual.ofDual) (a := OrderDual.toDual b) - (b := OrderDual.toDual a) (la := lb) - rw [Ico_toDual, Ioi_toDual, Ioo_toDual] at this - exact this hf hb + unsealing_newtype OrderDual => + have := continuousOn_Ico_extendFrom_Ioo (f := f ∘ OrderDual.ofDual) (a := OrderDual.toDual b) + (b := OrderDual.toDual a) (la := lb) + rw [Ico_toDual, Ioi_toDual, Ioo_toDual] at this + exact this hf hb end RegularSpace diff --git a/mathlib4/Mathlib/Topology/Order/ExtrClosure.lean b/mathlib4/Mathlib/Topology/Order/ExtrClosure.lean index 6581c86a0..11fcbc750 100644 --- a/mathlib4/Mathlib/Topology/Order/ExtrClosure.lean +++ b/mathlib4/Mathlib/Topology/Order/ExtrClosure.lean @@ -29,8 +29,9 @@ protected theorem IsMaxOn.closure (h : IsMaxOn f s a) (hc : ContinuousOn f (clos ContinuousWithinAt.closure_le hx ((hc x hx).mono subset_closure) continuousWithinAt_const h protected theorem IsMinOn.closure (h : IsMinOn f s a) (hc : ContinuousOn f (closure s)) : - IsMinOn f (closure s) a := - h.dual.closure hc + IsMinOn f (closure s) a := by + unsealing_newtype OrderDual => + exact h.dual.closure hc protected theorem IsExtrOn.closure (h : IsExtrOn f s a) (hc : ContinuousOn f (closure s)) : IsExtrOn f (closure s) a := @@ -48,8 +49,9 @@ protected theorem IsLocalMaxOn.closure (h : IsLocalMaxOn f s a) (hc : Continuous · exact (hc _ hxs).mono (inter_subset_right.trans subset_closure) protected theorem IsLocalMinOn.closure (h : IsLocalMinOn f s a) (hc : ContinuousOn f (closure s)) : - IsLocalMinOn f (closure s) a := - IsLocalMaxOn.closure h.dual hc + IsLocalMinOn f (closure s) a := by + unsealing_newtype OrderDual => + exact IsLocalMaxOn.closure h.dual hc protected theorem IsLocalExtrOn.closure (h : IsLocalExtrOn f s a) (hc : ContinuousOn f (closure s)) : IsLocalExtrOn f (closure s) a := diff --git a/mathlib4/Mathlib/Topology/Order/Filter.lean b/mathlib4/Mathlib/Topology/Order/Filter.lean index b8f085ef7..5068fc207 100644 --- a/mathlib4/Mathlib/Topology/Order/Filter.lean +++ b/mathlib4/Mathlib/Topology/Order/Filter.lean @@ -27,8 +27,9 @@ variable {α X : Type*} [TopologicalSpace X] [PartialOrder X] [OrderTopology X] protected theorem tendsto_nhds_atTop [NoMaxOrder X] : Tendsto 𝓝 (atTop : Filter X) (𝓝 atTop) := Filter.tendsto_nhds_atTop_iff.2 fun x => (eventually_gt_atTop x).mono fun _ => le_mem_nhds -protected theorem tendsto_nhds_atBot [NoMinOrder X] : Tendsto 𝓝 (atBot : Filter X) (𝓝 atBot) := - @Filter.tendsto_nhds_atTop Xᵒᵈ _ _ _ _ +protected theorem tendsto_nhds_atBot [NoMinOrder X] : Tendsto 𝓝 (atBot : Filter X) (𝓝 atBot) := by + unsealing_newtype OrderDual => + exact @Filter.tendsto_nhds_atTop Xᵒᵈ _ _ _ _ theorem Tendsto.nhds_atTop [NoMaxOrder X] {f : α → X} {l : Filter α} (h : Tendsto f l atTop) : Tendsto (𝓝 ∘ f) l (𝓝 atTop) := @@ -36,6 +37,6 @@ theorem Tendsto.nhds_atTop [NoMaxOrder X] {f : α → X} {l : Filter α} (h : Te theorem Tendsto.nhds_atBot [NoMinOrder X] {f : α → X} {l : Filter α} (h : Tendsto f l atBot) : Tendsto (𝓝 ∘ f) l (𝓝 atBot) := - @Tendsto.nhds_atTop α Xᵒᵈ _ _ _ _ _ _ h + Filter.tendsto_nhds_atBot.comp h end Filter diff --git a/mathlib4/Mathlib/Topology/Order/HullKernel.lean b/mathlib4/Mathlib/Topology/Order/HullKernel.lean index 14b525b16..12d94b8b8 100644 --- a/mathlib4/Mathlib/Topology/Order/HullKernel.lean +++ b/mathlib4/Mathlib/Topology/Order/HullKernel.lean @@ -189,15 +189,15 @@ def gi (hG : OrderGenerates T) : GaloisInsertion (α := Set T) (β := αᵒᵈ) (OrderDual.toDual ∘ kernel) (hull T ∘ OrderDual.ofDual) := gc.toGaloisInsertion fun a ↦ by - obtain ⟨S, rfl⟩ := hG a - rw [OrderDual.le_toDual, kernel, kernel] + obtain ⟨S, hS⟩ := hG (OrderDual.ofDual a) + change kernel (hull T (OrderDual.ofDual a)) ≤ OrderDual.ofDual a + rw [hS, kernel, kernel] exact sInf_le_sInf <| image_val_mono fun c hcS => by rw [hull, mem_preimage, mem_Ici] exact sInf_le (mem_image_of_mem Subtype.val hcS) -lemma kernel_hull (hG : OrderGenerates T) (a : α) : kernel (hull T a) = a := by - conv_rhs => rw [← OrderDual.ofDual_toDual a, ← (gi hG).l_u_eq a] - rfl +lemma kernel_hull (hG : OrderGenerates T) (a : α) : kernel (hull T a) = a := + OrderDual.toDual_inj.1 ((gi hG).l_u_eq (OrderDual.toDual a)) lemma hull_kernel_of_isClosed [TopologicalSpace α] [IsLower α] (hT : ∀ p ∈ T, InfPrime p) (hG : OrderGenerates T) {C : Set T} (h : IsClosed C) : diff --git a/mathlib4/Mathlib/Topology/Order/IntermediateValue.lean b/mathlib4/Mathlib/Topology/Order/IntermediateValue.lean index ec58c516e..e6212aaae 100644 --- a/mathlib4/Mathlib/Topology/Order/IntermediateValue.lean +++ b/mathlib4/Mathlib/Topology/Order/IntermediateValue.lean @@ -251,8 +251,9 @@ theorem IsPreconnected.Ioi_csInf_subset {s : Set α} (hs : IsPreconnected s) (hb hs.Icc_subset ys zs ⟨hy.le, hz.le⟩ theorem IsPreconnected.Iio_csSup_subset {s : Set α} (hs : IsPreconnected s) (hb : ¬BddBelow s) - (ha : BddAbove s) : Iio (sSup s) ⊆ s := - IsPreconnected.Ioi_csInf_subset (α := αᵒᵈ) hs ha hb + (ha : BddAbove s) : Iio (sSup s) ⊆ s := by + unsealing_newtype OrderDual => + exact IsPreconnected.Ioi_csInf_subset (α := αᵒᵈ) hs ha hb /-- A preconnected set in a conditionally complete linear order is either one of the intervals `[Inf s, Sup s]`, `[Inf s, Sup s)`, `(Inf s, Sup s]`, `(Inf s, Sup s)`, `[Inf s, +∞)`, @@ -341,12 +342,13 @@ theorem IsClosed.Icc_subset_of_forall_exists_gt {a b : α} {s : Set α} (hs : Is on a closed subset, contains `b`, and the set `s ∩ (a, b]` has no minimal point, then `a ∈ s`. -/ theorem IsClosed.mem_of_ge_of_forall_exists_lt {a b : α} {s : Set α} (hs : IsClosed (s ∩ Icc a b)) (hb : b ∈ s) (hab : a ≤ b) (hgt : ∀ x ∈ s ∩ Ioc a b, (s ∩ Ico a x).Nonempty) : a ∈ s := by - suffices OrderDual.toDual a ∈ ofDual ⁻¹' s by aesop - have : IsClosed (OrderDual.ofDual ⁻¹' (s ∩ Icc a b)) := hs - rw [preimage_inter, ← Icc_toDual] at this - apply this.mem_of_ge_of_forall_exists_gt (by simp_all) (by simp_all) (fun x hx ↦ ?_) - rw [Ico_toDual, ← preimage_inter, ← Equiv.image_symm_eq_preimage, mem_image] at hx - aesop + unsealing_newtype OrderDual => + suffices OrderDual.toDual a ∈ ofDual ⁻¹' s by aesop + have : IsClosed (OrderDual.ofDual ⁻¹' (s ∩ Icc a b)) := hs + rw [preimage_inter, ← Icc_toDual] at this + apply this.mem_of_ge_of_forall_exists_gt (by simp_all) (by simp_all) (fun x hx ↦ ?_) + rw [Ico_toDual, ← preimage_inter, ← Equiv.image_symm_eq_preimage, mem_image] at hx + aesop /-- A "continuous induction principle" for a closed interval: if a set `s` meets `[a, b]` on a closed subset, contains `b`, and for any `a ≤ y < x ≤ b`, `x ∈ s`, the set `s ∩ [y, x)` @@ -724,8 +726,9 @@ theorem Continuous.surjective {f : α → δ} (hf : Continuous f) (h_top : Tends /-- A continuous function which tends to `Filter.atBot` along `Filter.atTop` and to `Filter.atTop` along `Filter.atBot` is surjective. -/ theorem Continuous.surjective' {f : α → δ} (hf : Continuous f) (h_top : Tendsto f atBot atTop) - (h_bot : Tendsto f atTop atBot) : Function.Surjective f := - Continuous.surjective (α := αᵒᵈ) hf h_top h_bot + (h_bot : Tendsto f atTop atBot) : Function.Surjective f := by + unsealing_newtype OrderDual => + exact Continuous.surjective (α := αᵒᵈ) hf h_top h_bot /-- If a function `f : α → β` is continuous on a nonempty interval `s`, its restriction to `s` tends to `Filter.atBot : Filter β` along `Filter.atBot : Filter ↥s` and tends to @@ -743,8 +746,9 @@ tends to `Filter.atTop : Filter β` along `Filter.atBot : Filter ↥s` and tends surjective. We formulate the conclusion as `Function.surjOn f s Set.univ`. -/ theorem ContinuousOn.surjOn_of_tendsto' {f : α → δ} {s : Set α} [OrdConnected s] (hs : s.Nonempty) (hf : ContinuousOn f s) (hbot : Tendsto (fun x : s => f x) atBot atTop) - (htop : Tendsto (fun x : s => f x) atTop atBot) : SurjOn f s univ := - ContinuousOn.surjOn_of_tendsto (δ := δᵒᵈ) hs hf hbot htop + (htop : Tendsto (fun x : s => f x) atTop atBot) : SurjOn f s univ := by + unsealing_newtype OrderDual => + exact ContinuousOn.surjOn_of_tendsto (δ := δᵒᵈ) hs hf hbot htop /-! ### Monotonicity of injective continuous functions @@ -768,9 +772,11 @@ theorem Continuous.strictMono_of_inj_boundedOrder [BoundedOrder α] {f : α → have : u = ⊥ := hf_i hu.2 simp_all +set_option backward.isDefEq.respectTransparency false in theorem Continuous.strictAnti_of_inj_boundedOrder [BoundedOrder α] {f : α → δ} - (hf_c : Continuous f) (hf : f ⊤ ≤ f ⊥) (hf_i : Injective f) : StrictAnti f := - hf_c.strictMono_of_inj_boundedOrder (δ := δᵒᵈ) hf hf_i + (hf_c : Continuous f) (hf : f ⊤ ≤ f ⊥) (hf_i : Injective f) : StrictAnti f := by + unsealing_newtype OrderDual => + exact hf_c.strictMono_of_inj_boundedOrder (δ := δᵒᵈ) hf hf_i theorem Continuous.strictMono_of_inj_boundedOrder' [BoundedOrder α] {f : α → δ} (hf_c : Continuous f) (hf_i : Injective f) : StrictMono f ∨ StrictAnti f := @@ -824,7 +830,9 @@ continuous and injective. Then `f` is strictly antitone (decreasing) if `f(b) theorem ContinuousOn.strictAntiOn_of_injOn_Icc {a b : α} {f : α → δ} (hab : a ≤ b) (hfab : f b ≤ f a) (hf_c : ContinuousOn f (Icc a b)) (hf_i : InjOn f (Icc a b)) : - StrictAntiOn f (Icc a b) := ContinuousOn.strictMonoOn_of_injOn_Icc (δ := δᵒᵈ) hab hfab hf_c hf_i + StrictAntiOn f (Icc a b) := by + unsealing_newtype OrderDual => + exact ContinuousOn.strictMonoOn_of_injOn_Icc (δ := δᵒᵈ) hab hfab hf_c hf_i /-- Suppose `f : [a, b] → δ` is continuous and injective. Then `f` is strictly monotone or antitone (increasing or decreasing). -/ @@ -842,7 +850,8 @@ theorem Continuous.strictMono_of_inj {f : α → δ} have H {c d : α} (hcd : c < d) : StrictMono f ∨ StrictAnti f := (hf_c.continuousOn.strictMonoOn_of_injOn_Icc' hcd.le hf_i.injOn).imp (hf_c.strictMonoOn_of_inj_rigidity hf_i hcd) - (hf_c.strictMonoOn_of_inj_rigidity (δ := δᵒᵈ) hf_i hcd) + (Continuous.strictMonoOn_of_inj_rigidity (δ := δᵒᵈ) (continuous_toDual.comp hf_c) + (OrderDual.toDual.injective.comp hf_i) hcd) cases subsingleton_or_nontrivial α with | inl h => exact Or.inl <| Subsingleton.strictMono f | inr h => diff --git a/mathlib4/Mathlib/Topology/Order/IsLUB.lean b/mathlib4/Mathlib/Topology/Order/IsLUB.lean index b38f0860e..2aac68f20 100644 --- a/mathlib4/Mathlib/Topology/Order/IsLUB.lean +++ b/mathlib4/Mathlib/Topology/Order/IsLUB.lean @@ -42,8 +42,9 @@ theorem IsLUB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsLUB s a) (hs : s (ha.frequently_mem hs).filter_mono inf_le_left theorem IsGLB.frequently_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : - ∃ᶠ x in 𝓝[≥] a, x ∈ s := - IsLUB.frequently_mem (α := αᵒᵈ) ha hs + ∃ᶠ x in 𝓝[≥] a, x ∈ s := by + unsealing_newtype OrderDual => + exact IsLUB.frequently_mem (α := αᵒᵈ) ha hs theorem IsGLB.frequently_nhds_mem {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : ∃ᶠ x in 𝓝 a, x ∈ s := @@ -60,8 +61,9 @@ theorem IsLUB.nhdsWithin_neBot {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.No mem_closure_iff_nhdsWithin_neBot.1 (ha.mem_closure hs) theorem IsGLB.nhdsWithin_neBot {a : α} {s : Set α} (ha : IsGLB s a) (hs : s.Nonempty) : - NeBot (𝓝[s] a) := - IsLUB.nhdsWithin_neBot (α := αᵒᵈ) ha hs + NeBot (𝓝[s] a) := by + unsealing_newtype OrderDual => + exact IsLUB.nhdsWithin_neBot (α := αᵒᵈ) ha hs theorem isLUB_of_mem_nhds {s : Set α} {a : α} {f : Filter α} (hsa : a ∈ upperBounds s) (hsf : s ∈ f) [NeBot (f ⊓ 𝓝 a)] : IsLUB s a := @@ -80,12 +82,14 @@ theorem isLUB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ upperBounds s) ( set_option backward.isDefEq.respectTransparency false in theorem isGLB_of_mem_nhds {s : Set α} {a : α} {f : Filter α} (hsa : a ∈ lowerBounds s) (hsf : s ∈ f) [NeBot (f ⊓ 𝓝 a)] : - IsGLB s a := - isLUB_of_mem_nhds (α := αᵒᵈ) hsa hsf + IsGLB s a := by + unsealing_newtype OrderDual => + exact isLUB_of_mem_nhds (α := αᵒᵈ) hsa hsf theorem isGLB_of_mem_closure {s : Set α} {a : α} (hsa : a ∈ lowerBounds s) (hsf : a ∈ closure s) : - IsGLB s a := - isLUB_of_mem_closure (α := αᵒᵈ) hsa hsf + IsGLB s a := by + unsealing_newtype OrderDual => + exact isLUB_of_mem_closure (α := αᵒᵈ) hsa hsf theorem IsLUB.mem_upperBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsLUB s a) @@ -107,8 +111,9 @@ theorem IsLUB.isLUB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedT theorem IsGLB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) (ha : IsGLB s a) - (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) := - IsLUB.mem_upperBounds_of_tendsto (α := αᵒᵈ) (γ := γᵒᵈ) hf.dual ha hb + (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) := by + unsealing_newtype OrderDual => + exact IsLUB.mem_upperBounds_of_tendsto (α := αᵒᵈ) (γ := γᵒᵈ) hf.dual ha hb -- For a version of this theorem in which the convergence considered on the domain `α` is as -- `x : α` tends to negative infinity, rather than tending to a point `x` in `α`, see @@ -116,28 +121,33 @@ theorem IsGLB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [Or @[to_dual existing] theorem IsGLB.isGLB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : MonotoneOn f s) : - IsGLB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsGLB (f '' s) b := - IsLUB.isLUB_of_tendsto (α := αᵒᵈ) (γ := γᵒᵈ) hf.dual + IsGLB s a → s.Nonempty → Tendsto f (𝓝[s] a) (𝓝 b) → IsGLB (f '' s) b := by + unsealing_newtype OrderDual => + exact IsLUB.isLUB_of_tendsto (α := αᵒᵈ) (γ := γᵒᵈ) hf.dual theorem IsLUB.mem_lowerBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsLUB s a) - (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) := - IsLUB.mem_upperBounds_of_tendsto (γ := γᵒᵈ) hf ha hb + (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ lowerBounds (f '' s) := by + unsealing_newtype OrderDual => + exact IsLUB.mem_upperBounds_of_tendsto (γ := γᵒᵈ) hf ha hb theorem IsLUB.isGLB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsLUB s a) (hs : s.Nonempty) - (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : IsGLB (f '' s) b := - IsLUB.isLUB_of_tendsto (γ := γᵒᵈ) hf ha hs hb + (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : IsGLB (f '' s) b := by + unsealing_newtype OrderDual => + exact IsLUB.isLUB_of_tendsto (γ := γᵒᵈ) hf ha hs hb theorem IsGLB.mem_upperBounds_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsGLB s a) - (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ upperBounds (f '' s) := - IsGLB.mem_lowerBounds_of_tendsto (γ := γᵒᵈ) hf ha hb + (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : b ∈ upperBounds (f '' s) := by + unsealing_newtype OrderDual => + exact IsGLB.mem_lowerBounds_of_tendsto (γ := γᵒᵈ) hf ha hb theorem IsGLB.isLUB_of_tendsto [Preorder γ] [TopologicalSpace γ] [OrderClosedTopology γ] {f : α → γ} {s : Set α} {a : α} {b : γ} (hf : AntitoneOn f s) (ha : IsGLB s a) (hs : s.Nonempty) - (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : IsLUB (f '' s) b := - IsGLB.isGLB_of_tendsto (γ := γᵒᵈ) hf ha hs hb + (hb : Tendsto f (𝓝[s] a) (𝓝 b)) : IsLUB (f '' s) b := by + unsealing_newtype OrderDual => + exact IsGLB.isGLB_of_tendsto (γ := γᵒᵈ) hf ha hs hb theorem IsLUB.mem_of_isClosed {a : α} {s : Set α} (ha : IsLUB s a) (hs : s.Nonempty) (sc : IsClosed s) : a ∈ s := @@ -160,7 +170,8 @@ theorem isLUB_iff_of_subset_of_subset_closure {α : Type*} [TopologicalSpace α] theorem isGLB_iff_of_subset_of_subset_closure {α : Type*} [TopologicalSpace α] [Preorder α] [ClosedIciTopology α] {s t : Set α} (hst : s ⊆ t) (hts : t ⊆ closure s) {x : α} : IsGLB s x ↔ IsGLB t x := - isLUB_iff_of_subset_of_subset_closure (α := αᵒᵈ) hst hts + isGLB_congr <| (lowerBounds_closure (s := s) ▸ lowerBounds_mono_set hts).antisymm <| + lowerBounds_mono_set hst theorem Dense.isLUB_inter_iff {α : Type*} [TopologicalSpace α] [Preorder α] [ClosedIicTopology α] {s t : Set α} (hs : Dense s) (ht : IsOpen t) {x : α} : @@ -170,7 +181,7 @@ theorem Dense.isLUB_inter_iff {α : Type*} [TopologicalSpace α] [Preorder α] [ theorem Dense.isGLB_inter_iff {α : Type*} [TopologicalSpace α] [Preorder α] [ClosedIciTopology α] {s t : Set α} (hs : Dense s) (ht : IsOpen t) {x : α} : IsGLB (t ∩ s) x ↔ IsGLB t x := - hs.isLUB_inter_iff (α := αᵒᵈ) ht + isGLB_iff_of_subset_of_subset_closure (by simp) <| hs.open_subset_closure_inter ht /-- The upper bounds of the image of a continuous function on a dense set are equal to the upper bounds of the range of the universe. -/ @@ -189,8 +200,9 @@ bounds of the range of the universe. -/ theorem Dense.lowerBounds_image {α : Type*} [TopologicalSpace α] [Preorder α] [ClosedIciTopology α] {f : γ → α} [TopologicalSpace γ] {S : Set γ} (hS : Dense S) (hf : Continuous f) : - lowerBounds (f '' S) = lowerBounds (range f) := - hS.upperBounds_image (α := αᵒᵈ) hf + lowerBounds (f '' S) = lowerBounds (range f) := by + unsealing_newtype OrderDual => + exact hS.upperBounds_image (α := αᵒᵈ) hf /-- The supremum of a bounded above, continuous function on a dense set is equal to the supremum on the universe. -/ @@ -210,8 +222,9 @@ the universe. -/ theorem Dense.ciInf {α : Type*} [TopologicalSpace α] [ConditionallyCompleteLattice α] [ClosedIciTopology α] {f : γ → α} [TopologicalSpace γ] {S : Set γ} (hS : Dense S) (hf : Continuous f) (h : BddBelow (range f)) : - ⨅ s : S, f s = ⨅ i, f i := - hS.ciSup (α := αᵒᵈ) hf h + ⨅ s : S, f s = ⨅ i, f i := by + unsealing_newtype OrderDual => + exact hS.ciSup (α := αᵒᵈ) hf h /-- This is an analogue of `Dense.continuous_sup` for functions taking values in a conditionally complete linear order. The assumption of `BddAbove (range f)` is not needed in this theorem. -/ @@ -231,8 +244,9 @@ complete linear order. The assumption of `BddBelow (range f)` is not needed in t theorem Dense.ciInf' {α : Type*} [TopologicalSpace α] [ConditionallyCompleteLinearOrder α] [ClosedIciTopology α] {f : γ → α} [TopologicalSpace γ] {S : Set γ} (hS : Dense S) (hf : Continuous f) : - ⨅ s : S, f s = ⨅ i, f i := - hS.ciSup' (α := αᵒᵈ) hf + ⨅ s : S, f s = ⨅ i, f i := by + unsealing_newtype OrderDual => + exact hS.ciSup' (α := αᵒᵈ) hf section ConditionallyCompleteLinearOrder @@ -267,8 +281,9 @@ lemma upperClosure_eq_Ici_csInf {s : Set α} (h₁ : s.Nonempty) (h₂ : BddBelo (⟨_, (isGLB_csInf h₁ h₂).mem_of_isClosed h₁ hs, ·⟩)⟩ lemma lowerClosure_eq_Iic_csSup {s : Set α} (h₁ : s.Nonempty) (h₂ : BddAbove s) (hs : IsClosed s) : - lowerClosure s = Iic (sSup s) := - upperClosure_eq_Ici_csInf (α := αᵒᵈ) h₁ h₂ hs + lowerClosure s = Iic (sSup s) := by + unsealing_newtype OrderDual => + exact upperClosure_eq_Ici_csInf (α := αᵒᵈ) h₁ h₂ hs protected lemma IsClosed.upperClosure {s : Set α} (hs : IsClosed s) : IsClosed (upperClosure s : Set α) := by @@ -279,8 +294,9 @@ protected lemma IsClosed.upperClosure {s : Set α} (hs : IsClosed s) : · exact upperClosure_eq_bot h₂ ▸ isClosed_univ protected lemma IsClosed.lowerClosure {s : Set α} (hs : IsClosed s) : - IsClosed (lowerClosure s).1 := - IsClosed.upperClosure (α := αᵒᵈ) hs + IsClosed (lowerClosure s).1 := by + unsealing_newtype OrderDual => + exact IsClosed.upperClosure (α := αᵒᵈ) hs end ConditionallyCompleteLinearOrder @@ -374,30 +390,36 @@ theorem DenseRange.exists_seq_strictMono_tendsto {β : Type*} [LinearOrder β] [ obtain rfl : f ∘ v = u := funext hv exact ⟨v, fun a b hlt ↦ hmono.reflect_lt <| hu hlt, hux, hlim⟩ -set_option backward.isDefEq.respectTransparency false in theorem IsGLB.exists_seq_strictAnti_tendsto_of_notMem {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)] (htx : IsGLB t x) (notMem : x ∉ t) (ht : t.Nonempty) : - ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := - IsLUB.exists_seq_strictMono_tendsto_of_notMem (α := αᵒᵈ) htx notMem ht + ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := by + unsealing_newtype OrderDual => + let : IsCountablyGenerated (𝓝 (OrderDual.toDual x)) := ‹IsCountablyGenerated (𝓝 x)› + exact IsLUB.exists_seq_strictMono_tendsto_of_notMem (α := αᵒᵈ) + (x := OrderDual.toDual x) htx notMem ht -set_option backward.isDefEq.respectTransparency false in theorem IsGLB.exists_seq_antitone_tendsto {t : Set α} {x : α} [IsCountablyGenerated (𝓝 x)] (htx : IsGLB t x) (ht : t.Nonempty) : - ∃ u : ℕ → α, Antitone u ∧ (∀ n, x ≤ u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := - IsLUB.exists_seq_monotone_tendsto (α := αᵒᵈ) htx ht + ∃ u : ℕ → α, Antitone u ∧ (∀ n, x ≤ u n) ∧ Tendsto u atTop (𝓝 x) ∧ ∀ n, u n ∈ t := by + unsealing_newtype OrderDual => + let : IsCountablyGenerated (𝓝 (OrderDual.toDual x)) := ‹IsCountablyGenerated (𝓝 x)› + exact IsLUB.exists_seq_monotone_tendsto (α := αᵒᵈ) (x := OrderDual.toDual x) htx ht theorem exists_seq_strictAnti_tendsto' [DenselyOrdered α] [FirstCountableTopology α] {x y : α} (hy : x < y) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, u n ∈ Ioo x y) ∧ Tendsto u atTop (𝓝 x) := by - simpa using! exists_seq_strictMono_tendsto' (α := αᵒᵈ) (OrderDual.toDual_lt_toDual.2 hy) + unsealing_newtype OrderDual => + simpa using! exists_seq_strictMono_tendsto' (α := αᵒᵈ) (OrderDual.toDual_lt_toDual.2 hy) theorem exists_seq_strictAnti_tendsto [DenselyOrdered α] [NoMaxOrder α] [FirstCountableTopology α] - (x : α) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) := - exists_seq_strictMono_tendsto (α := αᵒᵈ) x + (x : α) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝 x) := by + unsealing_newtype OrderDual => + exact exists_seq_strictMono_tendsto (α := αᵒᵈ) x theorem exists_seq_strictAnti_tendsto_nhdsWithin [DenselyOrdered α] [NoMaxOrder α] [FirstCountableTopology α] (x : α) : - ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝[>] x) := - exists_seq_strictMono_tendsto_nhdsWithin (α := αᵒᵈ) _ + ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, x < u n) ∧ Tendsto u atTop (𝓝[>] x) := by + unsealing_newtype OrderDual => + exact exists_seq_strictMono_tendsto_nhdsWithin (α := αᵒᵈ) _ theorem exists_seq_strictAnti_strictMono_tendsto [DenselyOrdered α] [FirstCountableTopology α] {x y : α} (h : x < y) : @@ -411,31 +433,40 @@ theorem exists_seq_strictAnti_strictMono_tendsto [DenselyOrdered α] [FirstCount theorem exists_seq_tendsto_sInf {α : Type*} [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [OrderTopology α] [FirstCountableTopology α] {S : Set α} (hS : S.Nonempty) - (hS' : BddBelow S) : ∃ u : ℕ → α, Antitone u ∧ Tendsto u atTop (𝓝 (sInf S)) ∧ ∀ n, u n ∈ S := - exists_seq_tendsto_sSup (α := αᵒᵈ) hS hS' + (hS' : BddBelow S) : ∃ u : ℕ → α, Antitone u ∧ Tendsto u atTop (𝓝 (sInf S)) ∧ ∀ n, u n ∈ S := by + unsealing_newtype OrderDual => + exact exists_seq_tendsto_sSup (α := αᵒᵈ) hS hS' +set_option backward.isDefEq.respectTransparency false in theorem Dense.exists_seq_strictAnti_tendsto_of_lt [DenselyOrdered α] [FirstCountableTopology α] {s : Set α} (hs : Dense s) {x y : α} (hy : x < y) : ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, u n ∈ (Ioo x y ∩ s)) ∧ Tendsto u atTop (𝓝 x) := by - simpa using! hs.exists_seq_strictMono_tendsto_of_lt (α := αᵒᵈ) (OrderDual.toDual_lt_toDual.2 hy) + unsealing_newtype OrderDual => + simpa using! hs.exists_seq_strictMono_tendsto_of_lt (α := αᵒᵈ) (OrderDual.toDual_lt_toDual.2 hy) +set_option backward.isDefEq.respectTransparency false in theorem Dense.exists_seq_strictAnti_tendsto [DenselyOrdered α] [NoMaxOrder α] [FirstCountableTopology α] {s : Set α} (hs : Dense s) (x : α) : - ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, u n ∈ (Ioi x ∩ s)) ∧ Tendsto u atTop (𝓝 x) := - hs.exists_seq_strictMono_tendsto (α := αᵒᵈ) x + ∃ u : ℕ → α, StrictAnti u ∧ (∀ n, u n ∈ (Ioi x ∩ s)) ∧ Tendsto u atTop (𝓝 x) := by + unsealing_newtype OrderDual => + exact hs.exists_seq_strictMono_tendsto (α := αᵒᵈ) x +set_option backward.isDefEq.respectTransparency false in theorem DenseRange.exists_seq_strictAnti_tendsto_of_lt {β : Type*} [LinearOrder β] [DenselyOrdered α] [FirstCountableTopology α] {f : β → α} {x y : α} (hf : DenseRange f) (hmono : Monotone f) (hlt : x < y) : ∃ u : ℕ → β, StrictAnti u ∧ (∀ n, f (u n) ∈ Ioo x y) ∧ Tendsto (f ∘ u) atTop (𝓝 x) := by - simpa using! hf.exists_seq_strictMono_tendsto_of_lt (α := αᵒᵈ) (β := βᵒᵈ) hmono.dual - (OrderDual.toDual_lt_toDual.2 hlt) + unsealing_newtype OrderDual => + simpa using! hf.exists_seq_strictMono_tendsto_of_lt (α := αᵒᵈ) (β := βᵒᵈ) hmono.dual + (OrderDual.toDual_lt_toDual.2 hlt) +set_option backward.isDefEq.respectTransparency false in theorem DenseRange.exists_seq_strictAnti_tendsto {β : Type*} [LinearOrder β] [DenselyOrdered α] [NoMaxOrder α] [FirstCountableTopology α] {f : β → α} (hf : DenseRange f) (hmono : Monotone f) (x : α) : - ∃ u : ℕ → β, StrictAnti u ∧ (∀ n, f (u n) ∈ Ioi x) ∧ Tendsto (f ∘ u) atTop (𝓝 x) := - hf.exists_seq_strictMono_tendsto (α := αᵒᵈ) (β := βᵒᵈ) hmono.dual x + ∃ u : ℕ → β, StrictAnti u ∧ (∀ n, f (u n) ∈ Ioi x) ∧ Tendsto (f ∘ u) atTop (𝓝 x) := by + unsealing_newtype OrderDual => + exact hf.exists_seq_strictMono_tendsto (α := αᵒᵈ) (β := βᵒᵈ) hmono.dual x theorem eventually_le_const_iff_forall_gt_eventually_lt_const [FirstCountableTopology α] {l : Filter γ} [CountableInterFilter l] {f : γ → α} {a : α} : @@ -458,7 +489,8 @@ theorem eventually_le_const_iff_forall_gt_eventually_lt_const [FirstCountableTop theorem eventually_const_le_iff_forall_lt_eventually_const_lt [FirstCountableTopology α] {l : Filter γ} [CountableInterFilter l] {f : γ → α} {a : α} : - (∀ᶠ x in l, a ≤ f x) ↔ ∀ b, b < a → ∀ᶠ x in l, b < f x := - eventually_le_const_iff_forall_gt_eventually_lt_const (α := αᵒᵈ) + (∀ᶠ x in l, a ≤ f x) ↔ ∀ b, b < a → ∀ᶠ x in l, b < f x := by + unsealing_newtype OrderDual => + exact eventually_le_const_iff_forall_gt_eventually_lt_const (α := αᵒᵈ) end OrderTopology diff --git a/mathlib4/Mathlib/Topology/Order/Lattice.lean b/mathlib4/Mathlib/Topology/Order/Lattice.lean index 34441d3c1..fdcbd6b36 100644 --- a/mathlib4/Mathlib/Topology/Order/Lattice.lean +++ b/mathlib4/Mathlib/Topology/Order/Lattice.lean @@ -47,11 +47,13 @@ class ContinuousSup (L : Type*) [TopologicalSpace L] [Max L] : Prop where instance OrderDual.continuousSup (L : Type*) [TopologicalSpace L] [Min L] [h : ContinuousInf L] : ContinuousSup Lᵒᵈ where - continuous_sup := h.continuous_inf + continuous_sup := continuous_toDual.comp + (h.continuous_inf.comp (continuous_ofDual.prodMap continuous_ofDual)) instance OrderDual.continuousInf (L : Type*) [TopologicalSpace L] [Max L] [h : ContinuousSup L] : ContinuousInf Lᵒᵈ where - continuous_inf := h.continuous_sup + continuous_inf := continuous_toDual.comp + (h.continuous_sup.comp (continuous_ofDual.prodMap continuous_ofDual)) /-- Let `L` be a lattice equipped with a topology such that `L` has continuous infimum and supremum. Then `L` is said to be a *topological lattice*. @@ -133,13 +135,15 @@ lemma finset_sup'_nhds_apply [SemilatticeSup L] [ContinuousSup L] lemma finset_inf'_nhds [SemilatticeInf L] [ContinuousInf L] (hne : s.Nonempty) (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) : - Tendsto (s.inf' hne f) l (𝓝 (s.inf' hne g)) := - finset_sup'_nhds (L := Lᵒᵈ) hne hs + Tendsto (s.inf' hne f) l (𝓝 (s.inf' hne g)) := by + unsealing_newtype OrderDual => + exact finset_sup'_nhds (L := Lᵒᵈ) hne hs lemma finset_inf'_nhds_apply [SemilatticeInf L] [ContinuousInf L] (hne : s.Nonempty) (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) : - Tendsto (fun a ↦ s.inf' hne (f · a)) l (𝓝 (s.inf' hne g)) := - finset_sup'_nhds_apply (L := Lᵒᵈ) hne hs + Tendsto (fun a ↦ s.inf' hne (f · a)) l (𝓝 (s.inf' hne g)) := by + unsealing_newtype OrderDual => + exact finset_sup'_nhds_apply (L := Lᵒᵈ) hne hs lemma finset_sup_nhds [SemilatticeSup L] [OrderBot L] [ContinuousSup L] (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) : Tendsto (s.sup f) l (𝓝 (s.sup g)) := by @@ -154,13 +158,15 @@ lemma finset_sup_nhds_apply [SemilatticeSup L] [OrderBot L] [ContinuousSup L] simpa only [← Finset.sup_apply] using finset_sup_nhds hs lemma finset_inf_nhds [SemilatticeInf L] [OrderTop L] [ContinuousInf L] - (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) : Tendsto (s.inf f) l (𝓝 (s.inf g)) := - finset_sup_nhds (L := Lᵒᵈ) hs + (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) : Tendsto (s.inf f) l (𝓝 (s.inf g)) := by + unsealing_newtype OrderDual => + exact finset_sup_nhds (L := Lᵒᵈ) hs lemma finset_inf_nhds_apply [SemilatticeInf L] [OrderTop L] [ContinuousInf L] (hs : ∀ i ∈ s, Tendsto (f i) l (𝓝 (g i))) : - Tendsto (fun a ↦ s.inf (f · a)) l (𝓝 (s.inf g)) := - finset_sup_nhds_apply (L := Lᵒᵈ) hs + Tendsto (fun a ↦ s.inf (f · a)) l (𝓝 (s.inf g)) := by + unsealing_newtype OrderDual => + exact finset_sup_nhds_apply (L := Lᵒᵈ) hs end Filter.Tendsto diff --git a/mathlib4/Mathlib/Topology/Order/LeftRight.lean b/mathlib4/Mathlib/Topology/Order/LeftRight.lean index 3550da6c4..975aa9ec5 100644 --- a/mathlib4/Mathlib/Topology/Order/LeftRight.lean +++ b/mathlib4/Mathlib/Topology/Order/LeftRight.lean @@ -67,9 +67,10 @@ lemma IsAntichain.interior_eq_empty [∀ x : α, (𝓝[<] x).NeBot] {s : Set α} exact hs hys (interior_subset hx) hyx.ne hyx.le lemma IsAntichain.interior_eq_empty' [∀ x : α, (𝓝[>] x).NeBot] {s : Set α} - (hs : IsAntichain (· ≤ ·) s) : interior s = ∅ := - have : ∀ x : αᵒᵈ, NeBot (𝓝[<] x) := ‹_› - hs.to_dual.interior_eq_empty + (hs : IsAntichain (· ≤ ·) s) : interior s = ∅ := by + unsealing_newtype OrderDual => + exact have : ∀ x : αᵒᵈ, NeBot (𝓝[<] x) := ‹_› + hs.to_dual.interior_eq_empty end Preorder diff --git a/mathlib4/Mathlib/Topology/Order/LeftRightLim.lean b/mathlib4/Mathlib/Topology/Order/LeftRightLim.lean index 18013ceb9..55cde826a 100644 --- a/mathlib4/Mathlib/Topology/Order/LeftRightLim.lean +++ b/mathlib4/Mathlib/Topology/Order/LeftRightLim.lean @@ -58,7 +58,7 @@ let `a : α`. The limit strictly to the right of `f` at `a`, denoted with `right by using the order topology on `α`. If `a` is isolated to its right or the function has no right limit, we use `f a` instead to guarantee a good behavior in most cases. -/ noncomputable def Function.rightLim (f : α → β) (a : α) : β := - @Function.leftLim αᵒᵈ β _ _ f a + @Function.leftLim αᵒᵈ β _ _ (f ∘ ⇑OrderDual.ofDual) (OrderDual.toDual a) open Function @@ -72,8 +72,9 @@ theorem leftLim_eq_of_tendsto [hα : TopologicalSpace α] [h'α : OrderTopology theorem rightLim_eq_of_tendsto [TopologicalSpace α] [OrderTopology α] [T2Space β] {f : α → β} {a : α} {y : β} [h : (𝓝[>] a).NeBot] (h' : Tendsto f (𝓝[>] a) (𝓝 y)) : - Function.rightLim f a = y := - leftLim_eq_of_tendsto (α := αᵒᵈ) (h := h) h' + Function.rightLim f a = y := by + unsealing_newtype OrderDual => + exact leftLim_eq_of_tendsto (α := αᵒᵈ) (h := h) h' theorem leftLim_eq_of_eq_bot [hα : TopologicalSpace α] [h'α : OrderTopology α] (f : α → β) {a : α} (h : 𝓝[<] a = ⊥) : leftLim f a = f a := by @@ -81,8 +82,9 @@ theorem leftLim_eq_of_eq_bot [hα : TopologicalSpace α] [h'α : OrderTopology simp [leftLim, h] theorem rightLim_eq_of_eq_bot [TopologicalSpace α] [OrderTopology α] (f : α → β) {a : α} - (h : 𝓝[>] a = ⊥) : rightLim f a = f a := - leftLim_eq_of_eq_bot (α := αᵒᵈ) f h + (h : 𝓝[>] a = ⊥) : rightLim f a = f a := by + unsealing_newtype OrderDual => + exact leftLim_eq_of_eq_bot (α := αᵒᵈ) f h theorem leftLim_eq_of_not_tendsto [hα : TopologicalSpace α] [h'α : OrderTopology α] (f : α → β) {a : α} @@ -92,8 +94,9 @@ theorem leftLim_eq_of_not_tendsto theorem rightLim_eq_of_not_tendsto [hα : TopologicalSpace α] [h'α : OrderTopology α] (f : α → β) {a : α} - (h : ¬ ∃ y, Tendsto f (𝓝[>] a) (𝓝 y)) : rightLim f a = f a := - leftLim_eq_of_not_tendsto (α := αᵒᵈ) f h + (h : ¬ ∃ y, Tendsto f (𝓝[>] a) (𝓝 y)) : rightLim f a = f a := by + unsealing_newtype OrderDual => + exact leftLim_eq_of_not_tendsto (α := αᵒᵈ) f h theorem leftLim_eq_of_isBot {f : α → β} {a : α} (ha : IsBot a) : leftLim f a = f a := by @@ -104,8 +107,9 @@ theorem leftLim_eq_of_isBot {f : α → β} {a : α} (ha : IsBot a) : simp [this] theorem rightLim_eq_of_isTop {f : α → β} {a : α} (ha : IsTop a) : - rightLim f a = f a := - leftLim_eq_of_isBot (α := αᵒᵈ) ha + rightLim f a = f a := by + unsealing_newtype OrderDual => + exact leftLim_eq_of_isBot (α := αᵒᵈ) ha theorem ContinuousWithinAt.leftLim_eq [TopologicalSpace α] [OrderTopology α] [T2Space β] {f : α → β} {a : α} (hf : ContinuousWithinAt f (Iic a) a) : leftLim f a = f a := by @@ -115,8 +119,9 @@ theorem ContinuousWithinAt.leftLim_eq [TopologicalSpace α] [OrderTopology α] [ exact hf.tendsto.mono_left (nhdsWithin_mono _ Iio_subset_Iic_self) theorem ContinuousWithinAt.rightLim_eq [TopologicalSpace α] [OrderTopology α] [T2Space β] - {f : α → β} {a : α} (hf : ContinuousWithinAt f (Ici a) a) : rightLim f a = f a := - ContinuousWithinAt.leftLim_eq (α := αᵒᵈ) hf + {f : α → β} {a : α} (hf : ContinuousWithinAt f (Ici a) a) : rightLim f a = f a := by + unsealing_newtype OrderDual => + exact ContinuousWithinAt.leftLim_eq (α := αᵒᵈ) hf theorem tendsto_leftLim_of_tendsto [TopologicalSpace α] [h'α : OrderTopology α] {f : α → β} {a : α} (h : ∃ y, Tendsto f (𝓝[<] a) (𝓝 y)) : @@ -129,8 +134,9 @@ theorem tendsto_leftLim_of_tendsto [TopologicalSpace α] [h'α : OrderTopology theorem tendsto_rightLim_of_tendsto [TopologicalSpace α] [OrderTopology α] {f : α → β} {a : α} (h : ∃ y, Tendsto f (𝓝[>] a) (𝓝 y)) : - Tendsto f (𝓝[>] a) (𝓝 (f.rightLim a)) := - tendsto_leftLim_of_tendsto (α := αᵒᵈ) h + Tendsto f (𝓝[>] a) (𝓝 (f.rightLim a)) := by + unsealing_newtype OrderDual => + exact tendsto_leftLim_of_tendsto (α := αᵒᵈ) h theorem mapClusterPt_leftLim [TopologicalSpace α] [OrderTopology α] (f : α → β) (a : α) : MapClusterPt (f.leftLim a) (𝓝[≤] a) f := by @@ -147,8 +153,9 @@ theorem mapClusterPt_leftLim [TopologicalSpace α] [OrderTopology α] exact MapClusterPt.mono this (nhdsWithin_mono _ Iio_subset_Iic_self) theorem mapClusterPt_rightLim [TopologicalSpace α] [OrderTopology α] - (f : α → β) (a : α) : MapClusterPt (f.rightLim a) (𝓝[≥] a) f := - mapClusterPt_leftLim (α := αᵒᵈ) _ _ + (f : α → β) (a : α) : MapClusterPt (f.rightLim a) (𝓝[≥] a) f := by + unsealing_newtype OrderDual => + exact mapClusterPt_leftLim (α := αᵒᵈ) _ _ theorem continuousWithinAt_leftLim_Iic [TopologicalSpace α] [OrderTopology α] [T3Space β] {f : α → β} {a : α} (h : Tendsto f (𝓝[<] a) (𝓝 (f.leftLim a))) : @@ -181,13 +188,14 @@ theorem leftLim_leftLim [TopologicalSpace α] [OrderTopology α] [T3Space β] theorem continuousWithinAt_rightLim_Ici [TopologicalSpace α] [OrderTopology α] [T3Space β] {f : α → β} {a : α} (h : Tendsto f (𝓝[>] a) (𝓝 (f.rightLim a))) : - ContinuousWithinAt f.rightLim (Ici a) a := - continuousWithinAt_leftLim_Iic (α := αᵒᵈ) h + ContinuousWithinAt f.rightLim (Ici a) a := by + unsealing_newtype OrderDual => + exact continuousWithinAt_leftLim_Iic (α := αᵒᵈ) h theorem rightLim_rightLim [TopologicalSpace α] [OrderTopology α] [T3Space β] {f : α → β} {a : α} (h : Tendsto f (𝓝[>] a) (𝓝 (f.rightLim a))) : f.rightLim.rightLim a = f.rightLim a := - leftLim_leftLim (α := αᵒᵈ) h + (continuousWithinAt_rightLim_Ici h).rightLim_eq theorem leftLim_rightLim [TopologicalSpace α] [OrderTopology α] [T3Space β] {f : α → β} {a : α} (h : Tendsto f (𝓝[<] a) (𝓝 (f.leftLim a))) [h' : (𝓝[<] a).NeBot] : @@ -209,8 +217,9 @@ theorem leftLim_rightLim [TopologicalSpace α] [OrderTopology α] [T3Space β] theorem rightLim_leftLim [TopologicalSpace α] [OrderTopology α] [T3Space β] {f : α → β} {a : α} (h : Tendsto f (𝓝[>] a) (𝓝 (f.rightLim a))) [h' : (𝓝[>] a).NeBot] : - f.leftLim.rightLim a = f.rightLim a := - leftLim_rightLim (α := αᵒᵈ) h (h' := h') + f.leftLim.rightLim a = f.rightLim a := by + unsealing_newtype OrderDual => + exact leftLim_rightLim (α := αᵒᵈ) h (h' := h') theorem tendsto_atTop_of_mapClusterPt [TopologicalSpace α] [OrderTopology α] [T3Space β] [NoTopOrder α] {f g : α → β} {b : β} @@ -229,8 +238,9 @@ theorem tendsto_atTop_of_mapClusterPt theorem tendsto_atBot_of_mapClusterPt [TopologicalSpace α] [OrderTopology α] [T3Space β] [NoBotOrder α] {f g : α → β} {b : β} (h : Tendsto f atBot (𝓝 b)) (h' : ∀ᶠ x in atBot, MapClusterPt (g x) (𝓝 x) f) : - Tendsto g atBot (𝓝 b) := - tendsto_atTop_of_mapClusterPt (α := αᵒᵈ) h h' + Tendsto g atBot (𝓝 b) := by + unsealing_newtype OrderDual => + exact tendsto_atTop_of_mapClusterPt (α := αᵒᵈ) h h' theorem tendsto_leftLim_atTop_of_tendsto [TopologicalSpace α] [OrderTopology α] [NoTopOrder α] [T3Space β] @@ -253,13 +263,15 @@ theorem tendsto_rightLim_atTop_of_tendsto [TopologicalSpace α] [OrderTopology theorem tendsto_rightLim_atBot_of_tendsto [TopologicalSpace α] [OrderTopology α] [NoBotOrder α] [T3Space β] {f : α → β} {b : β} (h : Tendsto f atBot (𝓝 b)) : - Tendsto f.rightLim atBot (𝓝 b) := - tendsto_leftLim_atTop_of_tendsto (α := αᵒᵈ) h + Tendsto f.rightLim atBot (𝓝 b) := by + unsealing_newtype OrderDual => + exact tendsto_leftLim_atTop_of_tendsto (α := αᵒᵈ) h theorem tendsto_leftLim_atBot_of_tendsto [TopologicalSpace α] [OrderTopology α] [T3Space β] {f : α → β} {b : β} (h : Tendsto f atBot (𝓝 b)) : - Tendsto f.leftLim atBot (𝓝 b) := - tendsto_rightLim_atTop_of_tendsto (α := αᵒᵈ) h + Tendsto f.leftLim atBot (𝓝 b) := by + unsealing_newtype OrderDual => + exact tendsto_rightLim_atTop_of_tendsto (α := αᵒᵈ) h end @@ -312,14 +324,18 @@ protected theorem leftLim : Monotone (leftLim f) := by · exact le_rfl · exact (hf.leftLim_le le_rfl).trans (hf.le_leftLim hxy) -theorem le_rightLim (h : x ≤ y) : f x ≤ rightLim f y := - hf.dual.leftLim_le h +theorem le_rightLim (h : x ≤ y) : f x ≤ rightLim f y := by + unsealing_newtype OrderDual => + exact hf.dual.leftLim_le h -theorem rightLim_le (h : x < y) : rightLim f x ≤ f y := - hf.dual.le_leftLim h +theorem rightLim_le (h : x < y) : rightLim f x ≤ f y := by + unsealing_newtype OrderDual => + exact hf.dual.le_leftLim h @[gcongr, mono] -protected theorem rightLim : Monotone (rightLim f) := fun _ _ h => hf.dual.leftLim h +protected theorem rightLim : Monotone (rightLim f) := by + unsealing_newtype OrderDual => + exact fun _ _ h => hf.dual.leftLim h theorem leftLim_le_rightLim (h : x ≤ y) : leftLim f x ≤ rightLim f y := (hf.leftLim_le le_rfl).trans (hf.le_rightLim h) @@ -343,11 +359,13 @@ theorem tendsto_leftLim_within (x : α) : Tendsto f (𝓝[<] x) (𝓝[≤] leftL apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within f (hf.tendsto_leftLim x) filter_upwards [@self_mem_nhdsWithin _ _ x (Iio x)] with y hy using hf.le_leftLim hy -theorem tendsto_rightLim (x : α) : Tendsto f (𝓝[>] x) (𝓝 (rightLim f x)) := - hf.dual.tendsto_leftLim x +theorem tendsto_rightLim (x : α) : Tendsto f (𝓝[>] x) (𝓝 (rightLim f x)) := by + unsealing_newtype OrderDual => + exact hf.dual.tendsto_leftLim x -theorem tendsto_rightLim_within (x : α) : Tendsto f (𝓝[>] x) (𝓝[≥] rightLim f x) := - hf.dual.tendsto_leftLim_within x +theorem tendsto_rightLim_within (x : α) : Tendsto f (𝓝[>] x) (𝓝[≥] rightLim f x) := by + unsealing_newtype OrderDual => + exact hf.dual.tendsto_leftLim_within x /-- A monotone function is continuous to the left at a point if and only if its left limit coincides with the value of the function. -/ @@ -362,8 +380,9 @@ theorem continuousWithinAt_Iio_iff_leftLim_eq : /-- A monotone function is continuous to the right at a point if and only if its right limit coincides with the value of the function. -/ theorem continuousWithinAt_Ioi_iff_rightLim_eq : - ContinuousWithinAt f (Ioi x) x ↔ rightLim f x = f x := - hf.dual.continuousWithinAt_Iio_iff_leftLim_eq + ContinuousWithinAt f (Ioi x) x ↔ rightLim f x = f x := by + unsealing_newtype OrderDual => + exact hf.dual.continuousWithinAt_Iio_iff_leftLim_eq /-- A monotone function is continuous at a point if and only if its left and right limits coincide. -/ @@ -391,61 +410,76 @@ variable {α β : Type*} [LinearOrder α] [ConditionallyCompleteLinearOrder β] [OrderTopology β] {f : α → β} (hf : Antitone f) {x y : α} include hf -theorem le_leftLim (h : x ≤ y) : f y ≤ leftLim f x := - hf.dual_right.leftLim_le h +theorem le_leftLim (h : x ≤ y) : f y ≤ leftLim f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.leftLim_le h -theorem leftLim_le (h : x < y) : leftLim f y ≤ f x := - hf.dual_right.le_leftLim h +theorem leftLim_le (h : x < y) : leftLim f y ≤ f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.le_leftLim h @[gcongr, mono] -protected theorem leftLim : Antitone (leftLim f) := - hf.dual_right.leftLim +protected theorem leftLim : Antitone (leftLim f) := by + unsealing_newtype OrderDual => + exact hf.dual_right.leftLim -theorem rightLim_le (h : x ≤ y) : rightLim f y ≤ f x := - hf.dual_right.le_rightLim h +theorem rightLim_le (h : x ≤ y) : rightLim f y ≤ f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.le_rightLim h -theorem le_rightLim (h : x < y) : f y ≤ rightLim f x := - hf.dual_right.rightLim_le h +theorem le_rightLim (h : x < y) : f y ≤ rightLim f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.rightLim_le h @[gcongr, mono] -protected theorem rightLim : Antitone (rightLim f) := - hf.dual_right.rightLim +protected theorem rightLim : Antitone (rightLim f) := by + unsealing_newtype OrderDual => + exact hf.dual_right.rightLim -theorem rightLim_le_leftLim (h : x ≤ y) : rightLim f y ≤ leftLim f x := - hf.dual_right.leftLim_le_rightLim h +theorem rightLim_le_leftLim (h : x ≤ y) : rightLim f y ≤ leftLim f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.leftLim_le_rightLim h -theorem leftLim_le_rightLim (h : x < y) : leftLim f y ≤ rightLim f x := - hf.dual_right.rightLim_le_leftLim h +theorem leftLim_le_rightLim (h : x < y) : leftLim f y ≤ rightLim f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.rightLim_le_leftLim h variable [TopologicalSpace α] [OrderTopology α] -theorem tendsto_leftLim (x : α) : Tendsto f (𝓝[<] x) (𝓝 (leftLim f x)) := - hf.dual_right.tendsto_leftLim x +theorem tendsto_leftLim (x : α) : Tendsto f (𝓝[<] x) (𝓝 (leftLim f x)) := by + unsealing_newtype OrderDual => + exact hf.dual_right.tendsto_leftLim x -theorem tendsto_leftLim_within (x : α) : Tendsto f (𝓝[<] x) (𝓝[≥] leftLim f x) := - hf.dual_right.tendsto_leftLim_within x +theorem tendsto_leftLim_within (x : α) : Tendsto f (𝓝[<] x) (𝓝[≥] leftLim f x) := by + unsealing_newtype OrderDual => + exact hf.dual_right.tendsto_leftLim_within x -theorem tendsto_rightLim (x : α) : Tendsto f (𝓝[>] x) (𝓝 (rightLim f x)) := - hf.dual_right.tendsto_rightLim x +theorem tendsto_rightLim (x : α) : Tendsto f (𝓝[>] x) (𝓝 (rightLim f x)) := by + unsealing_newtype OrderDual => + exact hf.dual_right.tendsto_rightLim x -theorem tendsto_rightLim_within (x : α) : Tendsto f (𝓝[>] x) (𝓝[≤] rightLim f x) := - hf.dual_right.tendsto_rightLim_within x +theorem tendsto_rightLim_within (x : α) : Tendsto f (𝓝[>] x) (𝓝[≤] rightLim f x) := by + unsealing_newtype OrderDual => + exact hf.dual_right.tendsto_rightLim_within x /-- An antitone function is continuous to the left at a point if and only if its left limit coincides with the value of the function. -/ theorem continuousWithinAt_Iio_iff_leftLim_eq : - ContinuousWithinAt f (Iio x) x ↔ leftLim f x = f x := - hf.dual_right.continuousWithinAt_Iio_iff_leftLim_eq + ContinuousWithinAt f (Iio x) x ↔ leftLim f x = f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.continuousWithinAt_Iio_iff_leftLim_eq /-- An antitone function is continuous to the right at a point if and only if its right limit coincides with the value of the function. -/ theorem continuousWithinAt_Ioi_iff_rightLim_eq : - ContinuousWithinAt f (Ioi x) x ↔ rightLim f x = f x := - hf.dual_right.continuousWithinAt_Ioi_iff_rightLim_eq + ContinuousWithinAt f (Ioi x) x ↔ rightLim f x = f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.continuousWithinAt_Ioi_iff_rightLim_eq /-- An antitone function is continuous at a point if and only if its left and right limits coincide. -/ -theorem continuousAt_iff_leftLim_eq_rightLim : ContinuousAt f x ↔ leftLim f x = rightLim f x := - hf.dual_right.continuousAt_iff_leftLim_eq_rightLim +theorem continuousAt_iff_leftLim_eq_rightLim : ContinuousAt f x ↔ leftLim f x = rightLim f x := by + unsealing_newtype OrderDual => + exact hf.dual_right.continuousAt_iff_leftLim_eq_rightLim end Antitone diff --git a/mathlib4/Mathlib/Topology/Order/LeftRightNhds.lean b/mathlib4/Mathlib/Topology/Order/LeftRightNhds.lean index 2e9fd6d72..fa828a9e6 100644 --- a/mathlib4/Mathlib/Topology/Order/LeftRightNhds.lean +++ b/mathlib4/Mathlib/Topology/Order/LeftRightNhds.lean @@ -26,6 +26,18 @@ open OrderDual (toDual ofDual) variable {α β : Type*} +/-- Transport of a neighborhood filter within a set along `toDual`. -/ +private theorem nhdsWithin_toDual {X : Type*} [TopologicalSpace X] (x : X) (t : Set X) : + 𝓝[ofDual ⁻¹' t] (toDual x) = map toDual (𝓝[t] x) := by + rw [nhdsWithin, nhdsWithin, nhds_toDual, Filter.map_inf OrderDual.toDual.injective, + Filter.map_principal, Equiv.image_eq_preimage_symm, OrderDual.toDual_symm_eq] + +@[simp] +private theorem mem_nhdsWithin_toDual {X : Type*} [TopologicalSpace X] {x : X} {s t : Set X} : + ofDual ⁻¹' s ∈ 𝓝[ofDual ⁻¹' t] (toDual x) ↔ s ∈ 𝓝[t] x := by + rw [nhdsWithin_toDual, Filter.mem_map] + rfl + section LinearOrder variable [TopologicalSpace α] [LinearOrder α] @@ -119,8 +131,9 @@ alias countable_setOf_isolated_right := countable_setOfPred_isolated_right /-- The set of points which are isolated on the left is countable when the space is second-countable. -/ theorem countable_setOfPred_isolated_left [SecondCountableTopology α] : - { x : α | 𝓝[<] x = ⊥ }.Countable := - countable_setOfPred_isolated_right (α := αᵒᵈ) + { x : α | 𝓝[<] x = ⊥ }.Countable := by + unsealing_newtype OrderDual => + exact countable_setOfPred_isolated_right (α := αᵒᵈ) @[deprecated (since := "2026-07-09")] alias countable_setOf_isolated_left := countable_setOfPred_isolated_left @@ -171,8 +184,9 @@ alias countable_setOf_isolated_right_within := countable_setOfPred_isolated_righ /-- The set of points in a set which are isolated on the left in this set is countable when the space is second-countable. -/ theorem countable_setOfPred_isolated_left_within [SecondCountableTopology α] {s : Set α} : - { x ∈ s | 𝓝[s ∩ Iio x] x = ⊥ }.Countable := - countable_setOfPred_isolated_right_within (α := αᵒᵈ) + { x ∈ s | 𝓝[s ∩ Iio x] x = ⊥ }.Countable := by + unsealing_newtype OrderDual => + exact countable_setOfPred_isolated_right_within (α := αᵒᵈ) @[deprecated (since := "2026-07-09")] alias countable_setOf_isolated_left_within := countable_setOfPred_isolated_left_within @@ -249,9 +263,10 @@ lemma nhdsLT_basis_Ico [DenselyOrdered α] [NoMinOrder α] (a : α) : nhdsLT_basis_Ico_of_exists_lt <| exists_lt a theorem nhdsLT_eq_bot_iff {a : α} : 𝓝[<] a = ⊥ ↔ IsBot a ∨ ∃ b, b ⋖ a := by - convert! (config := { preTransparency := .default }) - nhdsGT_eq_bot_iff (a := OrderDual.toDual a) using 4 - exact ofDual_covBy_ofDual_iff + unsealing_newtype OrderDual => + convert! (config := { preTransparency := .default }) + nhdsGT_eq_bot_iff (a := OrderDual.toDual a) using 4 + exact ofDual_covBy_ofDual_iff open List in /-- The following statements are equivalent: @@ -348,11 +363,9 @@ theorem mem_nhdsLE_iff_exists_Ioc_subset [NoMinOrder α] {a : α} {s : Set α} : /-- A set is a neighborhood of `a` within `(-∞, a]` if and only if it contains an interval `[l, a]` with `l < a`. -/ theorem mem_nhdsLE_iff_exists_Icc_subset [NoMinOrder α] [DenselyOrdered α] {a : α} - {s : Set α} : s ∈ 𝓝[≤] a ↔ ∃ l, l < a ∧ Icc l a ⊆ s := - calc s ∈ 𝓝[≤] a ↔ ofDual ⁻¹' s ∈ 𝓝[≥] (toDual a) := Iff.rfl - _ ↔ ∃ u : α, toDual a < toDual u ∧ Icc (toDual a) (toDual u) ⊆ ofDual ⁻¹' s := - mem_nhdsGE_iff_exists_Icc_subset - _ ↔ ∃ l, l < a ∧ Icc l a ⊆ s := by simp + {s : Set α} : s ∈ 𝓝[≤] a ↔ ∃ l, l < a ∧ Icc l a ⊆ s := by + have h : ofDual ⁻¹' s ∈ 𝓝[≥] (toDual a) ↔ _ := mem_nhdsGE_iff_exists_Icc_subset + simpa using! h /-- The filter of left neighborhoods has a basis of closed intervals. -/ theorem nhdsLE_basis_Icc [NoMinOrder α] [DenselyOrdered α] {a : α} : @@ -411,8 +424,9 @@ if `f` tends to `C` and `g` tends to `atBot` then `f * g` tends to `atBot`. -/ @[to_additive add_atBot /-- In a linearly ordered additive commutative group with the order topology, if `f` tends to `C` and `g` tends to `atBot` then `f + g` tends to `atBot`. -/] theorem Filter.Tendsto.mul_atBot' {C : α} (hf : Tendsto f l (𝓝 C)) (hg : Tendsto g l atBot) : - Tendsto (fun x => f x * g x) l atBot := - Filter.Tendsto.mul_atTop' (α := αᵒᵈ) hf hg + Tendsto (fun x => f x * g x) l atBot := by + unsealing_newtype OrderDual => + exact Filter.Tendsto.mul_atTop' (α := αᵒᵈ) hf hg /-- In a linearly ordered commutative group with the order topology, if `f` tends to `atTop` and `g` tends to `C` then `f * g` tends to `atTop`. -/ @@ -497,13 +511,15 @@ variable [TopologicalSpace α] [LinearOrder α] [ClosedIicTopology α] {S : Set /-- If `S` is order-connected and contains two points `x < y`, then `S` is a left neighbourhood of `y`. -/ -lemma mem_nhdsLE (hS : OrdConnected S) (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y) : S ∈ 𝓝[≤] y := - hS.dual.mem_nhdsGE hy hx hxy +lemma mem_nhdsLE (hS : OrdConnected S) (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y) : S ∈ 𝓝[≤] y := by + unsealing_newtype OrderDual => + exact hS.dual.mem_nhdsGE hy hx hxy /-- If `S` is order-connected and contains two points `x < y`, then `S` is a punctured left neighbourhood of `y`. -/ -lemma mem_nhdsLT (hS : OrdConnected S) (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y) : S ∈ 𝓝[<] y := - hS.dual.mem_nhdsGT hy hx hxy +lemma mem_nhdsLT (hS : OrdConnected S) (hx : x ∈ S) (hy : y ∈ S) (hxy : x < y) : S ∈ 𝓝[<] y := by + unsealing_newtype OrderDual => + exact hS.dual.mem_nhdsGT hy hx hxy end OrdConnected diff --git a/mathlib4/Mathlib/Topology/Order/LiminfLimsup.lean b/mathlib4/Mathlib/Topology/Order/LiminfLimsup.lean index bffb8421d..2958d9e75 100644 --- a/mathlib4/Mathlib/Topology/Order/LiminfLimsup.lean +++ b/mathlib4/Mathlib/Topology/Order/LiminfLimsup.lean @@ -42,6 +42,10 @@ class BoundedLENhdsClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop class BoundedGENhdsClass (α : Type*) [Preorder α] [TopologicalSpace α] : Prop where isBounded_ge_nhds (a : α) : (𝓝 a).IsBounded (· ≥ ·) +open OrderDual (toDual ofDual) in +private lemma nhds_eq_map_toDual {α : Type*} [TopologicalSpace α] (a : αᵒᵈ) : + 𝓝 a = map toDual (𝓝 (ofDual a)) := nhds_toDual _ + section Preorder variable [Preorder α] [Preorder β] [TopologicalSpace α] [TopologicalSpace β] @@ -69,7 +73,10 @@ theorem Filter.Tendsto.isCoboundedUnder_ge [NeBot f] (h : Tendsto u f (𝓝 a)) f.IsCoboundedUnder (· ≥ ·) u := h.isBoundedUnder_le.isCobounded_flip -instance : BoundedGENhdsClass αᵒᵈ := ⟨@isBounded_le_nhds α _ _ _⟩ +instance : BoundedGENhdsClass αᵒᵈ := + ⟨fun a ↦ by + obtain ⟨b, hb⟩ := isBounded_le_nhds (OrderDual.ofDual a) + exact ⟨OrderDual.toDual b, by rw [nhds_eq_map_toDual, Filter.eventually_map]; exact hb⟩⟩ instance Prod.instBoundedLENhdsClass : BoundedLENhdsClass (α × β) := by refine ⟨fun x ↦ ?_⟩ @@ -111,14 +118,21 @@ theorem Filter.Tendsto.isCoboundedUnder_le [NeBot f] (h : Tendsto u f (𝓝 a)) f.IsCoboundedUnder (· ≤ ·) u := h.isBoundedUnder_ge.isCobounded_flip -instance : BoundedLENhdsClass αᵒᵈ := ⟨@isBounded_ge_nhds α _ _ _⟩ +instance : BoundedLENhdsClass αᵒᵈ := + ⟨fun a ↦ by + obtain ⟨b, hb⟩ := isBounded_ge_nhds (OrderDual.ofDual a) + exact ⟨OrderDual.toDual b, by rw [nhds_eq_map_toDual, Filter.eventually_map]; exact hb⟩⟩ -instance Prod.instBoundedGENhdsClass : BoundedGENhdsClass (α × β) := - ⟨(Prod.instBoundedLENhdsClass (α := αᵒᵈ) (β := βᵒᵈ)).isBounded_le_nhds⟩ +instance Prod.instBoundedGENhdsClass : BoundedGENhdsClass (α × β) := by + unsealing_newtype OrderDual => + exact ⟨(Prod.instBoundedLENhdsClass (α := αᵒᵈ) (β := βᵒᵈ)).isBounded_le_nhds⟩ instance Pi.instBoundedGENhdsClass [Finite ι] [∀ i, Preorder (π i)] [∀ i, TopologicalSpace (π i)] - [∀ i, BoundedGENhdsClass (π i)] : BoundedGENhdsClass (∀ i, π i) := - ⟨(Pi.instBoundedLENhdsClass (π := fun i ↦ (π i)ᵒᵈ)).isBounded_le_nhds⟩ + [∀ i, BoundedGENhdsClass (π i)] : BoundedGENhdsClass (∀ i, π i) := by + refine ⟨fun x ↦ ?_⟩ + rw [nhds_pi] + choose f hf using fun i ↦ isBounded_ge_nhds (x i) + exact ⟨f, eventually_pi hf⟩ end BoundedGENhdsClass @@ -140,8 +154,9 @@ instance (priority := 100) BoundedLENhdsClass.of_closedIciTopology [LinearOrder -- See note [lower instance priority] instance (priority := 100) BoundedGENhdsClass.of_closedIicTopology [LinearOrder α] - [TopologicalSpace α] [ClosedIicTopology α] : BoundedGENhdsClass α := - inferInstanceAs <| BoundedGENhdsClass αᵒᵈᵒᵈ + [TopologicalSpace α] [ClosedIicTopology α] : BoundedGENhdsClass α := by + unsealing_newtype OrderDual => + exact inferInstanceAs <| BoundedGENhdsClass αᵒᵈᵒᵈ section LiminfLimsup @@ -165,8 +180,9 @@ theorem limsSup_nhds (a : α) : limsSup (𝓝 a) = a := | Or.inl ⟨c, hac, hcb⟩ => ⟨c, ge_mem_nhds hac, hcb⟩ | Or.inr ⟨_, h⟩ => ⟨a, (𝓝 a).sets_of_superset (gt_mem_nhds hba) h, hba⟩ -theorem limsInf_nhds (a : α) : limsInf (𝓝 a) = a := - limsSup_nhds (α := αᵒᵈ) a +theorem limsInf_nhds (a : α) : limsInf (𝓝 a) = a := by + unsealing_newtype OrderDual => + exact limsSup_nhds (α := αᵒᵈ) a /-- If a filter is converging, its limsup coincides with its limit. -/ theorem limsInf_eq_of_le_nhds {f : Filter α} {a : α} [NeBot f] (h : f ≤ 𝓝 a) : f.limsInf = a := @@ -183,8 +199,9 @@ theorem limsInf_eq_of_le_nhds {f : Filter α} {a : α} [NeBot f] (h : f ≤ 𝓝 set_option backward.isDefEq.respectTransparency false in /-- If a filter is converging, its liminf coincides with its limit. -/ -theorem limsSup_eq_of_le_nhds {f : Filter α} {a : α} [NeBot f] (h : f ≤ 𝓝 a) : f.limsSup = a := - limsInf_eq_of_le_nhds (α := αᵒᵈ) h +theorem limsSup_eq_of_le_nhds {f : Filter α} {a : α} [NeBot f] (h : f ≤ 𝓝 a) : f.limsSup = a := by + unsealing_newtype OrderDual => + exact limsInf_eq_of_le_nhds (α := αᵒᵈ) h /-- If a function has a limit, then its limsup coincides with its limit. -/ theorem Filter.Tendsto.limsup_eq {f : Filter β} {u : β → α} {a : α} [NeBot f] @@ -216,8 +233,9 @@ set_option backward.isDefEq.respectTransparency false in /-- The `limsInf` of a filter `f` is a cluster point of `f`. -/ theorem ClusterPt.limsInf {f : Filter α} [NeBot f] (hc : f.IsCobounded (· ≥ ·) := by isBoundedDefault) - (hb : f.IsBounded (· ≥ ·) := by isBoundedDefault) : ClusterPt f.limsInf f := - ClusterPt.limsSup (α := αᵒᵈ) hc hb + (hb : f.IsBounded (· ≥ ·) := by isBoundedDefault) : ClusterPt f.limsInf f := by + unsealing_newtype OrderDual => + exact ClusterPt.limsSup (α := αᵒᵈ) hc hb /-- Every cluster point `x` of a filter `f` is less than or equal to `f.limsSup`. -/ theorem ClusterPt.le_limsSup {f : Filter α} {x : α} (hx : ClusterPt x f) @@ -228,11 +246,13 @@ theorem ClusterPt.le_limsSup {f : Filter α} {x : α} (hx : ClusterPt x f) refine this ▸ limsSup_le_limsSup_of_le inf_le_right ?_ hb exact (IsBounded.mono inf_le_left (isBounded_ge_nhds x)).isCobounded_le +set_option backward.isDefEq.respectTransparency false in /-- Every cluster point `x` of a filter `f` is greater than or equal to `f.limsInf`. -/ theorem ClusterPt.limsInf_le {f : Filter α} {x : α} (hx : ClusterPt x f) (hb : f.IsBounded (· ≥ ·) := by isBoundedDefault) : - f.limsInf ≤ x := - hx.le_limsSup (α := αᵒᵈ) + f.limsInf ≤ x := by + unsealing_newtype OrderDual => + exact hx.le_limsSup (α := αᵒᵈ) /-- The `limsSup` of a filter `f` is the greatest cluster point of `f`. -/ theorem isGreatest_clusterPt_limsSup {f : Filter α} [NeBot f] @@ -241,13 +261,12 @@ theorem isGreatest_clusterPt_limsSup {f : Filter α} [NeBot f] IsGreatest {x | ClusterPt x f} f.limsSup := ⟨ClusterPt.limsSup, fun a ha => ha.le_limsSup⟩ -set_option backward.isDefEq.respectTransparency false in /-- The `limsInf` of a filter `f` is the least cluster point of `f`. -/ theorem isLeast_clusterPt_limsInf {f : Filter α} [NeBot f] (hc : f.IsCobounded (· ≥ ·) := by isBoundedDefault) (hb : f.IsBounded (· ≥ ·) := by isBoundedDefault) : IsLeast {x | ClusterPt x f} f.limsInf := - isGreatest_clusterPt_limsSup (α := αᵒᵈ) + ⟨ClusterPt.limsInf hc hb, fun _a ha => ha.limsInf_le hb⟩ /-- The `limsup` of a function `u` along a filter `f` is a cluster point of `u` along `f`. -/ theorem MapClusterPt.limsup {u : β → α} {f : Filter β} [NeBot f] @@ -369,8 +388,9 @@ theorem eventually_le_limsup (hf : IsBoundedUnder (· ≤ ·) f u := by isBounde exact fun _ hc ↦ eventually_lt_of_limsup_lt hc theorem eventually_liminf_le (hf : IsBoundedUnder (· ≥ ·) f u := by isBoundedDefault) : - ∀ᶠ b in f, f.liminf u ≤ u b := - eventually_le_limsup (α := αᵒᵈ) hf + ∀ᶠ b in f, f.liminf u ≤ u b := by + unsealing_newtype OrderDual => + exact eventually_le_limsup (α := αᵒᵈ) hf end ConditionallyCompleteLinearOrder @@ -389,8 +409,9 @@ theorem limsup_eq_bot : f.limsup u = ⊥ ↔ u =ᶠ[f] ⊥ := exact limsup_const_bot⟩ @[simp] -theorem liminf_eq_top : f.liminf u = ⊤ ↔ u =ᶠ[f] ⊤ := - limsup_eq_bot (α := αᵒᵈ) +theorem liminf_eq_top : f.liminf u = ⊤ ↔ u =ᶠ[f] ⊤ := by + unsealing_newtype OrderDual => + exact limsup_eq_bot (α := αᵒᵈ) /-- Let `u : ι → α → β` be a sequence of antitone functions `α → β` indexed by `ι`. Suppose that for all `i : ι`, `u i` tends to `c` at infinity, and that furthermore the limsup of `i ↦ u i r` along @@ -559,8 +580,10 @@ set_option backward.isDefEq.respectTransparency false in theorem Antitone.map_limsInf_of_continuousAt {F : Filter R} [NeBot F] {f : R → S} (f_decr : Antitone f) (f_cont : ContinuousAt f F.limsInf) (cobdd : F.IsCobounded (· ≥ ·) := by isBoundedDefault) - (bdd_below : F.IsBounded (· ≥ ·) := by isBoundedDefault) : f F.limsInf = F.limsup f := - Antitone.map_limsSup_of_continuousAt (R := Rᵒᵈ) (S := Sᵒᵈ) f_decr.dual f_cont bdd_below cobdd + (bdd_below : F.IsBounded (· ≥ ·) := by isBoundedDefault) : f F.limsInf = F.limsup f := by + unsealing_newtype OrderDual => + exact Antitone.map_limsSup_of_continuousAt (R := Rᵒᵈ) (S := Sᵒᵈ) + f_decr.dual f_cont bdd_below cobdd /-- A continuous antitone function between (conditionally) complete linear ordered spaces sends a `Filter.liminf` to the `Filter.limsup` of the images (if the filter is bounded from below and @@ -578,8 +601,9 @@ theorem Antitone.map_liminf_of_continuousAt {f : R → S} (f_decr : Antitone f) theorem Monotone.map_limsSup_of_continuousAt {F : Filter R} [NeBot F] {f : R → S} (f_incr : Monotone f) (f_cont : ContinuousAt f F.limsSup) (bdd_above : F.IsBounded (· ≤ ·) := by isBoundedDefault) - (cobdd : F.IsCobounded (· ≤ ·) := by isBoundedDefault) : f F.limsSup = F.limsup f := - Antitone.map_limsSup_of_continuousAt (S := Sᵒᵈ) f_incr f_cont bdd_above cobdd + (cobdd : F.IsCobounded (· ≤ ·) := by isBoundedDefault) : f F.limsSup = F.limsup f := by + unsealing_newtype OrderDual => + exact Antitone.map_limsSup_of_continuousAt (S := Sᵒᵈ) f_incr f_cont bdd_above cobdd /-- A continuous monotone function between (conditionally) complete linear ordered spaces sends a `Filter.limsup` to the `Filter.limsup` of the images (if the filter is bounded from above and @@ -598,8 +622,9 @@ set_option backward.isDefEq.respectTransparency false in theorem Monotone.map_limsInf_of_continuousAt {F : Filter R} [NeBot F] {f : R → S} (f_incr : Monotone f) (f_cont : ContinuousAt f F.limsInf) (cobdd : F.IsCobounded (· ≥ ·) := by isBoundedDefault) - (bdd_below : F.IsBounded (· ≥ ·) := by isBoundedDefault) : f F.limsInf = F.liminf f := - Antitone.map_limsSup_of_continuousAt (R := Rᵒᵈ) f_incr.dual f_cont bdd_below cobdd + (bdd_below : F.IsBounded (· ≥ ·) := by isBoundedDefault) : f F.limsInf = F.liminf f := by + unsealing_newtype OrderDual => + exact Antitone.map_limsSup_of_continuousAt (R := Rᵒᵈ) f_incr.dual f_cont bdd_below cobdd /-- A continuous monotone function between (conditionally) complete linear ordered spaces sends a `Filter.liminf` to the `Filter.liminf` of the images (if the filter is bounded from below and diff --git a/mathlib4/Mathlib/Topology/Order/LocalExtr.lean b/mathlib4/Mathlib/Topology/Order/LocalExtr.lean index 2f51320b6..7f578e587 100644 --- a/mathlib4/Mathlib/Topology/Order/LocalExtr.lean +++ b/mathlib4/Mathlib/Topology/Order/LocalExtr.lean @@ -175,10 +175,10 @@ theorem IsLocalMinOn.not_nhds_le_map [TopologicalSpace β] (hf : IsLocalMinOn f let ⟨_y, hy⟩ := (this.and self_mem_nhdsWithin).exists hy.1.not_gt hy.2 -set_option backward.isDefEq.respectTransparency false in theorem IsLocalMaxOn.not_nhds_le_map [TopologicalSpace β] (hf : IsLocalMaxOn f s a) - [NeBot (𝓝[>] f a)] : ¬𝓝 (f a) ≤ map f (𝓝[s] a) := - @IsLocalMinOn.not_nhds_le_map α βᵒᵈ _ _ _ _ _ ‹_› hf ‹_› + [NeBot (𝓝[>] f a)] : ¬𝓝 (f a) ≤ map f (𝓝[s] a) := by + unsealing_newtype OrderDual => + exact @IsLocalMinOn.not_nhds_le_map α βᵒᵈ _ _ _ _ _ ‹_› hf ‹_› theorem IsLocalExtrOn.not_nhds_le_map [TopologicalSpace β] (hf : IsLocalExtrOn f s a) [NeBot (𝓝[<] f a)] [NeBot (𝓝[>] f a)] : ¬𝓝 (f a) ≤ map f (𝓝[s] a) := diff --git a/mathlib4/Mathlib/Topology/Order/LowerUpperTopology.lean b/mathlib4/Mathlib/Topology/Order/LowerUpperTopology.lean index 1a7e1dbea..3d6f970c7 100644 --- a/mathlib4/Mathlib/Topology/Order/LowerUpperTopology.lean +++ b/mathlib4/Mathlib/Topology/Order/LowerUpperTopology.lean @@ -75,6 +75,45 @@ def WithLower (α : Type*) := α variable {α β : Type*} +open OrderDual in +private lemma coinduced_toDual_eq (t : TopologicalSpace α) : + TopologicalSpace.coinduced (toDual : α → αᵒᵈ) t = TopologicalSpace.induced ofDual t := by + refine TopologicalSpace.ext_iff.2 fun s ↦ ⟨fun hs ↦ ⟨toDual ⁻¹' s, hs, rfl⟩, ?_⟩ + rintro ⟨u, hu, rfl⟩ + exact hu + +open OrderDual in +private lemma induced_ofDual_injective {t₁ t₂ : TopologicalSpace α} + (h : TopologicalSpace.induced (ofDual : αᵒᵈ → α) t₁ = + TopologicalSpace.induced ofDual t₂) : t₁ = t₂ := by + have := congrArg (TopologicalSpace.induced (toDual : α → αᵒᵈ)) h + rwa [induced_compose, induced_compose, show (ofDual : αᵒᵈ → α) ∘ toDual = id from rfl, + induced_id (t := t₁), induced_id (t := t₂)] at this + +open OrderDual in +private lemma induced_ofDual_lower [Preorder α] : + TopologicalSpace.induced (ofDual : αᵒᵈ → α) (lower α) = upper αᵒᵈ := by + rw [lower, upper, induced_generateFrom_eq] + congr 1 + ext s + constructor + · rintro ⟨u, ⟨a, rfl⟩, rfl⟩ + exact ⟨toDual a, rfl⟩ + · rintro ⟨a, rfl⟩ + exact ⟨(Set.Ici (ofDual a))ᶜ, ⟨ofDual a, rfl⟩, rfl⟩ + +open OrderDual in +private lemma induced_ofDual_upper [Preorder α] : + TopologicalSpace.induced (ofDual : αᵒᵈ → α) (upper α) = lower αᵒᵈ := by + rw [lower, upper, induced_generateFrom_eq] + congr 1 + ext s + constructor + · rintro ⟨u, ⟨a, rfl⟩, rfl⟩ + exact ⟨toDual a, rfl⟩ + · rintro ⟨a, rfl⟩ + exact ⟨(Set.Iic (ofDual a))ᶜ, ⟨ofDual a, rfl⟩, rfl⟩ + namespace WithLower /-- `toLower` is the identity function to the `WithLower` of a type. -/ @@ -210,10 +249,14 @@ The lower topology is homeomorphic to the upper topology on the dual order def WithLower.toDualHomeomorph [Preorder α] : WithLower α ≃ₜ WithUpper αᵒᵈ where toFun := OrderDual.toDual invFun := OrderDual.ofDual - left_inv := OrderDual.toDual_ofDual - right_inv := OrderDual.ofDual_toDual - continuous_toFun := continuous_coinduced_rng - continuous_invFun := continuous_coinduced_rng + left_inv := OrderDual.ofDual_toDual + right_inv := OrderDual.toDual_ofDual + continuous_toFun := continuous_generateFrom_iff.2 <| by + rintro _ ⟨a, rfl⟩ + exact GenerateOpen.basic _ ⟨OrderDual.ofDual a, rfl⟩ + continuous_invFun := continuous_generateFrom_iff.2 <| by + rintro _ ⟨a, rfl⟩ + exact GenerateOpen.basic _ ⟨OrderDual.toDual a, rfl⟩ namespace IsLower @@ -240,7 +283,9 @@ theorem isOpen_iff_generate_Ici_compl : IsOpen s ↔ GenerateOpen { t | ∃ a, ( rw [topology_eq α]; rfl instance _root_.OrderDual.instIsUpper : IsUpper αᵒᵈ where - topology_eq_upperTopology := topology_eq_lowerTopology (α := α) + topology_eq_upperTopology := by + rw [topology_eq α] + exact (coinduced_toDual_eq _).trans induced_ofDual_lower /-- Left-closed right-infinite intervals $[a, ∞)$ are closed in the lower topology. -/ instance : ClosedIciTopology α := @@ -400,43 +445,51 @@ theorem isOpen_iff_generate_Iic_compl : IsOpen s ↔ GenerateOpen { t | ∃ a, ( rw [topology_eq α]; rfl instance _root_.OrderDual.instIsLower : IsLower αᵒᵈ where - topology_eq_lowerTopology := topology_eq_upperTopology (α := α) + topology_eq_lowerTopology := by + rw [topology_eq α] + exact (coinduced_toDual_eq _).trans induced_ofDual_upper /-- Left-infinite right-closed intervals $(-∞,a]$ are closed in the upper topology. -/ instance : ClosedIicTopology α := ⟨fun a ↦ isOpen_compl_iff.1 <| isOpen_iff_generate_Iic_compl.2 <| GenerateOpen.basic _ ⟨a, rfl⟩⟩ /-- The lower closure of a finite set is closed in the upper topology. -/ -theorem isClosed_lowerClosure (h : s.Finite) : IsClosed (lowerClosure s : Set α) := - IsLower.isClosed_upperClosure (α := αᵒᵈ) h +theorem isClosed_lowerClosure (h : s.Finite) : IsClosed (lowerClosure s : Set α) := by + unsealing_newtype OrderDual => + exact IsLower.isClosed_upperClosure (α := αᵒᵈ) h /-- Every set open in the upper topology is an upper set. -/ -theorem isUpperSet_of_isOpen (h : IsOpen s) : IsUpperSet s := - IsLower.isLowerSet_of_isOpen (α := αᵒᵈ) h +theorem isUpperSet_of_isOpen (h : IsOpen s) : IsUpperSet s := by + unsealing_newtype OrderDual => + exact IsLower.isLowerSet_of_isOpen (α := αᵒᵈ) h theorem isLowerSet_of_isClosed (h : IsClosed s) : IsLowerSet s := isUpperSet_compl.1 <| isUpperSet_of_isOpen h.isOpen_compl theorem tendsto_nhds_iff_not_le {β : Type*} {f : β → α} {l : Filter β} {x : α} : - Filter.Tendsto f l (𝓝 x) ↔ ∀ y, ¬x ≤ y → ∀ᶠ z in l, ¬f z ≤ y := - IsLower.tendsto_nhds_iff_not_le (α := αᵒᵈ) + Filter.Tendsto f l (𝓝 x) ↔ ∀ y, ¬x ≤ y → ∀ᶠ z in l, ¬f z ≤ y := by + unsealing_newtype OrderDual => + exact IsLower.tendsto_nhds_iff_not_le (α := αᵒᵈ) /-- The closure of a singleton `{a}` in the upper topology is the left-infinite right-closed interval $(-∞,a]$. -/ @[simp] -theorem closure_singleton (a : α) : closure {a} = Iic a := - IsLower.closure_singleton (α := αᵒᵈ) _ +theorem closure_singleton (a : α) : closure {a} = Iic a := by + unsealing_newtype OrderDual => + exact IsLower.closure_singleton (α := αᵒᵈ) _ -protected theorem isTopologicalBasis : IsTopologicalBasis (upperBasis α) := - IsLower.isTopologicalBasis (α := αᵒᵈ) +protected theorem isTopologicalBasis : IsTopologicalBasis (upperBasis α) := by + unsealing_newtype OrderDual => + exact IsLower.isTopologicalBasis (α := αᵒᵈ) /-- A function `f : β → α` with upper topology in the codomain is continuous if and only if the preimage of every interval `Set.Iic a` is a closed set. -/ lemma continuous_iff_Iic [TopologicalSpace β] {f : β → α} : - Continuous f ↔ ∀ a, IsClosed (f ⁻¹' (Iic a)) := - IsLower.continuous_iff_Ici (α := αᵒᵈ) + Continuous f ↔ ∀ a, IsClosed (f ⁻¹' (Iic a)) := by + unsealing_newtype OrderDual => + exact IsLower.continuous_iff_Ici (α := αᵒᵈ) end Preorder @@ -447,8 +500,9 @@ variable [PartialOrder α] [TopologicalSpace α] [IsUpper α] -- see Note [lower instance priority] /-- The upper topology on a partial order is T₀. -/ -instance (priority := 90) t0Space : T0Space α := - IsLower.t0Space (α := αᵒᵈ) +instance (priority := 90) t0Space : T0Space α := by + unsealing_newtype OrderDual => + exact IsLower.t0Space (α := αᵒᵈ) end PartialOrder @@ -457,12 +511,13 @@ section LinearOrder variable [LinearOrder α] [TopologicalSpace α] [IsUpper α] lemma isTopologicalBasis_insert_univ_subbasis : - IsTopologicalBasis (insert univ {s : Set α | ∃ a, (Iic a)ᶜ = s}) := - IsLower.isTopologicalBasis_insert_univ_subbasis (α := αᵒᵈ) + IsTopologicalBasis (insert univ {s : Set α | ∃ a, (Iic a)ᶜ = s}) := by + unsealing_newtype OrderDual => + exact IsLower.isTopologicalBasis_insert_univ_subbasis (α := αᵒᵈ) theorem tendsto_nhds_iff_lt {β : Type*} {f : β → α} {l : Filter β} {x : α} : - Filter.Tendsto f l (𝓝 x) ↔ ∀ y < x, ∀ᶠ z in l, y < f z := - IsLower.tendsto_nhds_iff_lt (α := αᵒᵈ) + Filter.Tendsto f l (𝓝 x) ↔ ∀ y < x, ∀ᶠ z in l, y < f z := by + simp only [tendsto_nhds_iff_not_le, not_le] end LinearOrder @@ -470,8 +525,9 @@ section CompleteLinearOrder variable [CompleteLinearOrder α] [t : TopologicalSpace α] [IsUpper α] -lemma isTopologicalSpace_basis (U : Set α) : IsOpen U ↔ U = univ ∨ ∃ a, (Iic a)ᶜ = U := - IsLower.isTopologicalSpace_basis (α := αᵒᵈ) U +lemma isTopologicalSpace_basis (U : Set α) : IsOpen U ↔ U = univ ∨ ∃ a, (Iic a)ᶜ = U := by + unsealing_newtype OrderDual => + exact IsLower.isTopologicalSpace_basis (α := αᵒᵈ) U end CompleteLinearOrder @@ -500,8 +556,9 @@ instance instIsUpperProd [Preorder α] [TopologicalSpace α] [IsUpper α] [OrderTop α] [Preorder β] [TopologicalSpace β] [IsUpper β] [OrderTop β] : IsUpper (α × β) where topology_eq_upperTopology := by - suffices IsLower (α × β)ᵒᵈ from IsLower.topology_eq_lowerTopology (α := (α × β)ᵒᵈ) - exact instIsLowerProd (α := αᵒᵈ) (β := βᵒᵈ) + unsealing_newtype OrderDual => + suffices IsLower (α × β)ᵒᵈ from IsLower.topology_eq_lowerTopology (α := (α × β)ᵒᵈ) + exact instIsLowerProd (α := αᵒᵈ) (β := βᵒᵈ) section CompleteLattice_IsLower @@ -527,8 +584,9 @@ section CompleteLattice_IsUpper variable [CompleteLattice α] [CompleteLattice β] [TopologicalSpace α] [IsUpper α] [TopologicalSpace β] [IsUpper β] -protected lemma _root_.sSupHom.continuous (f : sSupHom α β) : Continuous f := - sInfHom.continuous (α := αᵒᵈ) (β := βᵒᵈ) (sSupHom.dual.toFun f) +protected lemma _root_.sSupHom.continuous (f : sSupHom α β) : Continuous f := by + unsealing_newtype OrderDual => + exact sInfHom.continuous (α := αᵒᵈ) (β := βᵒᵈ) (sSupHom.dual.toFun f) -- see Note [lower instance priority] instance (priority := 90) IsUpper.toContinuousInf : ContinuousSup α := @@ -536,13 +594,21 @@ instance (priority := 90) IsUpper.toContinuousInf : ContinuousSup α := end CompleteLattice_IsUpper -lemma isUpper_orderDual [Preorder α] [TopologicalSpace α] : IsUpper αᵒᵈ ↔ IsLower α := by - constructor - · apply OrderDual.instIsLower - · apply OrderDual.instIsUpper - -lemma isLower_orderDual [Preorder α] [TopologicalSpace α] : IsLower αᵒᵈ ↔ IsUpper α := - isUpper_orderDual.symm +lemma isUpper_orderDual [Preorder α] [t : TopologicalSpace α] : IsUpper αᵒᵈ ↔ IsLower α := by + refine ⟨fun h ↦ ⟨?_⟩, fun _ ↦ OrderDual.instIsUpper⟩ + have h := h.topology_eq_upperTopology + rw [show (OrderDual.instTopologicalSpace : TopologicalSpace αᵒᵈ) = + TopologicalSpace.coinduced OrderDual.toDual t from rfl, coinduced_toDual_eq, + ← induced_ofDual_lower] at h + exact induced_ofDual_injective h + +lemma isLower_orderDual [Preorder α] [t : TopologicalSpace α] : IsLower αᵒᵈ ↔ IsUpper α := by + refine ⟨fun h ↦ ⟨?_⟩, fun _ ↦ OrderDual.instIsLower⟩ + have h := h.topology_eq_lowerTopology + rw [show (OrderDual.instTopologicalSpace : TopologicalSpace αᵒᵈ) = + TopologicalSpace.coinduced OrderDual.toDual t from rfl, coinduced_toDual_eq, + ← induced_ofDual_upper] at h + exact induced_ofDual_injective h end Topology diff --git a/mathlib4/Mathlib/Topology/Order/Monotone.lean b/mathlib4/Mathlib/Topology/Order/Monotone.lean index 7d81dee74..e7d09a0cc 100644 --- a/mathlib4/Mathlib/Topology/Order/Monotone.lean +++ b/mathlib4/Mathlib/Topology/Order/Monotone.lean @@ -104,8 +104,9 @@ lemma Monotone.countable_setOfPred_two_preimages [SecondCountableTopology α] are only countably many points that have several preimages. -/ lemma AntitoneOn.countable_setOfPred_two_preimages [SecondCountableTopology α] (hf : AntitoneOn f s) : - Set.Countable {c | ∃ x y, x ∈ s ∧ y ∈ s ∧ x < y ∧ f x = c ∧ f y = c} := - (MonotoneOn.countable_setOfPred_two_preimages hf.dual_right :) + Set.Countable {c | ∃ x y, x ∈ s ∧ y ∈ s ∧ x < y ∧ f x = c ∧ f y = c} := by + unsealing_newtype OrderDual => + exact (MonotoneOn.countable_setOfPred_two_preimages hf.dual_right :) @[deprecated (since := "2026-07-09")] alias AntitoneOn.countable_setOf_two_preimages := AntitoneOn.countable_setOfPred_two_preimages @@ -114,8 +115,9 @@ lemma AntitoneOn.countable_setOfPred_two_preimages [SecondCountableTopology α] are only countably many points that have several preimages. -/ lemma Antitone.countable_setOfPred_two_preimages [SecondCountableTopology α] (hf : Antitone f) : - Set.Countable {c | ∃ x y, x < y ∧ f x = c ∧ f y = c} := - (Monotone.countable_setOfPred_two_preimages hf.dual_right :) + Set.Countable {c | ∃ x y, x < y ∧ f x = c ∧ f y = c} := by + unsealing_newtype OrderDual => + exact (Monotone.countable_setOfPred_two_preimages hf.dual_right :) @[deprecated (since := "2026-07-09")] alias Antitone.countable_setOf_two_preimages := Antitone.countable_setOfPred_two_preimages @@ -146,8 +148,9 @@ theorem MonotoneOn.countable_not_continuousWithinAt_Ioi (hf : MonotoneOn f s) : within a set is at most countable. Superseded by `MonotoneOn.countable_not_continuousWithinAt` which gives the two-sided version. -/ theorem MonotoneOn.countable_not_continuousWithinAt_Iio (hf : MonotoneOn f s) : - Set.Countable {x ∈ s | ¬ContinuousWithinAt f (s ∩ Iio x) x} := - hf.dual.countable_not_continuousWithinAt_Ioi + Set.Countable {x ∈ s | ¬ContinuousWithinAt f (s ∩ Iio x) x} := by + unsealing_newtype OrderDual => + exact hf.dual.countable_not_continuousWithinAt_Ioi /-- In a second countable space, the set of points where a monotone function is not continuous within a set is at most countable. -/ @@ -171,14 +174,16 @@ theorem Monotone.countable_not_continuousAt (hf : Monotone f) : within a set is at most countable. -/ theorem _root_.AntitoneOn.countable_not_continuousWithinAt {s : Set α} (hf : AntitoneOn f s) : - Set.Countable {x ∈ s | ¬ContinuousWithinAt f s x} := - hf.dual_right.countable_not_continuousWithinAt + Set.Countable {x ∈ s | ¬ContinuousWithinAt f s x} := by + unsealing_newtype OrderDual => + exact hf.dual_right.countable_not_continuousWithinAt /-- In a second countable space, the set of points where an antitone function is not continuous is at most countable. -/ theorem Antitone.countable_not_continuousAt (hf : Antitone f) : - Set.Countable {x | ¬ContinuousAt f x} := - hf.dual_right.countable_not_continuousAt + Set.Countable {x | ¬ContinuousAt f x} := by + unsealing_newtype OrderDual => + exact hf.dual_right.countable_not_continuousAt end Continuity @@ -242,15 +247,17 @@ the infimum of the image of this set. -/ theorem MonotoneOn.map_csInf_of_continuousWithinAt {f : α → β} {A : Set α} (Cf : ContinuousWithinAt f A (sInf A)) (Mf : MonotoneOn f A) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : - f (sInf A) = sInf (f '' A) := - MonotoneOn.map_csSup_of_continuousWithinAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd + f (sInf A) = sInf (f '' A) := by + unsealing_newtype OrderDual => + exact MonotoneOn.map_csSup_of_continuousWithinAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd /-- A monotone function continuous at the infimum of a nonempty set sends this infimum to the infimum of the image of this set. -/ theorem Monotone.map_csInf_of_continuousAt {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A)) (Mf : Monotone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : - f (sInf A) = sInf (f '' A) := - Monotone.map_csSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd + f (sInf A) = sInf (f '' A) := by + unsealing_newtype OrderDual => + exact Monotone.map_csSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual A_nonemp A_bdd /-- A monotone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed infimum to the indexed infimum of the composition. -/ @@ -265,15 +272,17 @@ the supremum of the image of this set. -/ theorem AntitoneOn.map_csInf_of_continuousWithinAt {f : α → β} {A : Set α} (Cf : ContinuousWithinAt f A (sInf A)) (Af : AntitoneOn f A) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : - f (sInf A) = sSup (f '' A) := - MonotoneOn.map_csInf_of_continuousWithinAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + f (sInf A) = sSup (f '' A) := by + unsealing_newtype OrderDual => + exact MonotoneOn.map_csInf_of_continuousWithinAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd /-- An antitone function continuous at the infimum of a nonempty set sends this infimum to the supremum of the image of this set. -/ theorem Antitone.map_csInf_of_continuousAt {f : α → β} {A : Set α} (Cf : ContinuousAt f (sInf A)) (Af : Antitone f) (A_nonemp : A.Nonempty) (A_bdd : BddBelow A := by bddDefault) : - f (sInf A) = sSup (f '' A) := - Monotone.map_csInf_of_continuousAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + f (sInf A) = sSup (f '' A) := by + unsealing_newtype OrderDual => + exact Monotone.map_csInf_of_continuousAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd /-- An antitone function continuous at the indexed infimum over a nonempty `Sort` sends this indexed infimum to the indexed supremum of the composition. -/ @@ -288,15 +297,17 @@ the infimum of the image of this set. -/ theorem AntitoneOn.map_csSup_of_continuousWithinAt {f : α → β} {A : Set α} (Cf : ContinuousWithinAt f A (sSup A)) (Af : AntitoneOn f A) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) : - f (sSup A) = sInf (f '' A) := - MonotoneOn.map_csSup_of_continuousWithinAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + f (sSup A) = sInf (f '' A) := by + unsealing_newtype OrderDual => + exact MonotoneOn.map_csSup_of_continuousWithinAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd /-- An antitone function continuous at the supremum of a nonempty set sends this supremum to the infimum of the image of this set. -/ theorem Antitone.map_csSup_of_continuousAt {f : α → β} {A : Set α} (Cf : ContinuousAt f (sSup A)) (Af : Antitone f) (A_nonemp : A.Nonempty) (A_bdd : BddAbove A := by bddDefault) : - f (sSup A) = sInf (f '' A) := - Monotone.map_csSup_of_continuousAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd + f (sSup A) = sInf (f '' A) := by + unsealing_newtype OrderDual => + exact Monotone.map_csSup_of_continuousAt (β := βᵒᵈ) Cf Af.dual_right A_nonemp A_bdd /-- An antitone function continuous at the indexed supremum over a nonempty `Sort` sends this indexed supremum to the indexed infimum of the composition. -/ @@ -351,65 +362,76 @@ theorem Monotone.map_iSup_of_continuousAt {ι : Sort*} {f : α → β} {g : ι this infimum to the infimum of the image of this set. -/ theorem MonotoneOn.map_sInf_of_continuousWithinAt {f : α → β} {s : Set α} (Cf : ContinuousWithinAt f s (sInf s)) (Mf : MonotoneOn f s) (ftop : f ⊤ = ⊤) : - f (sInf s) = sInf (f '' s) := - MonotoneOn.map_sSup_of_continuousWithinAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop + f (sInf s) = sInf (f '' s) := by + unsealing_newtype OrderDual => + exact MonotoneOn.map_sSup_of_continuousWithinAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop /-- A monotone function `f` sending `top` to `top` and continuous at the infimum of a set sends this infimum to the infimum of the image of this set. -/ theorem Monotone.map_sInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s)) - (Mf : Monotone f) (ftop : f ⊤ = ⊤) : f (sInf s) = sInf (f '' s) := - Monotone.map_sSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop + (Mf : Monotone f) (ftop : f ⊤ = ⊤) : f (sInf s) = sInf (f '' s) := by + unsealing_newtype OrderDual => + exact Monotone.map_sSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop /-- If a monotone function sending `top` to `top` is continuous at the indexed infimum over a `Sort`, then it sends this indexed infimum to the indexed infimum of the composition. -/ theorem Monotone.map_iInf_of_continuousAt {ι : Sort*} {f : α → β} {g : ι → α} - (Cf : ContinuousAt f (iInf g)) (Mf : Monotone f) (ftop : f ⊤ = ⊤) : f (iInf g) = iInf (f ∘ g) := - Monotone.map_iSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop + (Cf : ContinuousAt f (iInf g)) (Mf : Monotone f) (ftop : f ⊤ = ⊤) : + f (iInf g) = iInf (f ∘ g) := by + unsealing_newtype OrderDual => + exact Monotone.map_iSup_of_continuousAt (α := αᵒᵈ) (β := βᵒᵈ) Cf Mf.dual ftop /-- An antitone function `f` sending `bot` to `top` and continuous at the supremum of a set sends this supremum to the infimum of the image of this set. -/ theorem AntitoneOn.map_sSup_of_continuousWithinAt {f : α → β} {s : Set α} (Cf : ContinuousWithinAt f s (sSup s)) (Af : AntitoneOn f s) (fbot : f ⊥ = ⊤) : - f (sSup s) = sInf (f '' s) := - MonotoneOn.map_sSup_of_continuousWithinAt - (show ContinuousWithinAt (OrderDual.toDual ∘ f) s (sSup s) from Cf) Af fbot + f (sSup s) = sInf (f '' s) := by + unsealing_newtype OrderDual => + exact MonotoneOn.map_sSup_of_continuousWithinAt + (show ContinuousWithinAt (OrderDual.toDual ∘ f) s (sSup s) from Cf) Af fbot /-- An antitone function `f` sending `bot` to `top` and continuous at the supremum of a set sends this supremum to the infimum of the image of this set. -/ theorem Antitone.map_sSup_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sSup s)) - (Af : Antitone f) (fbot : f ⊥ = ⊤) : f (sSup s) = sInf (f '' s) := - Monotone.map_sSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (sSup s) from Cf) Af - fbot + (Af : Antitone f) (fbot : f ⊥ = ⊤) : f (sSup s) = sInf (f '' s) := by + unsealing_newtype OrderDual => + exact Monotone.map_sSup_of_continuousAt + (show ContinuousAt (OrderDual.toDual ∘ f) (sSup s) from Cf) Af fbot /-- An antitone function sending `bot` to `top` is continuous at the indexed supremum over a `Sort`, then it sends this indexed supremum to the indexed supremum of the composition. -/ theorem Antitone.map_iSup_of_continuousAt {ι : Sort*} {f : α → β} {g : ι → α} (Cf : ContinuousAt f (iSup g)) (Af : Antitone f) (fbot : f ⊥ = ⊤) : - f (⨆ i, g i) = ⨅ i, f (g i) := - Monotone.map_iSup_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (iSup g) from Cf) Af - fbot + f (⨆ i, g i) = ⨅ i, f (g i) := by + unsealing_newtype OrderDual => + exact Monotone.map_iSup_of_continuousAt + (show ContinuousAt (OrderDual.toDual ∘ f) (iSup g) from Cf) Af fbot /-- An antitone function `f` sending `top` to `bot` and continuous at the infimum of a set sends this infimum to the supremum of the image of this set. -/ theorem AntitoneOn.map_sInf_of_continuousWithinAt {f : α → β} {s : Set α} (Cf : ContinuousWithinAt f s (sInf s)) (Af : AntitoneOn f s) (ftop : f ⊤ = ⊥) : - f (sInf s) = sSup (f '' s) := - MonotoneOn.map_sInf_of_continuousWithinAt - (show ContinuousWithinAt (OrderDual.toDual ∘ f) s (sInf s) from Cf) Af ftop + f (sInf s) = sSup (f '' s) := by + unsealing_newtype OrderDual => + exact MonotoneOn.map_sInf_of_continuousWithinAt + (show ContinuousWithinAt (OrderDual.toDual ∘ f) s (sInf s) from Cf) Af ftop /-- An antitone function `f` sending `top` to `bot` and continuous at the infimum of a set sends this infimum to the supremum of the image of this set. -/ theorem Antitone.map_sInf_of_continuousAt {f : α → β} {s : Set α} (Cf : ContinuousAt f (sInf s)) - (Af : Antitone f) (ftop : f ⊤ = ⊥) : f (sInf s) = sSup (f '' s) := - Monotone.map_sInf_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (sInf s) from Cf) Af - ftop + (Af : Antitone f) (ftop : f ⊤ = ⊥) : f (sInf s) = sSup (f '' s) := by + unsealing_newtype OrderDual => + exact Monotone.map_sInf_of_continuousAt + (show ContinuousAt (OrderDual.toDual ∘ f) (sInf s) from Cf) Af ftop /-- If an antitone function sending `top` to `bot` is continuous at the indexed infimum over a `Sort`, then it sends this indexed infimum to the indexed supremum of the composition. -/ theorem Antitone.map_iInf_of_continuousAt {ι : Sort*} {f : α → β} {g : ι → α} - (Cf : ContinuousAt f (iInf g)) (Af : Antitone f) (ftop : f ⊤ = ⊥) : f (iInf g) = iSup (f ∘ g) := - Monotone.map_iInf_of_continuousAt (show ContinuousAt (OrderDual.toDual ∘ f) (iInf g) from Cf) Af - ftop + (Cf : ContinuousAt f (iInf g)) (Af : Antitone f) (ftop : f ⊤ = ⊥) : + f (iInf g) = iSup (f ∘ g) := by + unsealing_newtype OrderDual => + exact Monotone.map_iInf_of_continuousAt + (show ContinuousAt (OrderDual.toDual ∘ f) (iInf g) from Cf) Af ftop end CompleteLinearOrder @@ -437,7 +459,7 @@ theorem IsClosed.isLeast_csInf {s : Set α} (hc : IsClosed s) (hs : s.Nonempty) theorem IsClosed.isGreatest_csSup {s : Set α} (hc : IsClosed s) (hs : s.Nonempty) (B : BddAbove s) : IsGreatest s (sSup s) := - IsClosed.isLeast_csInf (α := αᵒᵈ) hc hs B + ⟨hc.csSup_mem hs B, (isLUB_csSup hs B).1⟩ lemma MonotoneOn.tendsto_nhdsWithin_Ioo_left {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] @@ -485,8 +507,9 @@ lemma MonotoneOn.tendsto_nhdsLT {α β : Type*} [LinearOrder α] [TopologicalSpa lemma MonotoneOn.tendsto_nhdsGT {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} {x : α} (Mf : MonotoneOn f (Ioi x)) (h_bdd : BddBelow (f '' Ioi x)) : - Tendsto f (𝓝[>] x) (𝓝 (sInf (f '' Ioi x))) := - MonotoneOn.tendsto_nhdsLT (α := αᵒᵈ) (β := βᵒᵈ) Mf.dual h_bdd + Tendsto f (𝓝[>] x) (𝓝 (sInf (f '' Ioi x))) := by + unsealing_newtype OrderDual => + exact MonotoneOn.tendsto_nhdsLT (α := αᵒᵈ) (β := βᵒᵈ) Mf.dual h_bdd /-- A monotone map has a limit to the left of any point `x`, equal to `sSup (f '' (Iio x))`. -/ theorem Monotone.tendsto_nhdsLT {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] @@ -497,45 +520,52 @@ theorem Monotone.tendsto_nhdsLT {α β : Type*} [LinearOrder α] [TopologicalSpa /-- A monotone map has a limit to the right of any point `x`, equal to `sInf (f '' (Ioi x))`. -/ theorem Monotone.tendsto_nhdsGT {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} - (Mf : Monotone f) (x : α) : Tendsto f (𝓝[>] x) (𝓝 (sInf (f '' Ioi x))) := - Monotone.tendsto_nhdsLT (α := αᵒᵈ) (β := βᵒᵈ) Mf.dual x + (Mf : Monotone f) (x : α) : Tendsto f (𝓝[>] x) (𝓝 (sInf (f '' Ioi x))) := by + unsealing_newtype OrderDual => + exact Monotone.tendsto_nhdsLT (α := αᵒᵈ) (β := βᵒᵈ) Mf.dual x lemma AntitoneOn.tendsto_nhdsWithin_Ioo_left {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} {x y : α} (h_nonempty : (Ioo y x).Nonempty) (Af : AntitoneOn f (Ioo y x)) (h_bdd : BddBelow (f '' Ioo y x)) : - Tendsto f (𝓝[<] x) (𝓝 (sInf (f '' Ioo y x))) := - MonotoneOn.tendsto_nhdsWithin_Ioo_left h_nonempty Af.dual_right h_bdd + Tendsto f (𝓝[<] x) (𝓝 (sInf (f '' Ioo y x))) := by + unsealing_newtype OrderDual => + exact MonotoneOn.tendsto_nhdsWithin_Ioo_left h_nonempty Af.dual_right h_bdd lemma AntitoneOn.tendsto_nhdsWithin_Ioo_right {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} {x y : α} (h_nonempty : (Ioo x y).Nonempty) (Af : AntitoneOn f (Ioo x y)) (h_bdd : BddAbove (f '' Ioo x y)) : - Tendsto f (𝓝[>] x) (𝓝 (sSup (f '' Ioo x y))) := - MonotoneOn.tendsto_nhdsWithin_Ioo_right h_nonempty Af.dual_right h_bdd + Tendsto f (𝓝[>] x) (𝓝 (sSup (f '' Ioo x y))) := by + unsealing_newtype OrderDual => + exact MonotoneOn.tendsto_nhdsWithin_Ioo_right h_nonempty Af.dual_right h_bdd lemma AntitoneOn.tendsto_nhdsLT {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} {x : α} (Af : AntitoneOn f (Iio x)) (h_bdd : BddBelow (f '' Iio x)) : - Tendsto f (𝓝[<] x) (𝓝 (sInf (f '' Iio x))) := - MonotoneOn.tendsto_nhdsLT Af.dual_right h_bdd + Tendsto f (𝓝[<] x) (𝓝 (sInf (f '' Iio x))) := by + unsealing_newtype OrderDual => + exact MonotoneOn.tendsto_nhdsLT Af.dual_right h_bdd lemma AntitoneOn.tendsto_nhdsGT {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} {x : α} (Af : AntitoneOn f (Ioi x)) (h_bdd : BddAbove (f '' Ioi x)) : - Tendsto f (𝓝[>] x) (𝓝 (sSup (f '' Ioi x))) := - MonotoneOn.tendsto_nhdsGT Af.dual_right h_bdd + Tendsto f (𝓝[>] x) (𝓝 (sSup (f '' Ioi x))) := by + unsealing_newtype OrderDual => + exact MonotoneOn.tendsto_nhdsGT Af.dual_right h_bdd /-- An antitone map has a limit to the left of any point `x`, equal to `sInf (f '' (Iio x))`. -/ theorem Antitone.tendsto_nhdsLT {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} - (Af : Antitone f) (x : α) : Tendsto f (𝓝[<] x) (𝓝 (sInf (f '' Iio x))) := - Monotone.tendsto_nhdsLT Af.dual_right x + (Af : Antitone f) (x : α) : Tendsto f (𝓝[<] x) (𝓝 (sInf (f '' Iio x))) := by + unsealing_newtype OrderDual => + exact Monotone.tendsto_nhdsLT Af.dual_right x /-- An antitone map has a limit to the right of any point `x`, equal to `sSup (f '' (Ioi x))`. -/ theorem Antitone.tendsto_nhdsGT {α β : Type*} [LinearOrder α] [TopologicalSpace α] [OrderTopology α] [ConditionallyCompleteLinearOrder β] [TopologicalSpace β] [OrderTopology β] {f : α → β} - (Af : Antitone f) (x : α) : Tendsto f (𝓝[>] x) (𝓝 (sSup (f '' Ioi x))) := - Monotone.tendsto_nhdsGT Af.dual_right x + (Af : Antitone f) (x : α) : Tendsto f (𝓝[>] x) (𝓝 (sSup (f '' Ioi x))) := by + unsealing_newtype OrderDual => + exact Monotone.tendsto_nhdsGT Af.dual_right x end ConditionallyCompleteLinearOrder diff --git a/mathlib4/Mathlib/Topology/Order/MonotoneContinuity.lean b/mathlib4/Mathlib/Topology/Order/MonotoneContinuity.lean index f26fcdf43..5d64988f9 100644 --- a/mathlib4/Mathlib/Topology/Order/MonotoneContinuity.lean +++ b/mathlib4/Mathlib/Topology/Order/MonotoneContinuity.lean @@ -130,10 +130,11 @@ function `f : ℝ → ℝ` given by `f x = if x < 0 then x else x + 1` would be `a = 0`. -/ theorem StrictMonoOn.continuousWithinAt_left_of_exists_between {f : α → β} {s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : ∀ b < f a, ∃ c ∈ s, f c ∈ Ico b (f a)) : - ContinuousWithinAt f (Iic a) a := - h_mono.dual.continuousWithinAt_right_of_exists_between hs fun b hb => - let ⟨c, hcs, hcb, hca⟩ := hfs b hb - ⟨c, hcs, hca, hcb⟩ + ContinuousWithinAt f (Iic a) a := by + unsealing_newtype OrderDual => + exact h_mono.dual.continuousWithinAt_right_of_exists_between hs fun b hb => + let ⟨c, hcs, hcb, hca⟩ := hfs b hb + ⟨c, hcs, hca, hcb⟩ /-- If `f` is a monotone function on a left neighborhood of `a` and the image of this neighborhood under `f` meets every interval `(b, f a)`, `b < f a`, then `f` is continuous at `a` from the left. @@ -143,20 +144,24 @@ assumption `hfs : ∀ b < f a, ∃ c ∈ s, f c ∈ Ico b (f a)` we use for stri because otherwise the function `floor : ℝ → ℤ` would be a counter-example at `a = 0`. -/ theorem continuousWithinAt_left_of_monotoneOn_of_exists_between {f : α → β} {s : Set α} {a : α} (hf : MonotoneOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : ∀ b < f a, ∃ c ∈ s, f c ∈ Ioo b (f a)) : - ContinuousWithinAt f (Iic a) a := - @continuousWithinAt_right_of_monotoneOn_of_exists_between αᵒᵈ βᵒᵈ _ _ _ _ _ _ f s a hf.dual hs - fun b hb => - let ⟨c, hcs, hcb, hca⟩ := hfs b hb - ⟨c, hcs, hca, hcb⟩ + ContinuousWithinAt f (Iic a) a := by + unsealing_newtype OrderDual => + exact @continuousWithinAt_right_of_monotoneOn_of_exists_between + αᵒᵈ βᵒᵈ _ _ _ _ _ _ f s a hf.dual hs + fun b hb => + let ⟨c, hcs, hcb, hca⟩ := hfs b hb + ⟨c, hcs, hca, hcb⟩ /-- If a function `f` with a densely ordered codomain is monotone on a left neighborhood of `a` and the closure of the image of this neighborhood under `f` is a left neighborhood of `f a`, then `f` is continuous at `a` from the left -/ theorem continuousWithinAt_left_of_monotoneOn_of_closure_image_mem_nhdsWithin [DenselyOrdered β] {f : α → β} {s : Set α} {a : α} (hf : MonotoneOn f s) (hs : s ∈ 𝓝[≤] a) - (hfs : closure (f '' s) ∈ 𝓝[≤] f a) : ContinuousWithinAt f (Iic a) a := - @continuousWithinAt_right_of_monotoneOn_of_closure_image_mem_nhdsWithin αᵒᵈ βᵒᵈ _ _ _ _ _ _ _ f s - a hf.dual hs hfs + (hfs : closure (f '' s) ∈ 𝓝[≤] f a) : ContinuousWithinAt f (Iic a) a := by + unsealing_newtype OrderDual => + exact @continuousWithinAt_right_of_monotoneOn_of_closure_image_mem_nhdsWithin + αᵒᵈ βᵒᵈ _ _ _ _ _ _ _ f s + a hf.dual hs hfs /-- If a function `f` with a densely ordered codomain is monotone on a left neighborhood of `a` and the image of this neighborhood under `f` is a left neighborhood of `f a`, then `f` is continuous at @@ -172,23 +177,26 @@ theorem continuousWithinAt_left_of_monotoneOn_of_image_mem_nhdsWithin [DenselyOr then `f` is continuous at `a` from the left. -/ theorem StrictMonoOn.continuousWithinAt_left_of_closure_image_mem_nhdsWithin [DenselyOrdered β] {f : α → β} {s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≤] a) - (hfs : closure (f '' s) ∈ 𝓝[≤] f a) : ContinuousWithinAt f (Iic a) a := - h_mono.dual.continuousWithinAt_right_of_closure_image_mem_nhdsWithin hs hfs + (hfs : closure (f '' s) ∈ 𝓝[≤] f a) : ContinuousWithinAt f (Iic a) a := by + unsealing_newtype OrderDual => + exact h_mono.dual.continuousWithinAt_right_of_closure_image_mem_nhdsWithin hs hfs /-- If a function `f` with a densely ordered codomain is strictly monotone on a left neighborhood of `a` and the image of this neighborhood under `f` is a left neighborhood of `f a`, then `f` is continuous at `a` from the left. -/ theorem StrictMonoOn.continuousWithinAt_left_of_image_mem_nhdsWithin [DenselyOrdered β] {f : α → β} {s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : f '' s ∈ 𝓝[≤] f a) : - ContinuousWithinAt f (Iic a) a := - h_mono.dual.continuousWithinAt_right_of_image_mem_nhdsWithin hs hfs + ContinuousWithinAt f (Iic a) a := by + unsealing_newtype OrderDual => + exact h_mono.dual.continuousWithinAt_right_of_image_mem_nhdsWithin hs hfs /-- If a function `f` is strictly monotone on a left neighborhood of `a` and the image of this neighborhood under `f` includes `Iio (f a)`, then `f` is continuous at `a` from the left. -/ theorem StrictMonoOn.continuousWithinAt_left_of_surjOn {f : α → β} {s : Set α} {a : α} (h_mono : StrictMonoOn f s) (hs : s ∈ 𝓝[≤] a) (hfs : SurjOn f s (Iio (f a))) : - ContinuousWithinAt f (Iic a) a := - h_mono.dual.continuousWithinAt_right_of_surjOn hs hfs + ContinuousWithinAt f (Iic a) a := by + unsealing_newtype OrderDual => + exact h_mono.dual.continuousWithinAt_right_of_surjOn hs hfs /-- If a function `f` is strictly monotone on a neighborhood of `a` and the image of this neighborhood under `f` meets every interval `[b, f a)`, `b < f a`, and every interval diff --git a/mathlib4/Mathlib/Topology/Order/MonotoneConvergence.lean b/mathlib4/Mathlib/Topology/Order/MonotoneConvergence.lean index 233563619..399c36626 100644 --- a/mathlib4/Mathlib/Topology/Order/MonotoneConvergence.lean +++ b/mathlib4/Mathlib/Topology/Order/MonotoneConvergence.lean @@ -34,6 +34,18 @@ open scoped Topology variable {α β : Type*} +open OrderDual in +private lemma tendsto_subtype_ofDual [Preorder α] {s : Set αᵒᵈ} : + Tendsto (fun y : s ↦ (⟨ofDual y.1, y.2⟩ : ↥(toDual ⁻¹' s))) atTop atBot := + tendsto_atBot.2 fun b ↦ + mem_of_superset (Ici_mem_atTop (⟨toDual b.1, b.2⟩ : ↥s)) fun _ hx ↦ hx + +open OrderDual in +private lemma tendsto_subtype_ofDual' [Preorder α] {s : Set αᵒᵈ} : + Tendsto (fun y : s ↦ (⟨ofDual y.1, y.2⟩ : ↥(toDual ⁻¹' s))) atBot atTop := + tendsto_atTop.2 fun b ↦ + mem_of_superset (Iic_mem_atBot (⟨toDual b.1, b.2⟩ : ↥s)) fun _ hx ↦ hx + /-- We say that `α` is a `SupConvergenceClass` if the following holds. Let `f : ι → α` be a monotone function, let `a : α` be a least upper bound of `Set.range f`. Then `f x` tends to `𝓝 a` as `x → ∞` (formally, at the filter `Filter.atTop`). We require this for `ι = (s : Set α)`, @@ -58,11 +70,15 @@ class InfConvergenceClass (α : Type*) [Preorder α] [TopologicalSpace α] : Pro instance OrderDual.supConvergenceClass [Preorder α] [TopologicalSpace α] [InfConvergenceClass α] : SupConvergenceClass αᵒᵈ := - ⟨‹InfConvergenceClass α›.1⟩ + ⟨fun a s ha ↦ (continuous_toDual.tendsto _).comp + ((InfConvergenceClass.tendsto_coe_atBot_isGLB (OrderDual.ofDual a) + (OrderDual.toDual ⁻¹' s) (isGLB_preimage_toDual.2 ha)).comp tendsto_subtype_ofDual)⟩ instance OrderDual.infConvergenceClass [Preorder α] [TopologicalSpace α] [SupConvergenceClass α] : InfConvergenceClass αᵒᵈ := - ⟨‹SupConvergenceClass α›.1⟩ + ⟨fun a s ha ↦ (continuous_toDual.tendsto _).comp + ((SupConvergenceClass.tendsto_coe_atTop_isLUB (OrderDual.ofDual a) + (OrderDual.toDual ⁻¹' s) (isLUB_preimage_toDual.2 ha)).comp tendsto_subtype_ofDual')⟩ -- see Note [lower instance priority] instance (priority := 100) LinearOrder.supConvergenceClass [TopologicalSpace α] [LinearOrder α] @@ -75,8 +91,9 @@ instance (priority := 100) LinearOrder.supConvergenceClass [TopologicalSpace α] -- see Note [lower instance priority] instance (priority := 100) LinearOrder.infConvergenceClass [TopologicalSpace α] [LinearOrder α] - [OrderTopology α] : InfConvergenceClass α := - show InfConvergenceClass αᵒᵈᵒᵈ from OrderDual.infConvergenceClass + [OrderTopology α] : InfConvergenceClass α := by + unsealing_newtype OrderDual => + exact show InfConvergenceClass αᵒᵈᵒᵈ from OrderDual.infConvergenceClass section @@ -93,7 +110,9 @@ theorem tendsto_atTop_isLUB (h_mono : Monotone f) (ha : IsLUB (Set.range f) a) : exact h_mono.rangeFactorization.tendsto_atTop_atTop fun b => b.2.imp fun a ha => ha.ge theorem tendsto_atBot_isLUB (h_anti : Antitone f) (ha : IsLUB (Set.range f) a) : - Tendsto f atBot (𝓝 a) := by convert! tendsto_atTop_isLUB h_anti.dual_left ha using 1 + Tendsto f atBot (𝓝 a) := by + unsealing_newtype OrderDual => + convert! tendsto_atTop_isLUB h_anti.dual_left ha using 1 end IsLUB @@ -102,10 +121,14 @@ section IsGLB variable [Preorder α] [InfConvergenceClass α] {f : ι → α} {a : α} theorem tendsto_atBot_isGLB (h_mono : Monotone f) (ha : IsGLB (Set.range f) a) : - Tendsto f atBot (𝓝 a) := by convert! tendsto_atTop_isLUB h_mono.dual ha.dual using 1 + Tendsto f atBot (𝓝 a) := by + unsealing_newtype OrderDual => + convert! tendsto_atTop_isLUB h_mono.dual ha.dual using 1 theorem tendsto_atTop_isGLB (h_anti : Antitone f) (ha : IsGLB (Set.range f) a) : - Tendsto f atTop (𝓝 a) := by convert! tendsto_atBot_isLUB h_anti.dual ha.dual using 1 + Tendsto f atTop (𝓝 a) := by + unsealing_newtype OrderDual => + convert! tendsto_atBot_isLUB h_anti.dual ha.dual using 1 end IsGLB @@ -124,7 +147,9 @@ theorem tendsto_atTop_ciSup (h_mono : Monotone f) (hbdd : BddAbove <| range f) : h_mono.directed_le.directedOn_range.isLUB_csSup (Set.range_nonempty f) hbdd theorem tendsto_atBot_ciSup (h_anti : Antitone f) (hbdd : BddAbove <| range f) : - Tendsto f atBot (𝓝 (⨆ i, f i)) := by convert! tendsto_atTop_ciSup h_anti.dual hbdd.dual using 1 + Tendsto f atBot (𝓝 (⨆ i, f i)) := by + unsealing_newtype OrderDual => + convert! tendsto_atTop_ciSup h_anti.dual hbdd.dual using 1 end ConditionallyCompletePartialOrder @@ -147,10 +172,14 @@ section ConditionallyCompletePartialOrder variable [ConditionallyCompletePartialOrderInf α] [InfConvergenceClass α] {f : ι → α} theorem tendsto_atBot_ciInf (h_mono : Monotone f) (hbdd : BddBelow <| range f) : - Tendsto f atBot (𝓝 (⨅ i, f i)) := by convert! tendsto_atTop_ciSup h_mono.dual hbdd.dual using 1 + Tendsto f atBot (𝓝 (⨅ i, f i)) := by + unsealing_newtype OrderDual => + convert! tendsto_atTop_ciSup h_mono.dual hbdd.dual using 1 theorem tendsto_atTop_ciInf (h_anti : Antitone f) (hbdd : BddBelow <| range f) : - Tendsto f atTop (𝓝 (⨅ i, f i)) := by convert! tendsto_atBot_ciSup h_anti.dual hbdd.dual using 1 + Tendsto f atTop (𝓝 (⨅ i, f i)) := by + unsealing_newtype OrderDual => + convert! tendsto_atBot_ciSup h_anti.dual hbdd.dual using 1 end ConditionallyCompletePartialOrder @@ -158,8 +187,9 @@ section ConditionallyCompleteLattice theorem tendsto_finsetInf_ciInf {ι} [ConditionallyCompleteLattice α] [OrderTop α] [InfConvergenceClass α] [Nonempty ι] {a : ι → α} (ha : BddBelow (range a)) : - Tendsto (fun F : Finset ι => F.inf a) atTop (𝓝 (⨅ i, a i)) := - tendsto_finsetSup_ciSup (α := αᵒᵈ) ha + Tendsto (fun F : Finset ι => F.inf a) atTop (𝓝 (⨅ i, a i)) := by + unsealing_newtype OrderDual => + exact tendsto_finsetSup_ciSup (α := αᵒᵈ) ha end ConditionallyCompleteLattice @@ -190,8 +220,9 @@ theorem tendsto_atBot_iInf (h_mono : Monotone f) : Tendsto f atBot (𝓝 (⨅ i, tendsto_atBot_ciInf h_mono (OrderBot.bddBelow _) theorem tendsto_finsetInf_iInf {ι} (a : ι → α) : - Tendsto (fun F : Finset ι => F.inf a) atTop (𝓝 (⨅ i, a i)) := - tendsto_finsetSup_iSup (α := αᵒᵈ) a + Tendsto (fun F : Finset ι => F.inf a) atTop (𝓝 (⨅ i, a i)) := by + unsealing_newtype OrderDual => + exact tendsto_finsetSup_iSup (α := αᵒᵈ) a theorem tendsto_atTop_iInf (h_anti : Antitone f) : Tendsto f atTop (𝓝 (⨅ i, f i)) := tendsto_atTop_ciInf h_anti (OrderBot.bddBelow _) @@ -212,9 +243,17 @@ instance Prod.supConvergenceClass tendsto_atTop_isLUB (monotone_snd.domRestrict s) h.2 exact A.prodMk_nhds B -instance [Preorder α] [Preorder β] [TopologicalSpace α] [TopologicalSpace β] [InfConvergenceClass α] - [InfConvergenceClass β] : InfConvergenceClass (α × β) := - show InfConvergenceClass (αᵒᵈ × βᵒᵈ)ᵒᵈ from OrderDual.infConvergenceClass +instance Prod.infConvergenceClass + [Preorder α] [Preorder β] [TopologicalSpace α] [TopologicalSpace β] [InfConvergenceClass α] + [InfConvergenceClass β] : InfConvergenceClass (α × β) := by + constructor + rintro ⟨a, b⟩ s h + rw [isGLB_prod, ← range_domRestrict, ← range_domRestrict] at h + have A : Tendsto (fun x : s => (x : α × β).1) atBot (𝓝 a) := + tendsto_atBot_isGLB (monotone_fst.domRestrict s) h.1 + have B : Tendsto (fun x : s => (x : α × β).2) atBot (𝓝 b) := + tendsto_atBot_isGLB (monotone_snd.domRestrict s) h.2 + exact A.prodMk_nhds B instance Pi.supConvergenceClass {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] @@ -225,8 +264,9 @@ instance Pi.supConvergenceClass instance Pi.infConvergenceClass {ι : Type*} {α : ι → Type*} [∀ i, Preorder (α i)] [∀ i, TopologicalSpace (α i)] - [∀ i, InfConvergenceClass (α i)] : InfConvergenceClass (∀ i, α i) := - show InfConvergenceClass (∀ i, (α i)ᵒᵈ)ᵒᵈ from OrderDual.infConvergenceClass + [∀ i, InfConvergenceClass (α i)] : InfConvergenceClass (∀ i, α i) := by + unsealing_newtype OrderDual => + exact show InfConvergenceClass (∀ i, (α i)ᵒᵈ)ᵒᵈ from OrderDual.infConvergenceClass instance Pi.supConvergenceClass' {ι : Type*} [Preorder α] [TopologicalSpace α] [SupConvergenceClass α] : SupConvergenceClass (ι → α) := @@ -245,18 +285,21 @@ theorem tendsto_atTop_of_monotone {ι α : Type*} [Preorder ι] [TopologicalSpac theorem tendsto_atTop_of_antitone {ι α : Type*} [Preorder ι] [TopologicalSpace α] [ConditionallyCompleteLinearOrder α] [OrderTopology α] {f : ι → α} (h_mono : Antitone f) : - Tendsto f atTop atBot ∨ ∃ l, Tendsto f atTop (𝓝 l) := - tendsto_atTop_of_monotone (α := αᵒᵈ) h_mono + Tendsto f atTop atBot ∨ ∃ l, Tendsto f atTop (𝓝 l) := by + unsealing_newtype OrderDual => + exact tendsto_atTop_of_monotone (α := αᵒᵈ) h_mono theorem tendsto_atBot_of_monotone {ι α : Type*} [Preorder ι] [TopologicalSpace α] [ConditionallyCompleteLinearOrder α] [OrderTopology α] {f : ι → α} (h_mono : Monotone f) : - Tendsto f atBot atBot ∨ ∃ l, Tendsto f atBot (𝓝 l) := - tendsto_atTop_of_monotone (ι := ιᵒᵈ) (α := αᵒᵈ) h_mono.dual + Tendsto f atBot atBot ∨ ∃ l, Tendsto f atBot (𝓝 l) := by + unsealing_newtype OrderDual => + exact tendsto_atTop_of_monotone (ι := ιᵒᵈ) (α := αᵒᵈ) h_mono.dual theorem tendsto_atBot_of_antitone {ι α : Type*} [Preorder ι] [TopologicalSpace α] [ConditionallyCompleteLinearOrder α] [OrderTopology α] {f : ι → α} (h_mono : Antitone f) : - Tendsto f atBot atTop ∨ ∃ l, Tendsto f atBot (𝓝 l) := - tendsto_atTop_of_antitone (ι := ιᵒᵈ) (α := αᵒᵈ) h_mono.dual + Tendsto f atBot atTop ∨ ∃ l, Tendsto f atBot (𝓝 l) := by + unsealing_newtype OrderDual => + exact tendsto_atTop_of_antitone (ι := ιᵒᵈ) (α := αᵒᵈ) h_mono.dual theorem tendsto_iff_tendsto_subseq_of_monotone {ι₁ ι₂ α : Type*} [SemilatticeSup ι₁] [Preorder ι₂] [Nonempty ι₁] [TopologicalSpace α] [ConditionallyCompleteLinearOrder α] [OrderTopology α] @@ -271,8 +314,9 @@ theorem tendsto_iff_tendsto_subseq_of_monotone {ι₁ ι₂ α : Type*} [Semilat theorem tendsto_iff_tendsto_subseq_of_antitone {ι₁ ι₂ α : Type*} [SemilatticeSup ι₁] [Preorder ι₂] [Nonempty ι₁] [TopologicalSpace α] [ConditionallyCompleteLinearOrder α] [OrderTopology α] [NoMinOrder α] {f : ι₂ → α} {φ : ι₁ → ι₂} {l : α} (hf : Antitone f) - (hg : Tendsto φ atTop atTop) : Tendsto f atTop (𝓝 l) ↔ Tendsto (f ∘ φ) atTop (𝓝 l) := - tendsto_iff_tendsto_subseq_of_monotone (α := αᵒᵈ) hf hg + (hg : Tendsto φ atTop atTop) : Tendsto f atTop (𝓝 l) ↔ Tendsto (f ∘ φ) atTop (𝓝 l) := by + unsealing_newtype OrderDual => + exact tendsto_iff_tendsto_subseq_of_monotone (α := αᵒᵈ) hf hg /-! The next family of results, such as `isLUB_of_tendsto_atTop` and `iSup_eq_of_tendsto`, are converses to the standard fact that bounded monotone functions converge. They state, that if a @@ -289,23 +333,25 @@ theorem Monotone.ge_of_tendsto [TopologicalSpace α] [Preorder α] [OrderClosedT haveI : Nonempty β := Nonempty.intro b _root_.ge_of_tendsto ha ((eventually_ge_atTop b).mono fun _ hxy => hf hxy) +set_option backward.isDefEq.respectTransparency false in theorem Monotone.le_of_tendsto [TopologicalSpace α] [Preorder α] [OrderClosedTopology α] [Preorder β] [IsCodirectedOrder β] {f : β → α} {a : α} (hf : Monotone f) (ha : Tendsto f atBot (𝓝 a)) (b : β) : - a ≤ f b := - hf.dual.ge_of_tendsto ha b + a ≤ f b := by + unsealing_newtype OrderDual => + exact hf.dual.ge_of_tendsto ha b theorem Antitone.le_of_tendsto [TopologicalSpace α] [Preorder α] [OrderClosedTopology α] [Preorder β] [IsDirectedOrder β] {f : β → α} {a : α} (hf : Antitone f) (ha : Tendsto f atTop (𝓝 a)) (b : β) : a ≤ f b := - hf.dual_right.ge_of_tendsto ha b + hf.dual_right.ge_of_tendsto ((continuous_toDual.tendsto _).comp ha) b theorem Antitone.ge_of_tendsto [TopologicalSpace α] [Preorder α] [OrderClosedTopology α] [Preorder β] [IsCodirectedOrder β] {f : β → α} {a : α} (hf : Antitone f) (ha : Tendsto f atBot (𝓝 a)) (b : β) : f b ≤ a := - hf.dual_right.le_of_tendsto ha b + hf.dual_right.le_of_tendsto ((continuous_toDual.tendsto _).comp ha) b theorem isLUB_of_tendsto_atTop [TopologicalSpace α] [Preorder α] [OrderClosedTopology α] [Preorder β] [IsDirectedOrder β] [Nonempty β] {f : β → α} {a : α} (hf : Monotone f) @@ -317,18 +363,21 @@ theorem isLUB_of_tendsto_atTop [TopologicalSpace α] [Preorder α] [OrderClosedT theorem isGLB_of_tendsto_atBot [TopologicalSpace α] [Preorder α] [OrderClosedTopology α] [Preorder β] [IsCodirectedOrder β] [Nonempty β] {f : β → α} {a : α} (hf : Monotone f) - (ha : Tendsto f atBot (𝓝 a)) : IsGLB (Set.range f) a := - isLUB_of_tendsto_atTop (α := αᵒᵈ) (β := βᵒᵈ) hf.dual ha + (ha : Tendsto f atBot (𝓝 a)) : IsGLB (Set.range f) a := by + unsealing_newtype OrderDual => + exact isLUB_of_tendsto_atTop (α := αᵒᵈ) (β := βᵒᵈ) hf.dual ha theorem isLUB_of_tendsto_atBot [TopologicalSpace α] [Preorder α] [OrderClosedTopology α] [Preorder β] [IsCodirectedOrder β] [Nonempty β] {f : β → α} {a : α} (hf : Antitone f) - (ha : Tendsto f atBot (𝓝 a)) : IsLUB (Set.range f) a := - isLUB_of_tendsto_atTop (α := α) (β := βᵒᵈ) hf.dual_left ha + (ha : Tendsto f atBot (𝓝 a)) : IsLUB (Set.range f) a := by + unsealing_newtype OrderDual => + exact isLUB_of_tendsto_atTop (α := α) (β := βᵒᵈ) hf.dual_left ha theorem isGLB_of_tendsto_atTop [TopologicalSpace α] [Preorder α] [OrderClosedTopology α] [Preorder β] [IsDirectedOrder β] [Nonempty β] {f : β → α} {a : α} (hf : Antitone f) - (ha : Tendsto f atTop (𝓝 a)) : IsGLB (Set.range f) a := - isGLB_of_tendsto_atBot (α := α) (β := βᵒᵈ) hf.dual_left ha + (ha : Tendsto f atTop (𝓝 a)) : IsGLB (Set.range f) a := by + unsealing_newtype OrderDual => + exact isGLB_of_tendsto_atBot (α := α) (β := βᵒᵈ) hf.dual_left ha theorem iSup_eq_of_tendsto {α β} [TopologicalSpace α] [CompleteLinearOrder α] [OrderTopology α] [Nonempty β] [SemilatticeSup β] {f : β → α} {a : α} (hf : Monotone f) : @@ -358,10 +407,12 @@ theorem iSup_eq_iSup_subseq_of_antitone {ι₁ ι₂ α : Type*} [Preorder ι₂ theorem iInf_eq_iInf_subseq_of_monotone {ι₁ ι₂ α : Type*} [Preorder ι₂] [CompleteLattice α] {l : Filter ι₁} [l.NeBot] {f : ι₂ → α} {φ : ι₁ → ι₂} (hf : Monotone f) - (hφ : Tendsto φ l atBot) : ⨅ i, f i = ⨅ i, f (φ i) := - iSup_eq_iSup_subseq_of_monotone hf.dual hφ + (hφ : Tendsto φ l atBot) : ⨅ i, f i = ⨅ i, f (φ i) := by + unsealing_newtype OrderDual => + exact iSup_eq_iSup_subseq_of_monotone hf.dual hφ theorem iInf_eq_iInf_subseq_of_antitone {ι₁ ι₂ α : Type*} [Preorder ι₂] [CompleteLattice α] {l : Filter ι₁} [l.NeBot] {f : ι₂ → α} {φ : ι₁ → ι₂} (hf : Antitone f) - (hφ : Tendsto φ l atTop) : ⨅ i, f i = ⨅ i, f (φ i) := - iSup_eq_iSup_subseq_of_antitone hf.dual hφ + (hφ : Tendsto φ l atTop) : ⨅ i, f i = ⨅ i, f (φ i) := by + unsealing_newtype OrderDual => + exact iSup_eq_iSup_subseq_of_antitone hf.dual hφ diff --git a/mathlib4/Mathlib/Topology/Order/NhdsSet.lean b/mathlib4/Mathlib/Topology/Order/NhdsSet.lean index 81898dc5b..332d55fe9 100644 --- a/mathlib4/Mathlib/Topology/Order/NhdsSet.lean +++ b/mathlib4/Mathlib/Topology/Order/NhdsSet.lean @@ -40,7 +40,9 @@ variable {α : Type*} [LinearOrder α] [TopologicalSpace α] [OrderClosedTopolog theorem nhdsSet_Ici : 𝓝ˢ (Ici a) = 𝓝 a ⊔ 𝓟 (Ioi a) := by rw [← Ioi_insert, nhdsSet_insert, nhdsSet_Ioi] -theorem nhdsSet_Iic : 𝓝ˢ (Iic a) = 𝓝 a ⊔ 𝓟 (Iio a) := nhdsSet_Ici (α := αᵒᵈ) +theorem nhdsSet_Iic : 𝓝ˢ (Iic a) = 𝓝 a ⊔ 𝓟 (Iio a) := by + unsealing_newtype OrderDual => + exact nhdsSet_Ici (α := αᵒᵈ) theorem nhdsSet_Ico (h : a < b) : 𝓝ˢ (Ico a b) = 𝓝 a ⊔ 𝓟 (Ioo a b) := by rw [← Ioo_insert_left h, nhdsSet_insert, nhdsSet_Ioo] @@ -70,13 +72,15 @@ theorem Ici_mem_nhdsSet_Ici (h : a < b) : Ici a ∈ 𝓝ˢ (Ici b) := ### Lemmas about `Iix _ ∈ 𝓝ˢ (Set.Iic _)` -/ -theorem Iio_mem_nhdsSet_Iic_iff : Iio b ∈ 𝓝ˢ (Iic a) ↔ a < b := - Ioi_mem_nhdsSet_Ici_iff (α := αᵒᵈ) +theorem Iio_mem_nhdsSet_Iic_iff : Iio b ∈ 𝓝ˢ (Iic a) ↔ a < b := by + unsealing_newtype OrderDual => + exact Ioi_mem_nhdsSet_Ici_iff (α := αᵒᵈ) alias ⟨_, Iio_mem_nhdsSet_Iic⟩ := Iio_mem_nhdsSet_Iic_iff -theorem Iic_mem_nhdsSet_Iic (h : a < b) : Iic b ∈ 𝓝ˢ (Iic a) := - Ici_mem_nhdsSet_Ici (α := αᵒᵈ) h +theorem Iic_mem_nhdsSet_Iic (h : a < b) : Iic b ∈ 𝓝ˢ (Iic a) := by + unsealing_newtype OrderDual => + exact Ici_mem_nhdsSet_Ici (α := αᵒᵈ) h /-! ### Lemmas about `Ixx _ ?_ ∈ 𝓝ˢ (Set.Icc _ _)` @@ -190,14 +194,18 @@ theorem Iic_mem_nhdsSet_Iic_iff {a b : α} [NeBot (𝓝[>] b)] : Iic a ∈ 𝓝 (hasBasis_nhdsSet_Iic_Iic b).mem_iff.trans ⟨fun ⟨_c, hbc, hca⟩ ↦ hbc.trans_le (Iic_subset_Iic.1 hca), fun h ↦ ⟨_, h, Subset.rfl⟩⟩ -theorem hasBasis_nhdsSet_Ici_Ioi (a : α) [Nonempty (Iio a)] : - HasBasis (𝓝ˢ (Ici a)) (· < a) Ioi := - have : Nonempty (Ioi (toDual a)) := ‹_›; hasBasis_nhdsSet_Iic_Iio (toDual a) +theorem hasBasis_nhdsSet_Ici_Ioi (a : α) [h : Nonempty (Iio a)] : + HasBasis (𝓝ˢ (Ici a)) (· < a) Ioi := by + unsealing_newtype OrderDual => + exact have : Nonempty (Ioi (toDual a)) := ‹_›; hasBasis_nhdsSet_Iic_Iio (toDual a) theorem hasBasis_nhdsSet_Ici_Ici (a : α) [NeBot (𝓝[<] a)] : - HasBasis (𝓝ˢ (Ici a)) (· < a) Ici := - have : NeBot (𝓝[>] (toDual a)) := ‹_›; hasBasis_nhdsSet_Iic_Iic (toDual a) + HasBasis (𝓝ˢ (Ici a)) (· < a) Ici := by + unsealing_newtype OrderDual => + exact have : NeBot (𝓝[>] (toDual a)) := ‹_›; hasBasis_nhdsSet_Iic_Iic (toDual a) @[simp] -theorem Ici_mem_nhdsSet_Ici_iff {a b : α} [NeBot (𝓝[<] b)] : Ici a ∈ 𝓝ˢ (Ici b) ↔ a < b := - have : NeBot (𝓝[>] (toDual b)) := ‹_›; Iic_mem_nhdsSet_Iic_iff (a := toDual a) (b := toDual b) +theorem Ici_mem_nhdsSet_Ici_iff {a b : α} [NeBot (𝓝[<] b)] : Ici a ∈ 𝓝ˢ (Ici b) ↔ a < b := by + unsealing_newtype OrderDual => + have : NeBot (𝓝[>] (toDual b)) := ‹_› + exact Iic_mem_nhdsSet_Iic_iff (a := toDual a) (b := toDual b) diff --git a/mathlib4/Mathlib/Topology/Order/OrderClosed.lean b/mathlib4/Mathlib/Topology/Order/OrderClosed.lean index 9603945a9..1449f6332 100644 --- a/mathlib4/Mathlib/Topology/Order/OrderClosed.lean +++ b/mathlib4/Mathlib/Topology/Order/OrderClosed.lean @@ -89,13 +89,20 @@ class OrderClosedTopology (α : Type*) [TopologicalSpace α] [Preorder α] : Pro /-- The set `{ (x, y) | x ≤ y }` is a closed set. -/ protected isClosed_le' : IsClosed { p : α × α | p.1 ≤ p.2 } -instance [TopologicalSpace α] [h : FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := h -instance [TopologicalSpace α] [h : SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := h -instance [TopologicalSpace α] [h : SeparableSpace α] : SeparableSpace αᵒᵈ := h +instance [TopologicalSpace α] [FirstCountableTopology α] : FirstCountableTopology αᵒᵈ := + (Topology.IsOpenEmbedding.of_continuous_injective_isOpenMap continuous_ofDual + OrderDual.ofDual.injective isOpenMap_ofDual).isInducing.firstCountableTopology + +instance [TopologicalSpace α] [SecondCountableTopology α] : SecondCountableTopology αᵒᵈ := + (Topology.IsOpenEmbedding.of_continuous_injective_isOpenMap continuous_ofDual + OrderDual.ofDual.injective isOpenMap_ofDual).isInducing.secondCountableTopology + +instance [TopologicalSpace α] [SeparableSpace α] : SeparableSpace αᵒᵈ := + OrderDual.toDual.surjective.denseRange.separableSpace continuous_toDual theorem Dense.orderDual [TopologicalSpace α] {s : Set α} (hs : Dense s) : Dense (OrderDual.ofDual ⁻¹' s) := - hs + hs.preimage isOpenMap_ofDual section General variable [TopologicalSpace α] [Preorder α] {s : Set α} @@ -118,7 +125,7 @@ theorem isClosed_Iic : IsClosed (Iic a) := @[to_dual] instance : ClosedIciTopology αᵒᵈ where - isClosed_Ici _ := isClosed_Iic (α := α) + isClosed_Ici _ := (isClosed_Iic (α := α)).preimage continuous_ofDual @[to_dual (attr := simp, closedness =)] theorem closure_Iic (a : α) : closure (Iic a) = Iic a := @@ -407,15 +414,17 @@ section ClosedIciTopology theorem iInf_eq_of_forall_le_of_tendsto {ι : Type*} {F : Filter ι} [F.NeBot] [ConditionallyCompleteLattice α] [TopologicalSpace α] [ClosedIciTopology α] {a : α} {f : ι → α} (hle : ∀ i, a ≤ f i) (hlim : Tendsto f F (𝓝 a)) : - ⨅ i, f i = a := - iSup_eq_of_forall_le_of_tendsto (α := αᵒᵈ) hle hlim + ⨅ i, f i = a := by + unsealing_newtype OrderDual => + exact iSup_eq_of_forall_le_of_tendsto (α := αᵒᵈ) hle hlim @[to_dual existing] theorem iUnion_Ici_eq_Ioi_of_lt_of_tendsto {ι : Type*} {F : Filter ι} [F.NeBot] [ConditionallyCompleteLinearOrder α] [TopologicalSpace α] [ClosedIciTopology α] {a : α} {f : ι → α} (hlt : ∀ i, a < f i) (hlim : Tendsto f F (𝓝 a)) : - ⋃ i : ι, Ici (f i) = Ioi a := - iUnion_Iic_eq_Iio_of_lt_of_tendsto (α := αᵒᵈ) hlt hlim + ⋃ i : ι, Ici (f i) = Ioi a := by + unsealing_newtype OrderDual => + exact iUnion_Iic_eq_Iio_of_lt_of_tendsto (α := αᵒᵈ) hlt hlim section OrderClosedTopology @@ -453,7 +462,7 @@ instance : ClosedIicTopology α where isClosed_Iic _ := isClosed_le continuous_id continuous_const instance : OrderClosedTopology αᵒᵈ := - ⟨isClosed_le_prod' (α := α)⟩ + ⟨(isClosed_le_prod' (α := α)).preimage (continuous_ofDual.prodMap continuous_ofDual)⟩ @[to_dual self, closedness .] theorem isClosed_Icc {a b : α} : IsClosed (Icc a b) := @@ -537,13 +546,15 @@ lemma monotone_of_frequently_monotone_of_tendsto (hF : ∃ᶠ i in l, Monotone ( /-- The limit of a collection of functions that is frequently antitone on a set is antitone on that set. -/ lemma antitoneOn_of_frequently_antitoneOn_of_tendsto (hF : ∃ᶠ i in l, AntitoneOn (F i) s) - (hlim : ∀ x ∈ s, Tendsto (fun i ↦ F i x) l (𝓝 (f x))) : AntitoneOn f s := - monotoneOn_of_frequently_monotoneOn_of_tendsto (α := αᵒᵈ) hF hlim + (hlim : ∀ x ∈ s, Tendsto (fun i ↦ F i x) l (𝓝 (f x))) : AntitoneOn f s := by + unsealing_newtype OrderDual => + exact monotoneOn_of_frequently_monotoneOn_of_tendsto (α := αᵒᵈ) hF hlim /-- The limit of a collection of functions that is frequently antitone is antitone. -/ lemma antitone_of_frequently_antitone_of_tendsto (hF : ∃ᶠ i in l, Antitone (F i)) - (hlim : ∀ x, Tendsto (fun i ↦ F i x) l (𝓝 (f x))) : Antitone f := - monotone_of_frequently_monotone_of_tendsto (α := αᵒᵈ) hF hlim + (hlim : ∀ x, Tendsto (fun i ↦ F i x) l (𝓝 (f x))) : Antitone f := by + unsealing_newtype OrderDual => + exact monotone_of_frequently_monotone_of_tendsto (α := αᵒᵈ) hF hlim /-- The set of monotone functions on a set is closed. -/ theorem isClosed_monotoneOn : IsClosed {f : β → α | MonotoneOn f s} := by @@ -557,12 +568,14 @@ theorem isClosed_monotone : IsClosed {f : β → α | Monotone f} := by exact isClosed_monotoneOn /-- The set of antitone functions on a set is closed. -/ -theorem isClosed_antitoneOn : IsClosed {f : β → α | AntitoneOn f s} := - isClosed_monotoneOn (α := αᵒᵈ) +theorem isClosed_antitoneOn : IsClosed {f : β → α | AntitoneOn f s} := by + unsealing_newtype OrderDual => + exact isClosed_monotoneOn (α := αᵒᵈ) /-- The set of antitone functions is closed. -/ -theorem isClosed_antitone : IsClosed {f : β → α | Antitone f} := - isClosed_monotone (α := αᵒᵈ) +theorem isClosed_antitone : IsClosed {f : β → α | Antitone f} := by + unsealing_newtype OrderDual => + exact isClosed_monotone (α := αᵒᵈ) end Tendsto diff --git a/mathlib4/Mathlib/Topology/Order/T5.lean b/mathlib4/Mathlib/Topology/Order/T5.lean index ea8c0041c..f40b10d6e 100644 --- a/mathlib4/Mathlib/Topology/Order/T5.lean +++ b/mathlib4/Mathlib/Topology/Order/T5.lean @@ -33,29 +33,33 @@ theorem ordConnectedComponent_mem_nhds : ordConnectedComponent s a ∈ 𝓝 a rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩ exact mem_of_superset ha' (subset_ordConnectedComponent ha hs) -theorem compl_ordConnectedSection_ordSeparatingSet_mem_nhdsGE (hd : Disjoint s (closure t)) - (ha : a ∈ s) : (ordConnectedSection (ordSeparatingSet s t))ᶜ ∈ 𝓝[≥] a := by +/-- A subset of the separating set with at most one point in each order-connected component +has a complement that is a right neighborhood of every point of `s`. -/ +private theorem compl_mem_nhdsGE_of_subset_ordSeparatingSet {u : Set X} + (hu : u ⊆ ordSeparatingSet s t) + (hu_unique : ∀ ⦃x⦄, x ∈ u → ∀ ⦃y⦄, y ∈ u → uIcc x y ⊆ ordSeparatingSet s t → x = y) + (hd : Disjoint s (closure t)) (ha : a ∈ s) : uᶜ ∈ 𝓝[≥] a := by have hmem : tᶜ ∈ 𝓝[≥] a := by refine mem_nhdsWithin_of_mem_nhds ?_ rw [← mem_interior_iff_mem_nhds, interior_compl] exact disjoint_left.1 hd ha rcases exists_Icc_mem_subset_of_mem_nhdsGE hmem with ⟨b, hab, hmem', hsub⟩ - by_cases H : Disjoint (Icc a b) (ordConnectedSection <| ordSeparatingSet s t) + by_cases H : Disjoint (Icc a b) u · exact mem_of_superset hmem' (disjoint_left.1 H) · simp only [Set.disjoint_left, not_forall, Classical.not_not] at H rcases H with ⟨c, ⟨hac, hcb⟩, hc⟩ have hsub' : Icc a b ⊆ ordConnectedComponent tᶜ a := subset_ordConnectedComponent (left_mem_Icc.2 hab) hsub - have hd : Disjoint s (ordConnectedSection (ordSeparatingSet s t)) := - disjoint_left_ordSeparatingSet.mono_right ordConnectedSection_subset + have hd : Disjoint s u := + disjoint_left_ordSeparatingSet.mono_right hu replace hac : a < c := hac.lt_of_ne <| Ne.symm <| ne_of_mem_of_not_mem hc <| disjoint_left.1 hd ha filter_upwards [Ico_mem_nhdsGE hac] with x hx hx' - refine hx.2.ne (eq_of_mem_ordConnectedSection_of_uIcc_subset hx' hc ?_) + refine hx.2.ne (hu_unique hx' hc ?_) refine subset_inter (subset_iUnion₂_of_subset a ha ?_) ?_ · exact OrdConnected.uIcc_subset inferInstance (hsub' ⟨hx.1, hx.2.le.trans hcb⟩) (hsub' ⟨hac.le, hcb⟩) - · rcases mem_iUnion₂.1 (ordConnectedSection_subset hx').2 with ⟨y, hyt, hxy⟩ + · rcases mem_iUnion₂.1 (hu hx').2 with ⟨y, hyt, hxy⟩ refine subset_iUnion₂_of_subset y hyt (OrdConnected.uIcc_subset inferInstance hxy ?_) refine subset_ordConnectedComponent left_mem_uIcc hxy ?_ suffices c < y by @@ -65,12 +69,25 @@ theorem compl_ordConnectedSection_ordSeparatingSet_mem_nhdsGE (hd : Disjoint s ( have hya : y < a := not_le.1 fun hay => hsub ⟨hay, hyc.trans hcb⟩ hyt exact hxy (Icc_subset_uIcc ⟨hya.le, hx.1⟩) ha +theorem compl_ordConnectedSection_ordSeparatingSet_mem_nhdsGE (hd : Disjoint s (closure t)) + (ha : a ∈ s) : (ordConnectedSection (ordSeparatingSet s t))ᶜ ∈ 𝓝[≥] a := + compl_mem_nhdsGE_of_subset_ordSeparatingSet ordConnectedSection_subset + (fun _ hx _ hy => eq_of_mem_ordConnectedSection_of_uIcc_subset hx hy) hd ha + theorem compl_ordConnectedSection_ordSeparatingSet_mem_nhdsLE (hd : Disjoint s (closure t)) - (ha : a ∈ s) : (ordConnectedSection <| ordSeparatingSet s t)ᶜ ∈ 𝓝[≤] a := by - have hd' : Disjoint (ofDual ⁻¹' s) (closure <| ofDual ⁻¹' t) := hd - have ha' : toDual a ∈ ofDual ⁻¹' s := ha - simpa only [dual_ordSeparatingSet, dual_ordConnectedSection] using! - compl_ordConnectedSection_ordSeparatingSet_mem_nhdsGE hd' ha' + (ha : a ∈ s) : (ordConnectedSection (ordSeparatingSet s t))ᶜ ∈ 𝓝[≤] a := by + unsealing_newtype OrderDual => + refine compl_mem_nhdsGE_of_subset_ordSeparatingSet (X := Xᵒᵈ) + (s := ofDual ⁻¹' s) (t := ofDual ⁻¹' t) + (u := ofDual ⁻¹' ordConnectedSection (ordSeparatingSet s t)) ?_ ?_ hd ha + · rw [dual_ordSeparatingSet] + exact preimage_mono ordConnectedSection_subset + · intro x hx y hy hxy + apply eq_of_mem_ordConnectedSection_of_uIcc_subset (α := X) hx hy + change uIcc (ofDual x) (ofDual y) ⊆ ordSeparatingSet s t + rw [dual_ordSeparatingSet] at hxy + rw [uIcc_ofDual] + exact fun _ hz => hxy hz theorem compl_ordConnectedSection_ordSeparatingSet_mem_nhds (hd : Disjoint s (closure t)) (ha : a ∈ s) : (ordConnectedSection <| ordSeparatingSet s t)ᶜ ∈ 𝓝 a := by diff --git a/mathlib4/Mathlib/Topology/Order/UpperLowerSetTopology.lean b/mathlib4/Mathlib/Topology/Order/UpperLowerSetTopology.lean index 64d933828..95d54b69e 100644 --- a/mathlib4/Mathlib/Topology/Order/UpperLowerSetTopology.lean +++ b/mathlib4/Mathlib/Topology/Order/UpperLowerSetTopology.lean @@ -180,10 +180,10 @@ The Upper Set topology is homeomorphic to the Lower Set topology on the dual ord def WithUpperSet.toDualHomeomorph [Preorder α] : WithUpperSet α ≃ₜ WithLowerSet αᵒᵈ where toFun := OrderDual.toDual invFun := OrderDual.ofDual - left_inv := OrderDual.toDual_ofDual - right_inv := OrderDual.ofDual_toDual - continuous_toFun := continuous_coinduced_rng - continuous_invFun := continuous_coinduced_rng + left_inv := OrderDual.ofDual_toDual + right_inv := OrderDual.toDual_ofDual + continuous_toFun := continuous_def.2 fun _ hu ↦ isUpperSet_preimage_toDual_iff.2 hu + continuous_invFun := continuous_def.2 fun _ hu ↦ isLowerSet_preimage_ofDual_iff.2 hu /-- Prop-valued mixin for an ordered topological space to be The upper set topology is the topology where the open sets are the upper sets. In general the upper @@ -228,7 +228,10 @@ variable {α} set_option backward.isDefEq.respectTransparency false in instance _root_.OrderDual.instIsLowerSet : Topology.IsLowerSet αᵒᵈ where - topology_eq_lowerSetTopology := by ext; rw [IsUpperSet.topology_eq α] + topology_eq_lowerSetTopology := by + ext u + rw [IsUpperSet.topology_eq α] + exact isUpperSet_preimage_toDual_iff /-- If `α` is equipped with the upper set topology, then it is homeomorphic to `WithUpperSet α`. -/ @@ -334,7 +337,10 @@ variable {α} set_option backward.isDefEq.respectTransparency false in instance _root_.OrderDual.instIsUpperSet : Topology.IsUpperSet αᵒᵈ where - topology_eq_upperSetTopology := by ext; rw [IsLowerSet.topology_eq α] + topology_eq_upperSetTopology := by + ext u + rw [IsLowerSet.topology_eq α] + exact isLowerSet_preimage_toDual_iff /-- If `α` is equipped with the lower set topology, then it is homeomorphic to `WithLowerSet α`. -/ def WithLowerSetHomeomorph : WithLowerSet α ≃ₜ α := @@ -342,13 +348,15 @@ def WithLowerSetHomeomorph : WithLowerSet α ≃ₜ α := lemma isOpen_iff_isLowerSet : IsOpen s ↔ IsLowerSet s := by rw [topology_eq α]; rfl -instance toAlexandrovDiscrete : AlexandrovDiscrete α := IsUpperSet.toAlexandrovDiscrete (α := αᵒᵈ) +instance toAlexandrovDiscrete : AlexandrovDiscrete α where + isOpen_sInter S := by simpa only [isOpen_iff_isLowerSet] using isLowerSet_sInter (α := α) lemma isClosed_iff_isUpper : IsClosed s ↔ IsUpperSet s := by rw [← isOpen_compl_iff, isOpen_iff_isLowerSet, isUpperSet_compl.symm, compl_compl] -lemma closure_eq_upperClosure {s : Set α} : closure s = upperClosure s := - IsUpperSet.closure_eq_lowerClosure (α := αᵒᵈ) +lemma closure_eq_upperClosure {s : Set α} : closure s = upperClosure s := by + unsealing_newtype OrderDual => + exact IsUpperSet.closure_eq_lowerClosure (α := αᵒᵈ) /-- The closure of a singleton `{a}` in the lower set topology is the right-closed left-infinite @@ -389,13 +397,15 @@ open OrderDual protected lemma monotone_iff_continuous [TopologicalSpace α] [TopologicalSpace β] [Topology.IsLowerSet α] [Topology.IsLowerSet β] {f : α → β} : Monotone f ↔ Continuous f := by - rw [← monotone_dual_iff] - exact IsUpperSet.monotone_iff_continuous (α := αᵒᵈ) (β := βᵒᵈ) - (f := (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ)) + unsealing_newtype OrderDual => + rw [← monotone_dual_iff] + exact IsUpperSet.monotone_iff_continuous (α := αᵒᵈ) (β := βᵒᵈ) + (f := (toDual ∘ f ∘ ofDual : αᵒᵈ → βᵒᵈ)) lemma monotone_to_lowerTopology_continuous [TopologicalSpace α] [TopologicalSpace β] - [Topology.IsLowerSet α] [IsLower β] {f : α → β} (hf : Monotone f) : Continuous f := - IsUpperSet.monotone_to_upperTopology_continuous (α := αᵒᵈ) (β := βᵒᵈ) hf.dual + [Topology.IsLowerSet α] [IsLower β] {f : α → β} (hf : Monotone f) : Continuous f := by + unsealing_newtype OrderDual => + exact IsUpperSet.monotone_to_upperTopology_continuous (α := αᵒᵈ) (β := βᵒᵈ) hf.dual lemma lowerSet_le_lower {t₁ t₂ : TopologicalSpace α} [@Topology.IsLowerSet α t₁ _] [@IsLower α t₂ _] : t₁ ≤ t₂ := fun s hs => by @@ -406,14 +416,21 @@ end maps end IsLowerSet -lemma isUpperSet_orderDual [Preorder α] [TopologicalSpace α] : +lemma isUpperSet_orderDual [Preorder α] [t : TopologicalSpace α] : Topology.IsUpperSet αᵒᵈ ↔ Topology.IsLowerSet α := by - constructor - · apply OrderDual.instIsLowerSet - · apply OrderDual.instIsUpperSet - -lemma isLowerSet_orderDual [Preorder α] [TopologicalSpace α] : - Topology.IsLowerSet αᵒᵈ ↔ Topology.IsUpperSet α := isUpperSet_orderDual.symm + refine ⟨fun h ↦ ⟨?_⟩, fun _ ↦ OrderDual.instIsUpperSet⟩ + ext u + have h2 := congrArg (fun τ : TopologicalSpace αᵒᵈ ↦ τ.IsOpen (OrderDual.ofDual ⁻¹' u)) + h.topology_eq_upperSetTopology + exact (Iff.of_eq h2).trans isUpperSet_preimage_ofDual_iff + +lemma isLowerSet_orderDual [Preorder α] [t : TopologicalSpace α] : + Topology.IsLowerSet αᵒᵈ ↔ Topology.IsUpperSet α := by + refine ⟨fun h ↦ ⟨?_⟩, fun _ ↦ OrderDual.instIsLowerSet⟩ + ext u + have h2 := congrArg (fun τ : TopologicalSpace αᵒᵈ ↦ τ.IsOpen (OrderDual.ofDual ⁻¹' u)) + h.topology_eq_lowerSetTopology + exact (Iff.of_eq h2).trans isLowerSet_preimage_ofDual_iff namespace WithUpperSet variable [Preorder α] [Preorder β] [Preorder γ] diff --git a/mathlib4/Mathlib/Topology/Semicontinuity/Basic.lean b/mathlib4/Mathlib/Topology/Semicontinuity/Basic.lean index 373a430d5..d941bf141 100644 --- a/mathlib4/Mathlib/Topology/Semicontinuity/Basic.lean +++ b/mathlib4/Mathlib/Topology/Semicontinuity/Basic.lean @@ -69,6 +69,20 @@ open Set Function Filter variable {α β γ : Type*} [TopologicalSpace α] [TopologicalSpace γ] {f : α → β} {s t : Set α} {x : α} {y z : β} +section DualBridge + +open OrderDual + +variable {α β : Type*} [TopologicalSpace α] [Preorder β] {f : α → β} {s : Set α} {x : α} + +/-- `toDual` as a homeomorphism, to transport closedness of (hypo/epi)graphs. -/ +private def toDualHomeomorph {X : Type*} [TopologicalSpace X] : X ≃ₜ Xᵒᵈ where + toEquiv := toDual + continuous_toFun := continuous_toDual + continuous_invFun := continuous_ofDual + +end DualBridge + /-! ### lower bounds -/ section @@ -222,8 +236,9 @@ theorem upperSemicontinuousOn_of_forall_isMinOn_and_mem {m : α → ι} (m_mem : ∀ x ∈ s, m x ∈ I) (m_min : ∀ x ∈ s, IsMinOn (fun i ↦ f i x) I (m x)) : - UpperSemicontinuousOn (fun x ↦ f (m x) x) s := - lowerSemicontinuousOn_of_forall_isMaxOn_and_mem (β := βᵒᵈ) hfy m_mem m_min + UpperSemicontinuousOn (fun x ↦ f (m x) x) s := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousOn_of_forall_isMaxOn_and_mem (β := βᵒᵈ) hfy m_mem m_min end @@ -396,13 +411,15 @@ theorem Continuous.comp_lowerSemicontinuous {g : γ → δ} {f : α → γ} (hg theorem ContinuousAt.comp_lowerSemicontinuousWithinAt_antitone {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Antitone g) : - UpperSemicontinuousWithinAt (g ∘ f) s x := - ContinuousAt.comp_lowerSemicontinuousWithinAt (δ := δᵒᵈ) hg hf gmon + UpperSemicontinuousWithinAt (g ∘ f) s x := by + unsealing_newtype OrderDual => + exact ContinuousAt.comp_lowerSemicontinuousWithinAt (δ := δᵒᵈ) (f := f) (g := g) hg hf gmon theorem ContinuousAt.comp_lowerSemicontinuousAt_antitone {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousAt f x) (gmon : Antitone g) : - UpperSemicontinuousAt (g ∘ f) x := - ContinuousAt.comp_lowerSemicontinuousAt (δ := δᵒᵈ) hg hf gmon + UpperSemicontinuousAt (g ∘ f) x := by + unsealing_newtype OrderDual => + exact ContinuousAt.comp_lowerSemicontinuousAt (δ := δᵒᵈ) (f := f) (g := g) hg hf gmon theorem Continuous.comp_lowerSemicontinuousOn_antitone {g : γ → δ} {f : α → γ} (hg : Continuous g) (hf : LowerSemicontinuousOn f s) (gmon : Antitone g) : UpperSemicontinuousOn (g ∘ f) s := @@ -739,13 +756,15 @@ variable {α : Type*} [TopologicalSpace α] {β : Type*} [LinearOrder β] {f : /-- An upper semicontinuous function attains its upper bound on a nonempty compact set. -/ theorem UpperSemicontinuousOn.exists_isMaxOn {s : Set α} (ne_s : s.Nonempty) (hs : IsCompact s) (hf : UpperSemicontinuousOn f s) : - ∃ a ∈ s, IsMaxOn f s a := - LowerSemicontinuousOn.exists_isMinOn (β := βᵒᵈ) ne_s hs hf + ∃ a ∈ s, IsMaxOn f s a := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousOn.exists_isMinOn (β := βᵒᵈ) ne_s hs hf /-- An upper semicontinuous function is bounded above on a compact set. -/ theorem UpperSemicontinuousOn.bddAbove_of_isCompact [Nonempty β] {s : Set α} - (hs : IsCompact s) (hf : UpperSemicontinuousOn f s) : BddAbove (f '' s) := - LowerSemicontinuousOn.bddBelow_of_isCompact (β := βᵒᵈ) hs hf + (hs : IsCompact s) (hf : UpperSemicontinuousOn f s) : BddAbove (f '' s) := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousOn.bddBelow_of_isCompact (β := βᵒᵈ) hs hf end @@ -757,8 +776,9 @@ section variable [Zero β] [Preorder β] theorem IsOpen.upperSemicontinuous_indicator (hs : IsOpen s) (hy : y ≤ 0) : - UpperSemicontinuous (indicator s fun _x => y) := - IsOpen.lowerSemicontinuous_indicator (β := βᵒᵈ) hs hy + UpperSemicontinuous (indicator s fun _x => y) := by + unsealing_newtype OrderDual => + exact IsOpen.lowerSemicontinuous_indicator (β := βᵒᵈ) hs hy theorem IsOpen.upperSemicontinuousOn_indicator (hs : IsOpen s) (hy : y ≤ 0) : UpperSemicontinuousOn (indicator s fun _x => y) t := @@ -773,8 +793,9 @@ theorem IsOpen.upperSemicontinuousWithinAt_indicator (hs : IsOpen s) (hy : y ≤ (hs.upperSemicontinuous_indicator hy).upperSemicontinuousWithinAt t x theorem IsClosed.upperSemicontinuous_indicator (hs : IsClosed s) (hy : 0 ≤ y) : - UpperSemicontinuous (indicator s fun _x => y) := - IsClosed.lowerSemicontinuous_indicator (β := βᵒᵈ) hs hy + UpperSemicontinuous (indicator s fun _x => y) := by + unsealing_newtype OrderDual => + exact IsClosed.lowerSemicontinuous_indicator (β := βᵒᵈ) hs hy theorem IsClosed.upperSemicontinuousOn_indicator (hs : IsClosed s) (hy : 0 ≤ y) : UpperSemicontinuousOn (indicator s fun _x => y) t := @@ -842,26 +863,30 @@ section variable {γ : Type*} [CompleteLinearOrder γ] theorem upperSemicontinuousWithinAt_iff_limsup_le {f : α → γ} : - UpperSemicontinuousWithinAt f s x ↔ limsup f (𝓝[s] x) ≤ f x := - lowerSemicontinuousWithinAt_iff_le_liminf (γ := γᵒᵈ) + UpperSemicontinuousWithinAt f s x ↔ limsup f (𝓝[s] x) ≤ f x := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousWithinAt_iff_le_liminf (γ := γᵒᵈ) alias ⟨UpperSemicontinuousWithinAt.limsup_le, _⟩ := upperSemicontinuousWithinAt_iff_limsup_le theorem upperSemicontinuousAt_iff_limsup_le {f : α → γ} : - UpperSemicontinuousAt f x ↔ limsup f (𝓝 x) ≤ f x := - lowerSemicontinuousAt_iff_le_liminf (γ := γᵒᵈ) + UpperSemicontinuousAt f x ↔ limsup f (𝓝 x) ≤ f x := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousAt_iff_le_liminf (γ := γᵒᵈ) alias ⟨UpperSemicontinuousAt.limsup_le, _⟩ := upperSemicontinuousAt_iff_limsup_le theorem upperSemicontinuous_iff_limsup_le {f : α → γ} : - UpperSemicontinuous f ↔ ∀ x, limsup f (𝓝 x) ≤ f x := - lowerSemicontinuous_iff_le_liminf (γ := γᵒᵈ) + UpperSemicontinuous f ↔ ∀ x, limsup f (𝓝 x) ≤ f x := by + unsealing_newtype OrderDual => + exact lowerSemicontinuous_iff_le_liminf (γ := γᵒᵈ) alias ⟨UpperSemicontinuous.limsup_le, _⟩ := upperSemicontinuous_iff_limsup_le theorem upperSemicontinuousOn_iff_limsup_le {f : α → γ} : - UpperSemicontinuousOn f s ↔ ∀ x ∈ s, limsup f (𝓝[s] x) ≤ f x := - lowerSemicontinuousOn_iff_le_liminf (γ := γᵒᵈ) + UpperSemicontinuousOn f s ↔ ∀ x ∈ s, limsup f (𝓝[s] x) ≤ f x := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousOn_iff_le_liminf (γ := γᵒᵈ) alias ⟨UpperSemicontinuousOn.limsup_le, _⟩ := upperSemicontinuousOn_iff_limsup_le @@ -874,8 +899,9 @@ variable {γ : Type*} [LinearOrder γ] /-- The overlevel sets of an upper semicontinuous function on a compact set are compact. -/ theorem UpperSemicontinuousOn.isCompact_inter_preimage_Ici {f : α → γ} (hfs : UpperSemicontinuousOn f s) (ks : IsCompact s) (c : γ) : - IsCompact (s ∩ f ⁻¹' Ici c) := - LowerSemicontinuousOn.isCompact_inter_preimage_Iic (γ := γᵒᵈ) hfs ks c + IsCompact (s ∩ f ⁻¹' Ici c) := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousOn.isCompact_inter_preimage_Iic (γ := γᵒᵈ) hfs ks c open scoped Set.Notation in /-- An intersection of overlevel sets of an upper semicontinuous function on a compact set is @@ -883,8 +909,9 @@ disjoint from the compact set if and only if a finite sub-intersection already i theorem UpperSemicontinuousOn.disjoint_biInter_preimage_Ici_iff_exists_finset {ι : Type*} {f : ι → α → γ} (ks : IsCompact s) {I : Set ι} {c : γ} (hfi : ∀ i ∈ I, UpperSemicontinuousOn (f i) s) : - Disjoint s (⋂ i ∈ I, (f i) ⁻¹' Ici c) ↔ ∃ u : Finset I, ∀ x ∈ s, ∃ i ∈ u, f i x < c := - LowerSemicontinuousOn.disjoint_biInter_preimage_Iic_iff_exists_finset ks hfi (γ := γᵒᵈ) + Disjoint s (⋂ i ∈ I, (f i) ⁻¹' Ici c) ↔ ∃ u : Finset I, ∀ x ∈ s, ∃ i ∈ u, f i x < c := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousOn.disjoint_biInter_preimage_Iic_iff_exists_finset ks hfi (γ := γᵒᵈ) @[deprecated (since := "2026-08-17")] alias UpperSemicontinuousOn.inter_biInter_preimage_Ici_eq_empty_iff_exists_finset := @@ -893,12 +920,14 @@ alias UpperSemicontinuousOn.inter_biInter_preimage_Ici_eq_empty_iff_exists_finse variable [TopologicalSpace γ] [ClosedIicTopology γ] theorem upperSemicontinuousOn_iff_isClosed_hypograph {f : α → γ} (hs : IsClosed s) : - UpperSemicontinuousOn f s ↔ IsClosed {p : α × γ | p.1 ∈ s ∧ p.2 ≤ f p.1} := - lowerSemicontinuousOn_iff_isClosed_epigraph hs (γ := γᵒᵈ) + UpperSemicontinuousOn f s ↔ IsClosed {p : α × γ | p.1 ∈ s ∧ p.2 ≤ f p.1} := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousOn_iff_isClosed_epigraph hs (γ := γᵒᵈ) theorem upperSemicontinuous_iff_IsClosed_hypograph {f : α → γ} : - UpperSemicontinuous f ↔ IsClosed {p : α × γ | p.2 ≤ f p.1} := - lowerSemicontinuous_iff_isClosed_epigraph (γ := γᵒᵈ) + UpperSemicontinuous f ↔ IsClosed {p : α × γ | p.2 ≤ f p.1} := by + unsealing_newtype OrderDual => + exact lowerSemicontinuous_iff_isClosed_epigraph (γ := γᵒᵈ) alias ⟨UpperSemicontinuous.IsClosed_hypograph, _⟩ := upperSemicontinuous_iff_IsClosed_hypograph @@ -914,12 +943,14 @@ variable {γ : Type*} [TopologicalSpace γ] variable {f : α → β} {s : Set α} {a : α} theorem upperSemicontinuousOn_iff_preimage_Iio [Preorder β] : - UpperSemicontinuousOn f s ↔ ∀ b, ∃ u : Set α, IsOpen u ∧ s ∩ f ⁻¹' Set.Iio b = s ∩ u := - lowerSemicontinuousOn_iff_preimage_Ioi (β := βᵒᵈ) + UpperSemicontinuousOn f s ↔ ∀ b, ∃ u : Set α, IsOpen u ∧ s ∩ f ⁻¹' Set.Iio b = s ∩ u := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousOn_iff_preimage_Ioi (β := βᵒᵈ) theorem upperSemicontinuousOn_iff_preimage_Ici [LinearOrder β] : - UpperSemicontinuousOn f s ↔ ∀ b, ∃ v : Set α, IsClosed v ∧ s ∩ f ⁻¹' Set.Ici b = s ∩ v := - lowerSemicontinuousOn_iff_preimage_Iic (γ := βᵒᵈ) + UpperSemicontinuousOn f s ↔ ∀ b, ∃ v : Set α, IsClosed v ∧ s ∩ f ⁻¹' Set.Ici b = s ∩ v := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousOn_iff_preimage_Iic (γ := βᵒᵈ) variable [PartialOrder β] [CommGroup β] [IsOrderedMonoid β] @@ -997,12 +1028,14 @@ variable {δ : Type*} [LinearOrder δ] [TopologicalSpace δ] [OrderTopology δ] theorem ContinuousAt.comp_upperSemicontinuousWithinAt {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : UpperSemicontinuousWithinAt f s x) (gmon : Monotone g) : - UpperSemicontinuousWithinAt (g ∘ f) s x := - ContinuousAt.comp_lowerSemicontinuousWithinAt (γ := γᵒᵈ) (δ := δᵒᵈ) hg hf gmon.dual + UpperSemicontinuousWithinAt (g ∘ f) s x := by + unsealing_newtype OrderDual => + exact ContinuousAt.comp_lowerSemicontinuousWithinAt (γ := γᵒᵈ) (δ := δᵒᵈ) hg hf gmon.dual theorem ContinuousAt.comp_upperSemicontinuousAt {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) - (hf : UpperSemicontinuousAt f x) (gmon : Monotone g) : UpperSemicontinuousAt (g ∘ f) x := - ContinuousAt.comp_lowerSemicontinuousAt (γ := γᵒᵈ) (δ := δᵒᵈ) hg hf gmon.dual + (hf : UpperSemicontinuousAt f x) (gmon : Monotone g) : UpperSemicontinuousAt (g ∘ f) x := by + unsealing_newtype OrderDual => + exact ContinuousAt.comp_lowerSemicontinuousAt (γ := γᵒᵈ) (δ := δᵒᵈ) hg hf gmon.dual theorem Continuous.comp_upperSemicontinuousOn {g : γ → δ} {f : α → γ} (hg : Continuous g) (hf : UpperSemicontinuousOn f s) (gmon : Monotone g) : UpperSemicontinuousOn (g ∘ f) s := @@ -1014,13 +1047,15 @@ theorem Continuous.comp_upperSemicontinuous {g : γ → δ} {f : α → γ} (hg theorem ContinuousAt.comp_upperSemicontinuousWithinAt_antitone {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : UpperSemicontinuousWithinAt f s x) (gmon : Antitone g) : - LowerSemicontinuousWithinAt (g ∘ f) s x := - ContinuousAt.comp_upperSemicontinuousWithinAt (δ := δᵒᵈ) hg hf gmon + LowerSemicontinuousWithinAt (g ∘ f) s x := by + unsealing_newtype OrderDual => + exact ContinuousAt.comp_upperSemicontinuousWithinAt (δ := δᵒᵈ) (f := f) (g := g) hg hf gmon theorem ContinuousAt.comp_upperSemicontinuousAt_antitone {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : UpperSemicontinuousAt f x) (gmon : Antitone g) : - LowerSemicontinuousAt (g ∘ f) x := - ContinuousAt.comp_upperSemicontinuousAt (δ := δᵒᵈ) hg hf gmon + LowerSemicontinuousAt (g ∘ f) x := by + unsealing_newtype OrderDual => + exact ContinuousAt.comp_upperSemicontinuousAt (δ := δᵒᵈ) (f := f) (g := g) hg hf gmon theorem Continuous.comp_upperSemicontinuousOn_antitone {g : γ → δ} {f : α → γ} (hg : Continuous g) (hf : UpperSemicontinuousOn f s) (gmon : Antitone g) : LowerSemicontinuousOn (g ∘ f) s := @@ -1048,8 +1083,9 @@ the lemma uses `[ContinuousAdd]`. -/ theorem UpperSemicontinuousWithinAt.add' {f g : α → γ} (hf : UpperSemicontinuousWithinAt f s x) (hg : UpperSemicontinuousWithinAt g s x) (hcont : ContinuousAt (fun p : γ × γ => p.1 + p.2) (f x, g x)) : - UpperSemicontinuousWithinAt (fun z => f z + g z) s x := - LowerSemicontinuousWithinAt.add' (γ := γᵒᵈ) hf hg hcont + UpperSemicontinuousWithinAt (fun z => f z + g z) s x := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousWithinAt.add' (γ := γᵒᵈ) hf hg hcont /-- The sum of two upper semicontinuous functions is upper semicontinuous. Formulated with an explicit continuity assumption on addition, for application to `EReal`. The unprimed version of @@ -1112,8 +1148,9 @@ theorem UpperSemicontinuous.add {f g : α → γ} (hf : UpperSemicontinuous f) theorem upperSemicontinuousWithinAt_sum {f : ι → α → γ} {a : Finset ι} (ha : ∀ i ∈ a, UpperSemicontinuousWithinAt (f i) s x) : - UpperSemicontinuousWithinAt (fun z => ∑ i ∈ a, f i z) s x := - lowerSemicontinuousWithinAt_sum (γ := γᵒᵈ) ha + UpperSemicontinuousWithinAt (fun z => ∑ i ∈ a, f i z) s x := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousWithinAt_sum (γ := γᵒᵈ) ha theorem upperSemicontinuousAt_sum {f : ι → α → γ} {a : Finset ι} (ha : ∀ i ∈ a, UpperSemicontinuousAt (f i) x) : @@ -1141,41 +1178,49 @@ variable {α : Type*} {β : Type*} [TopologicalSpace α] [LinearOrder β] theorem UpperSemicontinuousWithinAt.inf (hf : UpperSemicontinuousWithinAt f s a) (hg : UpperSemicontinuousWithinAt g s a) : - UpperSemicontinuousWithinAt (fun x ↦ f x ⊓ g x) s a := - LowerSemicontinuousWithinAt.sup (β := βᵒᵈ) hf hg + UpperSemicontinuousWithinAt (fun x ↦ f x ⊓ g x) s a := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousWithinAt.sup (β := βᵒᵈ) hf hg theorem UpperSemicontinuousAt.inf (hf : UpperSemicontinuousAt f a) (hg : UpperSemicontinuousAt g a) : - UpperSemicontinuousAt (fun x ↦ f x ⊓ g x) a := - LowerSemicontinuousAt.sup (β := βᵒᵈ) hf hg + UpperSemicontinuousAt (fun x ↦ f x ⊓ g x) a := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousAt.sup (β := βᵒᵈ) hf hg theorem UpperSemicontinuousOn.inf (hf : UpperSemicontinuousOn f s) (hg : UpperSemicontinuousOn g s) : - UpperSemicontinuousOn (fun x ↦ f x ⊓ g x) s := - LowerSemicontinuousOn.sup (β := βᵒᵈ) hf hg + UpperSemicontinuousOn (fun x ↦ f x ⊓ g x) s := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousOn.sup (β := βᵒᵈ) hf hg theorem UpperSemicontinuous.inf (hf : UpperSemicontinuous f) (hg : UpperSemicontinuous g) : - UpperSemicontinuous (fun x ↦ f x ⊓ g x) := - LowerSemicontinuous.sup (β := βᵒᵈ) hf hg + UpperSemicontinuous (fun x ↦ f x ⊓ g x) := by + unsealing_newtype OrderDual => + exact LowerSemicontinuous.sup (β := βᵒᵈ) hf hg theorem UpperSemicontinuousWithinAt.sup (hf : UpperSemicontinuousWithinAt f s a) (hg : UpperSemicontinuousWithinAt g s a) : - UpperSemicontinuousWithinAt (fun x ↦ f x ⊔ g x) s a := - LowerSemicontinuousWithinAt.inf (β := βᵒᵈ) hf hg + UpperSemicontinuousWithinAt (fun x ↦ f x ⊔ g x) s a := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousWithinAt.inf (β := βᵒᵈ) hf hg theorem UpperSemicontinuousAt.sup (hf : UpperSemicontinuousAt f a) (hg : UpperSemicontinuousAt g a) : - UpperSemicontinuousAt (fun x ↦ f x ⊔ g x) a := - LowerSemicontinuousAt.inf (β := βᵒᵈ) hf hg + UpperSemicontinuousAt (fun x ↦ f x ⊔ g x) a := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousAt.inf (β := βᵒᵈ) hf hg theorem UpperSemicontinuousOn.sup (hf : UpperSemicontinuousOn f s) (hg : UpperSemicontinuousOn g s) : - UpperSemicontinuousOn (fun x ↦ f x ⊔ g x) s := - LowerSemicontinuousOn.inf (β := βᵒᵈ) hf hg + UpperSemicontinuousOn (fun x ↦ f x ⊔ g x) s := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousOn.inf (β := βᵒᵈ) hf hg theorem UpperSemicontinuous.sup (hf : UpperSemicontinuous f) (hg : UpperSemicontinuous g) : - UpperSemicontinuous fun x ↦ f x ⊔ g x := - LowerSemicontinuous.inf (β := βᵒᵈ) hf hg + UpperSemicontinuous fun x ↦ f x ⊔ g x := by + unsealing_newtype OrderDual => + exact LowerSemicontinuous.inf (β := βᵒᵈ) hf hg end @@ -1187,13 +1232,15 @@ variable {ι : Sort*} {δ δ' : Type*} [CompleteLinearOrder δ] [ConditionallyCo theorem upperSemicontinuousWithinAt_ciInf {f : ι → α → δ'} (bdd : ∀ᶠ y in 𝓝[s] x, BddBelow (range fun i => f i y)) (h : ∀ i, UpperSemicontinuousWithinAt (f i) s x) : - UpperSemicontinuousWithinAt (fun x' => ⨅ i, f i x') s x := - lowerSemicontinuousWithinAt_ciSup (δ' := δ'ᵒᵈ) bdd h + UpperSemicontinuousWithinAt (fun x' => ⨅ i, f i x') s x := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousWithinAt_ciSup (δ' := δ'ᵒᵈ) bdd h theorem upperSemicontinuousWithinAt_iInf {f : ι → α → δ} (h : ∀ i, UpperSemicontinuousWithinAt (f i) s x) : - UpperSemicontinuousWithinAt (fun x' => ⨅ i, f i x') s x := - lowerSemicontinuousWithinAt_iSup (δ := δᵒᵈ) h + UpperSemicontinuousWithinAt (fun x' => ⨅ i, f i x') s x := by + unsealing_newtype OrderDual => + exact lowerSemicontinuousWithinAt_iSup (δ := δᵒᵈ) h theorem upperSemicontinuousWithinAt_biInf {p : ι → Prop} {f : ∀ i, p i → α → δ} (h : ∀ i hi, UpperSemicontinuousWithinAt (f i hi) s x) : @@ -1202,12 +1249,14 @@ theorem upperSemicontinuousWithinAt_biInf {p : ι → Prop} {f : ∀ i, p i → theorem upperSemicontinuousAt_ciInf {f : ι → α → δ'} (bdd : ∀ᶠ y in 𝓝 x, BddBelow (range fun i => f i y)) (h : ∀ i, UpperSemicontinuousAt (f i) x) : - UpperSemicontinuousAt (fun x' => ⨅ i, f i x') x := - @lowerSemicontinuousAt_ciSup α _ x ι δ'ᵒᵈ _ f bdd h + UpperSemicontinuousAt (fun x' => ⨅ i, f i x') x := by + unsealing_newtype OrderDual => + exact @lowerSemicontinuousAt_ciSup α _ x ι δ'ᵒᵈ _ f bdd h theorem upperSemicontinuousAt_iInf {f : ι → α → δ} (h : ∀ i, UpperSemicontinuousAt (f i) x) : - UpperSemicontinuousAt (fun x' => ⨅ i, f i x') x := - @lowerSemicontinuousAt_iSup α _ x ι δᵒᵈ _ f h + UpperSemicontinuousAt (fun x' => ⨅ i, f i x') x := by + unsealing_newtype OrderDual => + exact @lowerSemicontinuousAt_iSup α _ x ι δᵒᵈ _ f h theorem upperSemicontinuousAt_biInf {p : ι → Prop} {f : ∀ i, p i → α → δ} (h : ∀ i hi, UpperSemicontinuousAt (f i hi) x) : diff --git a/mathlib4/Mathlib/Topology/Semicontinuity/Defs.lean b/mathlib4/Mathlib/Topology/Semicontinuity/Defs.lean index d47c66a86..fa7761197 100644 --- a/mathlib4/Mathlib/Topology/Semicontinuity/Defs.lean +++ b/mathlib4/Mathlib/Topology/Semicontinuity/Defs.lean @@ -460,8 +460,9 @@ theorem UpperSemicontinuousWithinAt.mono (h : UpperSemicontinuousWithinAt f s x) theorem UpperSemicontinuousWithinAt.congr_of_eventuallyEq {a : α} (h : UpperSemicontinuousWithinAt f s a) (has : a ∈ s) (hfg : ∀ᶠ x in nhdsWithin a s, f x = g x) : - UpperSemicontinuousWithinAt g s a := - LowerSemicontinuousWithinAt.congr_of_eventuallyEq (β := βᵒᵈ) h has hfg + UpperSemicontinuousWithinAt g s a := by + unsealing_newtype OrderDual => + exact LowerSemicontinuousWithinAt.congr_of_eventuallyEq (β := βᵒᵈ) h has hfg theorem upperSemicontinuousWithinAt_univ_iff : UpperSemicontinuousWithinAt f univ x ↔ UpperSemicontinuousAt f x := @@ -469,7 +470,7 @@ theorem upperSemicontinuousWithinAt_univ_iff : @[simp] theorem upperSemicontinuousOn_iff_restrict {s : Set α} : UpperSemicontinuous (s.domRestrict f) ↔ UpperSemicontinuousOn f s := - lowerSemicontinuous_restrict_iff (β := βᵒᵈ) + semicontinuous_restrict_iff (r := (f · < ·)) theorem UpperSemicontinuousAt.upperSemicontinuousWithinAt (s : Set α) (h : UpperSemicontinuousAt f x) : UpperSemicontinuousWithinAt f s x := diff --git a/mathlib4/Mathlib/Topology/Semicontinuity/Lindelof.lean b/mathlib4/Mathlib/Topology/Semicontinuity/Lindelof.lean index ed6fc5f88..26e19e8bd 100644 --- a/mathlib4/Mathlib/Topology/Semicontinuity/Lindelof.lean +++ b/mathlib4/Mathlib/Topology/Semicontinuity/Lindelof.lean @@ -94,7 +94,8 @@ This is implication a) ⇒ b) in See the module docstring for a discussion of the assumptions on `E`. -/ theorem exists_countable_lowerSemicontinuous_isLUB {s : X → E} {𝓕 : Set (X → E)} (h𝓕_cont : ∀ f ∈ 𝓕, LowerSemicontinuous f) (h𝓕 : IsLUB 𝓕 s) : - ∃ 𝓕' ⊆ 𝓕, 𝓕'.Countable ∧ IsLUB 𝓕' s := - exists_countable_upperSemicontinuous_isGLB (E := Eᵒᵈ) h𝓕_cont h𝓕 + ∃ 𝓕' ⊆ 𝓕, 𝓕'.Countable ∧ IsLUB 𝓕' s := by + unsealing_newtype OrderDual => + exact exists_countable_upperSemicontinuous_isGLB (E := Eᵒᵈ) h𝓕_cont h𝓕 end diff --git a/mathlib4/Mathlib/Topology/Separation/Basic.lean b/mathlib4/Mathlib/Topology/Separation/Basic.lean index b702d1ad9..751af6c30 100644 --- a/mathlib4/Mathlib/Topology/Separation/Basic.lean +++ b/mathlib4/Mathlib/Topology/Separation/Basic.lean @@ -149,7 +149,9 @@ theorem exists_isOpen_xor_mem [T0Space X] {x y : X} (h : x ≠ y) : /-- Specialization forms a partial order on a t0 topological space. -/ @[instance_reducible] def specializationOrder (X) [TopologicalSpace X] [T0Space X] : PartialOrder X := - { specializationPreorder X, PartialOrder.lift (OrderDual.toDual ∘ 𝓝) nhds_injective with } + { specializationPreorder X, + PartialOrder.lift (OrderDual.toDual ∘ 𝓝) + (fun _ _ h ↦ nhds_injective (congrArg OrderDual.ofDual h)) with } instance SeparationQuotient.instT0Space : T0Space (SeparationQuotient X) := ⟨fun x y => Quotient.inductionOn₂' x y fun _ _ h => diff --git a/mathlib4/Mathlib/Topology/Separation/LinearUpperLowerSetTopology.lean b/mathlib4/Mathlib/Topology/Separation/LinearUpperLowerSetTopology.lean index 74abbed62..5878f81e7 100644 --- a/mathlib4/Mathlib/Topology/Separation/LinearUpperLowerSetTopology.lean +++ b/mathlib4/Mathlib/Topology/Separation/LinearUpperLowerSetTopology.lean @@ -29,10 +29,12 @@ instance (priority := low) {α : Type*} conv at hsct => equals b < a => simp exact lt_asymm hcst hsct +open Topology.IsLowerSet in instance (priority := low) {α : Type*} [TopologicalSpace α] [LinearOrder α] [Topology.IsLowerSet α] : - CompletelyNormalSpace α := - inferInstanceAs (CompletelyNormalSpace αᵒᵈ) + CompletelyNormalSpace α := by + unsealing_newtype OrderDual => + exact inferInstanceAs (CompletelyNormalSpace αᵒᵈ) instance : CompletelyNormalSpace Prop := let := Prop.linearOrder diff --git a/mathlib4/Mathlib/Topology/UniformSpace/Basic.lean b/mathlib4/Mathlib/Topology/UniformSpace/Basic.lean index 3dd54f846..2c3e354fa 100644 --- a/mathlib4/Mathlib/Topology/UniformSpace/Basic.lean +++ b/mathlib4/Mathlib/Topology/UniformSpace/Basic.lean @@ -561,9 +561,13 @@ end instance ULift.uniformSpace [UniformSpace α] : UniformSpace (ULift α) := UniformSpace.comap ULift.down ‹_› -/-- Uniform space structure on `αᵒᵈ`. -/ +/-- Uniform space structure on `αᵒᵈ`. The topology of `αᵒᵈ` is coinduced by `toDual`, which is the +same as being induced by `ofDual`, so `replaceTopology` keeps the two instances defeq. -/ instance OrderDual.instUniformSpace [UniformSpace α] : UniformSpace (αᵒᵈ) := - ‹UniformSpace α› + (UniformSpace.comap OrderDual.ofDual ‹_›).replaceTopology <| by + refine TopologicalSpace.ext_iff.2 fun s ↦ ⟨fun hs ↦ ⟨_, hs, rfl⟩, ?_⟩ + rintro ⟨u, hu, rfl⟩ + exact hu section UniformContinuousInfi diff --git a/mathlib4/Mathlib/Topology/UniformSpace/Dini.lean b/mathlib4/Mathlib/Topology/UniformSpace/Dini.lean index 21a7d06fc..ab46203be 100644 --- a/mathlib4/Mathlib/Topology/UniformSpace/Dini.lean +++ b/mathlib4/Mathlib/Topology/UniformSpace/Dini.lean @@ -105,13 +105,24 @@ end Monotone namespace Antitone +/-- The uniformity of `Xᵒᵈ` is the one comapped along `ofDual`, so `ofDual` is uniformly +continuous; this is what carries a `Tendsto*Uniformly*` statement back from the dual. -/ +private lemma uniformContinuous_ofDual {X : Type*} [UniformSpace X] : + UniformContinuous (OrderDual.ofDual : Xᵒᵈ → X) := + uniformContinuous_comap + /-- **Dini's theorem**: if `F n` is a monotone decreasing collection of continuous functions on a converging pointwise to a continuous function `f`, then `F n` converges locally uniformly to `f`. -/ lemma tendstoLocallyUniformly_of_forall_tendsto (hF_cont : ∀ i, Continuous (F i)) (hF_anti : Antitone F) (hf : Continuous f) (h_tendsto : ∀ x, Tendsto (F · x) atTop (𝓝 (f x))) : TendstoLocallyUniformly F f atTop := - Monotone.tendstoLocallyUniformly_of_forall_tendsto (G := Gᵒᵈ) hF_cont hF_anti hf h_tendsto + uniformContinuous_ofDual.comp_tendstoLocallyUniformly <| + Monotone.tendstoLocallyUniformly_of_forall_tendsto (G := Gᵒᵈ) + (F := fun i ↦ ⇑OrderDual.toDual ∘ F i) (f := ⇑OrderDual.toDual ∘ f) + (fun i ↦ continuous_toDual.comp (hF_cont i)) (fun _ _ hij x ↦ hF_anti hij x) + (continuous_toDual.comp hf) + (fun x ↦ (continuous_toDual.tendsto _).comp (h_tendsto x)) /-- **Dini's theorem**: if `F n` is a monotone decreasing collection of continuous functions on a set `s` converging pointwise to a continuous function `f`, then `F n` converges locally uniformly @@ -120,7 +131,13 @@ lemma tendstoLocallyUniformlyOn_of_forall_tendsto {s : Set α} (hF_cont : ∀ i, ContinuousOn (F i) s) (hF_anti : ∀ x ∈ s, Antitone (F · x)) (hf : ContinuousOn f s) (h_tendsto : ∀ x ∈ s, Tendsto (F · x) atTop (𝓝 (f x))) : TendstoLocallyUniformlyOn F f atTop s := - Monotone.tendstoLocallyUniformlyOn_of_forall_tendsto (G := Gᵒᵈ) hF_cont hF_anti hf h_tendsto + uniformContinuous_ofDual.comp_tendstoLocallyUniformlyOn <| + Monotone.tendstoLocallyUniformlyOn_of_forall_tendsto (G := Gᵒᵈ) + (F := fun i ↦ ⇑OrderDual.toDual ∘ F i) (f := ⇑OrderDual.toDual ∘ f) + (fun i ↦ continuous_toDual.comp_continuousOn (hF_cont i)) + (fun x hx _ _ hij ↦ hF_anti x hx hij) + (continuous_toDual.comp_continuousOn hf) + (fun x hx ↦ (continuous_toDual.tendsto _).comp (h_tendsto x hx)) /-- **Dini's theorem**: if `F n` is a monotone decreasing collection of continuous functions on a compact space converging pointwise to a continuous function `f`, then `F n` converges uniformly @@ -128,7 +145,12 @@ to `f`. -/ lemma tendstoUniformly_of_forall_tendsto [CompactSpace α] (hF_cont : ∀ i, Continuous (F i)) (hF_anti : Antitone F) (hf : Continuous f) (h_tendsto : ∀ x, Tendsto (F · x) atTop (𝓝 (f x))) : TendstoUniformly F f atTop := - Monotone.tendstoUniformly_of_forall_tendsto (G := Gᵒᵈ) hF_cont hF_anti hf h_tendsto + uniformContinuous_ofDual.comp_tendstoUniformly <| + Monotone.tendstoUniformly_of_forall_tendsto (G := Gᵒᵈ) + (F := fun i ↦ ⇑OrderDual.toDual ∘ F i) (f := ⇑OrderDual.toDual ∘ f) + (fun i ↦ continuous_toDual.comp (hF_cont i)) (fun _ _ hij x ↦ hF_anti hij x) + (continuous_toDual.comp hf) + (fun x ↦ (continuous_toDual.tendsto _).comp (h_tendsto x)) /-- **Dini's theorem**: if `F n` is a monotone decreasing collection of continuous functions on a compact set `s` converging pointwise to a continuous `f`, then `F n` converges uniformly to `f`. -/ @@ -136,7 +158,13 @@ lemma tendstoUniformlyOn_of_forall_tendsto {s : Set α} (hs : IsCompact s) (hF_cont : ∀ i, ContinuousOn (F i) s) (hF_anti : ∀ x ∈ s, Antitone (F · x)) (hf : ContinuousOn f s) (h_tendsto : ∀ x ∈ s, Tendsto (F · x) atTop (𝓝 (f x))) : TendstoUniformlyOn F f atTop s := - Monotone.tendstoUniformlyOn_of_forall_tendsto (G := Gᵒᵈ) hs hF_cont hF_anti hf h_tendsto + uniformContinuous_ofDual.comp_tendstoUniformlyOn <| + Monotone.tendstoUniformlyOn_of_forall_tendsto (G := Gᵒᵈ) hs + (F := fun i ↦ ⇑OrderDual.toDual ∘ F i) (f := ⇑OrderDual.toDual ∘ f) + (fun i ↦ continuous_toDual.comp_continuousOn (hF_cont i)) + (fun x hx _ _ hij ↦ hF_anti x hx hij) + (continuous_toDual.comp_continuousOn hf) + (fun x hx ↦ (continuous_toDual.tendsto _).comp (h_tendsto x hx)) end Antitone @@ -160,7 +188,8 @@ converging pointwise to a continuous function `f`, then `F n` converges to `f` i compact-open topology. -/ lemma tendsto_of_antitone_of_pointwise (hF_anti : Antitone F) (h_tendsto : ∀ x, Tendsto (F · x) atTop (𝓝 (f x))) : - Tendsto F atTop (𝓝 f) := - tendsto_of_monotone_of_pointwise (G := Gᵒᵈ) hF_anti h_tendsto + Tendsto F atTop (𝓝 f) := by + unsealing_newtype OrderDual => + exact tendsto_of_monotone_of_pointwise (G := Gᵒᵈ) hF_anti h_tendsto end ContinuousMap