Context
stringlengths
57
6.04k
file_name
stringlengths
21
79
start
int64
14
1.49k
end
int64
18
1.5k
theorem
stringlengths
25
1.55k
proof
stringlengths
5
7.36k
rank
int64
0
2.4k
import Mathlib.AlgebraicGeometry.Morphisms.Basic import Mathlib.Topology.Spectral.Hom import Mathlib.AlgebraicGeometry.Limits #align_import algebraic_geometry.morphisms.quasi_compact from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u open scoped AlgebraicGeometry namespace AlgebraicGeometry variable {X Y : Scheme.{u}} (f : X ⟶ Y) @[mk_iff] class QuasiCompact (f : X ⟶ Y) : Prop where isCompact_preimage : ∀ U : Set Y.carrier, IsOpen U → IsCompact U → IsCompact (f.1.base ⁻¹' U) #align algebraic_geometry.quasi_compact AlgebraicGeometry.QuasiCompact theorem quasiCompact_iff_spectral : QuasiCompact f ↔ IsSpectralMap f.1.base := ⟨fun ⟨h⟩ => ⟨by continuity, h⟩, fun h => ⟨h.2⟩⟩ #align algebraic_geometry.quasi_compact_iff_spectral AlgebraicGeometry.quasiCompact_iff_spectral def QuasiCompact.affineProperty : AffineTargetMorphismProperty := fun X _ _ _ => CompactSpace X.carrier #align algebraic_geometry.quasi_compact.affine_property AlgebraicGeometry.QuasiCompact.affineProperty instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : QuasiCompact f := by constructor intro U _ hU' convert hU'.image (inv f.1.base).continuous_toFun using 1 rw [Set.image_eq_preimage_of_inverse] · delta Function.LeftInverse exact IsIso.inv_hom_id_apply f.1.base · exact IsIso.hom_inv_id_apply f.1.base #align algebraic_geometry.quasi_compact_of_is_iso AlgebraicGeometry.quasiCompactOfIsIso instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f] [QuasiCompact g] : QuasiCompact (f ≫ g) := by constructor intro U hU hU' rw [Scheme.comp_val_base, TopCat.coe_comp, Set.preimage_comp] apply QuasiCompact.isCompact_preimage · exact Continuous.isOpen_preimage (by -- Porting note: `continuity` failed -- see https://github.com/leanprover-community/mathlib4/issues/5030 exact Scheme.Hom.continuous g) _ hU apply QuasiCompact.isCompact_preimage <;> assumption #align algebraic_geometry.quasi_compact_comp AlgebraicGeometry.quasiCompactComp theorem isCompact_open_iff_eq_finset_affine_union {X : Scheme} (U : Set X.carrier) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ (i : X.affineOpens) (_ : i ∈ s), i := by apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion (fun (U : X.affineOpens) => (U : Opens X.carrier)) · rw [Subtype.range_coe]; exact isBasis_affine_open X · exact fun i => i.2.isCompact #align algebraic_geometry.is_compact_open_iff_eq_finset_affine_union AlgebraicGeometry.isCompact_open_iff_eq_finset_affine_union theorem isCompact_open_iff_eq_basicOpen_union {X : Scheme} [IsAffine X] (U : Set X.carrier) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set (X.presheaf.obj (op ⊤)), s.Finite ∧ U = ⋃ (i : X.presheaf.obj (op ⊤)) (_ : i ∈ s), X.basicOpen i := (isBasis_basicOpen X).isCompact_open_iff_eq_finite_iUnion _ (fun _ => ((topIsAffineOpen _).basicOpenIsAffine _).isCompact) _ #align algebraic_geometry.is_compact_open_iff_eq_basic_open_union AlgebraicGeometry.isCompact_open_iff_eq_basicOpen_union theorem quasiCompact_iff_forall_affine : QuasiCompact f ↔ ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by rw [quasiCompact_iff] refine ⟨fun H U hU => H U U.isOpen hU.isCompact, ?_⟩ intro H U hU hU' obtain ⟨S, hS, rfl⟩ := (isCompact_open_iff_eq_finset_affine_union U).mp ⟨hU', hU⟩ simp only [Set.preimage_iUnion] exact Set.Finite.isCompact_biUnion hS (fun i _ => H i i.prop) #align algebraic_geometry.quasi_compact_iff_forall_affine AlgebraicGeometry.quasiCompact_iff_forall_affine @[simp] theorem QuasiCompact.affineProperty_toProperty {X Y : Scheme} (f : X ⟶ Y) : (QuasiCompact.affineProperty : _).toProperty f ↔ IsAffine Y ∧ CompactSpace X.carrier := by delta AffineTargetMorphismProperty.toProperty QuasiCompact.affineProperty; simp #align algebraic_geometry.quasi_compact.affine_property_to_property AlgebraicGeometry.QuasiCompact.affineProperty_toProperty
Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean
114
120
theorem quasiCompact_iff_affineProperty : QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by
rw [quasiCompact_iff_forall_affine] trans ∀ U : Y.affineOpens, IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) · exact ⟨fun h U => h U U.prop, fun h U hU => h ⟨U, hU⟩⟩ apply forall_congr' exact fun _ => isCompact_iff_compactSpace
460
import Mathlib.AlgebraicGeometry.Morphisms.Basic import Mathlib.Topology.Spectral.Hom import Mathlib.AlgebraicGeometry.Limits #align_import algebraic_geometry.morphisms.quasi_compact from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u open scoped AlgebraicGeometry namespace AlgebraicGeometry variable {X Y : Scheme.{u}} (f : X ⟶ Y) @[mk_iff] class QuasiCompact (f : X ⟶ Y) : Prop where isCompact_preimage : ∀ U : Set Y.carrier, IsOpen U → IsCompact U → IsCompact (f.1.base ⁻¹' U) #align algebraic_geometry.quasi_compact AlgebraicGeometry.QuasiCompact theorem quasiCompact_iff_spectral : QuasiCompact f ↔ IsSpectralMap f.1.base := ⟨fun ⟨h⟩ => ⟨by continuity, h⟩, fun h => ⟨h.2⟩⟩ #align algebraic_geometry.quasi_compact_iff_spectral AlgebraicGeometry.quasiCompact_iff_spectral def QuasiCompact.affineProperty : AffineTargetMorphismProperty := fun X _ _ _ => CompactSpace X.carrier #align algebraic_geometry.quasi_compact.affine_property AlgebraicGeometry.QuasiCompact.affineProperty instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : QuasiCompact f := by constructor intro U _ hU' convert hU'.image (inv f.1.base).continuous_toFun using 1 rw [Set.image_eq_preimage_of_inverse] · delta Function.LeftInverse exact IsIso.inv_hom_id_apply f.1.base · exact IsIso.hom_inv_id_apply f.1.base #align algebraic_geometry.quasi_compact_of_is_iso AlgebraicGeometry.quasiCompactOfIsIso instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f] [QuasiCompact g] : QuasiCompact (f ≫ g) := by constructor intro U hU hU' rw [Scheme.comp_val_base, TopCat.coe_comp, Set.preimage_comp] apply QuasiCompact.isCompact_preimage · exact Continuous.isOpen_preimage (by -- Porting note: `continuity` failed -- see https://github.com/leanprover-community/mathlib4/issues/5030 exact Scheme.Hom.continuous g) _ hU apply QuasiCompact.isCompact_preimage <;> assumption #align algebraic_geometry.quasi_compact_comp AlgebraicGeometry.quasiCompactComp theorem isCompact_open_iff_eq_finset_affine_union {X : Scheme} (U : Set X.carrier) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ (i : X.affineOpens) (_ : i ∈ s), i := by apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion (fun (U : X.affineOpens) => (U : Opens X.carrier)) · rw [Subtype.range_coe]; exact isBasis_affine_open X · exact fun i => i.2.isCompact #align algebraic_geometry.is_compact_open_iff_eq_finset_affine_union AlgebraicGeometry.isCompact_open_iff_eq_finset_affine_union theorem isCompact_open_iff_eq_basicOpen_union {X : Scheme} [IsAffine X] (U : Set X.carrier) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set (X.presheaf.obj (op ⊤)), s.Finite ∧ U = ⋃ (i : X.presheaf.obj (op ⊤)) (_ : i ∈ s), X.basicOpen i := (isBasis_basicOpen X).isCompact_open_iff_eq_finite_iUnion _ (fun _ => ((topIsAffineOpen _).basicOpenIsAffine _).isCompact) _ #align algebraic_geometry.is_compact_open_iff_eq_basic_open_union AlgebraicGeometry.isCompact_open_iff_eq_basicOpen_union theorem quasiCompact_iff_forall_affine : QuasiCompact f ↔ ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by rw [quasiCompact_iff] refine ⟨fun H U hU => H U U.isOpen hU.isCompact, ?_⟩ intro H U hU hU' obtain ⟨S, hS, rfl⟩ := (isCompact_open_iff_eq_finset_affine_union U).mp ⟨hU', hU⟩ simp only [Set.preimage_iUnion] exact Set.Finite.isCompact_biUnion hS (fun i _ => H i i.prop) #align algebraic_geometry.quasi_compact_iff_forall_affine AlgebraicGeometry.quasiCompact_iff_forall_affine @[simp] theorem QuasiCompact.affineProperty_toProperty {X Y : Scheme} (f : X ⟶ Y) : (QuasiCompact.affineProperty : _).toProperty f ↔ IsAffine Y ∧ CompactSpace X.carrier := by delta AffineTargetMorphismProperty.toProperty QuasiCompact.affineProperty; simp #align algebraic_geometry.quasi_compact.affine_property_to_property AlgebraicGeometry.QuasiCompact.affineProperty_toProperty theorem quasiCompact_iff_affineProperty : QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by rw [quasiCompact_iff_forall_affine] trans ∀ U : Y.affineOpens, IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) · exact ⟨fun h U => h U U.prop, fun h U hU => h ⟨U, hU⟩⟩ apply forall_congr' exact fun _ => isCompact_iff_compactSpace #align algebraic_geometry.quasi_compact_iff_affine_property AlgebraicGeometry.quasiCompact_iff_affineProperty
Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean
123
126
theorem quasiCompact_eq_affineProperty : @QuasiCompact = targetAffineLocally QuasiCompact.affineProperty := by
ext exact quasiCompact_iff_affineProperty _
460
import Mathlib.AlgebraicGeometry.Morphisms.Basic import Mathlib.Topology.Spectral.Hom import Mathlib.AlgebraicGeometry.Limits #align_import algebraic_geometry.morphisms.quasi_compact from "leanprover-community/mathlib"@"5dc6092d09e5e489106865241986f7f2ad28d4c8" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u open scoped AlgebraicGeometry namespace AlgebraicGeometry variable {X Y : Scheme.{u}} (f : X ⟶ Y) @[mk_iff] class QuasiCompact (f : X ⟶ Y) : Prop where isCompact_preimage : ∀ U : Set Y.carrier, IsOpen U → IsCompact U → IsCompact (f.1.base ⁻¹' U) #align algebraic_geometry.quasi_compact AlgebraicGeometry.QuasiCompact theorem quasiCompact_iff_spectral : QuasiCompact f ↔ IsSpectralMap f.1.base := ⟨fun ⟨h⟩ => ⟨by continuity, h⟩, fun h => ⟨h.2⟩⟩ #align algebraic_geometry.quasi_compact_iff_spectral AlgebraicGeometry.quasiCompact_iff_spectral def QuasiCompact.affineProperty : AffineTargetMorphismProperty := fun X _ _ _ => CompactSpace X.carrier #align algebraic_geometry.quasi_compact.affine_property AlgebraicGeometry.QuasiCompact.affineProperty instance (priority := 900) quasiCompactOfIsIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : QuasiCompact f := by constructor intro U _ hU' convert hU'.image (inv f.1.base).continuous_toFun using 1 rw [Set.image_eq_preimage_of_inverse] · delta Function.LeftInverse exact IsIso.inv_hom_id_apply f.1.base · exact IsIso.hom_inv_id_apply f.1.base #align algebraic_geometry.quasi_compact_of_is_iso AlgebraicGeometry.quasiCompactOfIsIso instance quasiCompactComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f] [QuasiCompact g] : QuasiCompact (f ≫ g) := by constructor intro U hU hU' rw [Scheme.comp_val_base, TopCat.coe_comp, Set.preimage_comp] apply QuasiCompact.isCompact_preimage · exact Continuous.isOpen_preimage (by -- Porting note: `continuity` failed -- see https://github.com/leanprover-community/mathlib4/issues/5030 exact Scheme.Hom.continuous g) _ hU apply QuasiCompact.isCompact_preimage <;> assumption #align algebraic_geometry.quasi_compact_comp AlgebraicGeometry.quasiCompactComp theorem isCompact_open_iff_eq_finset_affine_union {X : Scheme} (U : Set X.carrier) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ (i : X.affineOpens) (_ : i ∈ s), i := by apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion (fun (U : X.affineOpens) => (U : Opens X.carrier)) · rw [Subtype.range_coe]; exact isBasis_affine_open X · exact fun i => i.2.isCompact #align algebraic_geometry.is_compact_open_iff_eq_finset_affine_union AlgebraicGeometry.isCompact_open_iff_eq_finset_affine_union theorem isCompact_open_iff_eq_basicOpen_union {X : Scheme} [IsAffine X] (U : Set X.carrier) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set (X.presheaf.obj (op ⊤)), s.Finite ∧ U = ⋃ (i : X.presheaf.obj (op ⊤)) (_ : i ∈ s), X.basicOpen i := (isBasis_basicOpen X).isCompact_open_iff_eq_finite_iUnion _ (fun _ => ((topIsAffineOpen _).basicOpenIsAffine _).isCompact) _ #align algebraic_geometry.is_compact_open_iff_eq_basic_open_union AlgebraicGeometry.isCompact_open_iff_eq_basicOpen_union theorem quasiCompact_iff_forall_affine : QuasiCompact f ↔ ∀ U : Opens Y.carrier, IsAffineOpen U → IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) := by rw [quasiCompact_iff] refine ⟨fun H U hU => H U U.isOpen hU.isCompact, ?_⟩ intro H U hU hU' obtain ⟨S, hS, rfl⟩ := (isCompact_open_iff_eq_finset_affine_union U).mp ⟨hU', hU⟩ simp only [Set.preimage_iUnion] exact Set.Finite.isCompact_biUnion hS (fun i _ => H i i.prop) #align algebraic_geometry.quasi_compact_iff_forall_affine AlgebraicGeometry.quasiCompact_iff_forall_affine @[simp] theorem QuasiCompact.affineProperty_toProperty {X Y : Scheme} (f : X ⟶ Y) : (QuasiCompact.affineProperty : _).toProperty f ↔ IsAffine Y ∧ CompactSpace X.carrier := by delta AffineTargetMorphismProperty.toProperty QuasiCompact.affineProperty; simp #align algebraic_geometry.quasi_compact.affine_property_to_property AlgebraicGeometry.QuasiCompact.affineProperty_toProperty theorem quasiCompact_iff_affineProperty : QuasiCompact f ↔ targetAffineLocally QuasiCompact.affineProperty f := by rw [quasiCompact_iff_forall_affine] trans ∀ U : Y.affineOpens, IsCompact (f.1.base ⁻¹' (U : Set Y.carrier)) · exact ⟨fun h U => h U U.prop, fun h U hU => h ⟨U, hU⟩⟩ apply forall_congr' exact fun _ => isCompact_iff_compactSpace #align algebraic_geometry.quasi_compact_iff_affine_property AlgebraicGeometry.quasiCompact_iff_affineProperty theorem quasiCompact_eq_affineProperty : @QuasiCompact = targetAffineLocally QuasiCompact.affineProperty := by ext exact quasiCompact_iff_affineProperty _ #align algebraic_geometry.quasi_compact_eq_affine_property AlgebraicGeometry.quasiCompact_eq_affineProperty
Mathlib/AlgebraicGeometry/Morphisms/QuasiCompact.lean
129
158
theorem isCompact_basicOpen (X : Scheme) {U : Opens X.carrier} (hU : IsCompact (U : Set X.carrier)) (f : X.presheaf.obj (op U)) : IsCompact (X.basicOpen f : Set X.carrier) := by
classical refine ((isCompact_open_iff_eq_finset_affine_union _).mpr ?_).1 obtain ⟨s, hs, e⟩ := (isCompact_open_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩ let g : s → X.affineOpens := by intro V use V.1 ⊓ X.basicOpen f have : V.1.1 ⟶ U := by apply homOfLE; change _ ⊆ (U : Set X.carrier); rw [e] convert Set.subset_iUnion₂ (s := fun (U : X.affineOpens) (_ : U ∈ s) => (U : Set X.carrier)) V V.prop using 1 erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op] exact IsAffineOpen.basicOpenIsAffine V.1.prop _ haveI : Finite s := hs.to_subtype refine ⟨Set.range g, Set.finite_range g, ?_⟩ refine (Set.inter_eq_right.mpr (SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans ?_ rw [e, Set.iUnion₂_inter] apply le_antisymm <;> apply Set.iUnion₂_subset · intro i hi -- Porting note: had to make explicit the first given parameter to `Set.subset_iUnion₂` exact Set.Subset.trans (Set.Subset.rfl : _ ≤ g ⟨i, hi⟩) (@Set.subset_iUnion₂ _ _ _ (fun (i : Scheme.affineOpens X) (_ : i ∈ Set.range g) => (i : Set X.toPresheafedSpace)) _ (Set.mem_range_self ⟨i, hi⟩)) · rintro ⟨i, hi⟩ ⟨⟨j, hj⟩, hj'⟩ rw [← hj'] refine Set.Subset.trans ?_ (Set.subset_iUnion₂ j hj) exact Set.Subset.rfl
460
import Mathlib.Topology.LocalAtTarget import Mathlib.AlgebraicGeometry.Morphisms.Basic #align_import algebraic_geometry.morphisms.open_immersion from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u namespace AlgebraicGeometry variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
Mathlib/AlgebraicGeometry/Morphisms/OpenImmersion.lean
34
38
theorem isOpenImmersion_iff_stalk {f : X ⟶ Y} : IsOpenImmersion f ↔ OpenEmbedding f.1.base ∧ ∀ x, IsIso (PresheafedSpace.stalkMap f.1 x) := by
constructor · intro h; exact ⟨h.1, inferInstance⟩ · rintro ⟨h₁, h₂⟩; exact IsOpenImmersion.of_stalk_iso f h₁
461
import Mathlib.Topology.LocalAtTarget import Mathlib.AlgebraicGeometry.Morphisms.Basic #align_import algebraic_geometry.morphisms.open_immersion from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u namespace AlgebraicGeometry variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) theorem isOpenImmersion_iff_stalk {f : X ⟶ Y} : IsOpenImmersion f ↔ OpenEmbedding f.1.base ∧ ∀ x, IsIso (PresheafedSpace.stalkMap f.1 x) := by constructor · intro h; exact ⟨h.1, inferInstance⟩ · rintro ⟨h₁, h₂⟩; exact IsOpenImmersion.of_stalk_iso f h₁ #align algebraic_geometry.is_open_immersion_iff_stalk AlgebraicGeometry.isOpenImmersion_iff_stalk instance isOpenImmersion_isStableUnderComposition : MorphismProperty.IsStableUnderComposition @IsOpenImmersion where comp_mem f g _ _ := LocallyRingedSpace.IsOpenImmersion.comp f g #align algebraic_geometry.is_open_immersion_stable_under_composition AlgebraicGeometry.isOpenImmersion_isStableUnderComposition
Mathlib/AlgebraicGeometry/Morphisms/OpenImmersion.lean
46
50
theorem isOpenImmersion_respectsIso : MorphismProperty.RespectsIso @IsOpenImmersion := by
apply MorphismProperty.respectsIso_of_isStableUnderComposition intro _ _ f (hf : IsIso f) have : IsIso f := hf infer_instance
461
import Mathlib.Topology.LocalAtTarget import Mathlib.AlgebraicGeometry.Morphisms.Basic #align_import algebraic_geometry.morphisms.open_immersion from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace universe u namespace AlgebraicGeometry variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) theorem isOpenImmersion_iff_stalk {f : X ⟶ Y} : IsOpenImmersion f ↔ OpenEmbedding f.1.base ∧ ∀ x, IsIso (PresheafedSpace.stalkMap f.1 x) := by constructor · intro h; exact ⟨h.1, inferInstance⟩ · rintro ⟨h₁, h₂⟩; exact IsOpenImmersion.of_stalk_iso f h₁ #align algebraic_geometry.is_open_immersion_iff_stalk AlgebraicGeometry.isOpenImmersion_iff_stalk instance isOpenImmersion_isStableUnderComposition : MorphismProperty.IsStableUnderComposition @IsOpenImmersion where comp_mem f g _ _ := LocallyRingedSpace.IsOpenImmersion.comp f g #align algebraic_geometry.is_open_immersion_stable_under_composition AlgebraicGeometry.isOpenImmersion_isStableUnderComposition theorem isOpenImmersion_respectsIso : MorphismProperty.RespectsIso @IsOpenImmersion := by apply MorphismProperty.respectsIso_of_isStableUnderComposition intro _ _ f (hf : IsIso f) have : IsIso f := hf infer_instance #align algebraic_geometry.is_open_immersion_respects_iso AlgebraicGeometry.isOpenImmersion_respectsIso
Mathlib/AlgebraicGeometry/Morphisms/OpenImmersion.lean
53
74
theorem isOpenImmersion_is_local_at_target : PropertyIsLocalAtTarget @IsOpenImmersion := by
constructor · exact isOpenImmersion_respectsIso · intros; infer_instance · intro X Y f 𝒰 H rw [isOpenImmersion_iff_stalk] constructor · apply (openEmbedding_iff_openEmbedding_of_iSup_eq_top 𝒰.iSup_opensRange f.1.base.2).mpr intro i have := ((isOpenImmersion_respectsIso.arrow_iso_iff (morphismRestrictOpensRange f (𝒰.map i))).mpr (H i)).1 erw [Arrow.mk_hom, morphismRestrict_val_base] at this norm_cast · intro x have := Arrow.iso_w (morphismRestrictStalkMap f (Scheme.Hom.opensRange (𝒰.map <| 𝒰.f <| f.1.base x)) ⟨x, 𝒰.Covers _⟩) dsimp only [Arrow.mk_hom] at this rw [this] haveI : IsOpenImmersion (f ∣_ Scheme.Hom.opensRange (𝒰.map <| 𝒰.f <| f.1.base x)) := (isOpenImmersion_respectsIso.arrow_iso_iff (morphismRestrictOpensRange f (𝒰.map _))).mpr (H _) infer_instance
461
import Mathlib.Data.Opposite import Mathlib.Data.Set.Defs #align_import data.set.opposite from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" variable {α : Type*} open Opposite namespace Set protected def op (s : Set α) : Set αᵒᵖ := unop ⁻¹' s #align set.op Set.op protected def unop (s : Set αᵒᵖ) : Set α := op ⁻¹' s #align set.unop Set.unop @[simp] theorem mem_op {s : Set α} {a : αᵒᵖ} : a ∈ s.op ↔ unop a ∈ s := Iff.rfl #align set.mem_op Set.mem_op @[simp 1100]
Mathlib/Data/Set/Opposite.lean
39
39
theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by
rfl
462
import Mathlib.Data.Opposite import Mathlib.Data.Set.Defs #align_import data.set.opposite from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" variable {α : Type*} open Opposite namespace Set protected def op (s : Set α) : Set αᵒᵖ := unop ⁻¹' s #align set.op Set.op protected def unop (s : Set αᵒᵖ) : Set α := op ⁻¹' s #align set.unop Set.unop @[simp] theorem mem_op {s : Set α} {a : αᵒᵖ} : a ∈ s.op ↔ unop a ∈ s := Iff.rfl #align set.mem_op Set.mem_op @[simp 1100] theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by rfl #align set.op_mem_op Set.op_mem_op @[simp] theorem mem_unop {s : Set αᵒᵖ} {a : α} : a ∈ s.unop ↔ op a ∈ s := Iff.rfl #align set.mem_unop Set.mem_unop @[simp 1100]
Mathlib/Data/Set/Opposite.lean
48
48
theorem unop_mem_unop {s : Set αᵒᵖ} {a : αᵒᵖ} : unop a ∈ s.unop ↔ a ∈ s := by
rfl
462
import Mathlib.Data.Opposite import Mathlib.Data.Set.Defs #align_import data.set.opposite from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" variable {α : Type*} open Opposite namespace Set protected def op (s : Set α) : Set αᵒᵖ := unop ⁻¹' s #align set.op Set.op protected def unop (s : Set αᵒᵖ) : Set α := op ⁻¹' s #align set.unop Set.unop @[simp] theorem mem_op {s : Set α} {a : αᵒᵖ} : a ∈ s.op ↔ unop a ∈ s := Iff.rfl #align set.mem_op Set.mem_op @[simp 1100] theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by rfl #align set.op_mem_op Set.op_mem_op @[simp] theorem mem_unop {s : Set αᵒᵖ} {a : α} : a ∈ s.unop ↔ op a ∈ s := Iff.rfl #align set.mem_unop Set.mem_unop @[simp 1100] theorem unop_mem_unop {s : Set αᵒᵖ} {a : αᵒᵖ} : unop a ∈ s.unop ↔ a ∈ s := by rfl #align set.unop_mem_unop Set.unop_mem_unop @[simp] theorem op_unop (s : Set α) : s.op.unop = s := rfl #align set.op_unop Set.op_unop @[simp] theorem unop_op (s : Set αᵒᵖ) : s.unop.op = s := rfl #align set.unop_op Set.unop_op @[simps] def opEquiv_self (s : Set α) : s.op ≃ s := ⟨fun x ↦ ⟨unop x, x.2⟩, fun x ↦ ⟨op x, x.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩ #align set.op_equiv_self Set.opEquiv_self #align set.op_equiv_self_apply_coe Set.opEquiv_self_apply_coe #align set.op_equiv_self_symm_apply_coe Set.opEquiv_self_symm_apply_coe @[simps] def opEquiv : Set α ≃ Set αᵒᵖ := ⟨Set.op, Set.unop, op_unop, unop_op⟩ #align set.op_equiv Set.opEquiv #align set.op_equiv_symm_apply Set.opEquiv_symm_apply #align set.op_equiv_apply Set.opEquiv_apply @[simp]
Mathlib/Data/Set/Opposite.lean
76
80
theorem singleton_op (x : α) : ({x} : Set α).op = {op x} := by
ext constructor · apply unop_injective · apply op_injective
462
import Mathlib.Data.Opposite import Mathlib.Data.Set.Defs #align_import data.set.opposite from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" variable {α : Type*} open Opposite namespace Set protected def op (s : Set α) : Set αᵒᵖ := unop ⁻¹' s #align set.op Set.op protected def unop (s : Set αᵒᵖ) : Set α := op ⁻¹' s #align set.unop Set.unop @[simp] theorem mem_op {s : Set α} {a : αᵒᵖ} : a ∈ s.op ↔ unop a ∈ s := Iff.rfl #align set.mem_op Set.mem_op @[simp 1100] theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by rfl #align set.op_mem_op Set.op_mem_op @[simp] theorem mem_unop {s : Set αᵒᵖ} {a : α} : a ∈ s.unop ↔ op a ∈ s := Iff.rfl #align set.mem_unop Set.mem_unop @[simp 1100] theorem unop_mem_unop {s : Set αᵒᵖ} {a : αᵒᵖ} : unop a ∈ s.unop ↔ a ∈ s := by rfl #align set.unop_mem_unop Set.unop_mem_unop @[simp] theorem op_unop (s : Set α) : s.op.unop = s := rfl #align set.op_unop Set.op_unop @[simp] theorem unop_op (s : Set αᵒᵖ) : s.unop.op = s := rfl #align set.unop_op Set.unop_op @[simps] def opEquiv_self (s : Set α) : s.op ≃ s := ⟨fun x ↦ ⟨unop x, x.2⟩, fun x ↦ ⟨op x, x.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩ #align set.op_equiv_self Set.opEquiv_self #align set.op_equiv_self_apply_coe Set.opEquiv_self_apply_coe #align set.op_equiv_self_symm_apply_coe Set.opEquiv_self_symm_apply_coe @[simps] def opEquiv : Set α ≃ Set αᵒᵖ := ⟨Set.op, Set.unop, op_unop, unop_op⟩ #align set.op_equiv Set.opEquiv #align set.op_equiv_symm_apply Set.opEquiv_symm_apply #align set.op_equiv_apply Set.opEquiv_apply @[simp] theorem singleton_op (x : α) : ({x} : Set α).op = {op x} := by ext constructor · apply unop_injective · apply op_injective #align set.singleton_op Set.singleton_op @[simp]
Mathlib/Data/Set/Opposite.lean
84
88
theorem singleton_unop (x : αᵒᵖ) : ({x} : Set αᵒᵖ).unop = {unop x} := by
ext constructor · apply op_injective · apply unop_injective
462
import Mathlib.Data.Opposite import Mathlib.Data.Set.Defs #align_import data.set.opposite from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" variable {α : Type*} open Opposite namespace Set protected def op (s : Set α) : Set αᵒᵖ := unop ⁻¹' s #align set.op Set.op protected def unop (s : Set αᵒᵖ) : Set α := op ⁻¹' s #align set.unop Set.unop @[simp] theorem mem_op {s : Set α} {a : αᵒᵖ} : a ∈ s.op ↔ unop a ∈ s := Iff.rfl #align set.mem_op Set.mem_op @[simp 1100] theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by rfl #align set.op_mem_op Set.op_mem_op @[simp] theorem mem_unop {s : Set αᵒᵖ} {a : α} : a ∈ s.unop ↔ op a ∈ s := Iff.rfl #align set.mem_unop Set.mem_unop @[simp 1100] theorem unop_mem_unop {s : Set αᵒᵖ} {a : αᵒᵖ} : unop a ∈ s.unop ↔ a ∈ s := by rfl #align set.unop_mem_unop Set.unop_mem_unop @[simp] theorem op_unop (s : Set α) : s.op.unop = s := rfl #align set.op_unop Set.op_unop @[simp] theorem unop_op (s : Set αᵒᵖ) : s.unop.op = s := rfl #align set.unop_op Set.unop_op @[simps] def opEquiv_self (s : Set α) : s.op ≃ s := ⟨fun x ↦ ⟨unop x, x.2⟩, fun x ↦ ⟨op x, x.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩ #align set.op_equiv_self Set.opEquiv_self #align set.op_equiv_self_apply_coe Set.opEquiv_self_apply_coe #align set.op_equiv_self_symm_apply_coe Set.opEquiv_self_symm_apply_coe @[simps] def opEquiv : Set α ≃ Set αᵒᵖ := ⟨Set.op, Set.unop, op_unop, unop_op⟩ #align set.op_equiv Set.opEquiv #align set.op_equiv_symm_apply Set.opEquiv_symm_apply #align set.op_equiv_apply Set.opEquiv_apply @[simp] theorem singleton_op (x : α) : ({x} : Set α).op = {op x} := by ext constructor · apply unop_injective · apply op_injective #align set.singleton_op Set.singleton_op @[simp] theorem singleton_unop (x : αᵒᵖ) : ({x} : Set αᵒᵖ).unop = {unop x} := by ext constructor · apply op_injective · apply unop_injective #align set.singleton_unop Set.singleton_unop @[simp 1100]
Mathlib/Data/Set/Opposite.lean
92
96
theorem singleton_op_unop (x : α) : ({op x} : Set αᵒᵖ).unop = {x} := by
ext constructor · apply op_injective · apply unop_injective
462
import Mathlib.Data.Opposite import Mathlib.Data.Set.Defs #align_import data.set.opposite from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" variable {α : Type*} open Opposite namespace Set protected def op (s : Set α) : Set αᵒᵖ := unop ⁻¹' s #align set.op Set.op protected def unop (s : Set αᵒᵖ) : Set α := op ⁻¹' s #align set.unop Set.unop @[simp] theorem mem_op {s : Set α} {a : αᵒᵖ} : a ∈ s.op ↔ unop a ∈ s := Iff.rfl #align set.mem_op Set.mem_op @[simp 1100] theorem op_mem_op {s : Set α} {a : α} : op a ∈ s.op ↔ a ∈ s := by rfl #align set.op_mem_op Set.op_mem_op @[simp] theorem mem_unop {s : Set αᵒᵖ} {a : α} : a ∈ s.unop ↔ op a ∈ s := Iff.rfl #align set.mem_unop Set.mem_unop @[simp 1100] theorem unop_mem_unop {s : Set αᵒᵖ} {a : αᵒᵖ} : unop a ∈ s.unop ↔ a ∈ s := by rfl #align set.unop_mem_unop Set.unop_mem_unop @[simp] theorem op_unop (s : Set α) : s.op.unop = s := rfl #align set.op_unop Set.op_unop @[simp] theorem unop_op (s : Set αᵒᵖ) : s.unop.op = s := rfl #align set.unop_op Set.unop_op @[simps] def opEquiv_self (s : Set α) : s.op ≃ s := ⟨fun x ↦ ⟨unop x, x.2⟩, fun x ↦ ⟨op x, x.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩ #align set.op_equiv_self Set.opEquiv_self #align set.op_equiv_self_apply_coe Set.opEquiv_self_apply_coe #align set.op_equiv_self_symm_apply_coe Set.opEquiv_self_symm_apply_coe @[simps] def opEquiv : Set α ≃ Set αᵒᵖ := ⟨Set.op, Set.unop, op_unop, unop_op⟩ #align set.op_equiv Set.opEquiv #align set.op_equiv_symm_apply Set.opEquiv_symm_apply #align set.op_equiv_apply Set.opEquiv_apply @[simp] theorem singleton_op (x : α) : ({x} : Set α).op = {op x} := by ext constructor · apply unop_injective · apply op_injective #align set.singleton_op Set.singleton_op @[simp] theorem singleton_unop (x : αᵒᵖ) : ({x} : Set αᵒᵖ).unop = {unop x} := by ext constructor · apply op_injective · apply unop_injective #align set.singleton_unop Set.singleton_unop @[simp 1100] theorem singleton_op_unop (x : α) : ({op x} : Set αᵒᵖ).unop = {x} := by ext constructor · apply op_injective · apply unop_injective #align set.singleton_op_unop Set.singleton_op_unop @[simp 1100]
Mathlib/Data/Set/Opposite.lean
100
104
theorem singleton_unop_op (x : αᵒᵖ) : ({unop x} : Set α).op = {x} := by
ext constructor · apply unop_injective · apply op_injective
462
import Mathlib.Algebra.Category.GroupCat.Basic import Mathlib.CategoryTheory.Limits.Shapes.ZeroObjects #align_import algebra.category.Group.zero from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" open CategoryTheory open CategoryTheory.Limits universe u namespace GroupCat @[to_additive]
Mathlib/Algebra/Category/GroupCat/Zero.lean
28
34
theorem isZero_of_subsingleton (G : GroupCat) [Subsingleton G] : IsZero G := by
refine ⟨fun X => ⟨⟨⟨1⟩, fun f => ?_⟩⟩, fun X => ⟨⟨⟨1⟩, fun f => ?_⟩⟩⟩ · ext x have : x = 1 := Subsingleton.elim _ _ rw [this, map_one, map_one] · ext apply Subsingleton.elim
463
import Mathlib.Algebra.Category.GroupCat.Basic import Mathlib.CategoryTheory.Limits.Shapes.ZeroObjects #align_import algebra.category.Group.zero from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" open CategoryTheory open CategoryTheory.Limits universe u namespace CommGroupCat @[to_additive]
Mathlib/Algebra/Category/GroupCat/Zero.lean
49
55
theorem isZero_of_subsingleton (G : CommGroupCat) [Subsingleton G] : IsZero G := by
refine ⟨fun X => ⟨⟨⟨1⟩, fun f => ?_⟩⟩, fun X => ⟨⟨⟨1⟩, fun f => ?_⟩⟩⟩ · ext x have : x = 1 := Subsingleton.elim _ _ rw [this, map_one, map_one] · ext apply Subsingleton.elim
463
import Mathlib.Algebra.Order.Ring.Int #align_import data.int.least_greatest from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" namespace Int def leastOfBdd {P : ℤ → Prop} [DecidablePred P] (b : ℤ) (Hb : ∀ z : ℤ, P z → b ≤ z) (Hinh : ∃ z : ℤ, P z) : { lb : ℤ // P lb ∧ ∀ z : ℤ, P z → lb ≤ z } := have EX : ∃ n : ℕ, P (b + n) := let ⟨elt, Helt⟩ := Hinh match elt, le.dest (Hb _ Helt), Helt with | _, ⟨n, rfl⟩, Hn => ⟨n, Hn⟩ ⟨b + (Nat.find EX : ℤ), Nat.find_spec EX, fun z h => match z, le.dest (Hb _ h), h with | _, ⟨_, rfl⟩, h => add_le_add_left (Int.ofNat_le.2 <| Nat.find_min' _ h) _⟩ #align int.least_of_bdd Int.leastOfBdd
Mathlib/Data/Int/LeastGreatest.lean
61
68
theorem exists_least_of_bdd {P : ℤ → Prop} (Hbdd : ∃ b : ℤ , ∀ z : ℤ , P z → b ≤ z) (Hinh : ∃ z : ℤ , P z) : ∃ lb : ℤ , P lb ∧ ∀ z : ℤ , P z → lb ≤ z := by
classical let ⟨b , Hb⟩ := Hbdd let ⟨lb , H⟩ := leastOfBdd b Hb Hinh exact ⟨lb , H⟩
464
import Mathlib.Algebra.Order.Ring.Int #align_import data.int.least_greatest from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" namespace Int def leastOfBdd {P : ℤ → Prop} [DecidablePred P] (b : ℤ) (Hb : ∀ z : ℤ, P z → b ≤ z) (Hinh : ∃ z : ℤ, P z) : { lb : ℤ // P lb ∧ ∀ z : ℤ, P z → lb ≤ z } := have EX : ∃ n : ℕ, P (b + n) := let ⟨elt, Helt⟩ := Hinh match elt, le.dest (Hb _ Helt), Helt with | _, ⟨n, rfl⟩, Hn => ⟨n, Hn⟩ ⟨b + (Nat.find EX : ℤ), Nat.find_spec EX, fun z h => match z, le.dest (Hb _ h), h with | _, ⟨_, rfl⟩, h => add_le_add_left (Int.ofNat_le.2 <| Nat.find_min' _ h) _⟩ #align int.least_of_bdd Int.leastOfBdd theorem exists_least_of_bdd {P : ℤ → Prop} (Hbdd : ∃ b : ℤ , ∀ z : ℤ , P z → b ≤ z) (Hinh : ∃ z : ℤ , P z) : ∃ lb : ℤ , P lb ∧ ∀ z : ℤ , P z → lb ≤ z := by classical let ⟨b , Hb⟩ := Hbdd let ⟨lb , H⟩ := leastOfBdd b Hb Hinh exact ⟨lb , H⟩ #align int.exists_least_of_bdd Int.exists_least_of_bdd
Mathlib/Data/Int/LeastGreatest.lean
71
76
theorem coe_leastOfBdd_eq {P : ℤ → Prop} [DecidablePred P] {b b' : ℤ} (Hb : ∀ z : ℤ, P z → b ≤ z) (Hb' : ∀ z : ℤ, P z → b' ≤ z) (Hinh : ∃ z : ℤ, P z) : (leastOfBdd b Hb Hinh : ℤ) = leastOfBdd b' Hb' Hinh := by
rcases leastOfBdd b Hb Hinh with ⟨n, hn, h2n⟩ rcases leastOfBdd b' Hb' Hinh with ⟨n', hn', h2n'⟩ exact le_antisymm (h2n _ hn') (h2n' _ hn)
464
import Mathlib.Algebra.Order.Ring.Int #align_import data.int.least_greatest from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" namespace Int def leastOfBdd {P : ℤ → Prop} [DecidablePred P] (b : ℤ) (Hb : ∀ z : ℤ, P z → b ≤ z) (Hinh : ∃ z : ℤ, P z) : { lb : ℤ // P lb ∧ ∀ z : ℤ, P z → lb ≤ z } := have EX : ∃ n : ℕ, P (b + n) := let ⟨elt, Helt⟩ := Hinh match elt, le.dest (Hb _ Helt), Helt with | _, ⟨n, rfl⟩, Hn => ⟨n, Hn⟩ ⟨b + (Nat.find EX : ℤ), Nat.find_spec EX, fun z h => match z, le.dest (Hb _ h), h with | _, ⟨_, rfl⟩, h => add_le_add_left (Int.ofNat_le.2 <| Nat.find_min' _ h) _⟩ #align int.least_of_bdd Int.leastOfBdd theorem exists_least_of_bdd {P : ℤ → Prop} (Hbdd : ∃ b : ℤ , ∀ z : ℤ , P z → b ≤ z) (Hinh : ∃ z : ℤ , P z) : ∃ lb : ℤ , P lb ∧ ∀ z : ℤ , P z → lb ≤ z := by classical let ⟨b , Hb⟩ := Hbdd let ⟨lb , H⟩ := leastOfBdd b Hb Hinh exact ⟨lb , H⟩ #align int.exists_least_of_bdd Int.exists_least_of_bdd theorem coe_leastOfBdd_eq {P : ℤ → Prop} [DecidablePred P] {b b' : ℤ} (Hb : ∀ z : ℤ, P z → b ≤ z) (Hb' : ∀ z : ℤ, P z → b' ≤ z) (Hinh : ∃ z : ℤ, P z) : (leastOfBdd b Hb Hinh : ℤ) = leastOfBdd b' Hb' Hinh := by rcases leastOfBdd b Hb Hinh with ⟨n, hn, h2n⟩ rcases leastOfBdd b' Hb' Hinh with ⟨n', hn', h2n'⟩ exact le_antisymm (h2n _ hn') (h2n' _ hn) #align int.coe_least_of_bdd_eq Int.coe_leastOfBdd_eq def greatestOfBdd {P : ℤ → Prop} [DecidablePred P] (b : ℤ) (Hb : ∀ z : ℤ, P z → z ≤ b) (Hinh : ∃ z : ℤ, P z) : { ub : ℤ // P ub ∧ ∀ z : ℤ, P z → z ≤ ub } := have Hbdd' : ∀ z : ℤ, P (-z) → -b ≤ z := fun z h => neg_le.1 (Hb _ h) have Hinh' : ∃ z : ℤ, P (-z) := let ⟨elt, Helt⟩ := Hinh ⟨-elt, by rw [neg_neg]; exact Helt⟩ let ⟨lb, Plb, al⟩ := leastOfBdd (-b) Hbdd' Hinh' ⟨-lb, Plb, fun z h => le_neg.1 <| al _ <| by rwa [neg_neg]⟩ #align int.greatest_of_bdd Int.greatestOfBdd
Mathlib/Data/Int/LeastGreatest.lean
96
103
theorem exists_greatest_of_bdd {P : ℤ → Prop} (Hbdd : ∃ b : ℤ , ∀ z : ℤ , P z → z ≤ b) (Hinh : ∃ z : ℤ , P z) : ∃ ub : ℤ , P ub ∧ ∀ z : ℤ , P z → z ≤ ub := by
classical let ⟨b, Hb⟩ := Hbdd let ⟨lb, H⟩ := greatestOfBdd b Hb Hinh exact ⟨lb, H⟩
464
import Mathlib.Algebra.Order.Ring.Int #align_import data.int.least_greatest from "leanprover-community/mathlib"@"3342d1b2178381196f818146ff79bc0e7ccd9e2d" namespace Int def leastOfBdd {P : ℤ → Prop} [DecidablePred P] (b : ℤ) (Hb : ∀ z : ℤ, P z → b ≤ z) (Hinh : ∃ z : ℤ, P z) : { lb : ℤ // P lb ∧ ∀ z : ℤ, P z → lb ≤ z } := have EX : ∃ n : ℕ, P (b + n) := let ⟨elt, Helt⟩ := Hinh match elt, le.dest (Hb _ Helt), Helt with | _, ⟨n, rfl⟩, Hn => ⟨n, Hn⟩ ⟨b + (Nat.find EX : ℤ), Nat.find_spec EX, fun z h => match z, le.dest (Hb _ h), h with | _, ⟨_, rfl⟩, h => add_le_add_left (Int.ofNat_le.2 <| Nat.find_min' _ h) _⟩ #align int.least_of_bdd Int.leastOfBdd theorem exists_least_of_bdd {P : ℤ → Prop} (Hbdd : ∃ b : ℤ , ∀ z : ℤ , P z → b ≤ z) (Hinh : ∃ z : ℤ , P z) : ∃ lb : ℤ , P lb ∧ ∀ z : ℤ , P z → lb ≤ z := by classical let ⟨b , Hb⟩ := Hbdd let ⟨lb , H⟩ := leastOfBdd b Hb Hinh exact ⟨lb , H⟩ #align int.exists_least_of_bdd Int.exists_least_of_bdd theorem coe_leastOfBdd_eq {P : ℤ → Prop} [DecidablePred P] {b b' : ℤ} (Hb : ∀ z : ℤ, P z → b ≤ z) (Hb' : ∀ z : ℤ, P z → b' ≤ z) (Hinh : ∃ z : ℤ, P z) : (leastOfBdd b Hb Hinh : ℤ) = leastOfBdd b' Hb' Hinh := by rcases leastOfBdd b Hb Hinh with ⟨n, hn, h2n⟩ rcases leastOfBdd b' Hb' Hinh with ⟨n', hn', h2n'⟩ exact le_antisymm (h2n _ hn') (h2n' _ hn) #align int.coe_least_of_bdd_eq Int.coe_leastOfBdd_eq def greatestOfBdd {P : ℤ → Prop} [DecidablePred P] (b : ℤ) (Hb : ∀ z : ℤ, P z → z ≤ b) (Hinh : ∃ z : ℤ, P z) : { ub : ℤ // P ub ∧ ∀ z : ℤ, P z → z ≤ ub } := have Hbdd' : ∀ z : ℤ, P (-z) → -b ≤ z := fun z h => neg_le.1 (Hb _ h) have Hinh' : ∃ z : ℤ, P (-z) := let ⟨elt, Helt⟩ := Hinh ⟨-elt, by rw [neg_neg]; exact Helt⟩ let ⟨lb, Plb, al⟩ := leastOfBdd (-b) Hbdd' Hinh' ⟨-lb, Plb, fun z h => le_neg.1 <| al _ <| by rwa [neg_neg]⟩ #align int.greatest_of_bdd Int.greatestOfBdd theorem exists_greatest_of_bdd {P : ℤ → Prop} (Hbdd : ∃ b : ℤ , ∀ z : ℤ , P z → z ≤ b) (Hinh : ∃ z : ℤ , P z) : ∃ ub : ℤ , P ub ∧ ∀ z : ℤ , P z → z ≤ ub := by classical let ⟨b, Hb⟩ := Hbdd let ⟨lb, H⟩ := greatestOfBdd b Hb Hinh exact ⟨lb, H⟩ #align int.exists_greatest_of_bdd Int.exists_greatest_of_bdd
Mathlib/Data/Int/LeastGreatest.lean
106
111
theorem coe_greatestOfBdd_eq {P : ℤ → Prop} [DecidablePred P] {b b' : ℤ} (Hb : ∀ z : ℤ, P z → z ≤ b) (Hb' : ∀ z : ℤ, P z → z ≤ b') (Hinh : ∃ z : ℤ, P z) : (greatestOfBdd b Hb Hinh : ℤ) = greatestOfBdd b' Hb' Hinh := by
rcases greatestOfBdd b Hb Hinh with ⟨n, hn, h2n⟩ rcases greatestOfBdd b' Hb' Hinh with ⟨n', hn', h2n'⟩ exact le_antisymm (h2n' _ hn) (h2n _ hn')
464
import Mathlib.Algebra.Group.Indicator import Mathlib.Algebra.Group.Submonoid.Basic import Mathlib.Data.Set.Finite #align_import data.finsupp.defs from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {α β γ ι M M' N P G H R S : Type*} structure Finsupp (α : Type*) (M : Type*) [Zero M] where support : Finset α toFun : α → M mem_support_toFun : ∀ a, a ∈ support ↔ toFun a ≠ 0 #align finsupp Finsupp #align finsupp.support Finsupp.support #align finsupp.to_fun Finsupp.toFun #align finsupp.mem_support_to_fun Finsupp.mem_support_toFun @[inherit_doc] infixr:25 " →₀ " => Finsupp namespace Finsupp section Basic variable [Zero M] instance instFunLike : FunLike (α →₀ M) α M := ⟨toFun, by rintro ⟨s, f, hf⟩ ⟨t, g, hg⟩ (rfl : f = g) congr ext a exact (hf _).trans (hg _).symm⟩ #align finsupp.fun_like Finsupp.instFunLike instance instCoeFun : CoeFun (α →₀ M) fun _ => α → M := inferInstance #align finsupp.has_coe_to_fun Finsupp.instCoeFun @[ext] theorem ext {f g : α →₀ M} (h : ∀ a, f a = g a) : f = g := DFunLike.ext _ _ h #align finsupp.ext Finsupp.ext #align finsupp.ext_iff DFunLike.ext_iff lemma ne_iff {f g : α →₀ M} : f ≠ g ↔ ∃ a, f a ≠ g a := DFunLike.ne_iff #align finsupp.coe_fn_inj DFunLike.coe_fn_eq #align finsupp.coe_fn_injective DFunLike.coe_injective #align finsupp.congr_fun DFunLike.congr_fun @[simp, norm_cast] theorem coe_mk (f : α → M) (s : Finset α) (h : ∀ a, a ∈ s ↔ f a ≠ 0) : ⇑(⟨s, f, h⟩ : α →₀ M) = f := rfl #align finsupp.coe_mk Finsupp.coe_mk instance instZero : Zero (α →₀ M) := ⟨⟨∅, 0, fun _ => ⟨fun h ↦ (not_mem_empty _ h).elim, fun H => (H rfl).elim⟩⟩⟩ #align finsupp.has_zero Finsupp.instZero @[simp, norm_cast] lemma coe_zero : ⇑(0 : α →₀ M) = 0 := rfl #align finsupp.coe_zero Finsupp.coe_zero theorem zero_apply {a : α} : (0 : α →₀ M) a = 0 := rfl #align finsupp.zero_apply Finsupp.zero_apply @[simp] theorem support_zero : (0 : α →₀ M).support = ∅ := rfl #align finsupp.support_zero Finsupp.support_zero instance instInhabited : Inhabited (α →₀ M) := ⟨0⟩ #align finsupp.inhabited Finsupp.instInhabited @[simp] theorem mem_support_iff {f : α →₀ M} : ∀ {a : α}, a ∈ f.support ↔ f a ≠ 0 := @(f.mem_support_toFun) #align finsupp.mem_support_iff Finsupp.mem_support_iff @[simp, norm_cast] theorem fun_support_eq (f : α →₀ M) : Function.support f = f.support := Set.ext fun _x => mem_support_iff.symm #align finsupp.fun_support_eq Finsupp.fun_support_eq theorem not_mem_support_iff {f : α →₀ M} {a} : a ∉ f.support ↔ f a = 0 := not_iff_comm.1 mem_support_iff.symm #align finsupp.not_mem_support_iff Finsupp.not_mem_support_iff @[simp, norm_cast]
Mathlib/Data/Finsupp/Defs.lean
185
185
theorem coe_eq_zero {f : α →₀ M} : (f : α → M) = 0 ↔ f = 0 := by
rw [← coe_zero, DFunLike.coe_fn_eq]
465
import Mathlib.Algebra.Group.Indicator import Mathlib.Algebra.Group.Submonoid.Basic import Mathlib.Data.Set.Finite #align_import data.finsupp.defs from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {α β γ ι M M' N P G H R S : Type*} structure Finsupp (α : Type*) (M : Type*) [Zero M] where support : Finset α toFun : α → M mem_support_toFun : ∀ a, a ∈ support ↔ toFun a ≠ 0 #align finsupp Finsupp #align finsupp.support Finsupp.support #align finsupp.to_fun Finsupp.toFun #align finsupp.mem_support_to_fun Finsupp.mem_support_toFun @[inherit_doc] infixr:25 " →₀ " => Finsupp namespace Finsupp section Basic variable [Zero M] instance instFunLike : FunLike (α →₀ M) α M := ⟨toFun, by rintro ⟨s, f, hf⟩ ⟨t, g, hg⟩ (rfl : f = g) congr ext a exact (hf _).trans (hg _).symm⟩ #align finsupp.fun_like Finsupp.instFunLike instance instCoeFun : CoeFun (α →₀ M) fun _ => α → M := inferInstance #align finsupp.has_coe_to_fun Finsupp.instCoeFun @[ext] theorem ext {f g : α →₀ M} (h : ∀ a, f a = g a) : f = g := DFunLike.ext _ _ h #align finsupp.ext Finsupp.ext #align finsupp.ext_iff DFunLike.ext_iff lemma ne_iff {f g : α →₀ M} : f ≠ g ↔ ∃ a, f a ≠ g a := DFunLike.ne_iff #align finsupp.coe_fn_inj DFunLike.coe_fn_eq #align finsupp.coe_fn_injective DFunLike.coe_injective #align finsupp.congr_fun DFunLike.congr_fun @[simp, norm_cast] theorem coe_mk (f : α → M) (s : Finset α) (h : ∀ a, a ∈ s ↔ f a ≠ 0) : ⇑(⟨s, f, h⟩ : α →₀ M) = f := rfl #align finsupp.coe_mk Finsupp.coe_mk instance instZero : Zero (α →₀ M) := ⟨⟨∅, 0, fun _ => ⟨fun h ↦ (not_mem_empty _ h).elim, fun H => (H rfl).elim⟩⟩⟩ #align finsupp.has_zero Finsupp.instZero @[simp, norm_cast] lemma coe_zero : ⇑(0 : α →₀ M) = 0 := rfl #align finsupp.coe_zero Finsupp.coe_zero theorem zero_apply {a : α} : (0 : α →₀ M) a = 0 := rfl #align finsupp.zero_apply Finsupp.zero_apply @[simp] theorem support_zero : (0 : α →₀ M).support = ∅ := rfl #align finsupp.support_zero Finsupp.support_zero instance instInhabited : Inhabited (α →₀ M) := ⟨0⟩ #align finsupp.inhabited Finsupp.instInhabited @[simp] theorem mem_support_iff {f : α →₀ M} : ∀ {a : α}, a ∈ f.support ↔ f a ≠ 0 := @(f.mem_support_toFun) #align finsupp.mem_support_iff Finsupp.mem_support_iff @[simp, norm_cast] theorem fun_support_eq (f : α →₀ M) : Function.support f = f.support := Set.ext fun _x => mem_support_iff.symm #align finsupp.fun_support_eq Finsupp.fun_support_eq theorem not_mem_support_iff {f : α →₀ M} {a} : a ∉ f.support ↔ f a = 0 := not_iff_comm.1 mem_support_iff.symm #align finsupp.not_mem_support_iff Finsupp.not_mem_support_iff @[simp, norm_cast] theorem coe_eq_zero {f : α →₀ M} : (f : α → M) = 0 ↔ f = 0 := by rw [← coe_zero, DFunLike.coe_fn_eq] #align finsupp.coe_eq_zero Finsupp.coe_eq_zero
Mathlib/Data/Finsupp/Defs.lean
188
195
theorem ext_iff' {f g : α →₀ M} : f = g ↔ f.support = g.support ∧ ∀ x ∈ f.support, f x = g x := ⟨fun h => h ▸ ⟨rfl, fun _ _ => rfl⟩, fun ⟨h₁, h₂⟩ => ext fun a => by classical exact if h : a ∈ f.support then h₂ a h else by have hf : f a = 0 := not_mem_support_iff.1 h have hg : g a = 0 := by
rwa [h₁, not_mem_support_iff] at h rw [hf, hg]⟩
465
import Mathlib.Algebra.Group.Indicator import Mathlib.Algebra.Group.Submonoid.Basic import Mathlib.Data.Set.Finite #align_import data.finsupp.defs from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {α β γ ι M M' N P G H R S : Type*} structure Finsupp (α : Type*) (M : Type*) [Zero M] where support : Finset α toFun : α → M mem_support_toFun : ∀ a, a ∈ support ↔ toFun a ≠ 0 #align finsupp Finsupp #align finsupp.support Finsupp.support #align finsupp.to_fun Finsupp.toFun #align finsupp.mem_support_to_fun Finsupp.mem_support_toFun @[inherit_doc] infixr:25 " →₀ " => Finsupp namespace Finsupp section Basic variable [Zero M] instance instFunLike : FunLike (α →₀ M) α M := ⟨toFun, by rintro ⟨s, f, hf⟩ ⟨t, g, hg⟩ (rfl : f = g) congr ext a exact (hf _).trans (hg _).symm⟩ #align finsupp.fun_like Finsupp.instFunLike instance instCoeFun : CoeFun (α →₀ M) fun _ => α → M := inferInstance #align finsupp.has_coe_to_fun Finsupp.instCoeFun @[ext] theorem ext {f g : α →₀ M} (h : ∀ a, f a = g a) : f = g := DFunLike.ext _ _ h #align finsupp.ext Finsupp.ext #align finsupp.ext_iff DFunLike.ext_iff lemma ne_iff {f g : α →₀ M} : f ≠ g ↔ ∃ a, f a ≠ g a := DFunLike.ne_iff #align finsupp.coe_fn_inj DFunLike.coe_fn_eq #align finsupp.coe_fn_injective DFunLike.coe_injective #align finsupp.congr_fun DFunLike.congr_fun @[simp, norm_cast] theorem coe_mk (f : α → M) (s : Finset α) (h : ∀ a, a ∈ s ↔ f a ≠ 0) : ⇑(⟨s, f, h⟩ : α →₀ M) = f := rfl #align finsupp.coe_mk Finsupp.coe_mk instance instZero : Zero (α →₀ M) := ⟨⟨∅, 0, fun _ => ⟨fun h ↦ (not_mem_empty _ h).elim, fun H => (H rfl).elim⟩⟩⟩ #align finsupp.has_zero Finsupp.instZero @[simp, norm_cast] lemma coe_zero : ⇑(0 : α →₀ M) = 0 := rfl #align finsupp.coe_zero Finsupp.coe_zero theorem zero_apply {a : α} : (0 : α →₀ M) a = 0 := rfl #align finsupp.zero_apply Finsupp.zero_apply @[simp] theorem support_zero : (0 : α →₀ M).support = ∅ := rfl #align finsupp.support_zero Finsupp.support_zero instance instInhabited : Inhabited (α →₀ M) := ⟨0⟩ #align finsupp.inhabited Finsupp.instInhabited @[simp] theorem mem_support_iff {f : α →₀ M} : ∀ {a : α}, a ∈ f.support ↔ f a ≠ 0 := @(f.mem_support_toFun) #align finsupp.mem_support_iff Finsupp.mem_support_iff @[simp, norm_cast] theorem fun_support_eq (f : α →₀ M) : Function.support f = f.support := Set.ext fun _x => mem_support_iff.symm #align finsupp.fun_support_eq Finsupp.fun_support_eq theorem not_mem_support_iff {f : α →₀ M} {a} : a ∉ f.support ↔ f a = 0 := not_iff_comm.1 mem_support_iff.symm #align finsupp.not_mem_support_iff Finsupp.not_mem_support_iff @[simp, norm_cast] theorem coe_eq_zero {f : α →₀ M} : (f : α → M) = 0 ↔ f = 0 := by rw [← coe_zero, DFunLike.coe_fn_eq] #align finsupp.coe_eq_zero Finsupp.coe_eq_zero theorem ext_iff' {f g : α →₀ M} : f = g ↔ f.support = g.support ∧ ∀ x ∈ f.support, f x = g x := ⟨fun h => h ▸ ⟨rfl, fun _ _ => rfl⟩, fun ⟨h₁, h₂⟩ => ext fun a => by classical exact if h : a ∈ f.support then h₂ a h else by have hf : f a = 0 := not_mem_support_iff.1 h have hg : g a = 0 := by rwa [h₁, not_mem_support_iff] at h rw [hf, hg]⟩ #align finsupp.ext_iff' Finsupp.ext_iff' @[simp] theorem support_eq_empty {f : α →₀ M} : f.support = ∅ ↔ f = 0 := mod_cast @Function.support_eq_empty_iff _ _ _ f #align finsupp.support_eq_empty Finsupp.support_eq_empty
Mathlib/Data/Finsupp/Defs.lean
203
204
theorem support_nonempty_iff {f : α →₀ M} : f.support.Nonempty ↔ f ≠ 0 := by
simp only [Finsupp.support_eq_empty, Finset.nonempty_iff_ne_empty, Ne]
465
import Mathlib.Algebra.Group.Indicator import Mathlib.Algebra.Group.Submonoid.Basic import Mathlib.Data.Set.Finite #align_import data.finsupp.defs from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {α β γ ι M M' N P G H R S : Type*} structure Finsupp (α : Type*) (M : Type*) [Zero M] where support : Finset α toFun : α → M mem_support_toFun : ∀ a, a ∈ support ↔ toFun a ≠ 0 #align finsupp Finsupp #align finsupp.support Finsupp.support #align finsupp.to_fun Finsupp.toFun #align finsupp.mem_support_to_fun Finsupp.mem_support_toFun @[inherit_doc] infixr:25 " →₀ " => Finsupp namespace Finsupp section Basic variable [Zero M] instance instFunLike : FunLike (α →₀ M) α M := ⟨toFun, by rintro ⟨s, f, hf⟩ ⟨t, g, hg⟩ (rfl : f = g) congr ext a exact (hf _).trans (hg _).symm⟩ #align finsupp.fun_like Finsupp.instFunLike instance instCoeFun : CoeFun (α →₀ M) fun _ => α → M := inferInstance #align finsupp.has_coe_to_fun Finsupp.instCoeFun @[ext] theorem ext {f g : α →₀ M} (h : ∀ a, f a = g a) : f = g := DFunLike.ext _ _ h #align finsupp.ext Finsupp.ext #align finsupp.ext_iff DFunLike.ext_iff lemma ne_iff {f g : α →₀ M} : f ≠ g ↔ ∃ a, f a ≠ g a := DFunLike.ne_iff #align finsupp.coe_fn_inj DFunLike.coe_fn_eq #align finsupp.coe_fn_injective DFunLike.coe_injective #align finsupp.congr_fun DFunLike.congr_fun @[simp, norm_cast] theorem coe_mk (f : α → M) (s : Finset α) (h : ∀ a, a ∈ s ↔ f a ≠ 0) : ⇑(⟨s, f, h⟩ : α →₀ M) = f := rfl #align finsupp.coe_mk Finsupp.coe_mk instance instZero : Zero (α →₀ M) := ⟨⟨∅, 0, fun _ => ⟨fun h ↦ (not_mem_empty _ h).elim, fun H => (H rfl).elim⟩⟩⟩ #align finsupp.has_zero Finsupp.instZero @[simp, norm_cast] lemma coe_zero : ⇑(0 : α →₀ M) = 0 := rfl #align finsupp.coe_zero Finsupp.coe_zero theorem zero_apply {a : α} : (0 : α →₀ M) a = 0 := rfl #align finsupp.zero_apply Finsupp.zero_apply @[simp] theorem support_zero : (0 : α →₀ M).support = ∅ := rfl #align finsupp.support_zero Finsupp.support_zero instance instInhabited : Inhabited (α →₀ M) := ⟨0⟩ #align finsupp.inhabited Finsupp.instInhabited @[simp] theorem mem_support_iff {f : α →₀ M} : ∀ {a : α}, a ∈ f.support ↔ f a ≠ 0 := @(f.mem_support_toFun) #align finsupp.mem_support_iff Finsupp.mem_support_iff @[simp, norm_cast] theorem fun_support_eq (f : α →₀ M) : Function.support f = f.support := Set.ext fun _x => mem_support_iff.symm #align finsupp.fun_support_eq Finsupp.fun_support_eq theorem not_mem_support_iff {f : α →₀ M} {a} : a ∉ f.support ↔ f a = 0 := not_iff_comm.1 mem_support_iff.symm #align finsupp.not_mem_support_iff Finsupp.not_mem_support_iff @[simp, norm_cast] theorem coe_eq_zero {f : α →₀ M} : (f : α → M) = 0 ↔ f = 0 := by rw [← coe_zero, DFunLike.coe_fn_eq] #align finsupp.coe_eq_zero Finsupp.coe_eq_zero theorem ext_iff' {f g : α →₀ M} : f = g ↔ f.support = g.support ∧ ∀ x ∈ f.support, f x = g x := ⟨fun h => h ▸ ⟨rfl, fun _ _ => rfl⟩, fun ⟨h₁, h₂⟩ => ext fun a => by classical exact if h : a ∈ f.support then h₂ a h else by have hf : f a = 0 := not_mem_support_iff.1 h have hg : g a = 0 := by rwa [h₁, not_mem_support_iff] at h rw [hf, hg]⟩ #align finsupp.ext_iff' Finsupp.ext_iff' @[simp] theorem support_eq_empty {f : α →₀ M} : f.support = ∅ ↔ f = 0 := mod_cast @Function.support_eq_empty_iff _ _ _ f #align finsupp.support_eq_empty Finsupp.support_eq_empty theorem support_nonempty_iff {f : α →₀ M} : f.support.Nonempty ↔ f ≠ 0 := by simp only [Finsupp.support_eq_empty, Finset.nonempty_iff_ne_empty, Ne] #align finsupp.support_nonempty_iff Finsupp.support_nonempty_iff #align finsupp.nonzero_iff_exists Finsupp.ne_iff
Mathlib/Data/Finsupp/Defs.lean
209
209
theorem card_support_eq_zero {f : α →₀ M} : card f.support = 0 ↔ f = 0 := by
simp
465
import Mathlib.Algebra.Group.Indicator import Mathlib.Algebra.Group.Submonoid.Basic import Mathlib.Data.Set.Finite #align_import data.finsupp.defs from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {α β γ ι M M' N P G H R S : Type*} structure Finsupp (α : Type*) (M : Type*) [Zero M] where support : Finset α toFun : α → M mem_support_toFun : ∀ a, a ∈ support ↔ toFun a ≠ 0 #align finsupp Finsupp #align finsupp.support Finsupp.support #align finsupp.to_fun Finsupp.toFun #align finsupp.mem_support_to_fun Finsupp.mem_support_toFun @[inherit_doc] infixr:25 " →₀ " => Finsupp namespace Finsupp section Basic variable [Zero M] instance instFunLike : FunLike (α →₀ M) α M := ⟨toFun, by rintro ⟨s, f, hf⟩ ⟨t, g, hg⟩ (rfl : f = g) congr ext a exact (hf _).trans (hg _).symm⟩ #align finsupp.fun_like Finsupp.instFunLike instance instCoeFun : CoeFun (α →₀ M) fun _ => α → M := inferInstance #align finsupp.has_coe_to_fun Finsupp.instCoeFun @[ext] theorem ext {f g : α →₀ M} (h : ∀ a, f a = g a) : f = g := DFunLike.ext _ _ h #align finsupp.ext Finsupp.ext #align finsupp.ext_iff DFunLike.ext_iff lemma ne_iff {f g : α →₀ M} : f ≠ g ↔ ∃ a, f a ≠ g a := DFunLike.ne_iff #align finsupp.coe_fn_inj DFunLike.coe_fn_eq #align finsupp.coe_fn_injective DFunLike.coe_injective #align finsupp.congr_fun DFunLike.congr_fun @[simp, norm_cast] theorem coe_mk (f : α → M) (s : Finset α) (h : ∀ a, a ∈ s ↔ f a ≠ 0) : ⇑(⟨s, f, h⟩ : α →₀ M) = f := rfl #align finsupp.coe_mk Finsupp.coe_mk instance instZero : Zero (α →₀ M) := ⟨⟨∅, 0, fun _ => ⟨fun h ↦ (not_mem_empty _ h).elim, fun H => (H rfl).elim⟩⟩⟩ #align finsupp.has_zero Finsupp.instZero @[simp, norm_cast] lemma coe_zero : ⇑(0 : α →₀ M) = 0 := rfl #align finsupp.coe_zero Finsupp.coe_zero theorem zero_apply {a : α} : (0 : α →₀ M) a = 0 := rfl #align finsupp.zero_apply Finsupp.zero_apply @[simp] theorem support_zero : (0 : α →₀ M).support = ∅ := rfl #align finsupp.support_zero Finsupp.support_zero instance instInhabited : Inhabited (α →₀ M) := ⟨0⟩ #align finsupp.inhabited Finsupp.instInhabited @[simp] theorem mem_support_iff {f : α →₀ M} : ∀ {a : α}, a ∈ f.support ↔ f a ≠ 0 := @(f.mem_support_toFun) #align finsupp.mem_support_iff Finsupp.mem_support_iff @[simp, norm_cast] theorem fun_support_eq (f : α →₀ M) : Function.support f = f.support := Set.ext fun _x => mem_support_iff.symm #align finsupp.fun_support_eq Finsupp.fun_support_eq theorem not_mem_support_iff {f : α →₀ M} {a} : a ∉ f.support ↔ f a = 0 := not_iff_comm.1 mem_support_iff.symm #align finsupp.not_mem_support_iff Finsupp.not_mem_support_iff @[simp, norm_cast] theorem coe_eq_zero {f : α →₀ M} : (f : α → M) = 0 ↔ f = 0 := by rw [← coe_zero, DFunLike.coe_fn_eq] #align finsupp.coe_eq_zero Finsupp.coe_eq_zero theorem ext_iff' {f g : α →₀ M} : f = g ↔ f.support = g.support ∧ ∀ x ∈ f.support, f x = g x := ⟨fun h => h ▸ ⟨rfl, fun _ _ => rfl⟩, fun ⟨h₁, h₂⟩ => ext fun a => by classical exact if h : a ∈ f.support then h₂ a h else by have hf : f a = 0 := not_mem_support_iff.1 h have hg : g a = 0 := by rwa [h₁, not_mem_support_iff] at h rw [hf, hg]⟩ #align finsupp.ext_iff' Finsupp.ext_iff' @[simp] theorem support_eq_empty {f : α →₀ M} : f.support = ∅ ↔ f = 0 := mod_cast @Function.support_eq_empty_iff _ _ _ f #align finsupp.support_eq_empty Finsupp.support_eq_empty theorem support_nonempty_iff {f : α →₀ M} : f.support.Nonempty ↔ f ≠ 0 := by simp only [Finsupp.support_eq_empty, Finset.nonempty_iff_ne_empty, Ne] #align finsupp.support_nonempty_iff Finsupp.support_nonempty_iff #align finsupp.nonzero_iff_exists Finsupp.ne_iff theorem card_support_eq_zero {f : α →₀ M} : card f.support = 0 ↔ f = 0 := by simp #align finsupp.card_support_eq_zero Finsupp.card_support_eq_zero instance instDecidableEq [DecidableEq α] [DecidableEq M] : DecidableEq (α →₀ M) := fun f g => decidable_of_iff (f.support = g.support ∧ ∀ a ∈ f.support, f a = g a) ext_iff'.symm #align finsupp.decidable_eq Finsupp.instDecidableEq theorem finite_support (f : α →₀ M) : Set.Finite (Function.support f) := f.fun_support_eq.symm ▸ f.support.finite_toSet #align finsupp.finite_support Finsupp.finite_support
Mathlib/Data/Finsupp/Defs.lean
220
222
theorem support_subset_iff {s : Set α} {f : α →₀ M} : ↑f.support ⊆ s ↔ ∀ a ∉ s, f a = 0 := by
simp only [Set.subset_def, mem_coe, mem_support_iff]; exact forall_congr' fun a => not_imp_comm
465
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" variable {α M N P : Type*} namespace Finsupp variable [DecidableEq α] section NHasZero variable [DecidableEq N] [Zero N] (f g : α →₀ N) def neLocus (f g : α →₀ N) : Finset α := (f.support ∪ g.support).filter fun x => f x ≠ g x #align finsupp.ne_locus Finsupp.neLocus @[simp]
Mathlib/Data/Finsupp/NeLocus.lean
42
44
theorem mem_neLocus {f g : α →₀ N} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by
simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff, and_iff_right_iff_imp] using Ne.ne_or_ne _
466
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" variable {α M N P : Type*} namespace Finsupp variable [DecidableEq α] section NHasZero variable [DecidableEq N] [Zero N] (f g : α →₀ N) def neLocus (f g : α →₀ N) : Finset α := (f.support ∪ g.support).filter fun x => f x ≠ g x #align finsupp.ne_locus Finsupp.neLocus @[simp] theorem mem_neLocus {f g : α →₀ N} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff, and_iff_right_iff_imp] using Ne.ne_or_ne _ #align finsupp.mem_ne_locus Finsupp.mem_neLocus theorem not_mem_neLocus {f g : α →₀ N} {a : α} : a ∉ f.neLocus g ↔ f a = g a := mem_neLocus.not.trans not_ne_iff #align finsupp.not_mem_ne_locus Finsupp.not_mem_neLocus @[simp]
Mathlib/Data/Finsupp/NeLocus.lean
52
54
theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } := by
ext exact mem_neLocus
466
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" variable {α M N P : Type*} namespace Finsupp variable [DecidableEq α] section NHasZero variable [DecidableEq N] [Zero N] (f g : α →₀ N) def neLocus (f g : α →₀ N) : Finset α := (f.support ∪ g.support).filter fun x => f x ≠ g x #align finsupp.ne_locus Finsupp.neLocus @[simp] theorem mem_neLocus {f g : α →₀ N} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff, and_iff_right_iff_imp] using Ne.ne_or_ne _ #align finsupp.mem_ne_locus Finsupp.mem_neLocus theorem not_mem_neLocus {f g : α →₀ N} {a : α} : a ∉ f.neLocus g ↔ f a = g a := mem_neLocus.not.trans not_ne_iff #align finsupp.not_mem_ne_locus Finsupp.not_mem_neLocus @[simp] theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } := by ext exact mem_neLocus #align finsupp.coe_ne_locus Finsupp.coe_neLocus @[simp] theorem neLocus_eq_empty {f g : α →₀ N} : f.neLocus g = ∅ ↔ f = g := ⟨fun h => ext fun a => not_not.mp (mem_neLocus.not.mp (Finset.eq_empty_iff_forall_not_mem.mp h a)), fun h => h ▸ by simp only [neLocus, Ne, eq_self_iff_true, not_true, Finset.filter_False]⟩ #align finsupp.ne_locus_eq_empty Finsupp.neLocus_eq_empty @[simp] theorem nonempty_neLocus_iff {f g : α →₀ N} : (f.neLocus g).Nonempty ↔ f ≠ g := Finset.nonempty_iff_ne_empty.trans neLocus_eq_empty.not #align finsupp.nonempty_ne_locus_iff Finsupp.nonempty_neLocus_iff
Mathlib/Data/Finsupp/NeLocus.lean
69
70
theorem neLocus_comm : f.neLocus g = g.neLocus f := by
simp_rw [neLocus, Finset.union_comm, ne_comm]
466
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.ne_locus from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" variable {α M N P : Type*} namespace Finsupp variable [DecidableEq α] section NHasZero variable [DecidableEq N] [Zero N] (f g : α →₀ N) def neLocus (f g : α →₀ N) : Finset α := (f.support ∪ g.support).filter fun x => f x ≠ g x #align finsupp.ne_locus Finsupp.neLocus @[simp] theorem mem_neLocus {f g : α →₀ N} {a : α} : a ∈ f.neLocus g ↔ f a ≠ g a := by simpa only [neLocus, Finset.mem_filter, Finset.mem_union, mem_support_iff, and_iff_right_iff_imp] using Ne.ne_or_ne _ #align finsupp.mem_ne_locus Finsupp.mem_neLocus theorem not_mem_neLocus {f g : α →₀ N} {a : α} : a ∉ f.neLocus g ↔ f a = g a := mem_neLocus.not.trans not_ne_iff #align finsupp.not_mem_ne_locus Finsupp.not_mem_neLocus @[simp] theorem coe_neLocus : ↑(f.neLocus g) = { x | f x ≠ g x } := by ext exact mem_neLocus #align finsupp.coe_ne_locus Finsupp.coe_neLocus @[simp] theorem neLocus_eq_empty {f g : α →₀ N} : f.neLocus g = ∅ ↔ f = g := ⟨fun h => ext fun a => not_not.mp (mem_neLocus.not.mp (Finset.eq_empty_iff_forall_not_mem.mp h a)), fun h => h ▸ by simp only [neLocus, Ne, eq_self_iff_true, not_true, Finset.filter_False]⟩ #align finsupp.ne_locus_eq_empty Finsupp.neLocus_eq_empty @[simp] theorem nonempty_neLocus_iff {f g : α →₀ N} : (f.neLocus g).Nonempty ↔ f ≠ g := Finset.nonempty_iff_ne_empty.trans neLocus_eq_empty.not #align finsupp.nonempty_ne_locus_iff Finsupp.nonempty_neLocus_iff theorem neLocus_comm : f.neLocus g = g.neLocus f := by simp_rw [neLocus, Finset.union_comm, ne_comm] #align finsupp.ne_locus_comm Finsupp.neLocus_comm @[simp]
Mathlib/Data/Finsupp/NeLocus.lean
74
76
theorem neLocus_zero_right : f.neLocus 0 = f.support := by
ext rw [mem_neLocus, mem_support_iff, coe_zero, Pi.zero_apply]
466
import Mathlib.Data.Finsupp.Defs #align_import data.list.to_finsupp from "leanprover-community/mathlib"@"06a655b5fcfbda03502f9158bbf6c0f1400886f9" namespace List variable {M : Type*} [Zero M] (l : List M) [DecidablePred (getD l · 0 ≠ 0)] (n : ℕ) def toFinsupp : ℕ →₀ M where toFun i := getD l i 0 support := (Finset.range l.length).filter fun i => getD l i 0 ≠ 0 mem_support_toFun n := by simp only [Ne, Finset.mem_filter, Finset.mem_range, and_iff_right_iff_imp] contrapose! exact getD_eq_default _ _ #align list.to_finsupp List.toFinsupp @[norm_cast] theorem coe_toFinsupp : (l.toFinsupp : ℕ → M) = (l.getD · 0) := rfl #align list.coe_to_finsupp List.coe_toFinsupp @[simp, norm_cast] theorem toFinsupp_apply (i : ℕ) : (l.toFinsupp : ℕ → M) i = l.getD i 0 := rfl #align list.to_finsupp_apply List.toFinsupp_apply theorem toFinsupp_support : l.toFinsupp.support = (Finset.range l.length).filter (getD l · 0 ≠ 0) := rfl #align list.to_finsupp_support List.toFinsupp_support theorem toFinsupp_apply_lt (hn : n < l.length) : l.toFinsupp n = l.get ⟨n, hn⟩ := getD_eq_get _ _ _ theorem toFinsupp_apply_fin (n : Fin l.length) : l.toFinsupp n = l.get n := getD_eq_get _ _ _ set_option linter.deprecated false in @[deprecated (since := "2023-04-10")] theorem toFinsupp_apply_lt' (hn : n < l.length) : l.toFinsupp n = l.nthLe n hn := getD_eq_get _ _ _ #align list.to_finsupp_apply_lt List.toFinsupp_apply_lt' theorem toFinsupp_apply_le (hn : l.length ≤ n) : l.toFinsupp n = 0 := getD_eq_default _ _ hn #align list.to_finsupp_apply_le List.toFinsupp_apply_le @[simp]
Mathlib/Data/List/ToFinsupp.lean
86
89
theorem toFinsupp_nil [DecidablePred fun i => getD ([] : List M) i 0 ≠ 0] : toFinsupp ([] : List M) = 0 := by
ext simp
467
import Mathlib.Data.Finsupp.Defs #align_import data.list.to_finsupp from "leanprover-community/mathlib"@"06a655b5fcfbda03502f9158bbf6c0f1400886f9" namespace List variable {M : Type*} [Zero M] (l : List M) [DecidablePred (getD l · 0 ≠ 0)] (n : ℕ) def toFinsupp : ℕ →₀ M where toFun i := getD l i 0 support := (Finset.range l.length).filter fun i => getD l i 0 ≠ 0 mem_support_toFun n := by simp only [Ne, Finset.mem_filter, Finset.mem_range, and_iff_right_iff_imp] contrapose! exact getD_eq_default _ _ #align list.to_finsupp List.toFinsupp @[norm_cast] theorem coe_toFinsupp : (l.toFinsupp : ℕ → M) = (l.getD · 0) := rfl #align list.coe_to_finsupp List.coe_toFinsupp @[simp, norm_cast] theorem toFinsupp_apply (i : ℕ) : (l.toFinsupp : ℕ → M) i = l.getD i 0 := rfl #align list.to_finsupp_apply List.toFinsupp_apply theorem toFinsupp_support : l.toFinsupp.support = (Finset.range l.length).filter (getD l · 0 ≠ 0) := rfl #align list.to_finsupp_support List.toFinsupp_support theorem toFinsupp_apply_lt (hn : n < l.length) : l.toFinsupp n = l.get ⟨n, hn⟩ := getD_eq_get _ _ _ theorem toFinsupp_apply_fin (n : Fin l.length) : l.toFinsupp n = l.get n := getD_eq_get _ _ _ set_option linter.deprecated false in @[deprecated (since := "2023-04-10")] theorem toFinsupp_apply_lt' (hn : n < l.length) : l.toFinsupp n = l.nthLe n hn := getD_eq_get _ _ _ #align list.to_finsupp_apply_lt List.toFinsupp_apply_lt' theorem toFinsupp_apply_le (hn : l.length ≤ n) : l.toFinsupp n = 0 := getD_eq_default _ _ hn #align list.to_finsupp_apply_le List.toFinsupp_apply_le @[simp] theorem toFinsupp_nil [DecidablePred fun i => getD ([] : List M) i 0 ≠ 0] : toFinsupp ([] : List M) = 0 := by ext simp #align list.to_finsupp_nil List.toFinsupp_nil
Mathlib/Data/List/ToFinsupp.lean
92
94
theorem toFinsupp_singleton (x : M) [DecidablePred (getD [x] · 0 ≠ 0)] : toFinsupp [x] = Finsupp.single 0 x := by
ext ⟨_ | i⟩ <;> simp [Finsupp.single_apply, (Nat.zero_lt_succ _).ne]
467
import Mathlib.Data.Finsupp.Defs #align_import data.list.to_finsupp from "leanprover-community/mathlib"@"06a655b5fcfbda03502f9158bbf6c0f1400886f9" namespace List variable {M : Type*} [Zero M] (l : List M) [DecidablePred (getD l · 0 ≠ 0)] (n : ℕ) def toFinsupp : ℕ →₀ M where toFun i := getD l i 0 support := (Finset.range l.length).filter fun i => getD l i 0 ≠ 0 mem_support_toFun n := by simp only [Ne, Finset.mem_filter, Finset.mem_range, and_iff_right_iff_imp] contrapose! exact getD_eq_default _ _ #align list.to_finsupp List.toFinsupp @[norm_cast] theorem coe_toFinsupp : (l.toFinsupp : ℕ → M) = (l.getD · 0) := rfl #align list.coe_to_finsupp List.coe_toFinsupp @[simp, norm_cast] theorem toFinsupp_apply (i : ℕ) : (l.toFinsupp : ℕ → M) i = l.getD i 0 := rfl #align list.to_finsupp_apply List.toFinsupp_apply theorem toFinsupp_support : l.toFinsupp.support = (Finset.range l.length).filter (getD l · 0 ≠ 0) := rfl #align list.to_finsupp_support List.toFinsupp_support theorem toFinsupp_apply_lt (hn : n < l.length) : l.toFinsupp n = l.get ⟨n, hn⟩ := getD_eq_get _ _ _ theorem toFinsupp_apply_fin (n : Fin l.length) : l.toFinsupp n = l.get n := getD_eq_get _ _ _ set_option linter.deprecated false in @[deprecated (since := "2023-04-10")] theorem toFinsupp_apply_lt' (hn : n < l.length) : l.toFinsupp n = l.nthLe n hn := getD_eq_get _ _ _ #align list.to_finsupp_apply_lt List.toFinsupp_apply_lt' theorem toFinsupp_apply_le (hn : l.length ≤ n) : l.toFinsupp n = 0 := getD_eq_default _ _ hn #align list.to_finsupp_apply_le List.toFinsupp_apply_le @[simp] theorem toFinsupp_nil [DecidablePred fun i => getD ([] : List M) i 0 ≠ 0] : toFinsupp ([] : List M) = 0 := by ext simp #align list.to_finsupp_nil List.toFinsupp_nil theorem toFinsupp_singleton (x : M) [DecidablePred (getD [x] · 0 ≠ 0)] : toFinsupp [x] = Finsupp.single 0 x := by ext ⟨_ | i⟩ <;> simp [Finsupp.single_apply, (Nat.zero_lt_succ _).ne] #align list.to_finsupp_singleton List.toFinsupp_singleton @[simp] theorem toFinsupp_cons_apply_zero (x : M) (xs : List M) [DecidablePred (getD (x::xs) · 0 ≠ 0)] : (x::xs).toFinsupp 0 = x := rfl #align list.to_finsupp_cons_apply_zero List.toFinsupp_cons_apply_zero @[simp] theorem toFinsupp_cons_apply_succ (x : M) (xs : List M) (n : ℕ) [DecidablePred (getD (x::xs) · 0 ≠ 0)] [DecidablePred (getD xs · 0 ≠ 0)] : (x::xs).toFinsupp n.succ = xs.toFinsupp n := rfl #align list.to_finsupp_cons_apply_succ List.toFinsupp_cons_apply_succ -- Porting note (#10756): new theorem
Mathlib/Data/List/ToFinsupp.lean
111
126
theorem toFinsupp_append {R : Type*} [AddZeroClass R] (l₁ l₂ : List R) [DecidablePred (getD (l₁ ++ l₂) · 0 ≠ 0)] [DecidablePred (getD l₁ · 0 ≠ 0)] [DecidablePred (getD l₂ · 0 ≠ 0)] : toFinsupp (l₁ ++ l₂) = toFinsupp l₁ + (toFinsupp l₂).embDomain (addLeftEmbedding l₁.length) := by
ext n simp only [toFinsupp_apply, Finsupp.add_apply] cases lt_or_le n l₁.length with | inl h => rw [getD_append _ _ _ _ h, Finsupp.embDomain_notin_range, add_zero] rintro ⟨k, rfl : length l₁ + k = n⟩ omega | inr h => rcases Nat.exists_eq_add_of_le h with ⟨k, rfl⟩ rw [getD_append_right _ _ _ _ h, Nat.add_sub_cancel_left, getD_eq_default _ _ h, zero_add] exact Eq.symm (Finsupp.embDomain_apply _ _ _)
467
import Mathlib.Data.Finsupp.Defs #align_import data.list.to_finsupp from "leanprover-community/mathlib"@"06a655b5fcfbda03502f9158bbf6c0f1400886f9" namespace List variable {M : Type*} [Zero M] (l : List M) [DecidablePred (getD l · 0 ≠ 0)] (n : ℕ) def toFinsupp : ℕ →₀ M where toFun i := getD l i 0 support := (Finset.range l.length).filter fun i => getD l i 0 ≠ 0 mem_support_toFun n := by simp only [Ne, Finset.mem_filter, Finset.mem_range, and_iff_right_iff_imp] contrapose! exact getD_eq_default _ _ #align list.to_finsupp List.toFinsupp @[norm_cast] theorem coe_toFinsupp : (l.toFinsupp : ℕ → M) = (l.getD · 0) := rfl #align list.coe_to_finsupp List.coe_toFinsupp @[simp, norm_cast] theorem toFinsupp_apply (i : ℕ) : (l.toFinsupp : ℕ → M) i = l.getD i 0 := rfl #align list.to_finsupp_apply List.toFinsupp_apply theorem toFinsupp_support : l.toFinsupp.support = (Finset.range l.length).filter (getD l · 0 ≠ 0) := rfl #align list.to_finsupp_support List.toFinsupp_support theorem toFinsupp_apply_lt (hn : n < l.length) : l.toFinsupp n = l.get ⟨n, hn⟩ := getD_eq_get _ _ _ theorem toFinsupp_apply_fin (n : Fin l.length) : l.toFinsupp n = l.get n := getD_eq_get _ _ _ set_option linter.deprecated false in @[deprecated (since := "2023-04-10")] theorem toFinsupp_apply_lt' (hn : n < l.length) : l.toFinsupp n = l.nthLe n hn := getD_eq_get _ _ _ #align list.to_finsupp_apply_lt List.toFinsupp_apply_lt' theorem toFinsupp_apply_le (hn : l.length ≤ n) : l.toFinsupp n = 0 := getD_eq_default _ _ hn #align list.to_finsupp_apply_le List.toFinsupp_apply_le @[simp] theorem toFinsupp_nil [DecidablePred fun i => getD ([] : List M) i 0 ≠ 0] : toFinsupp ([] : List M) = 0 := by ext simp #align list.to_finsupp_nil List.toFinsupp_nil theorem toFinsupp_singleton (x : M) [DecidablePred (getD [x] · 0 ≠ 0)] : toFinsupp [x] = Finsupp.single 0 x := by ext ⟨_ | i⟩ <;> simp [Finsupp.single_apply, (Nat.zero_lt_succ _).ne] #align list.to_finsupp_singleton List.toFinsupp_singleton @[simp] theorem toFinsupp_cons_apply_zero (x : M) (xs : List M) [DecidablePred (getD (x::xs) · 0 ≠ 0)] : (x::xs).toFinsupp 0 = x := rfl #align list.to_finsupp_cons_apply_zero List.toFinsupp_cons_apply_zero @[simp] theorem toFinsupp_cons_apply_succ (x : M) (xs : List M) (n : ℕ) [DecidablePred (getD (x::xs) · 0 ≠ 0)] [DecidablePred (getD xs · 0 ≠ 0)] : (x::xs).toFinsupp n.succ = xs.toFinsupp n := rfl #align list.to_finsupp_cons_apply_succ List.toFinsupp_cons_apply_succ -- Porting note (#10756): new theorem theorem toFinsupp_append {R : Type*} [AddZeroClass R] (l₁ l₂ : List R) [DecidablePred (getD (l₁ ++ l₂) · 0 ≠ 0)] [DecidablePred (getD l₁ · 0 ≠ 0)] [DecidablePred (getD l₂ · 0 ≠ 0)] : toFinsupp (l₁ ++ l₂) = toFinsupp l₁ + (toFinsupp l₂).embDomain (addLeftEmbedding l₁.length) := by ext n simp only [toFinsupp_apply, Finsupp.add_apply] cases lt_or_le n l₁.length with | inl h => rw [getD_append _ _ _ _ h, Finsupp.embDomain_notin_range, add_zero] rintro ⟨k, rfl : length l₁ + k = n⟩ omega | inr h => rcases Nat.exists_eq_add_of_le h with ⟨k, rfl⟩ rw [getD_append_right _ _ _ _ h, Nat.add_sub_cancel_left, getD_eq_default _ _ h, zero_add] exact Eq.symm (Finsupp.embDomain_apply _ _ _)
Mathlib/Data/List/ToFinsupp.lean
128
136
theorem toFinsupp_cons_eq_single_add_embDomain {R : Type*} [AddZeroClass R] (x : R) (xs : List R) [DecidablePred (getD (x::xs) · 0 ≠ 0)] [DecidablePred (getD xs · 0 ≠ 0)] : toFinsupp (x::xs) = Finsupp.single 0 x + (toFinsupp xs).embDomain ⟨Nat.succ, Nat.succ_injective⟩ := by
classical convert toFinsupp_append [x] xs using 3 · exact (toFinsupp_singleton x).symm · ext n exact add_comm n 1
467
import Mathlib.Data.Finsupp.Defs #align_import data.list.to_finsupp from "leanprover-community/mathlib"@"06a655b5fcfbda03502f9158bbf6c0f1400886f9" namespace List variable {M : Type*} [Zero M] (l : List M) [DecidablePred (getD l · 0 ≠ 0)] (n : ℕ) def toFinsupp : ℕ →₀ M where toFun i := getD l i 0 support := (Finset.range l.length).filter fun i => getD l i 0 ≠ 0 mem_support_toFun n := by simp only [Ne, Finset.mem_filter, Finset.mem_range, and_iff_right_iff_imp] contrapose! exact getD_eq_default _ _ #align list.to_finsupp List.toFinsupp @[norm_cast] theorem coe_toFinsupp : (l.toFinsupp : ℕ → M) = (l.getD · 0) := rfl #align list.coe_to_finsupp List.coe_toFinsupp @[simp, norm_cast] theorem toFinsupp_apply (i : ℕ) : (l.toFinsupp : ℕ → M) i = l.getD i 0 := rfl #align list.to_finsupp_apply List.toFinsupp_apply theorem toFinsupp_support : l.toFinsupp.support = (Finset.range l.length).filter (getD l · 0 ≠ 0) := rfl #align list.to_finsupp_support List.toFinsupp_support theorem toFinsupp_apply_lt (hn : n < l.length) : l.toFinsupp n = l.get ⟨n, hn⟩ := getD_eq_get _ _ _ theorem toFinsupp_apply_fin (n : Fin l.length) : l.toFinsupp n = l.get n := getD_eq_get _ _ _ set_option linter.deprecated false in @[deprecated (since := "2023-04-10")] theorem toFinsupp_apply_lt' (hn : n < l.length) : l.toFinsupp n = l.nthLe n hn := getD_eq_get _ _ _ #align list.to_finsupp_apply_lt List.toFinsupp_apply_lt' theorem toFinsupp_apply_le (hn : l.length ≤ n) : l.toFinsupp n = 0 := getD_eq_default _ _ hn #align list.to_finsupp_apply_le List.toFinsupp_apply_le @[simp] theorem toFinsupp_nil [DecidablePred fun i => getD ([] : List M) i 0 ≠ 0] : toFinsupp ([] : List M) = 0 := by ext simp #align list.to_finsupp_nil List.toFinsupp_nil theorem toFinsupp_singleton (x : M) [DecidablePred (getD [x] · 0 ≠ 0)] : toFinsupp [x] = Finsupp.single 0 x := by ext ⟨_ | i⟩ <;> simp [Finsupp.single_apply, (Nat.zero_lt_succ _).ne] #align list.to_finsupp_singleton List.toFinsupp_singleton @[simp] theorem toFinsupp_cons_apply_zero (x : M) (xs : List M) [DecidablePred (getD (x::xs) · 0 ≠ 0)] : (x::xs).toFinsupp 0 = x := rfl #align list.to_finsupp_cons_apply_zero List.toFinsupp_cons_apply_zero @[simp] theorem toFinsupp_cons_apply_succ (x : M) (xs : List M) (n : ℕ) [DecidablePred (getD (x::xs) · 0 ≠ 0)] [DecidablePred (getD xs · 0 ≠ 0)] : (x::xs).toFinsupp n.succ = xs.toFinsupp n := rfl #align list.to_finsupp_cons_apply_succ List.toFinsupp_cons_apply_succ -- Porting note (#10756): new theorem theorem toFinsupp_append {R : Type*} [AddZeroClass R] (l₁ l₂ : List R) [DecidablePred (getD (l₁ ++ l₂) · 0 ≠ 0)] [DecidablePred (getD l₁ · 0 ≠ 0)] [DecidablePred (getD l₂ · 0 ≠ 0)] : toFinsupp (l₁ ++ l₂) = toFinsupp l₁ + (toFinsupp l₂).embDomain (addLeftEmbedding l₁.length) := by ext n simp only [toFinsupp_apply, Finsupp.add_apply] cases lt_or_le n l₁.length with | inl h => rw [getD_append _ _ _ _ h, Finsupp.embDomain_notin_range, add_zero] rintro ⟨k, rfl : length l₁ + k = n⟩ omega | inr h => rcases Nat.exists_eq_add_of_le h with ⟨k, rfl⟩ rw [getD_append_right _ _ _ _ h, Nat.add_sub_cancel_left, getD_eq_default _ _ h, zero_add] exact Eq.symm (Finsupp.embDomain_apply _ _ _) theorem toFinsupp_cons_eq_single_add_embDomain {R : Type*} [AddZeroClass R] (x : R) (xs : List R) [DecidablePred (getD (x::xs) · 0 ≠ 0)] [DecidablePred (getD xs · 0 ≠ 0)] : toFinsupp (x::xs) = Finsupp.single 0 x + (toFinsupp xs).embDomain ⟨Nat.succ, Nat.succ_injective⟩ := by classical convert toFinsupp_append [x] xs using 3 · exact (toFinsupp_singleton x).symm · ext n exact add_comm n 1 #align list.to_finsupp_cons_eq_single_add_emb_domain List.toFinsupp_cons_eq_single_add_embDomain
Mathlib/Data/List/ToFinsupp.lean
139
143
theorem toFinsupp_concat_eq_toFinsupp_add_single {R : Type*} [AddZeroClass R] (x : R) (xs : List R) [DecidablePred fun i => getD (xs ++ [x]) i 0 ≠ 0] [DecidablePred fun i => getD xs i 0 ≠ 0] : toFinsupp (xs ++ [x]) = toFinsupp xs + Finsupp.single xs.length x := by
classical rw [toFinsupp_append, toFinsupp_singleton, Finsupp.embDomain_single, addLeftEmbedding_apply, add_zero]
467
import Mathlib.Data.Finsupp.Defs #align_import data.list.to_finsupp from "leanprover-community/mathlib"@"06a655b5fcfbda03502f9158bbf6c0f1400886f9" namespace List variable {M : Type*} [Zero M] (l : List M) [DecidablePred (getD l · 0 ≠ 0)] (n : ℕ) def toFinsupp : ℕ →₀ M where toFun i := getD l i 0 support := (Finset.range l.length).filter fun i => getD l i 0 ≠ 0 mem_support_toFun n := by simp only [Ne, Finset.mem_filter, Finset.mem_range, and_iff_right_iff_imp] contrapose! exact getD_eq_default _ _ #align list.to_finsupp List.toFinsupp @[norm_cast] theorem coe_toFinsupp : (l.toFinsupp : ℕ → M) = (l.getD · 0) := rfl #align list.coe_to_finsupp List.coe_toFinsupp @[simp, norm_cast] theorem toFinsupp_apply (i : ℕ) : (l.toFinsupp : ℕ → M) i = l.getD i 0 := rfl #align list.to_finsupp_apply List.toFinsupp_apply theorem toFinsupp_support : l.toFinsupp.support = (Finset.range l.length).filter (getD l · 0 ≠ 0) := rfl #align list.to_finsupp_support List.toFinsupp_support theorem toFinsupp_apply_lt (hn : n < l.length) : l.toFinsupp n = l.get ⟨n, hn⟩ := getD_eq_get _ _ _ theorem toFinsupp_apply_fin (n : Fin l.length) : l.toFinsupp n = l.get n := getD_eq_get _ _ _ set_option linter.deprecated false in @[deprecated (since := "2023-04-10")] theorem toFinsupp_apply_lt' (hn : n < l.length) : l.toFinsupp n = l.nthLe n hn := getD_eq_get _ _ _ #align list.to_finsupp_apply_lt List.toFinsupp_apply_lt' theorem toFinsupp_apply_le (hn : l.length ≤ n) : l.toFinsupp n = 0 := getD_eq_default _ _ hn #align list.to_finsupp_apply_le List.toFinsupp_apply_le @[simp] theorem toFinsupp_nil [DecidablePred fun i => getD ([] : List M) i 0 ≠ 0] : toFinsupp ([] : List M) = 0 := by ext simp #align list.to_finsupp_nil List.toFinsupp_nil theorem toFinsupp_singleton (x : M) [DecidablePred (getD [x] · 0 ≠ 0)] : toFinsupp [x] = Finsupp.single 0 x := by ext ⟨_ | i⟩ <;> simp [Finsupp.single_apply, (Nat.zero_lt_succ _).ne] #align list.to_finsupp_singleton List.toFinsupp_singleton @[simp] theorem toFinsupp_cons_apply_zero (x : M) (xs : List M) [DecidablePred (getD (x::xs) · 0 ≠ 0)] : (x::xs).toFinsupp 0 = x := rfl #align list.to_finsupp_cons_apply_zero List.toFinsupp_cons_apply_zero @[simp] theorem toFinsupp_cons_apply_succ (x : M) (xs : List M) (n : ℕ) [DecidablePred (getD (x::xs) · 0 ≠ 0)] [DecidablePred (getD xs · 0 ≠ 0)] : (x::xs).toFinsupp n.succ = xs.toFinsupp n := rfl #align list.to_finsupp_cons_apply_succ List.toFinsupp_cons_apply_succ -- Porting note (#10756): new theorem theorem toFinsupp_append {R : Type*} [AddZeroClass R] (l₁ l₂ : List R) [DecidablePred (getD (l₁ ++ l₂) · 0 ≠ 0)] [DecidablePred (getD l₁ · 0 ≠ 0)] [DecidablePred (getD l₂ · 0 ≠ 0)] : toFinsupp (l₁ ++ l₂) = toFinsupp l₁ + (toFinsupp l₂).embDomain (addLeftEmbedding l₁.length) := by ext n simp only [toFinsupp_apply, Finsupp.add_apply] cases lt_or_le n l₁.length with | inl h => rw [getD_append _ _ _ _ h, Finsupp.embDomain_notin_range, add_zero] rintro ⟨k, rfl : length l₁ + k = n⟩ omega | inr h => rcases Nat.exists_eq_add_of_le h with ⟨k, rfl⟩ rw [getD_append_right _ _ _ _ h, Nat.add_sub_cancel_left, getD_eq_default _ _ h, zero_add] exact Eq.symm (Finsupp.embDomain_apply _ _ _) theorem toFinsupp_cons_eq_single_add_embDomain {R : Type*} [AddZeroClass R] (x : R) (xs : List R) [DecidablePred (getD (x::xs) · 0 ≠ 0)] [DecidablePred (getD xs · 0 ≠ 0)] : toFinsupp (x::xs) = Finsupp.single 0 x + (toFinsupp xs).embDomain ⟨Nat.succ, Nat.succ_injective⟩ := by classical convert toFinsupp_append [x] xs using 3 · exact (toFinsupp_singleton x).symm · ext n exact add_comm n 1 #align list.to_finsupp_cons_eq_single_add_emb_domain List.toFinsupp_cons_eq_single_add_embDomain theorem toFinsupp_concat_eq_toFinsupp_add_single {R : Type*} [AddZeroClass R] (x : R) (xs : List R) [DecidablePred fun i => getD (xs ++ [x]) i 0 ≠ 0] [DecidablePred fun i => getD xs i 0 ≠ 0] : toFinsupp (xs ++ [x]) = toFinsupp xs + Finsupp.single xs.length x := by classical rw [toFinsupp_append, toFinsupp_singleton, Finsupp.embDomain_single, addLeftEmbedding_apply, add_zero] #align list.to_finsupp_concat_eq_to_finsupp_add_single List.toFinsupp_concat_eq_toFinsupp_add_single
Mathlib/Data/List/ToFinsupp.lean
147
156
theorem toFinsupp_eq_sum_map_enum_single {R : Type*} [AddMonoid R] (l : List R) [DecidablePred (getD l · 0 ≠ 0)] : toFinsupp l = (l.enum.map fun nr : ℕ × R => Finsupp.single nr.1 nr.2).sum := by
/- Porting note (#11215): TODO: `induction` fails to substitute `l = []` in `[DecidablePred (getD l · 0 ≠ 0)]`, so we manually do some `revert`/`intro` as a workaround -/ revert l; intro l induction l using List.reverseRecOn with | nil => exact toFinsupp_nil | append_singleton x xs ih => classical simp [toFinsupp_concat_eq_toFinsupp_add_single, enum_append, ih]
467
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.indicator from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {ι α : Type*} namespace Finsupp variable [Zero α] {s : Finset ι} (f : ∀ i ∈ s, α) {i : ι} def indicator (s : Finset ι) (f : ∀ i ∈ s, α) : ι →₀ α where toFun i := haveI := Classical.decEq ι if H : i ∈ s then f i H else 0 support := haveI := Classical.decEq α (s.attach.filter fun i : s => f i.1 i.2 ≠ 0).map (Embedding.subtype _) mem_support_toFun i := by classical simp #align finsupp.indicator Finsupp.indicator theorem indicator_of_mem (hi : i ∈ s) (f : ∀ i ∈ s, α) : indicator s f i = f i hi := @dif_pos _ (id _) hi _ _ _ #align finsupp.indicator_of_mem Finsupp.indicator_of_mem theorem indicator_of_not_mem (hi : i ∉ s) (f : ∀ i ∈ s, α) : indicator s f i = 0 := @dif_neg _ (id _) hi _ _ _ #align finsupp.indicator_of_not_mem Finsupp.indicator_of_not_mem variable (s i) @[simp]
Mathlib/Data/Finsupp/Indicator.lean
54
56
theorem indicator_apply [DecidableEq ι] : indicator s f i = if hi : i ∈ s then f i hi else 0 := by
simp only [indicator, ne_eq, coe_mk] congr
468
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.indicator from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {ι α : Type*} namespace Finsupp variable [Zero α] {s : Finset ι} (f : ∀ i ∈ s, α) {i : ι} def indicator (s : Finset ι) (f : ∀ i ∈ s, α) : ι →₀ α where toFun i := haveI := Classical.decEq ι if H : i ∈ s then f i H else 0 support := haveI := Classical.decEq α (s.attach.filter fun i : s => f i.1 i.2 ≠ 0).map (Embedding.subtype _) mem_support_toFun i := by classical simp #align finsupp.indicator Finsupp.indicator theorem indicator_of_mem (hi : i ∈ s) (f : ∀ i ∈ s, α) : indicator s f i = f i hi := @dif_pos _ (id _) hi _ _ _ #align finsupp.indicator_of_mem Finsupp.indicator_of_mem theorem indicator_of_not_mem (hi : i ∉ s) (f : ∀ i ∈ s, α) : indicator s f i = 0 := @dif_neg _ (id _) hi _ _ _ #align finsupp.indicator_of_not_mem Finsupp.indicator_of_not_mem variable (s i) @[simp] theorem indicator_apply [DecidableEq ι] : indicator s f i = if hi : i ∈ s then f i hi else 0 := by simp only [indicator, ne_eq, coe_mk] congr #align finsupp.indicator_apply Finsupp.indicator_apply
Mathlib/Data/Finsupp/Indicator.lean
59
63
theorem indicator_injective : Injective fun f : ∀ i ∈ s, α => indicator s f := by
intro a b h ext i hi rw [← indicator_of_mem hi a, ← indicator_of_mem hi b] exact DFunLike.congr_fun h i
468
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.indicator from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71" noncomputable section open Finset Function variable {ι α : Type*} namespace Finsupp variable [Zero α] {s : Finset ι} (f : ∀ i ∈ s, α) {i : ι} def indicator (s : Finset ι) (f : ∀ i ∈ s, α) : ι →₀ α where toFun i := haveI := Classical.decEq ι if H : i ∈ s then f i H else 0 support := haveI := Classical.decEq α (s.attach.filter fun i : s => f i.1 i.2 ≠ 0).map (Embedding.subtype _) mem_support_toFun i := by classical simp #align finsupp.indicator Finsupp.indicator theorem indicator_of_mem (hi : i ∈ s) (f : ∀ i ∈ s, α) : indicator s f i = f i hi := @dif_pos _ (id _) hi _ _ _ #align finsupp.indicator_of_mem Finsupp.indicator_of_mem theorem indicator_of_not_mem (hi : i ∉ s) (f : ∀ i ∈ s, α) : indicator s f i = 0 := @dif_neg _ (id _) hi _ _ _ #align finsupp.indicator_of_not_mem Finsupp.indicator_of_not_mem variable (s i) @[simp] theorem indicator_apply [DecidableEq ι] : indicator s f i = if hi : i ∈ s then f i hi else 0 := by simp only [indicator, ne_eq, coe_mk] congr #align finsupp.indicator_apply Finsupp.indicator_apply theorem indicator_injective : Injective fun f : ∀ i ∈ s, α => indicator s f := by intro a b h ext i hi rw [← indicator_of_mem hi a, ← indicator_of_mem hi b] exact DFunLike.congr_fun h i #align finsupp.indicator_injective Finsupp.indicator_injective
Mathlib/Data/Finsupp/Indicator.lean
66
70
theorem support_indicator_subset : ((indicator s f).support : Set ι) ⊆ s := by
intro i hi rw [mem_coe, mem_support_iff] at hi by_contra h exact hi (indicator_of_not_mem h _)
468
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.fin from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" noncomputable section namespace Finsupp variable {n : ℕ} (i : Fin n) {M : Type*} [Zero M] (y : M) (t : Fin (n + 1) →₀ M) (s : Fin n →₀ M) def tail (s : Fin (n + 1) →₀ M) : Fin n →₀ M := Finsupp.equivFunOnFinite.symm (Fin.tail s) #align finsupp.tail Finsupp.tail def cons (y : M) (s : Fin n →₀ M) : Fin (n + 1) →₀ M := Finsupp.equivFunOnFinite.symm (Fin.cons y s : Fin (n + 1) → M) #align finsupp.cons Finsupp.cons theorem tail_apply : tail t i = t i.succ := rfl #align finsupp.tail_apply Finsupp.tail_apply @[simp] theorem cons_zero : cons y s 0 = y := rfl #align finsupp.cons_zero Finsupp.cons_zero @[simp] theorem cons_succ : cons y s i.succ = s i := -- Porting note: was Fin.cons_succ _ _ _ rfl #align finsupp.cons_succ Finsupp.cons_succ @[simp] theorem tail_cons : tail (cons y s) = s := ext fun k => by simp only [tail_apply, cons_succ] #align finsupp.tail_cons Finsupp.tail_cons @[simp]
Mathlib/Data/Finsupp/Fin.lean
60
64
theorem cons_tail : cons (t 0) (tail t) = t := by
ext a by_cases c_a : a = 0 · rw [c_a, cons_zero] · rw [← Fin.succ_pred a c_a, cons_succ, ← tail_apply]
469
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.fin from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" noncomputable section namespace Finsupp variable {n : ℕ} (i : Fin n) {M : Type*} [Zero M] (y : M) (t : Fin (n + 1) →₀ M) (s : Fin n →₀ M) def tail (s : Fin (n + 1) →₀ M) : Fin n →₀ M := Finsupp.equivFunOnFinite.symm (Fin.tail s) #align finsupp.tail Finsupp.tail def cons (y : M) (s : Fin n →₀ M) : Fin (n + 1) →₀ M := Finsupp.equivFunOnFinite.symm (Fin.cons y s : Fin (n + 1) → M) #align finsupp.cons Finsupp.cons theorem tail_apply : tail t i = t i.succ := rfl #align finsupp.tail_apply Finsupp.tail_apply @[simp] theorem cons_zero : cons y s 0 = y := rfl #align finsupp.cons_zero Finsupp.cons_zero @[simp] theorem cons_succ : cons y s i.succ = s i := -- Porting note: was Fin.cons_succ _ _ _ rfl #align finsupp.cons_succ Finsupp.cons_succ @[simp] theorem tail_cons : tail (cons y s) = s := ext fun k => by simp only [tail_apply, cons_succ] #align finsupp.tail_cons Finsupp.tail_cons @[simp] theorem cons_tail : cons (t 0) (tail t) = t := by ext a by_cases c_a : a = 0 · rw [c_a, cons_zero] · rw [← Fin.succ_pred a c_a, cons_succ, ← tail_apply] #align finsupp.cons_tail Finsupp.cons_tail @[simp]
Mathlib/Data/Finsupp/Fin.lean
68
73
theorem cons_zero_zero : cons 0 (0 : Fin n →₀ M) = 0 := by
ext a by_cases c : a = 0 · simp [c] · rw [← Fin.succ_pred a c, cons_succ] simp
469
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.fin from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" noncomputable section namespace Finsupp variable {n : ℕ} (i : Fin n) {M : Type*} [Zero M] (y : M) (t : Fin (n + 1) →₀ M) (s : Fin n →₀ M) def tail (s : Fin (n + 1) →₀ M) : Fin n →₀ M := Finsupp.equivFunOnFinite.symm (Fin.tail s) #align finsupp.tail Finsupp.tail def cons (y : M) (s : Fin n →₀ M) : Fin (n + 1) →₀ M := Finsupp.equivFunOnFinite.symm (Fin.cons y s : Fin (n + 1) → M) #align finsupp.cons Finsupp.cons theorem tail_apply : tail t i = t i.succ := rfl #align finsupp.tail_apply Finsupp.tail_apply @[simp] theorem cons_zero : cons y s 0 = y := rfl #align finsupp.cons_zero Finsupp.cons_zero @[simp] theorem cons_succ : cons y s i.succ = s i := -- Porting note: was Fin.cons_succ _ _ _ rfl #align finsupp.cons_succ Finsupp.cons_succ @[simp] theorem tail_cons : tail (cons y s) = s := ext fun k => by simp only [tail_apply, cons_succ] #align finsupp.tail_cons Finsupp.tail_cons @[simp] theorem cons_tail : cons (t 0) (tail t) = t := by ext a by_cases c_a : a = 0 · rw [c_a, cons_zero] · rw [← Fin.succ_pred a c_a, cons_succ, ← tail_apply] #align finsupp.cons_tail Finsupp.cons_tail @[simp] theorem cons_zero_zero : cons 0 (0 : Fin n →₀ M) = 0 := by ext a by_cases c : a = 0 · simp [c] · rw [← Fin.succ_pred a c, cons_succ] simp #align finsupp.cons_zero_zero Finsupp.cons_zero_zero variable {s} {y}
Mathlib/Data/Finsupp/Fin.lean
78
80
theorem cons_ne_zero_of_left (h : y ≠ 0) : cons y s ≠ 0 := by
contrapose! h with c rw [← cons_zero y s, c, Finsupp.coe_zero, Pi.zero_apply]
469
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.fin from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" noncomputable section namespace Finsupp variable {n : ℕ} (i : Fin n) {M : Type*} [Zero M] (y : M) (t : Fin (n + 1) →₀ M) (s : Fin n →₀ M) def tail (s : Fin (n + 1) →₀ M) : Fin n →₀ M := Finsupp.equivFunOnFinite.symm (Fin.tail s) #align finsupp.tail Finsupp.tail def cons (y : M) (s : Fin n →₀ M) : Fin (n + 1) →₀ M := Finsupp.equivFunOnFinite.symm (Fin.cons y s : Fin (n + 1) → M) #align finsupp.cons Finsupp.cons theorem tail_apply : tail t i = t i.succ := rfl #align finsupp.tail_apply Finsupp.tail_apply @[simp] theorem cons_zero : cons y s 0 = y := rfl #align finsupp.cons_zero Finsupp.cons_zero @[simp] theorem cons_succ : cons y s i.succ = s i := -- Porting note: was Fin.cons_succ _ _ _ rfl #align finsupp.cons_succ Finsupp.cons_succ @[simp] theorem tail_cons : tail (cons y s) = s := ext fun k => by simp only [tail_apply, cons_succ] #align finsupp.tail_cons Finsupp.tail_cons @[simp] theorem cons_tail : cons (t 0) (tail t) = t := by ext a by_cases c_a : a = 0 · rw [c_a, cons_zero] · rw [← Fin.succ_pred a c_a, cons_succ, ← tail_apply] #align finsupp.cons_tail Finsupp.cons_tail @[simp] theorem cons_zero_zero : cons 0 (0 : Fin n →₀ M) = 0 := by ext a by_cases c : a = 0 · simp [c] · rw [← Fin.succ_pred a c, cons_succ] simp #align finsupp.cons_zero_zero Finsupp.cons_zero_zero variable {s} {y} theorem cons_ne_zero_of_left (h : y ≠ 0) : cons y s ≠ 0 := by contrapose! h with c rw [← cons_zero y s, c, Finsupp.coe_zero, Pi.zero_apply] #align finsupp.cons_ne_zero_of_left Finsupp.cons_ne_zero_of_left
Mathlib/Data/Finsupp/Fin.lean
83
86
theorem cons_ne_zero_of_right (h : s ≠ 0) : cons y s ≠ 0 := by
contrapose! h with c ext a simp [← cons_succ a y s, c]
469
import Mathlib.Data.Finsupp.Defs #align_import data.finsupp.fin from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" noncomputable section namespace Finsupp variable {n : ℕ} (i : Fin n) {M : Type*} [Zero M] (y : M) (t : Fin (n + 1) →₀ M) (s : Fin n →₀ M) def tail (s : Fin (n + 1) →₀ M) : Fin n →₀ M := Finsupp.equivFunOnFinite.symm (Fin.tail s) #align finsupp.tail Finsupp.tail def cons (y : M) (s : Fin n →₀ M) : Fin (n + 1) →₀ M := Finsupp.equivFunOnFinite.symm (Fin.cons y s : Fin (n + 1) → M) #align finsupp.cons Finsupp.cons theorem tail_apply : tail t i = t i.succ := rfl #align finsupp.tail_apply Finsupp.tail_apply @[simp] theorem cons_zero : cons y s 0 = y := rfl #align finsupp.cons_zero Finsupp.cons_zero @[simp] theorem cons_succ : cons y s i.succ = s i := -- Porting note: was Fin.cons_succ _ _ _ rfl #align finsupp.cons_succ Finsupp.cons_succ @[simp] theorem tail_cons : tail (cons y s) = s := ext fun k => by simp only [tail_apply, cons_succ] #align finsupp.tail_cons Finsupp.tail_cons @[simp] theorem cons_tail : cons (t 0) (tail t) = t := by ext a by_cases c_a : a = 0 · rw [c_a, cons_zero] · rw [← Fin.succ_pred a c_a, cons_succ, ← tail_apply] #align finsupp.cons_tail Finsupp.cons_tail @[simp] theorem cons_zero_zero : cons 0 (0 : Fin n →₀ M) = 0 := by ext a by_cases c : a = 0 · simp [c] · rw [← Fin.succ_pred a c, cons_succ] simp #align finsupp.cons_zero_zero Finsupp.cons_zero_zero variable {s} {y} theorem cons_ne_zero_of_left (h : y ≠ 0) : cons y s ≠ 0 := by contrapose! h with c rw [← cons_zero y s, c, Finsupp.coe_zero, Pi.zero_apply] #align finsupp.cons_ne_zero_of_left Finsupp.cons_ne_zero_of_left theorem cons_ne_zero_of_right (h : s ≠ 0) : cons y s ≠ 0 := by contrapose! h with c ext a simp [← cons_succ a y s, c] #align finsupp.cons_ne_zero_of_right Finsupp.cons_ne_zero_of_right
Mathlib/Data/Finsupp/Fin.lean
89
92
theorem cons_ne_zero_iff : cons y s ≠ 0 ↔ y ≠ 0 ∨ s ≠ 0 := by
refine ⟨fun h => ?_, fun h => h.casesOn cons_ne_zero_of_left cons_ne_zero_of_right⟩ refine imp_iff_not_or.1 fun h' c => h ?_ rw [h', c, Finsupp.cons_zero_zero]
469
import Mathlib.Data.Vector.Basic import Mathlib.Data.List.Zip #align_import data.vector.zip from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" namespace Vector section ZipWith variable {α β γ : Type*} {n : ℕ} (f : α → β → γ) def zipWith : Vector α n → Vector β n → Vector γ n := fun x y => ⟨List.zipWith f x.1 y.1, by simp⟩ #align vector.zip_with Vector.zipWith @[simp] theorem zipWith_toList (x : Vector α n) (y : Vector β n) : (Vector.zipWith f x y).toList = List.zipWith f x.toList y.toList := rfl #align vector.zip_with_to_list Vector.zipWith_toList @[simp]
Mathlib/Data/Vector/Zip.lean
33
36
theorem zipWith_get (x : Vector α n) (y : Vector β n) (i) : (Vector.zipWith f x y).get i = f (x.get i) (y.get i) := by
dsimp only [Vector.zipWith, Vector.get] simp only [List.get_zipWith, Fin.cast]
470
import Mathlib.Data.Vector.Basic import Mathlib.Data.List.Zip #align_import data.vector.zip from "leanprover-community/mathlib"@"1126441d6bccf98c81214a0780c73d499f6721fe" namespace Vector section ZipWith variable {α β γ : Type*} {n : ℕ} (f : α → β → γ) def zipWith : Vector α n → Vector β n → Vector γ n := fun x y => ⟨List.zipWith f x.1 y.1, by simp⟩ #align vector.zip_with Vector.zipWith @[simp] theorem zipWith_toList (x : Vector α n) (y : Vector β n) : (Vector.zipWith f x y).toList = List.zipWith f x.toList y.toList := rfl #align vector.zip_with_to_list Vector.zipWith_toList @[simp] theorem zipWith_get (x : Vector α n) (y : Vector β n) (i) : (Vector.zipWith f x y).get i = f (x.get i) (y.get i) := by dsimp only [Vector.zipWith, Vector.get] simp only [List.get_zipWith, Fin.cast] #align vector.zip_with_nth Vector.zipWith_get @[simp]
Mathlib/Data/Vector/Zip.lean
40
43
theorem zipWith_tail (x : Vector α n) (y : Vector β n) : (Vector.zipWith f x y).tail = Vector.zipWith f x.tail y.tail := by
ext simp [get_tail]
470
import Mathlib.Init.ZeroOne import Mathlib.Data.Set.Defs import Mathlib.Order.Basic import Mathlib.Order.SymmDiff import Mathlib.Tactic.Tauto import Mathlib.Tactic.ByContra import Mathlib.Util.Delaborators #align_import data.set.basic from "leanprover-community/mathlib"@"001ffdc42920050657fd45bd2b8bfbec8eaaeb29" open Function universe u v w x namespace Set variable {α : Type u} {s t : Set α} instance instBooleanAlgebraSet : BooleanAlgebra (Set α) := { (inferInstance : BooleanAlgebra (α → Prop)) with sup := (· ∪ ·), le := (· ≤ ·), lt := fun s t => s ⊆ t ∧ ¬t ⊆ s, inf := (· ∩ ·), bot := ∅, compl := (·ᶜ), top := univ, sdiff := (· \ ·) } instance : HasSSubset (Set α) := ⟨(· < ·)⟩ @[simp] theorem top_eq_univ : (⊤ : Set α) = univ := rfl #align set.top_eq_univ Set.top_eq_univ @[simp] theorem bot_eq_empty : (⊥ : Set α) = ∅ := rfl #align set.bot_eq_empty Set.bot_eq_empty @[simp] theorem sup_eq_union : ((· ⊔ ·) : Set α → Set α → Set α) = (· ∪ ·) := rfl #align set.sup_eq_union Set.sup_eq_union @[simp] theorem inf_eq_inter : ((· ⊓ ·) : Set α → Set α → Set α) = (· ∩ ·) := rfl #align set.inf_eq_inter Set.inf_eq_inter @[simp] theorem le_eq_subset : ((· ≤ ·) : Set α → Set α → Prop) = (· ⊆ ·) := rfl #align set.le_eq_subset Set.le_eq_subset @[simp] theorem lt_eq_ssubset : ((· < ·) : Set α → Set α → Prop) = (· ⊂ ·) := rfl #align set.lt_eq_ssubset Set.lt_eq_ssubset theorem le_iff_subset : s ≤ t ↔ s ⊆ t := Iff.rfl #align set.le_iff_subset Set.le_iff_subset theorem lt_iff_ssubset : s < t ↔ s ⊂ t := Iff.rfl #align set.lt_iff_ssubset Set.lt_iff_ssubset alias ⟨_root_.LE.le.subset, _root_.HasSubset.Subset.le⟩ := le_iff_subset #align has_subset.subset.le HasSubset.Subset.le alias ⟨_root_.LT.lt.ssubset, _root_.HasSSubset.SSubset.lt⟩ := lt_iff_ssubset #align has_ssubset.ssubset.lt HasSSubset.SSubset.lt instance PiSetCoe.canLift (ι : Type u) (α : ι → Type v) [∀ i, Nonempty (α i)] (s : Set ι) : CanLift (∀ i : s, α i) (∀ i, α i) (fun f i => f i) fun _ => True := PiSubtype.canLift ι α s #align set.pi_set_coe.can_lift Set.PiSetCoe.canLift instance PiSetCoe.canLift' (ι : Type u) (α : Type v) [Nonempty α] (s : Set ι) : CanLift (s → α) (ι → α) (fun f i => f i) fun _ => True := PiSetCoe.canLift ι (fun _ => α) s #align set.pi_set_coe.can_lift' Set.PiSetCoe.canLift' end Set theorem Subtype.mem {α : Type*} {s : Set α} (p : s) : (p : α) ∈ s := p.prop #align subtype.mem Subtype.mem theorem Eq.subset {α} {s t : Set α} : s = t → s ⊆ t := fun h₁ _ h₂ => by rw [← h₁]; exact h₂ #align eq.subset Eq.subset namespace Set variable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} {a b : α} {s s₁ s₂ t t₁ t₂ u : Set α} instance : Inhabited (Set α) := ⟨∅⟩ theorem ext_iff {s t : Set α} : s = t ↔ ∀ x, x ∈ s ↔ x ∈ t := ⟨fun h x => by rw [h], ext⟩ #align set.ext_iff Set.ext_iff @[trans] theorem mem_of_mem_of_subset {x : α} {s t : Set α} (hx : x ∈ s) (h : s ⊆ t) : x ∈ t := h hx #align set.mem_of_mem_of_subset Set.mem_of_mem_of_subset
Mathlib/Data/Set/Basic.lean
224
225
theorem forall_in_swap {p : α → β → Prop} : (∀ a ∈ s, ∀ (b), p a b) ↔ ∀ (b), ∀ a ∈ s, p a b := by
tauto
471
import Mathlib.Data.Set.Basic #align_import order.well_founded from "leanprover-community/mathlib"@"2c84c2c5496117349007d97104e7bbb471381592" variable {α β γ : Type*} namespace WellFounded variable {r r' : α → α → Prop} #align well_founded_relation.r WellFoundedRelation.rel protected theorem isAsymm (h : WellFounded r) : IsAsymm α r := ⟨h.asymmetric⟩ #align well_founded.is_asymm WellFounded.isAsymm protected theorem isIrrefl (h : WellFounded r) : IsIrrefl α r := @IsAsymm.isIrrefl α r h.isAsymm #align well_founded.is_irrefl WellFounded.isIrrefl instance [WellFoundedRelation α] : IsAsymm α WellFoundedRelation.rel := WellFoundedRelation.wf.isAsymm instance : IsIrrefl α WellFoundedRelation.rel := IsAsymm.isIrrefl theorem mono (hr : WellFounded r) (h : ∀ a b, r' a b → r a b) : WellFounded r' := Subrelation.wf (h _ _) hr #align well_founded.mono WellFounded.mono theorem onFun {α β : Sort*} {r : β → β → Prop} {f : α → β} : WellFounded r → WellFounded (r on f) := InvImage.wf _ #align well_founded.on_fun WellFounded.onFun theorem has_min {α} {r : α → α → Prop} (H : WellFounded r) (s : Set α) : s.Nonempty → ∃ a ∈ s, ∀ x ∈ s, ¬r x a | ⟨a, ha⟩ => show ∃ b ∈ s, ∀ x ∈ s, ¬r x b from Acc.recOn (H.apply a) (fun x _ IH => not_imp_not.1 fun hne hx => hne <| ⟨x, hx, fun y hy hyx => hne <| IH y hyx hy⟩) ha #align well_founded.has_min WellFounded.has_min noncomputable def min {r : α → α → Prop} (H : WellFounded r) (s : Set α) (h : s.Nonempty) : α := Classical.choose (H.has_min s h) #align well_founded.min WellFounded.min theorem min_mem {r : α → α → Prop} (H : WellFounded r) (s : Set α) (h : s.Nonempty) : H.min s h ∈ s := let ⟨h, _⟩ := Classical.choose_spec (H.has_min s h) h #align well_founded.min_mem WellFounded.min_mem theorem not_lt_min {r : α → α → Prop} (H : WellFounded r) (s : Set α) (h : s.Nonempty) {x} (hx : x ∈ s) : ¬r x (H.min s h) := let ⟨_, h'⟩ := Classical.choose_spec (H.has_min s h) h' _ hx #align well_founded.not_lt_min WellFounded.not_lt_min
Mathlib/Order/WellFounded.lean
82
89
theorem wellFounded_iff_has_min {r : α → α → Prop} : WellFounded r ↔ ∀ s : Set α, s.Nonempty → ∃ m ∈ s, ∀ x ∈ s, ¬r x m := by
refine ⟨fun h => h.has_min, fun h => ⟨fun x => ?_⟩⟩ by_contra hx obtain ⟨m, hm, hm'⟩ := h {x | ¬Acc r x} ⟨x, hx⟩ refine hm ⟨_, fun y hy => ?_⟩ by_contra hy' exact hm' y hy' hy
472
import Mathlib.Order.WellFounded import Mathlib.Tactic.Common #align_import data.pi.lex from "leanprover-community/mathlib"@"6623e6af705e97002a9054c1c05a980180276fc1" assert_not_exists Monoid variable {ι : Type*} {β : ι → Type*} (r : ι → ι → Prop) (s : ∀ {i}, β i → β i → Prop) namespace Pi protected def Lex (x y : ∀ i, β i) : Prop := ∃ i, (∀ j, r j i → x j = y j) ∧ s (x i) (y i) #align pi.lex Pi.Lex notation3 (prettyPrint := false) "Πₗ "(...)", "r:(scoped p => Lex (∀ i, p i)) => r @[simp] theorem toLex_apply (x : ∀ i, β i) (i : ι) : toLex x i = x i := rfl #align pi.to_lex_apply Pi.toLex_apply @[simp] theorem ofLex_apply (x : Lex (∀ i, β i)) (i : ι) : ofLex x i = x i := rfl #align pi.of_lex_apply Pi.ofLex_apply theorem lex_lt_of_lt_of_preorder [∀ i, Preorder (β i)] {r} (hwf : WellFounded r) {x y : ∀ i, β i} (hlt : x < y) : ∃ i, (∀ j, r j i → x j ≤ y j ∧ y j ≤ x j) ∧ x i < y i := let h' := Pi.lt_def.1 hlt let ⟨i, hi, hl⟩ := hwf.has_min _ h'.2 ⟨i, fun j hj => ⟨h'.1 j, not_not.1 fun h => hl j (lt_of_le_not_le (h'.1 j) h) hj⟩, hi⟩ #align pi.lex_lt_of_lt_of_preorder Pi.lex_lt_of_lt_of_preorder
Mathlib/Order/PiLex.lean
65
68
theorem lex_lt_of_lt [∀ i, PartialOrder (β i)] {r} (hwf : WellFounded r) {x y : ∀ i, β i} (hlt : x < y) : Pi.Lex r (@fun i => (· < ·)) x y := by
simp_rw [Pi.Lex, le_antisymm_iff] exact lex_lt_of_lt_of_preorder hwf hlt
473
import Mathlib.Order.WellFounded import Mathlib.Tactic.Common #align_import data.pi.lex from "leanprover-community/mathlib"@"6623e6af705e97002a9054c1c05a980180276fc1" assert_not_exists Monoid variable {ι : Type*} {β : ι → Type*} (r : ι → ι → Prop) (s : ∀ {i}, β i → β i → Prop) namespace Pi protected def Lex (x y : ∀ i, β i) : Prop := ∃ i, (∀ j, r j i → x j = y j) ∧ s (x i) (y i) #align pi.lex Pi.Lex notation3 (prettyPrint := false) "Πₗ "(...)", "r:(scoped p => Lex (∀ i, p i)) => r @[simp] theorem toLex_apply (x : ∀ i, β i) (i : ι) : toLex x i = x i := rfl #align pi.to_lex_apply Pi.toLex_apply @[simp] theorem ofLex_apply (x : Lex (∀ i, β i)) (i : ι) : ofLex x i = x i := rfl #align pi.of_lex_apply Pi.ofLex_apply theorem lex_lt_of_lt_of_preorder [∀ i, Preorder (β i)] {r} (hwf : WellFounded r) {x y : ∀ i, β i} (hlt : x < y) : ∃ i, (∀ j, r j i → x j ≤ y j ∧ y j ≤ x j) ∧ x i < y i := let h' := Pi.lt_def.1 hlt let ⟨i, hi, hl⟩ := hwf.has_min _ h'.2 ⟨i, fun j hj => ⟨h'.1 j, not_not.1 fun h => hl j (lt_of_le_not_le (h'.1 j) h) hj⟩, hi⟩ #align pi.lex_lt_of_lt_of_preorder Pi.lex_lt_of_lt_of_preorder theorem lex_lt_of_lt [∀ i, PartialOrder (β i)] {r} (hwf : WellFounded r) {x y : ∀ i, β i} (hlt : x < y) : Pi.Lex r (@fun i => (· < ·)) x y := by simp_rw [Pi.Lex, le_antisymm_iff] exact lex_lt_of_lt_of_preorder hwf hlt #align pi.lex_lt_of_lt Pi.lex_lt_of_lt
Mathlib/Order/PiLex.lean
71
85
theorem isTrichotomous_lex [∀ i, IsTrichotomous (β i) s] (wf : WellFounded r) : IsTrichotomous (∀ i, β i) (Pi.Lex r @s) := { trichotomous := fun a b => by rcases eq_or_ne a b with hab | hab · exact Or.inr (Or.inl hab) · rw [Function.ne_iff] at hab let i := wf.min _ hab have hri : ∀ j, r j i → a j = b j := by
intro j rw [← not_imp_not] exact fun h' => wf.not_lt_min _ _ h' have hne : a i ≠ b i := wf.min_mem _ hab cases' trichotomous_of s (a i) (b i) with hi hi exacts [Or.inl ⟨i, hri, hi⟩, Or.inr <| Or.inr <| ⟨i, fun j hj => (hri j hj).symm, hi.resolve_left hne⟩] }
473
import Mathlib.Algebra.Group.Commute.Units import Mathlib.Algebra.Group.Invertible.Basic import Mathlib.Algebra.GroupWithZero.Units.Basic import Mathlib.Data.Set.Basic import Mathlib.Logic.Basic #align_import group_theory.subsemigroup.center from "leanprover-community/mathlib"@"1ac8d4304efba9d03fa720d06516fac845aa5353" variable {M : Type*} structure IsAddCentral [Add M] (z : M) : Prop where comm (a : M) : z + a = a + z left_assoc (b c : M) : z + (b + c) = (z + b) + c mid_assoc (a c : M) : (a + z) + c = a + (z + c) right_assoc (a b : M) : (a + b) + z = a + (b + z) @[to_additive] structure IsMulCentral [Mul M] (z : M) : Prop where comm (a : M) : z * a = a * z left_assoc (b c : M) : z * (b * c) = (z * b) * c mid_assoc (a c : M) : (a * z) * c = a * (z * c) right_assoc (a b : M) : (a * b) * z = a * (b * z) attribute [mk_iff] IsMulCentral IsAddCentral attribute [to_additive existing] isMulCentral_iff namespace Set section Mul variable (M) [Mul M] @[to_additive addCenter " The center of an additive magma. "] def center : Set M := { z | IsMulCentral z } #align set.center Set.center #align set.add_center Set.addCenter -- Porting note: The `to_additive` version used to be `mem_addCenter` without the iff @[to_additive mem_addCenter_iff] theorem mem_center_iff {z : M} : z ∈ center M ↔ IsMulCentral z := Iff.rfl #align set.mem_center_iff Set.mem_center_iff #align set.mem_add_center Set.mem_addCenter_iff variable {M} @[to_additive (attr := simp) add_mem_addCenter]
Mathlib/Algebra/Group/Center.lean
98
119
theorem mul_mem_center [Mul M] {z₁ z₂ : M} (hz₁ : z₁ ∈ Set.center M) (hz₂ : z₂ ∈ Set.center M) : z₁ * z₂ ∈ Set.center M where comm a := calc z₁ * z₂ * a = z₂ * z₁ * a := by
rw [hz₁.comm] _ = z₂ * (z₁ * a) := by rw [hz₁.mid_assoc z₂] _ = (a * z₁) * z₂ := by rw [hz₁.comm, hz₂.comm] _ = a * (z₁ * z₂) := by rw [hz₂.right_assoc a z₁] left_assoc (b c : M) := calc z₁ * z₂ * (b * c) = z₁ * (z₂ * (b * c)) := by rw [hz₂.mid_assoc] _ = z₁ * ((z₂ * b) * c) := by rw [hz₂.left_assoc] _ = (z₁ * (z₂ * b)) * c := by rw [hz₁.left_assoc] _ = z₁ * z₂ * b * c := by rw [hz₂.mid_assoc] mid_assoc (a c : M) := calc a * (z₁ * z₂) * c = ((a * z₁) * z₂) * c := by rw [hz₁.mid_assoc] _ = (a * z₁) * (z₂ * c) := by rw [hz₂.mid_assoc] _ = a * (z₁ * (z₂ * c)) := by rw [hz₁.mid_assoc] _ = a * (z₁ * z₂ * c) := by rw [hz₂.mid_assoc] right_assoc (a b : M) := calc a * b * (z₁ * z₂) = ((a * b) * z₁) * z₂ := by rw [hz₂.right_assoc] _ = (a * (b * z₁)) * z₂ := by rw [hz₁.right_assoc] _ = a * ((b * z₁) * z₂) := by rw [hz₂.right_assoc] _ = a * (b * (z₁ * z₂)) := by rw [hz₁.mid_assoc]
474
import Mathlib.Algebra.Group.Center #align_import group_theory.subsemigroup.centralizer from "leanprover-community/mathlib"@"cc67cd75b4e54191e13c2e8d722289a89e67e4fa" variable {M : Type*} {S T : Set M} namespace Set variable (S) @[to_additive addCentralizer " The centralizer of a subset of an additive magma. "] def centralizer [Mul M] : Set M := { c | ∀ m ∈ S, m * c = c * m } #align set.centralizer Set.centralizer #align set.add_centralizer Set.addCentralizer variable {S} @[to_additive mem_addCentralizer] theorem mem_centralizer_iff [Mul M] {c : M} : c ∈ centralizer S ↔ ∀ m ∈ S, m * c = c * m := Iff.rfl #align set.mem_centralizer_iff Set.mem_centralizer_iff #align set.mem_add_centralizer Set.mem_addCentralizer @[to_additive decidableMemAddCentralizer] instance decidableMemCentralizer [Mul M] [∀ a : M, Decidable <| ∀ b ∈ S, b * a = a * b] : DecidablePred (· ∈ centralizer S) := fun _ => decidable_of_iff' _ mem_centralizer_iff #align set.decidable_mem_centralizer Set.decidableMemCentralizer #align set.decidable_mem_add_centralizer Set.decidableMemAddCentralizer variable (S) @[to_additive (attr := simp) zero_mem_addCentralizer]
Mathlib/Algebra/Group/Centralizer.lean
58
59
theorem one_mem_centralizer [MulOneClass M] : (1 : M) ∈ centralizer S := by
simp [mem_centralizer_iff]
475
import Mathlib.Algebra.Group.Center #align_import group_theory.subsemigroup.centralizer from "leanprover-community/mathlib"@"cc67cd75b4e54191e13c2e8d722289a89e67e4fa" variable {M : Type*} {S T : Set M} namespace Set variable (S) @[to_additive addCentralizer " The centralizer of a subset of an additive magma. "] def centralizer [Mul M] : Set M := { c | ∀ m ∈ S, m * c = c * m } #align set.centralizer Set.centralizer #align set.add_centralizer Set.addCentralizer variable {S} @[to_additive mem_addCentralizer] theorem mem_centralizer_iff [Mul M] {c : M} : c ∈ centralizer S ↔ ∀ m ∈ S, m * c = c * m := Iff.rfl #align set.mem_centralizer_iff Set.mem_centralizer_iff #align set.mem_add_centralizer Set.mem_addCentralizer @[to_additive decidableMemAddCentralizer] instance decidableMemCentralizer [Mul M] [∀ a : M, Decidable <| ∀ b ∈ S, b * a = a * b] : DecidablePred (· ∈ centralizer S) := fun _ => decidable_of_iff' _ mem_centralizer_iff #align set.decidable_mem_centralizer Set.decidableMemCentralizer #align set.decidable_mem_add_centralizer Set.decidableMemAddCentralizer variable (S) @[to_additive (attr := simp) zero_mem_addCentralizer] theorem one_mem_centralizer [MulOneClass M] : (1 : M) ∈ centralizer S := by simp [mem_centralizer_iff] #align set.one_mem_centralizer Set.one_mem_centralizer #align set.zero_mem_add_centralizer Set.zero_mem_addCentralizer @[simp]
Mathlib/Algebra/Group/Centralizer.lean
64
65
theorem zero_mem_centralizer [MulZeroClass M] : (0 : M) ∈ centralizer S := by
simp [mem_centralizer_iff]
475
import Mathlib.Algebra.Group.Center #align_import group_theory.subsemigroup.centralizer from "leanprover-community/mathlib"@"cc67cd75b4e54191e13c2e8d722289a89e67e4fa" variable {M : Type*} {S T : Set M} namespace Set variable (S) @[to_additive addCentralizer " The centralizer of a subset of an additive magma. "] def centralizer [Mul M] : Set M := { c | ∀ m ∈ S, m * c = c * m } #align set.centralizer Set.centralizer #align set.add_centralizer Set.addCentralizer variable {S} @[to_additive mem_addCentralizer] theorem mem_centralizer_iff [Mul M] {c : M} : c ∈ centralizer S ↔ ∀ m ∈ S, m * c = c * m := Iff.rfl #align set.mem_centralizer_iff Set.mem_centralizer_iff #align set.mem_add_centralizer Set.mem_addCentralizer @[to_additive decidableMemAddCentralizer] instance decidableMemCentralizer [Mul M] [∀ a : M, Decidable <| ∀ b ∈ S, b * a = a * b] : DecidablePred (· ∈ centralizer S) := fun _ => decidable_of_iff' _ mem_centralizer_iff #align set.decidable_mem_centralizer Set.decidableMemCentralizer #align set.decidable_mem_add_centralizer Set.decidableMemAddCentralizer variable (S) @[to_additive (attr := simp) zero_mem_addCentralizer] theorem one_mem_centralizer [MulOneClass M] : (1 : M) ∈ centralizer S := by simp [mem_centralizer_iff] #align set.one_mem_centralizer Set.one_mem_centralizer #align set.zero_mem_add_centralizer Set.zero_mem_addCentralizer @[simp] theorem zero_mem_centralizer [MulZeroClass M] : (0 : M) ∈ centralizer S := by simp [mem_centralizer_iff] #align set.zero_mem_centralizer Set.zero_mem_centralizer variable {S} {a b : M} @[to_additive (attr := simp) add_mem_addCentralizer] theorem mul_mem_centralizer [Semigroup M] (ha : a ∈ centralizer S) (hb : b ∈ centralizer S) : a * b ∈ centralizer S := fun g hg => by rw [mul_assoc, ← hb g hg, ← mul_assoc, ha g hg, mul_assoc] #align set.mul_mem_centralizer Set.mul_mem_centralizer #align set.add_mem_add_centralizer Set.add_mem_addCentralizer @[to_additive (attr := simp) neg_mem_addCentralizer] theorem inv_mem_centralizer [Group M] (ha : a ∈ centralizer S) : a⁻¹ ∈ centralizer S := fun g hg => by rw [mul_inv_eq_iff_eq_mul, mul_assoc, eq_inv_mul_iff_mul_eq, ha g hg] #align set.inv_mem_centralizer Set.inv_mem_centralizer #align set.neg_mem_add_centralizer Set.neg_mem_addCentralizer @[simp] theorem inv_mem_centralizer₀ [GroupWithZero M] (ha : a ∈ centralizer S) : a⁻¹ ∈ centralizer S := (eq_or_ne a 0).elim (fun h => by rw [h, inv_zero] exact zero_mem_centralizer S) fun ha0 c hc => by rw [mul_inv_eq_iff_eq_mul₀ ha0, mul_assoc, eq_inv_mul_iff_mul_eq₀ ha0, ha c hc] #align set.inv_mem_centralizer₀ Set.inv_mem_centralizer₀ @[to_additive (attr := simp) sub_mem_addCentralizer]
Mathlib/Algebra/Group/Centralizer.lean
94
97
theorem div_mem_centralizer [Group M] (ha : a ∈ centralizer S) (hb : b ∈ centralizer S) : a / b ∈ centralizer S := by
rw [div_eq_mul_inv] exact mul_mem_centralizer ha (inv_mem_centralizer hb)
475
import Mathlib.Algebra.Group.Center #align_import group_theory.subsemigroup.centralizer from "leanprover-community/mathlib"@"cc67cd75b4e54191e13c2e8d722289a89e67e4fa" variable {M : Type*} {S T : Set M} namespace Set variable (S) @[to_additive addCentralizer " The centralizer of a subset of an additive magma. "] def centralizer [Mul M] : Set M := { c | ∀ m ∈ S, m * c = c * m } #align set.centralizer Set.centralizer #align set.add_centralizer Set.addCentralizer variable {S} @[to_additive mem_addCentralizer] theorem mem_centralizer_iff [Mul M] {c : M} : c ∈ centralizer S ↔ ∀ m ∈ S, m * c = c * m := Iff.rfl #align set.mem_centralizer_iff Set.mem_centralizer_iff #align set.mem_add_centralizer Set.mem_addCentralizer @[to_additive decidableMemAddCentralizer] instance decidableMemCentralizer [Mul M] [∀ a : M, Decidable <| ∀ b ∈ S, b * a = a * b] : DecidablePred (· ∈ centralizer S) := fun _ => decidable_of_iff' _ mem_centralizer_iff #align set.decidable_mem_centralizer Set.decidableMemCentralizer #align set.decidable_mem_add_centralizer Set.decidableMemAddCentralizer variable (S) @[to_additive (attr := simp) zero_mem_addCentralizer] theorem one_mem_centralizer [MulOneClass M] : (1 : M) ∈ centralizer S := by simp [mem_centralizer_iff] #align set.one_mem_centralizer Set.one_mem_centralizer #align set.zero_mem_add_centralizer Set.zero_mem_addCentralizer @[simp] theorem zero_mem_centralizer [MulZeroClass M] : (0 : M) ∈ centralizer S := by simp [mem_centralizer_iff] #align set.zero_mem_centralizer Set.zero_mem_centralizer variable {S} {a b : M} @[to_additive (attr := simp) add_mem_addCentralizer] theorem mul_mem_centralizer [Semigroup M] (ha : a ∈ centralizer S) (hb : b ∈ centralizer S) : a * b ∈ centralizer S := fun g hg => by rw [mul_assoc, ← hb g hg, ← mul_assoc, ha g hg, mul_assoc] #align set.mul_mem_centralizer Set.mul_mem_centralizer #align set.add_mem_add_centralizer Set.add_mem_addCentralizer @[to_additive (attr := simp) neg_mem_addCentralizer] theorem inv_mem_centralizer [Group M] (ha : a ∈ centralizer S) : a⁻¹ ∈ centralizer S := fun g hg => by rw [mul_inv_eq_iff_eq_mul, mul_assoc, eq_inv_mul_iff_mul_eq, ha g hg] #align set.inv_mem_centralizer Set.inv_mem_centralizer #align set.neg_mem_add_centralizer Set.neg_mem_addCentralizer @[simp] theorem inv_mem_centralizer₀ [GroupWithZero M] (ha : a ∈ centralizer S) : a⁻¹ ∈ centralizer S := (eq_or_ne a 0).elim (fun h => by rw [h, inv_zero] exact zero_mem_centralizer S) fun ha0 c hc => by rw [mul_inv_eq_iff_eq_mul₀ ha0, mul_assoc, eq_inv_mul_iff_mul_eq₀ ha0, ha c hc] #align set.inv_mem_centralizer₀ Set.inv_mem_centralizer₀ @[to_additive (attr := simp) sub_mem_addCentralizer] theorem div_mem_centralizer [Group M] (ha : a ∈ centralizer S) (hb : b ∈ centralizer S) : a / b ∈ centralizer S := by rw [div_eq_mul_inv] exact mul_mem_centralizer ha (inv_mem_centralizer hb) #align set.div_mem_centralizer Set.div_mem_centralizer #align set.sub_mem_add_centralizer Set.sub_mem_addCentralizer @[simp]
Mathlib/Algebra/Group/Centralizer.lean
102
105
theorem div_mem_centralizer₀ [GroupWithZero M] (ha : a ∈ centralizer S) (hb : b ∈ centralizer S) : a / b ∈ centralizer S := by
rw [div_eq_mul_inv] exact mul_mem_centralizer ha (inv_mem_centralizer₀ hb)
475
import Mathlib.Algebra.Star.Basic import Mathlib.Algebra.Star.Pointwise import Mathlib.Algebra.Group.Centralizer variable {R : Type*} [Mul R] [StarMul R] {a : R} {s : Set R}
Mathlib/Algebra/Star/Center.lean
14
34
theorem Set.star_mem_center (ha : a ∈ Set.center R) : star a ∈ Set.center R where comm := by
simpa only [star_mul, star_star] using fun g => congr_arg star (((Set.mem_center_iff R).mp ha).comm <| star g).symm left_assoc b c := calc star a * (b * c) = star a * (star (star b) * star (star c)) := by rw [star_star, star_star] _ = star a * star (star c * star b) := by rw [star_mul] _ = star ((star c * star b) * a) := by rw [← star_mul] _ = star (star c * (star b * a)) := by rw [ha.right_assoc] _ = star (star b * a) * c := by rw [star_mul, star_star] _ = (star a * b) * c := by rw [star_mul, star_star] mid_assoc b c := calc b * star a * c = star (star c * star (b * star a)) := by rw [← star_mul, star_star] _ = star (star c * (a * star b)) := by rw [star_mul b, star_star] _ = star ((star c * a) * star b) := by rw [ha.mid_assoc] _ = b * (star a * c) := by rw [star_mul, star_star, star_mul (star c), star_star] right_assoc b c := calc b * c * star a = star (a * star (b * c)) := by rw [star_mul, star_star] _ = star (a * (star c * star b)) := by rw [star_mul b] _ = star ((a * star c) * star b) := by rw [ha.left_assoc] _ = b * star (a * star c) := by rw [star_mul, star_star] _ = b * (c * star a) := by rw [star_mul, star_star]
476
import Mathlib.Algebra.Algebra.NonUnitalSubalgebra import Mathlib.Algebra.Star.StarAlgHom import Mathlib.Algebra.Star.Center universe u u' v v' w w' w'' variable {F : Type v'} {R' : Type u'} {R : Type u} variable {A : Type v} {B : Type w} {C : Type w'} namespace NonUnitalSubalgebra open scoped Pointwise variable [CommSemiring R] [StarRing R] variable [NonUnitalSemiring A] [StarRing A] [Module R A] variable [IsScalarTower R A A] [SMulCommClass R A A] [StarModule R A] variable [NonUnitalSemiring B] [StarRing B] [Module R B] variable [IsScalarTower R B B] [SMulCommClass R B B] [StarModule R B] instance instInvolutiveStar : InvolutiveStar (NonUnitalSubalgebra R A) where star S := { carrier := star S.carrier mul_mem' := @fun x y hx hy => by simpa only [Set.mem_star, NonUnitalSubalgebra.mem_carrier] using (star_mul x y).symm ▸ mul_mem hy hx add_mem' := @fun x y hx hy => by simpa only [Set.mem_star, NonUnitalSubalgebra.mem_carrier] using (star_add x y).symm ▸ add_mem hx hy zero_mem' := Set.mem_star.mp ((star_zero A).symm ▸ zero_mem S : star (0 : A) ∈ S) smul_mem' := fun r x hx => by simpa only [Set.mem_star, NonUnitalSubalgebra.mem_carrier] using (star_smul r x).symm ▸ SMulMemClass.smul_mem (star r) hx } star_involutive S := NonUnitalSubalgebra.ext fun x => ⟨fun hx => star_star x ▸ hx, fun hx => ((star_star x).symm ▸ hx : star (star x) ∈ S)⟩ @[simp] theorem mem_star_iff (S : NonUnitalSubalgebra R A) (x : A) : x ∈ star S ↔ star x ∈ S := Iff.rfl
Mathlib/Algebra/Star/NonUnitalSubalgebra.lean
544
545
theorem star_mem_star_iff (S : NonUnitalSubalgebra R A) (x : A) : star x ∈ star S ↔ x ∈ S := by
simp
477
import Mathlib.Algebra.Algebra.Unitization import Mathlib.Algebra.Star.NonUnitalSubalgebra import Mathlib.Algebra.Star.Subalgebra import Mathlib.GroupTheory.GroupAction.Ring section Subalgebra variable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] def Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A := { S with smul_mem' := fun r _x hx => S.smul_mem hx r } theorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) : (1 : A) ∈ S.toNonUnitalSubalgebra := S.one_mem def NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) : Subalgebra R A := { S with one_mem' := h1 algebraMap_mem' := fun r => (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 }
Mathlib/Algebra/Algebra/Subalgebra/Unitization.lean
70
71
theorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) : S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by
cases S; rfl
478
import Mathlib.Algebra.Algebra.Unitization import Mathlib.Algebra.Star.NonUnitalSubalgebra import Mathlib.Algebra.Star.Subalgebra import Mathlib.GroupTheory.GroupAction.Ring section Subalgebra variable {R A : Type*} [CommSemiring R] [Semiring A] [Algebra R A] def Subalgebra.toNonUnitalSubalgebra (S : Subalgebra R A) : NonUnitalSubalgebra R A := { S with smul_mem' := fun r _x hx => S.smul_mem hx r } theorem Subalgebra.one_mem_toNonUnitalSubalgebra (S : Subalgebra R A) : (1 : A) ∈ S.toNonUnitalSubalgebra := S.one_mem def NonUnitalSubalgebra.toSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) : Subalgebra R A := { S with one_mem' := h1 algebraMap_mem' := fun r => (Algebra.algebraMap_eq_smul_one (R := R) (A := A) r).symm ▸ SMulMemClass.smul_mem r h1 } theorem Subalgebra.toNonUnitalSubalgebra_toSubalgebra (S : Subalgebra R A) : S.toNonUnitalSubalgebra.toSubalgebra S.one_mem = S := by cases S; rfl
Mathlib/Algebra/Algebra/Subalgebra/Unitization.lean
73
75
theorem NonUnitalSubalgebra.toSubalgebra_toNonUnitalSubalgebra (S : NonUnitalSubalgebra R A) (h1 : (1 : A) ∈ S) : (NonUnitalSubalgebra.toSubalgebra S h1).toNonUnitalSubalgebra = S := by
cases S; rfl
478
import Mathlib.Algebra.Algebra.Unitization import Mathlib.Algebra.Star.NonUnitalSubalgebra import Mathlib.Algebra.Star.Subalgebra import Mathlib.GroupTheory.GroupAction.Ring namespace NonUnitalSubalgebra
Mathlib/Algebra/Algebra/Subalgebra/Unitization.lean
145
157
theorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A] [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [FunLike F (Unitization R s) A] [AlgHomClass F R (Unitization R s) A] (f : F) (hf : ∀ x : s, f x = x) : Function.Injective f := by
refine (injective_iff_map_eq_zero f).mpr fun x hx => ?_ induction' x with r a simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx rw [add_eq_zero_iff_eq_neg] at hx ⊢ by_cases hr : r = 0 · ext <;> simp [hr] at hx ⊢ exact hx · exact (h r hr <| hx ▸ (neg_mem a.property)).elim
478
import Mathlib.Algebra.Algebra.Unitization import Mathlib.Algebra.Star.NonUnitalSubalgebra import Mathlib.Algebra.Star.Subalgebra import Mathlib.GroupTheory.GroupAction.Ring namespace NonUnitalSubalgebra theorem _root_.AlgHomClass.unitization_injective' {F R S A : Type*} [CommRing R] [Ring A] [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S) (h : ∀ r, r ≠ 0 → algebraMap R A r ∉ s) [FunLike F (Unitization R s) A] [AlgHomClass F R (Unitization R s) A] (f : F) (hf : ∀ x : s, f x = x) : Function.Injective f := by refine (injective_iff_map_eq_zero f).mpr fun x hx => ?_ induction' x with r a simp_rw [map_add, hf, ← Unitization.algebraMap_eq_inl, AlgHomClass.commutes] at hx rw [add_eq_zero_iff_eq_neg] at hx ⊢ by_cases hr : r = 0 · ext <;> simp [hr] at hx ⊢ exact hx · exact (h r hr <| hx ▸ (neg_mem a.property)).elim
Mathlib/Algebra/Algebra/Subalgebra/Unitization.lean
161
167
theorem _root_.AlgHomClass.unitization_injective {F R S A : Type*} [Field R] [Ring A] [Algebra R A] [SetLike S A] [hSA : NonUnitalSubringClass S A] [hSRA : SMulMemClass S R A] (s : S) (h1 : 1 ∉ s) [FunLike F (Unitization R s) A] [AlgHomClass F R (Unitization R s) A] (f : F) (hf : ∀ x : s, f x = x) : Function.Injective f := by
refine AlgHomClass.unitization_injective' s (fun r hr hr' ↦ ?_) f hf rw [Algebra.algebraMap_eq_smul_one] at hr' exact h1 <| inv_smul_smul₀ hr (1 : A) ▸ SMulMemClass.smul_mem r⁻¹ hr'
478
import Mathlib.Data.Set.Basic #align_import data.bundle from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" open Function Set namespace Bundle variable {B F : Type*} (E : B → Type*) @[ext] structure TotalSpace (F : Type*) (E : B → Type*) where proj : B snd : E proj #align bundle.total_space Bundle.TotalSpace instance [Inhabited B] [Inhabited (E default)] : Inhabited (TotalSpace F E) := ⟨⟨default, default⟩⟩ variable {E} @[inherit_doc] scoped notation:max "π" F':max E':max => Bundle.TotalSpace.proj (F := F') (E := E') abbrev TotalSpace.mk' (F : Type*) (x : B) (y : E x) : TotalSpace F E := ⟨x, y⟩
Mathlib/Data/Bundle.lean
69
70
theorem TotalSpace.mk_cast {x x' : B} (h : x = x') (b : E x) : .mk' F x' (cast (congr_arg E h) b) = TotalSpace.mk x b := by
subst h; rfl
479
import Mathlib.Data.Set.Basic #align_import data.bundle from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" open Function Set namespace Bundle variable {B F : Type*} (E : B → Type*) @[ext] structure TotalSpace (F : Type*) (E : B → Type*) where proj : B snd : E proj #align bundle.total_space Bundle.TotalSpace instance [Inhabited B] [Inhabited (E default)] : Inhabited (TotalSpace F E) := ⟨⟨default, default⟩⟩ variable {E} @[inherit_doc] scoped notation:max "π" F':max E':max => Bundle.TotalSpace.proj (F := F') (E := E') abbrev TotalSpace.mk' (F : Type*) (x : B) (y : E x) : TotalSpace F E := ⟨x, y⟩ theorem TotalSpace.mk_cast {x x' : B} (h : x = x') (b : E x) : .mk' F x' (cast (congr_arg E h) b) = TotalSpace.mk x b := by subst h; rfl #align bundle.total_space.mk_cast Bundle.TotalSpace.mk_cast @[simp 1001, mfld_simps 1001]
Mathlib/Data/Bundle.lean
74
75
theorem TotalSpace.mk_inj {b : B} {y y' : E b} : mk' F b y = mk' F b y' ↔ y = y' := by
simp [TotalSpace.ext_iff]
479
import Mathlib.Data.Set.Basic #align_import data.bundle from "leanprover-community/mathlib"@"e473c3198bb41f68560cab68a0529c854b618833" open Function Set namespace Bundle variable {B F : Type*} (E : B → Type*) @[ext] structure TotalSpace (F : Type*) (E : B → Type*) where proj : B snd : E proj #align bundle.total_space Bundle.TotalSpace instance [Inhabited B] [Inhabited (E default)] : Inhabited (TotalSpace F E) := ⟨⟨default, default⟩⟩ variable {E} @[inherit_doc] scoped notation:max "π" F':max E':max => Bundle.TotalSpace.proj (F := F') (E := E') abbrev TotalSpace.mk' (F : Type*) (x : B) (y : E x) : TotalSpace F E := ⟨x, y⟩ theorem TotalSpace.mk_cast {x x' : B} (h : x = x') (b : E x) : .mk' F x' (cast (congr_arg E h) b) = TotalSpace.mk x b := by subst h; rfl #align bundle.total_space.mk_cast Bundle.TotalSpace.mk_cast @[simp 1001, mfld_simps 1001] theorem TotalSpace.mk_inj {b : B} {y y' : E b} : mk' F b y = mk' F b y' ↔ y = y' := by simp [TotalSpace.ext_iff] theorem TotalSpace.mk_injective (b : B) : Injective (mk b : E b → TotalSpace F E) := fun _ _ ↦ mk_inj.1 instance {x : B} : CoeTC (E x) (TotalSpace F E) := ⟨TotalSpace.mk x⟩ #noalign bundle.total_space.coe_proj #noalign bundle.total_space.coe_snd #noalign bundle.total_space.coe_eq_mk theorem TotalSpace.eta (z : TotalSpace F E) : TotalSpace.mk z.proj z.2 = z := rfl #align bundle.total_space.eta Bundle.TotalSpace.eta @[simp] theorem TotalSpace.exists {p : TotalSpace F E → Prop} : (∃ x, p x) ↔ ∃ b y, p ⟨b, y⟩ := ⟨fun ⟨x, hx⟩ ↦ ⟨x.1, x.2, hx⟩, fun ⟨b, y, h⟩ ↦ ⟨⟨b, y⟩, h⟩⟩ @[simp]
Mathlib/Data/Bundle.lean
95
100
theorem TotalSpace.range_mk (b : B) : range ((↑) : E b → TotalSpace F E) = π F E ⁻¹' {b} := by
apply Subset.antisymm · rintro _ ⟨x, rfl⟩ rfl · rintro ⟨_, x⟩ rfl exact ⟨x, rfl⟩
479
import Mathlib.Algebra.Group.Basic import Mathlib.Algebra.Group.Nat import Mathlib.Data.Set.Basic import Mathlib.Tactic.Common #align_import data.set.enumerate from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" noncomputable section open Function namespace Set section Enumerate variable {α : Type*} (sel : Set α → Option α) def enumerate : Set α → ℕ → Option α | s, 0 => sel s | s, n + 1 => do let a ← sel s enumerate (s \ {a}) n #align set.enumerate Set.enumerate theorem enumerate_eq_none_of_sel {s : Set α} (h : sel s = none) : ∀ {n}, enumerate sel s n = none | 0 => by simp [h, enumerate] | n + 1 => by simp [h, enumerate] #align set.enumerate_eq_none_of_sel Set.enumerate_eq_none_of_sel theorem enumerate_eq_none : ∀ {s n₁ n₂}, enumerate sel s n₁ = none → n₁ ≤ n₂ → enumerate sel s n₂ = none | s, 0, m => fun h _ ↦ enumerate_eq_none_of_sel sel h | s, n + 1, m => fun h hm ↦ by cases hs : sel s · exact enumerate_eq_none_of_sel sel hs · cases m with | zero => contradiction | succ m' => simp? [hs, enumerate] at h ⊢ says simp only [enumerate, hs, Option.bind_eq_bind, Option.some_bind] at h ⊢ have hm : n ≤ m' := Nat.le_of_succ_le_succ hm exact enumerate_eq_none h hm #align set.enumerate_eq_none Set.enumerate_eq_none theorem enumerate_mem (h_sel : ∀ s a, sel s = some a → a ∈ s) : ∀ {s n a}, enumerate sel s n = some a → a ∈ s | s, 0, a => h_sel s a | s, n + 1, a => by cases h : sel s with | none => simp [enumerate_eq_none_of_sel, h] | some a' => simp only [enumerate, h, Nat.add_eq, add_zero] exact fun h' : enumerate sel (s \ {a'}) n = some a ↦ have : a ∈ s \ {a'} := enumerate_mem h_sel h' this.left #align set.enumerate_mem Set.enumerate_mem
Mathlib/Data/Set/Enumerate.lean
75
101
theorem enumerate_inj {n₁ n₂ : ℕ} {a : α} {s : Set α} (h_sel : ∀ s a, sel s = some a → a ∈ s) (h₁ : enumerate sel s n₁ = some a) (h₂ : enumerate sel s n₂ = some a) : n₁ = n₂ := by
/- Porting note: The `rcase, on_goal, all_goals` has been used instead of the not-yet-ported `wlog` -/ rcases le_total n₁ n₂ with (hn|hn) on_goal 2 => swap_var n₁ ↔ n₂, h₁ ↔ h₂ all_goals rcases Nat.le.dest hn with ⟨m, rfl⟩ clear hn induction n₁ generalizing s with | zero => cases m with | zero => rfl | succ m => have h' : enumerate sel (s \ {a}) m = some a := by simp_all only [enumerate, Nat.zero_eq, Nat.add_eq, zero_add]; exact h₂ have : a ∈ s \ {a} := enumerate_mem sel h_sel h' simp_all [Set.mem_diff_singleton] | succ k ih => cases h : sel s with /- Porting note: The original covered both goals with just `simp_all <;> tauto` -/ | none => simp_all only [add_comm, self_eq_add_left, Nat.add_succ, enumerate_eq_none_of_sel _ h] | some => simp_all only [add_comm, self_eq_add_left, enumerate, Option.some.injEq, Nat.add_succ, Nat.succ.injEq] exact ih h₁ h₂
480
import Mathlib.Data.Option.Basic import Mathlib.Data.Set.Basic #align_import data.pequiv from "leanprover-community/mathlib"@"7c3269ca3fa4c0c19e4d127cd7151edbdbf99ed4" universe u v w x structure PEquiv (α : Type u) (β : Type v) where toFun : α → Option β invFun : β → Option α inv : ∀ (a : α) (b : β), a ∈ invFun b ↔ b ∈ toFun a #align pequiv PEquiv infixr:25 " ≃. " => PEquiv namespace PEquiv variable {α : Type u} {β : Type v} {γ : Type w} {δ : Type x} open Function Option instance : FunLike (α ≃. β) α (Option β) := { coe := toFun coe_injective' := by rintro ⟨f₁, f₂, hf⟩ ⟨g₁, g₂, hg⟩ (rfl : f₁ = g₁) congr with y x simp only [hf, hg] } @[simp] theorem coe_mk (f₁ : α → Option β) (f₂ h) : (mk f₁ f₂ h : α → Option β) = f₁ := rfl theorem coe_mk_apply (f₁ : α → Option β) (f₂ : β → Option α) (h) (x : α) : (PEquiv.mk f₁ f₂ h : α → Option β) x = f₁ x := rfl #align pequiv.coe_mk_apply PEquiv.coe_mk_apply @[ext] theorem ext {f g : α ≃. β} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h #align pequiv.ext PEquiv.ext theorem ext_iff {f g : α ≃. β} : f = g ↔ ∀ x, f x = g x := DFunLike.ext_iff #align pequiv.ext_iff PEquiv.ext_iff @[refl] protected def refl (α : Type*) : α ≃. α where toFun := some invFun := some inv _ _ := eq_comm #align pequiv.refl PEquiv.refl @[symm] protected def symm (f : α ≃. β) : β ≃. α where toFun := f.2 invFun := f.1 inv _ _ := (f.inv _ _).symm #align pequiv.symm PEquiv.symm theorem mem_iff_mem (f : α ≃. β) : ∀ {a : α} {b : β}, a ∈ f.symm b ↔ b ∈ f a := f.3 _ _ #align pequiv.mem_iff_mem PEquiv.mem_iff_mem theorem eq_some_iff (f : α ≃. β) : ∀ {a : α} {b : β}, f.symm b = some a ↔ f a = some b := f.3 _ _ #align pequiv.eq_some_iff PEquiv.eq_some_iff @[trans] protected def trans (f : α ≃. β) (g : β ≃. γ) : α ≃. γ where toFun a := (f a).bind g invFun a := (g.symm a).bind f.symm inv a b := by simp_all [and_comm, eq_some_iff f, eq_some_iff g, bind_eq_some] #align pequiv.trans PEquiv.trans @[simp] theorem refl_apply (a : α) : PEquiv.refl α a = some a := rfl #align pequiv.refl_apply PEquiv.refl_apply @[simp] theorem symm_refl : (PEquiv.refl α).symm = PEquiv.refl α := rfl #align pequiv.symm_refl PEquiv.symm_refl @[simp]
Mathlib/Data/PEquiv.lean
136
136
theorem symm_symm (f : α ≃. β) : f.symm.symm = f := by
cases f; rfl
481
import Mathlib.Data.Option.Basic import Mathlib.Data.Set.Basic #align_import data.pequiv from "leanprover-community/mathlib"@"7c3269ca3fa4c0c19e4d127cd7151edbdbf99ed4" universe u v w x structure PEquiv (α : Type u) (β : Type v) where toFun : α → Option β invFun : β → Option α inv : ∀ (a : α) (b : β), a ∈ invFun b ↔ b ∈ toFun a #align pequiv PEquiv infixr:25 " ≃. " => PEquiv namespace PEquiv variable {α : Type u} {β : Type v} {γ : Type w} {δ : Type x} open Function Option instance : FunLike (α ≃. β) α (Option β) := { coe := toFun coe_injective' := by rintro ⟨f₁, f₂, hf⟩ ⟨g₁, g₂, hg⟩ (rfl : f₁ = g₁) congr with y x simp only [hf, hg] } @[simp] theorem coe_mk (f₁ : α → Option β) (f₂ h) : (mk f₁ f₂ h : α → Option β) = f₁ := rfl theorem coe_mk_apply (f₁ : α → Option β) (f₂ : β → Option α) (h) (x : α) : (PEquiv.mk f₁ f₂ h : α → Option β) x = f₁ x := rfl #align pequiv.coe_mk_apply PEquiv.coe_mk_apply @[ext] theorem ext {f g : α ≃. β} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h #align pequiv.ext PEquiv.ext theorem ext_iff {f g : α ≃. β} : f = g ↔ ∀ x, f x = g x := DFunLike.ext_iff #align pequiv.ext_iff PEquiv.ext_iff @[refl] protected def refl (α : Type*) : α ≃. α where toFun := some invFun := some inv _ _ := eq_comm #align pequiv.refl PEquiv.refl @[symm] protected def symm (f : α ≃. β) : β ≃. α where toFun := f.2 invFun := f.1 inv _ _ := (f.inv _ _).symm #align pequiv.symm PEquiv.symm theorem mem_iff_mem (f : α ≃. β) : ∀ {a : α} {b : β}, a ∈ f.symm b ↔ b ∈ f a := f.3 _ _ #align pequiv.mem_iff_mem PEquiv.mem_iff_mem theorem eq_some_iff (f : α ≃. β) : ∀ {a : α} {b : β}, f.symm b = some a ↔ f a = some b := f.3 _ _ #align pequiv.eq_some_iff PEquiv.eq_some_iff @[trans] protected def trans (f : α ≃. β) (g : β ≃. γ) : α ≃. γ where toFun a := (f a).bind g invFun a := (g.symm a).bind f.symm inv a b := by simp_all [and_comm, eq_some_iff f, eq_some_iff g, bind_eq_some] #align pequiv.trans PEquiv.trans @[simp] theorem refl_apply (a : α) : PEquiv.refl α a = some a := rfl #align pequiv.refl_apply PEquiv.refl_apply @[simp] theorem symm_refl : (PEquiv.refl α).symm = PEquiv.refl α := rfl #align pequiv.symm_refl PEquiv.symm_refl @[simp] theorem symm_symm (f : α ≃. β) : f.symm.symm = f := by cases f; rfl #align pequiv.symm_symm PEquiv.symm_symm theorem symm_bijective : Function.Bijective (PEquiv.symm : (α ≃. β) → β ≃. α) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ theorem symm_injective : Function.Injective (@PEquiv.symm α β) := symm_bijective.injective #align pequiv.symm_injective PEquiv.symm_injective theorem trans_assoc (f : α ≃. β) (g : β ≃. γ) (h : γ ≃. δ) : (f.trans g).trans h = f.trans (g.trans h) := ext fun _ => Option.bind_assoc _ _ _ #align pequiv.trans_assoc PEquiv.trans_assoc theorem mem_trans (f : α ≃. β) (g : β ≃. γ) (a : α) (c : γ) : c ∈ f.trans g a ↔ ∃ b, b ∈ f a ∧ c ∈ g b := Option.bind_eq_some' #align pequiv.mem_trans PEquiv.mem_trans theorem trans_eq_some (f : α ≃. β) (g : β ≃. γ) (a : α) (c : γ) : f.trans g a = some c ↔ ∃ b, f a = some b ∧ g b = some c := Option.bind_eq_some' #align pequiv.trans_eq_some PEquiv.trans_eq_some
Mathlib/Data/PEquiv.lean
161
165
theorem trans_eq_none (f : α ≃. β) (g : β ≃. γ) (a : α) : f.trans g a = none ↔ ∀ b c, b ∉ f a ∨ c ∉ g b := by
simp only [eq_none_iff_forall_not_mem, mem_trans, imp_iff_not_or.symm] push_neg exact forall_swap
481
import Mathlib.Data.Option.Basic import Mathlib.Data.Set.Basic #align_import data.pequiv from "leanprover-community/mathlib"@"7c3269ca3fa4c0c19e4d127cd7151edbdbf99ed4" universe u v w x structure PEquiv (α : Type u) (β : Type v) where toFun : α → Option β invFun : β → Option α inv : ∀ (a : α) (b : β), a ∈ invFun b ↔ b ∈ toFun a #align pequiv PEquiv infixr:25 " ≃. " => PEquiv namespace PEquiv variable {α : Type u} {β : Type v} {γ : Type w} {δ : Type x} open Function Option instance : FunLike (α ≃. β) α (Option β) := { coe := toFun coe_injective' := by rintro ⟨f₁, f₂, hf⟩ ⟨g₁, g₂, hg⟩ (rfl : f₁ = g₁) congr with y x simp only [hf, hg] } @[simp] theorem coe_mk (f₁ : α → Option β) (f₂ h) : (mk f₁ f₂ h : α → Option β) = f₁ := rfl theorem coe_mk_apply (f₁ : α → Option β) (f₂ : β → Option α) (h) (x : α) : (PEquiv.mk f₁ f₂ h : α → Option β) x = f₁ x := rfl #align pequiv.coe_mk_apply PEquiv.coe_mk_apply @[ext] theorem ext {f g : α ≃. β} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h #align pequiv.ext PEquiv.ext theorem ext_iff {f g : α ≃. β} : f = g ↔ ∀ x, f x = g x := DFunLike.ext_iff #align pequiv.ext_iff PEquiv.ext_iff @[refl] protected def refl (α : Type*) : α ≃. α where toFun := some invFun := some inv _ _ := eq_comm #align pequiv.refl PEquiv.refl @[symm] protected def symm (f : α ≃. β) : β ≃. α where toFun := f.2 invFun := f.1 inv _ _ := (f.inv _ _).symm #align pequiv.symm PEquiv.symm theorem mem_iff_mem (f : α ≃. β) : ∀ {a : α} {b : β}, a ∈ f.symm b ↔ b ∈ f a := f.3 _ _ #align pequiv.mem_iff_mem PEquiv.mem_iff_mem theorem eq_some_iff (f : α ≃. β) : ∀ {a : α} {b : β}, f.symm b = some a ↔ f a = some b := f.3 _ _ #align pequiv.eq_some_iff PEquiv.eq_some_iff @[trans] protected def trans (f : α ≃. β) (g : β ≃. γ) : α ≃. γ where toFun a := (f a).bind g invFun a := (g.symm a).bind f.symm inv a b := by simp_all [and_comm, eq_some_iff f, eq_some_iff g, bind_eq_some] #align pequiv.trans PEquiv.trans @[simp] theorem refl_apply (a : α) : PEquiv.refl α a = some a := rfl #align pequiv.refl_apply PEquiv.refl_apply @[simp] theorem symm_refl : (PEquiv.refl α).symm = PEquiv.refl α := rfl #align pequiv.symm_refl PEquiv.symm_refl @[simp] theorem symm_symm (f : α ≃. β) : f.symm.symm = f := by cases f; rfl #align pequiv.symm_symm PEquiv.symm_symm theorem symm_bijective : Function.Bijective (PEquiv.symm : (α ≃. β) → β ≃. α) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ theorem symm_injective : Function.Injective (@PEquiv.symm α β) := symm_bijective.injective #align pequiv.symm_injective PEquiv.symm_injective theorem trans_assoc (f : α ≃. β) (g : β ≃. γ) (h : γ ≃. δ) : (f.trans g).trans h = f.trans (g.trans h) := ext fun _ => Option.bind_assoc _ _ _ #align pequiv.trans_assoc PEquiv.trans_assoc theorem mem_trans (f : α ≃. β) (g : β ≃. γ) (a : α) (c : γ) : c ∈ f.trans g a ↔ ∃ b, b ∈ f a ∧ c ∈ g b := Option.bind_eq_some' #align pequiv.mem_trans PEquiv.mem_trans theorem trans_eq_some (f : α ≃. β) (g : β ≃. γ) (a : α) (c : γ) : f.trans g a = some c ↔ ∃ b, f a = some b ∧ g b = some c := Option.bind_eq_some' #align pequiv.trans_eq_some PEquiv.trans_eq_some theorem trans_eq_none (f : α ≃. β) (g : β ≃. γ) (a : α) : f.trans g a = none ↔ ∀ b c, b ∉ f a ∨ c ∉ g b := by simp only [eq_none_iff_forall_not_mem, mem_trans, imp_iff_not_or.symm] push_neg exact forall_swap #align pequiv.trans_eq_none PEquiv.trans_eq_none @[simp]
Mathlib/Data/PEquiv.lean
169
170
theorem refl_trans (f : α ≃. β) : (PEquiv.refl α).trans f = f := by
ext; dsimp [PEquiv.trans]; rfl
481
import Mathlib.Data.Option.Basic import Mathlib.Data.Set.Basic #align_import data.pequiv from "leanprover-community/mathlib"@"7c3269ca3fa4c0c19e4d127cd7151edbdbf99ed4" universe u v w x structure PEquiv (α : Type u) (β : Type v) where toFun : α → Option β invFun : β → Option α inv : ∀ (a : α) (b : β), a ∈ invFun b ↔ b ∈ toFun a #align pequiv PEquiv infixr:25 " ≃. " => PEquiv namespace PEquiv variable {α : Type u} {β : Type v} {γ : Type w} {δ : Type x} open Function Option instance : FunLike (α ≃. β) α (Option β) := { coe := toFun coe_injective' := by rintro ⟨f₁, f₂, hf⟩ ⟨g₁, g₂, hg⟩ (rfl : f₁ = g₁) congr with y x simp only [hf, hg] } @[simp] theorem coe_mk (f₁ : α → Option β) (f₂ h) : (mk f₁ f₂ h : α → Option β) = f₁ := rfl theorem coe_mk_apply (f₁ : α → Option β) (f₂ : β → Option α) (h) (x : α) : (PEquiv.mk f₁ f₂ h : α → Option β) x = f₁ x := rfl #align pequiv.coe_mk_apply PEquiv.coe_mk_apply @[ext] theorem ext {f g : α ≃. β} (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h #align pequiv.ext PEquiv.ext theorem ext_iff {f g : α ≃. β} : f = g ↔ ∀ x, f x = g x := DFunLike.ext_iff #align pequiv.ext_iff PEquiv.ext_iff @[refl] protected def refl (α : Type*) : α ≃. α where toFun := some invFun := some inv _ _ := eq_comm #align pequiv.refl PEquiv.refl @[symm] protected def symm (f : α ≃. β) : β ≃. α where toFun := f.2 invFun := f.1 inv _ _ := (f.inv _ _).symm #align pequiv.symm PEquiv.symm theorem mem_iff_mem (f : α ≃. β) : ∀ {a : α} {b : β}, a ∈ f.symm b ↔ b ∈ f a := f.3 _ _ #align pequiv.mem_iff_mem PEquiv.mem_iff_mem theorem eq_some_iff (f : α ≃. β) : ∀ {a : α} {b : β}, f.symm b = some a ↔ f a = some b := f.3 _ _ #align pequiv.eq_some_iff PEquiv.eq_some_iff @[trans] protected def trans (f : α ≃. β) (g : β ≃. γ) : α ≃. γ where toFun a := (f a).bind g invFun a := (g.symm a).bind f.symm inv a b := by simp_all [and_comm, eq_some_iff f, eq_some_iff g, bind_eq_some] #align pequiv.trans PEquiv.trans @[simp] theorem refl_apply (a : α) : PEquiv.refl α a = some a := rfl #align pequiv.refl_apply PEquiv.refl_apply @[simp] theorem symm_refl : (PEquiv.refl α).symm = PEquiv.refl α := rfl #align pequiv.symm_refl PEquiv.symm_refl @[simp] theorem symm_symm (f : α ≃. β) : f.symm.symm = f := by cases f; rfl #align pequiv.symm_symm PEquiv.symm_symm theorem symm_bijective : Function.Bijective (PEquiv.symm : (α ≃. β) → β ≃. α) := Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩ theorem symm_injective : Function.Injective (@PEquiv.symm α β) := symm_bijective.injective #align pequiv.symm_injective PEquiv.symm_injective theorem trans_assoc (f : α ≃. β) (g : β ≃. γ) (h : γ ≃. δ) : (f.trans g).trans h = f.trans (g.trans h) := ext fun _ => Option.bind_assoc _ _ _ #align pequiv.trans_assoc PEquiv.trans_assoc theorem mem_trans (f : α ≃. β) (g : β ≃. γ) (a : α) (c : γ) : c ∈ f.trans g a ↔ ∃ b, b ∈ f a ∧ c ∈ g b := Option.bind_eq_some' #align pequiv.mem_trans PEquiv.mem_trans theorem trans_eq_some (f : α ≃. β) (g : β ≃. γ) (a : α) (c : γ) : f.trans g a = some c ↔ ∃ b, f a = some b ∧ g b = some c := Option.bind_eq_some' #align pequiv.trans_eq_some PEquiv.trans_eq_some theorem trans_eq_none (f : α ≃. β) (g : β ≃. γ) (a : α) : f.trans g a = none ↔ ∀ b c, b ∉ f a ∨ c ∉ g b := by simp only [eq_none_iff_forall_not_mem, mem_trans, imp_iff_not_or.symm] push_neg exact forall_swap #align pequiv.trans_eq_none PEquiv.trans_eq_none @[simp] theorem refl_trans (f : α ≃. β) : (PEquiv.refl α).trans f = f := by ext; dsimp [PEquiv.trans]; rfl #align pequiv.refl_trans PEquiv.refl_trans @[simp]
Mathlib/Data/PEquiv.lean
174
175
theorem trans_refl (f : α ≃. β) : f.trans (PEquiv.refl β) = f := by
ext; dsimp [PEquiv.trans]; simp
481
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply
Mathlib/Data/Matrix/PEquiv.lean
62
67
theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by
dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm]
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply
Mathlib/Data/Matrix/PEquiv.lean
70
74
theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by
ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp]
Mathlib/Data/Matrix/PEquiv.lean
78
81
theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by
ext simp [toMatrix_apply, one_apply]
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl
Mathlib/Data/Matrix/PEquiv.lean
84
93
theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by
dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply
Mathlib/Data/Matrix/PEquiv.lean
96
99
theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by
ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id]
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id] #align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n) (M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm := Matrix.ext fun i j => by rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply, Matrix.submatrix_apply, id] #align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix
Mathlib/Data/Matrix/PEquiv.lean
109
114
theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m) (g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by
ext i j rw [mul_matrix_apply] dsimp [toMatrix, PEquiv.trans] cases f i <;> simp
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id] #align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n) (M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm := Matrix.ext fun i j => by rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply, Matrix.submatrix_apply, id] #align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m) (g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by ext i j rw [mul_matrix_apply] dsimp [toMatrix, PEquiv.trans] cases f i <;> simp #align pequiv.to_matrix_trans PEquiv.toMatrix_trans @[simp] theorem toMatrix_bot [DecidableEq n] [Zero α] [One α] : ((⊥ : PEquiv m n).toMatrix : Matrix m n α) = 0 := rfl #align pequiv.to_matrix_bot PEquiv.toMatrix_bot
Mathlib/Data/Matrix/PEquiv.lean
123
139
theorem toMatrix_injective [DecidableEq n] [MonoidWithZero α] [Nontrivial α] : Function.Injective (@toMatrix m n α _ _ _) := by
classical intro f g refine not_imp_not.1 ?_ simp only [Matrix.ext_iff.symm, toMatrix_apply, PEquiv.ext_iff, not_forall, exists_imp] intro i hi use i cases' hf : f i with fi · cases' hg : g i with gi -- Porting note: was `cc` · rw [hf, hg] at hi exact (hi rfl).elim · use gi simp · use fi simp [hf.symm, Ne.symm hi]
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id] #align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n) (M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm := Matrix.ext fun i j => by rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply, Matrix.submatrix_apply, id] #align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m) (g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by ext i j rw [mul_matrix_apply] dsimp [toMatrix, PEquiv.trans] cases f i <;> simp #align pequiv.to_matrix_trans PEquiv.toMatrix_trans @[simp] theorem toMatrix_bot [DecidableEq n] [Zero α] [One α] : ((⊥ : PEquiv m n).toMatrix : Matrix m n α) = 0 := rfl #align pequiv.to_matrix_bot PEquiv.toMatrix_bot theorem toMatrix_injective [DecidableEq n] [MonoidWithZero α] [Nontrivial α] : Function.Injective (@toMatrix m n α _ _ _) := by classical intro f g refine not_imp_not.1 ?_ simp only [Matrix.ext_iff.symm, toMatrix_apply, PEquiv.ext_iff, not_forall, exists_imp] intro i hi use i cases' hf : f i with fi · cases' hg : g i with gi -- Porting note: was `cc` · rw [hf, hg] at hi exact (hi rfl).elim · use gi simp · use fi simp [hf.symm, Ne.symm hi] #align pequiv.to_matrix_injective PEquiv.toMatrix_injective
Mathlib/Data/Matrix/PEquiv.lean
142
148
theorem toMatrix_swap [DecidableEq n] [Ring α] (i j : n) : (Equiv.swap i j).toPEquiv.toMatrix = (1 : Matrix n n α) - (single i i).toMatrix - (single j j).toMatrix + (single i j).toMatrix + (single j i).toMatrix := by
ext dsimp [toMatrix, single, Equiv.swap_apply_def, Equiv.toPEquiv, one_apply] split_ifs <;> simp_all
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id] #align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n) (M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm := Matrix.ext fun i j => by rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply, Matrix.submatrix_apply, id] #align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m) (g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by ext i j rw [mul_matrix_apply] dsimp [toMatrix, PEquiv.trans] cases f i <;> simp #align pequiv.to_matrix_trans PEquiv.toMatrix_trans @[simp] theorem toMatrix_bot [DecidableEq n] [Zero α] [One α] : ((⊥ : PEquiv m n).toMatrix : Matrix m n α) = 0 := rfl #align pequiv.to_matrix_bot PEquiv.toMatrix_bot theorem toMatrix_injective [DecidableEq n] [MonoidWithZero α] [Nontrivial α] : Function.Injective (@toMatrix m n α _ _ _) := by classical intro f g refine not_imp_not.1 ?_ simp only [Matrix.ext_iff.symm, toMatrix_apply, PEquiv.ext_iff, not_forall, exists_imp] intro i hi use i cases' hf : f i with fi · cases' hg : g i with gi -- Porting note: was `cc` · rw [hf, hg] at hi exact (hi rfl).elim · use gi simp · use fi simp [hf.symm, Ne.symm hi] #align pequiv.to_matrix_injective PEquiv.toMatrix_injective theorem toMatrix_swap [DecidableEq n] [Ring α] (i j : n) : (Equiv.swap i j).toPEquiv.toMatrix = (1 : Matrix n n α) - (single i i).toMatrix - (single j j).toMatrix + (single i j).toMatrix + (single j i).toMatrix := by ext dsimp [toMatrix, single, Equiv.swap_apply_def, Equiv.toPEquiv, one_apply] split_ifs <;> simp_all #align pequiv.to_matrix_swap PEquiv.toMatrix_swap @[simp]
Mathlib/Data/Matrix/PEquiv.lean
152
155
theorem single_mul_single [Fintype n] [DecidableEq k] [DecidableEq m] [DecidableEq n] [Semiring α] (a : m) (b : n) (c : k) : ((single a b).toMatrix : Matrix _ _ α) * (single b c).toMatrix = (single a c).toMatrix := by
rw [← toMatrix_trans, single_trans_single]
482
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id] #align pequiv.to_pequiv_mul_matrix PEquiv.toPEquiv_mul_matrix theorem mul_toPEquiv_toMatrix {m n α : Type*} [Fintype n] [DecidableEq n] [Semiring α] (f : n ≃ n) (M : Matrix m n α) : M * f.toPEquiv.toMatrix = M.submatrix id f.symm := Matrix.ext fun i j => by rw [PEquiv.matrix_mul_apply, ← Equiv.toPEquiv_symm, Equiv.toPEquiv_apply, Matrix.submatrix_apply, id] #align pequiv.mul_to_pequiv_to_matrix PEquiv.mul_toPEquiv_toMatrix theorem toMatrix_trans [Fintype m] [DecidableEq m] [DecidableEq n] [Semiring α] (f : l ≃. m) (g : m ≃. n) : ((f.trans g).toMatrix : Matrix l n α) = f.toMatrix * g.toMatrix := by ext i j rw [mul_matrix_apply] dsimp [toMatrix, PEquiv.trans] cases f i <;> simp #align pequiv.to_matrix_trans PEquiv.toMatrix_trans @[simp] theorem toMatrix_bot [DecidableEq n] [Zero α] [One α] : ((⊥ : PEquiv m n).toMatrix : Matrix m n α) = 0 := rfl #align pequiv.to_matrix_bot PEquiv.toMatrix_bot theorem toMatrix_injective [DecidableEq n] [MonoidWithZero α] [Nontrivial α] : Function.Injective (@toMatrix m n α _ _ _) := by classical intro f g refine not_imp_not.1 ?_ simp only [Matrix.ext_iff.symm, toMatrix_apply, PEquiv.ext_iff, not_forall, exists_imp] intro i hi use i cases' hf : f i with fi · cases' hg : g i with gi -- Porting note: was `cc` · rw [hf, hg] at hi exact (hi rfl).elim · use gi simp · use fi simp [hf.symm, Ne.symm hi] #align pequiv.to_matrix_injective PEquiv.toMatrix_injective theorem toMatrix_swap [DecidableEq n] [Ring α] (i j : n) : (Equiv.swap i j).toPEquiv.toMatrix = (1 : Matrix n n α) - (single i i).toMatrix - (single j j).toMatrix + (single i j).toMatrix + (single j i).toMatrix := by ext dsimp [toMatrix, single, Equiv.swap_apply_def, Equiv.toPEquiv, one_apply] split_ifs <;> simp_all #align pequiv.to_matrix_swap PEquiv.toMatrix_swap @[simp] theorem single_mul_single [Fintype n] [DecidableEq k] [DecidableEq m] [DecidableEq n] [Semiring α] (a : m) (b : n) (c : k) : ((single a b).toMatrix : Matrix _ _ α) * (single b c).toMatrix = (single a c).toMatrix := by rw [← toMatrix_trans, single_trans_single] #align pequiv.single_mul_single PEquiv.single_mul_single
Mathlib/Data/Matrix/PEquiv.lean
158
161
theorem single_mul_single_of_ne [Fintype n] [DecidableEq n] [DecidableEq k] [DecidableEq m] [Semiring α] {b₁ b₂ : n} (hb : b₁ ≠ b₂) (a : m) (c : k) : (single a b₁).toMatrix * (single b₂ c).toMatrix = (0 : Matrix _ _ α) := by
rw [← toMatrix_trans, single_trans_single_of_ne hb, toMatrix_bot]
482
import Mathlib.Data.Set.Basic #align_import data.set.bool_indicator from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Bool namespace Set variable {α : Type*} (s : Set α) noncomputable def boolIndicator (x : α) := @ite _ (x ∈ s) (Classical.propDecidable _) true false #align set.bool_indicator Set.boolIndicator
Mathlib/Data/Set/BoolIndicator.lean
27
29
theorem mem_iff_boolIndicator (x : α) : x ∈ s ↔ s.boolIndicator x = true := by
unfold boolIndicator split_ifs with h <;> simp [h]
483
import Mathlib.Data.Set.Basic #align_import data.set.bool_indicator from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Bool namespace Set variable {α : Type*} (s : Set α) noncomputable def boolIndicator (x : α) := @ite _ (x ∈ s) (Classical.propDecidable _) true false #align set.bool_indicator Set.boolIndicator theorem mem_iff_boolIndicator (x : α) : x ∈ s ↔ s.boolIndicator x = true := by unfold boolIndicator split_ifs with h <;> simp [h] #align set.mem_iff_bool_indicator Set.mem_iff_boolIndicator
Mathlib/Data/Set/BoolIndicator.lean
32
34
theorem not_mem_iff_boolIndicator (x : α) : x ∉ s ↔ s.boolIndicator x = false := by
unfold boolIndicator split_ifs with h <;> simp [h]
483
import Mathlib.Data.Set.Basic #align_import data.set.bool_indicator from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Bool namespace Set variable {α : Type*} (s : Set α) noncomputable def boolIndicator (x : α) := @ite _ (x ∈ s) (Classical.propDecidable _) true false #align set.bool_indicator Set.boolIndicator theorem mem_iff_boolIndicator (x : α) : x ∈ s ↔ s.boolIndicator x = true := by unfold boolIndicator split_ifs with h <;> simp [h] #align set.mem_iff_bool_indicator Set.mem_iff_boolIndicator theorem not_mem_iff_boolIndicator (x : α) : x ∉ s ↔ s.boolIndicator x = false := by unfold boolIndicator split_ifs with h <;> simp [h] #align set.not_mem_iff_bool_indicator Set.not_mem_iff_boolIndicator theorem preimage_boolIndicator_true : s.boolIndicator ⁻¹' {true} = s := ext fun x ↦ (s.mem_iff_boolIndicator x).symm #align set.preimage_bool_indicator_true Set.preimage_boolIndicator_true theorem preimage_boolIndicator_false : s.boolIndicator ⁻¹' {false} = sᶜ := ext fun x ↦ (s.not_mem_iff_boolIndicator x).symm #align set.preimage_bool_indicator_false Set.preimage_boolIndicator_false open scoped Classical
Mathlib/Data/Set/BoolIndicator.lean
47
51
theorem preimage_boolIndicator_eq_union (t : Set Bool) : s.boolIndicator ⁻¹' t = (if true ∈ t then s else ∅) ∪ if false ∈ t then sᶜ else ∅ := by
ext x simp only [boolIndicator, mem_preimage] split_ifs <;> simp [*]
483
import Mathlib.Data.Set.Basic #align_import data.set.bool_indicator from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" open Bool namespace Set variable {α : Type*} (s : Set α) noncomputable def boolIndicator (x : α) := @ite _ (x ∈ s) (Classical.propDecidable _) true false #align set.bool_indicator Set.boolIndicator theorem mem_iff_boolIndicator (x : α) : x ∈ s ↔ s.boolIndicator x = true := by unfold boolIndicator split_ifs with h <;> simp [h] #align set.mem_iff_bool_indicator Set.mem_iff_boolIndicator theorem not_mem_iff_boolIndicator (x : α) : x ∉ s ↔ s.boolIndicator x = false := by unfold boolIndicator split_ifs with h <;> simp [h] #align set.not_mem_iff_bool_indicator Set.not_mem_iff_boolIndicator theorem preimage_boolIndicator_true : s.boolIndicator ⁻¹' {true} = s := ext fun x ↦ (s.mem_iff_boolIndicator x).symm #align set.preimage_bool_indicator_true Set.preimage_boolIndicator_true theorem preimage_boolIndicator_false : s.boolIndicator ⁻¹' {false} = sᶜ := ext fun x ↦ (s.not_mem_iff_boolIndicator x).symm #align set.preimage_bool_indicator_false Set.preimage_boolIndicator_false open scoped Classical theorem preimage_boolIndicator_eq_union (t : Set Bool) : s.boolIndicator ⁻¹' t = (if true ∈ t then s else ∅) ∪ if false ∈ t then sᶜ else ∅ := by ext x simp only [boolIndicator, mem_preimage] split_ifs <;> simp [*] #align set.preimage_bool_indicator_eq_union Set.preimage_boolIndicator_eq_union
Mathlib/Data/Set/BoolIndicator.lean
54
58
theorem preimage_boolIndicator (t : Set Bool) : s.boolIndicator ⁻¹' t = univ ∨ s.boolIndicator ⁻¹' t = s ∨ s.boolIndicator ⁻¹' t = sᶜ ∨ s.boolIndicator ⁻¹' t = ∅ := by
simp only [preimage_boolIndicator_eq_union] split_ifs <;> simp [s.union_compl_self]
483
import Mathlib.Topology.ContinuousOn import Mathlib.Data.Set.BoolIndicator open Set Filter Topology TopologicalSpace Classical universe u v variable {X : Type u} {Y : Type v} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} section Clopen protected theorem IsClopen.isOpen (hs : IsClopen s) : IsOpen s := hs.2 #align is_clopen.is_open IsClopen.isOpen protected theorem IsClopen.isClosed (hs : IsClopen s) : IsClosed s := hs.1 #align is_clopen.is_closed IsClopen.isClosed
Mathlib/Topology/Clopen.lean
30
34
theorem isClopen_iff_frontier_eq_empty : IsClopen s ↔ frontier s = ∅ := by
rw [IsClopen, ← closure_eq_iff_isClosed, ← interior_eq_iff_isOpen, frontier, diff_eq_empty] refine ⟨fun h => (h.1.trans h.2.symm).subset, fun h => ?_⟩ exact ⟨(h.trans interior_subset).antisymm subset_closure, interior_subset.antisymm (subset_closure.trans h)⟩
484
import Mathlib.Topology.ContinuousOn import Mathlib.Data.Set.BoolIndicator open Set Filter Topology TopologicalSpace Classical universe u v variable {X : Type u} {Y : Type v} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} section Clopen protected theorem IsClopen.isOpen (hs : IsClopen s) : IsOpen s := hs.2 #align is_clopen.is_open IsClopen.isOpen protected theorem IsClopen.isClosed (hs : IsClopen s) : IsClosed s := hs.1 #align is_clopen.is_closed IsClopen.isClosed theorem isClopen_iff_frontier_eq_empty : IsClopen s ↔ frontier s = ∅ := by rw [IsClopen, ← closure_eq_iff_isClosed, ← interior_eq_iff_isOpen, frontier, diff_eq_empty] refine ⟨fun h => (h.1.trans h.2.symm).subset, fun h => ?_⟩ exact ⟨(h.trans interior_subset).antisymm subset_closure, interior_subset.antisymm (subset_closure.trans h)⟩ #align is_clopen_iff_frontier_eq_empty isClopen_iff_frontier_eq_empty @[simp] alias ⟨IsClopen.frontier_eq, _⟩ := isClopen_iff_frontier_eq_empty #align is_clopen.frontier_eq IsClopen.frontier_eq theorem IsClopen.union (hs : IsClopen s) (ht : IsClopen t) : IsClopen (s ∪ t) := ⟨hs.1.union ht.1, hs.2.union ht.2⟩ #align is_clopen.union IsClopen.union theorem IsClopen.inter (hs : IsClopen s) (ht : IsClopen t) : IsClopen (s ∩ t) := ⟨hs.1.inter ht.1, hs.2.inter ht.2⟩ #align is_clopen.inter IsClopen.inter theorem isClopen_empty : IsClopen (∅ : Set X) := ⟨isClosed_empty, isOpen_empty⟩ #align is_clopen_empty isClopen_empty theorem isClopen_univ : IsClopen (univ : Set X) := ⟨isClosed_univ, isOpen_univ⟩ #align is_clopen_univ isClopen_univ theorem IsClopen.compl (hs : IsClopen s) : IsClopen sᶜ := ⟨hs.2.isClosed_compl, hs.1.isOpen_compl⟩ #align is_clopen.compl IsClopen.compl @[simp] theorem isClopen_compl_iff : IsClopen sᶜ ↔ IsClopen s := ⟨fun h => compl_compl s ▸ IsClopen.compl h, IsClopen.compl⟩ #align is_clopen_compl_iff isClopen_compl_iff theorem IsClopen.diff (hs : IsClopen s) (ht : IsClopen t) : IsClopen (s \ t) := hs.inter ht.compl #align is_clopen.diff IsClopen.diff theorem IsClopen.prod {t : Set Y} (hs : IsClopen s) (ht : IsClopen t) : IsClopen (s ×ˢ t) := ⟨hs.1.prod ht.1, hs.2.prod ht.2⟩ #align is_clopen.prod IsClopen.prod theorem isClopen_iUnion_of_finite [Finite Y] {s : Y → Set X} (h : ∀ i, IsClopen (s i)) : IsClopen (⋃ i, s i) := ⟨isClosed_iUnion_of_finite (forall_and.1 h).1, isOpen_iUnion (forall_and.1 h).2⟩ #align is_clopen_Union isClopen_iUnion_of_finite theorem Set.Finite.isClopen_biUnion {s : Set Y} {f : Y → Set X} (hs : s.Finite) (h : ∀ i ∈ s, IsClopen <| f i) : IsClopen (⋃ i ∈ s, f i) := ⟨hs.isClosed_biUnion fun i hi => (h i hi).1, isOpen_biUnion fun i hi => (h i hi).2⟩ #align is_clopen_bUnion Set.Finite.isClopen_biUnion theorem isClopen_biUnion_finset {s : Finset Y} {f : Y → Set X} (h : ∀ i ∈ s, IsClopen <| f i) : IsClopen (⋃ i ∈ s, f i) := s.finite_toSet.isClopen_biUnion h #align is_clopen_bUnion_finset isClopen_biUnion_finset theorem isClopen_iInter_of_finite [Finite Y] {s : Y → Set X} (h : ∀ i, IsClopen (s i)) : IsClopen (⋂ i, s i) := ⟨isClosed_iInter (forall_and.1 h).1, isOpen_iInter_of_finite (forall_and.1 h).2⟩ #align is_clopen_Inter isClopen_iInter_of_finite theorem Set.Finite.isClopen_biInter {s : Set Y} (hs : s.Finite) {f : Y → Set X} (h : ∀ i ∈ s, IsClopen (f i)) : IsClopen (⋂ i ∈ s, f i) := ⟨isClosed_biInter fun i hi => (h i hi).1, hs.isOpen_biInter fun i hi => (h i hi).2⟩ #align is_clopen_bInter Set.Finite.isClopen_biInter theorem isClopen_biInter_finset {s : Finset Y} {f : Y → Set X} (h : ∀ i ∈ s, IsClopen (f i)) : IsClopen (⋂ i ∈ s, f i) := s.finite_toSet.isClopen_biInter h #align is_clopen_bInter_finset isClopen_biInter_finset theorem IsClopen.preimage {s : Set Y} (h : IsClopen s) {f : X → Y} (hf : Continuous f) : IsClopen (f ⁻¹' s) := ⟨h.1.preimage hf, h.2.preimage hf⟩ #align is_clopen.preimage IsClopen.preimage theorem ContinuousOn.preimage_isClopen_of_isClopen {f : X → Y} {s : Set X} {t : Set Y} (hf : ContinuousOn f s) (hs : IsClopen s) (ht : IsClopen t) : IsClopen (s ∩ f ⁻¹' t) := ⟨ContinuousOn.preimage_isClosed_of_isClosed hf hs.1 ht.1, ContinuousOn.isOpen_inter_preimage hf hs.2 ht.2⟩ #align continuous_on.preimage_clopen_of_clopen ContinuousOn.preimage_isClopen_of_isClopen
Mathlib/Topology/Clopen.lean
113
120
theorem isClopen_inter_of_disjoint_cover_clopen {s a b : Set X} (h : IsClopen s) (cover : s ⊆ a ∪ b) (ha : IsOpen a) (hb : IsOpen b) (hab : Disjoint a b) : IsClopen (s ∩ a) := by
refine ⟨?_, IsOpen.inter h.2 ha⟩ have : IsClosed (s ∩ bᶜ) := IsClosed.inter h.1 (isClosed_compl_iff.2 hb) convert this using 1 refine (inter_subset_inter_right s hab.subset_compl_right).antisymm ?_ rintro x ⟨hx₁, hx₂⟩ exact ⟨hx₁, by simpa [not_mem_of_mem_compl hx₂] using cover hx₁⟩
484
import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts import Mathlib.CategoryTheory.Limits.Shapes.Terminal import Mathlib.CategoryTheory.Subobject.MonoOver #align_import category_theory.subterminal from "leanprover-community/mathlib"@"bb103f356534a9a7d3596a672097e375290a4c3a" universe v₁ v₂ u₁ u₂ noncomputable section namespace CategoryTheory open Limits Category variable {C : Type u₁} [Category.{v₁} C] {A : C} def IsSubterminal (A : C) : Prop := ∀ ⦃Z : C⦄ (f g : Z ⟶ A), f = g #align category_theory.is_subterminal CategoryTheory.IsSubterminal theorem IsSubterminal.def : IsSubterminal A ↔ ∀ ⦃Z : C⦄ (f g : Z ⟶ A), f = g := Iff.rfl #align category_theory.is_subterminal.def CategoryTheory.IsSubterminal.def theorem IsSubterminal.mono_isTerminal_from (hA : IsSubterminal A) {T : C} (hT : IsTerminal T) : Mono (hT.from A) := { right_cancellation := fun _ _ _ => hA _ _ } #align category_theory.is_subterminal.mono_is_terminal_from CategoryTheory.IsSubterminal.mono_isTerminal_from theorem IsSubterminal.mono_terminal_from [HasTerminal C] (hA : IsSubterminal A) : Mono (terminal.from A) := hA.mono_isTerminal_from terminalIsTerminal #align category_theory.is_subterminal.mono_terminal_from CategoryTheory.IsSubterminal.mono_terminal_from theorem isSubterminal_of_mono_isTerminal_from {T : C} (hT : IsTerminal T) [Mono (hT.from A)] : IsSubterminal A := fun Z f g => by rw [← cancel_mono (hT.from A)] apply hT.hom_ext #align category_theory.is_subterminal_of_mono_is_terminal_from CategoryTheory.isSubterminal_of_mono_isTerminal_from theorem isSubterminal_of_mono_terminal_from [HasTerminal C] [Mono (terminal.from A)] : IsSubterminal A := fun Z f g => by rw [← cancel_mono (terminal.from A)] apply Subsingleton.elim #align category_theory.is_subterminal_of_mono_terminal_from CategoryTheory.isSubterminal_of_mono_terminal_from theorem isSubterminal_of_isTerminal {T : C} (hT : IsTerminal T) : IsSubterminal T := fun _ _ _ => hT.hom_ext _ _ #align category_theory.is_subterminal_of_is_terminal CategoryTheory.isSubterminal_of_isTerminal theorem isSubterminal_of_terminal [HasTerminal C] : IsSubterminal (⊤_ C) := fun _ _ _ => Subsingleton.elim _ _ #align category_theory.is_subterminal_of_terminal CategoryTheory.isSubterminal_of_terminal theorem IsSubterminal.isIso_diag (hA : IsSubterminal A) [HasBinaryProduct A A] : IsIso (diag A) := ⟨⟨Limits.prod.fst, ⟨by simp, by rw [IsSubterminal.def] at hA aesop_cat⟩⟩⟩ #align category_theory.is_subterminal.is_iso_diag CategoryTheory.IsSubterminal.isIso_diag
Mathlib/CategoryTheory/Subterminal.lean
107
110
theorem isSubterminal_of_isIso_diag [HasBinaryProduct A A] [IsIso (diag A)] : IsSubterminal A := fun Z f g => by have : (Limits.prod.fst : A ⨯ A ⟶ _) = Limits.prod.snd := by
simp [← cancel_epi (diag A)] rw [← prod.lift_fst f g, this, prod.lift_snd]
485
import Mathlib.Order.Filter.Prod #align_import order.filter.n_ary from "leanprover-community/mathlib"@"78f647f8517f021d839a7553d5dc97e79b508dea" open Function Set open Filter namespace Filter variable {α α' β β' γ γ' δ δ' ε ε' : Type*} {m : α → β → γ} {f f₁ f₂ : Filter α} {g g₁ g₂ : Filter β} {h h₁ h₂ : Filter γ} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {u : Set γ} {v : Set δ} {a : α} {b : β} {c : γ} def map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter γ := ((f ×ˢ g).map (uncurry m)).copy { s | ∃ u ∈ f, ∃ v ∈ g, image2 m u v ⊆ s } fun _ ↦ by simp only [mem_map, mem_prod_iff, image2_subset_iff, prod_subset_iff]; rfl #align filter.map₂ Filter.map₂ @[simp 900] theorem mem_map₂_iff : u ∈ map₂ m f g ↔ ∃ s ∈ f, ∃ t ∈ g, image2 m s t ⊆ u := Iff.rfl #align filter.mem_map₂_iff Filter.mem_map₂_iff theorem image2_mem_map₂ (hs : s ∈ f) (ht : t ∈ g) : image2 m s t ∈ map₂ m f g := ⟨_, hs, _, ht, Subset.rfl⟩ #align filter.image2_mem_map₂ Filter.image2_mem_map₂
Mathlib/Order/Filter/NAry.lean
53
55
theorem map_prod_eq_map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter.map (fun p : α × β => m p.1 p.2) (f ×ˢ g) = map₂ m f g := by
rw [map₂, copy_eq, uncurry_def]
486
import Mathlib.Order.Filter.Prod #align_import order.filter.n_ary from "leanprover-community/mathlib"@"78f647f8517f021d839a7553d5dc97e79b508dea" open Function Set open Filter namespace Filter variable {α α' β β' γ γ' δ δ' ε ε' : Type*} {m : α → β → γ} {f f₁ f₂ : Filter α} {g g₁ g₂ : Filter β} {h h₁ h₂ : Filter γ} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {u : Set γ} {v : Set δ} {a : α} {b : β} {c : γ} def map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter γ := ((f ×ˢ g).map (uncurry m)).copy { s | ∃ u ∈ f, ∃ v ∈ g, image2 m u v ⊆ s } fun _ ↦ by simp only [mem_map, mem_prod_iff, image2_subset_iff, prod_subset_iff]; rfl #align filter.map₂ Filter.map₂ @[simp 900] theorem mem_map₂_iff : u ∈ map₂ m f g ↔ ∃ s ∈ f, ∃ t ∈ g, image2 m s t ⊆ u := Iff.rfl #align filter.mem_map₂_iff Filter.mem_map₂_iff theorem image2_mem_map₂ (hs : s ∈ f) (ht : t ∈ g) : image2 m s t ∈ map₂ m f g := ⟨_, hs, _, ht, Subset.rfl⟩ #align filter.image2_mem_map₂ Filter.image2_mem_map₂ theorem map_prod_eq_map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter.map (fun p : α × β => m p.1 p.2) (f ×ˢ g) = map₂ m f g := by rw [map₂, copy_eq, uncurry_def] #align filter.map_prod_eq_map₂ Filter.map_prod_eq_map₂ theorem map_prod_eq_map₂' (m : α × β → γ) (f : Filter α) (g : Filter β) : Filter.map m (f ×ˢ g) = map₂ (fun a b => m (a, b)) f g := map_prod_eq_map₂ (curry m) f g #align filter.map_prod_eq_map₂' Filter.map_prod_eq_map₂' @[simp]
Mathlib/Order/Filter/NAry.lean
64
65
theorem map₂_mk_eq_prod (f : Filter α) (g : Filter β) : map₂ Prod.mk f g = f ×ˢ g := by
simp only [← map_prod_eq_map₂, map_id']
486
import Mathlib.Order.Filter.Prod #align_import order.filter.n_ary from "leanprover-community/mathlib"@"78f647f8517f021d839a7553d5dc97e79b508dea" open Function Set open Filter namespace Filter variable {α α' β β' γ γ' δ δ' ε ε' : Type*} {m : α → β → γ} {f f₁ f₂ : Filter α} {g g₁ g₂ : Filter β} {h h₁ h₂ : Filter γ} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {u : Set γ} {v : Set δ} {a : α} {b : β} {c : γ} def map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter γ := ((f ×ˢ g).map (uncurry m)).copy { s | ∃ u ∈ f, ∃ v ∈ g, image2 m u v ⊆ s } fun _ ↦ by simp only [mem_map, mem_prod_iff, image2_subset_iff, prod_subset_iff]; rfl #align filter.map₂ Filter.map₂ @[simp 900] theorem mem_map₂_iff : u ∈ map₂ m f g ↔ ∃ s ∈ f, ∃ t ∈ g, image2 m s t ⊆ u := Iff.rfl #align filter.mem_map₂_iff Filter.mem_map₂_iff theorem image2_mem_map₂ (hs : s ∈ f) (ht : t ∈ g) : image2 m s t ∈ map₂ m f g := ⟨_, hs, _, ht, Subset.rfl⟩ #align filter.image2_mem_map₂ Filter.image2_mem_map₂ theorem map_prod_eq_map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter.map (fun p : α × β => m p.1 p.2) (f ×ˢ g) = map₂ m f g := by rw [map₂, copy_eq, uncurry_def] #align filter.map_prod_eq_map₂ Filter.map_prod_eq_map₂ theorem map_prod_eq_map₂' (m : α × β → γ) (f : Filter α) (g : Filter β) : Filter.map m (f ×ˢ g) = map₂ (fun a b => m (a, b)) f g := map_prod_eq_map₂ (curry m) f g #align filter.map_prod_eq_map₂' Filter.map_prod_eq_map₂' @[simp] theorem map₂_mk_eq_prod (f : Filter α) (g : Filter β) : map₂ Prod.mk f g = f ×ˢ g := by simp only [← map_prod_eq_map₂, map_id'] #align filter.map₂_mk_eq_prod Filter.map₂_mk_eq_prod -- lemma image2_mem_map₂_iff (hm : injective2 m) : image2 m s t ∈ map₂ m f g ↔ s ∈ f ∧ t ∈ g := -- ⟨by { rintro ⟨u, v, hu, hv, h⟩, rw image2_subset_image2_iff hm at h, -- exact ⟨mem_of_superset hu h.1, mem_of_superset hv h.2⟩ }, λ h, image2_mem_map₂ h.1 h.2⟩ theorem map₂_mono (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) : map₂ m f₁ g₁ ≤ map₂ m f₂ g₂ := fun _ ⟨s, hs, t, ht, hst⟩ => ⟨s, hf hs, t, hg ht, hst⟩ #align filter.map₂_mono Filter.map₂_mono theorem map₂_mono_left (h : g₁ ≤ g₂) : map₂ m f g₁ ≤ map₂ m f g₂ := map₂_mono Subset.rfl h #align filter.map₂_mono_left Filter.map₂_mono_left theorem map₂_mono_right (h : f₁ ≤ f₂) : map₂ m f₁ g ≤ map₂ m f₂ g := map₂_mono h Subset.rfl #align filter.map₂_mono_right Filter.map₂_mono_right @[simp] theorem le_map₂_iff {h : Filter γ} : h ≤ map₂ m f g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → image2 m s t ∈ h := ⟨fun H _ hs _ ht => H <| image2_mem_map₂ hs ht, fun H _ ⟨_, hs, _, ht, hu⟩ => mem_of_superset (H hs ht) hu⟩ #align filter.le_map₂_iff Filter.le_map₂_iff @[simp]
Mathlib/Order/Filter/NAry.lean
91
91
theorem map₂_eq_bot_iff : map₂ m f g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := by
simp [← map_prod_eq_map₂]
486
import Mathlib.Order.Filter.Prod #align_import order.filter.n_ary from "leanprover-community/mathlib"@"78f647f8517f021d839a7553d5dc97e79b508dea" open Function Set open Filter namespace Filter variable {α α' β β' γ γ' δ δ' ε ε' : Type*} {m : α → β → γ} {f f₁ f₂ : Filter α} {g g₁ g₂ : Filter β} {h h₁ h₂ : Filter γ} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {u : Set γ} {v : Set δ} {a : α} {b : β} {c : γ} def map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter γ := ((f ×ˢ g).map (uncurry m)).copy { s | ∃ u ∈ f, ∃ v ∈ g, image2 m u v ⊆ s } fun _ ↦ by simp only [mem_map, mem_prod_iff, image2_subset_iff, prod_subset_iff]; rfl #align filter.map₂ Filter.map₂ @[simp 900] theorem mem_map₂_iff : u ∈ map₂ m f g ↔ ∃ s ∈ f, ∃ t ∈ g, image2 m s t ⊆ u := Iff.rfl #align filter.mem_map₂_iff Filter.mem_map₂_iff theorem image2_mem_map₂ (hs : s ∈ f) (ht : t ∈ g) : image2 m s t ∈ map₂ m f g := ⟨_, hs, _, ht, Subset.rfl⟩ #align filter.image2_mem_map₂ Filter.image2_mem_map₂ theorem map_prod_eq_map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter.map (fun p : α × β => m p.1 p.2) (f ×ˢ g) = map₂ m f g := by rw [map₂, copy_eq, uncurry_def] #align filter.map_prod_eq_map₂ Filter.map_prod_eq_map₂ theorem map_prod_eq_map₂' (m : α × β → γ) (f : Filter α) (g : Filter β) : Filter.map m (f ×ˢ g) = map₂ (fun a b => m (a, b)) f g := map_prod_eq_map₂ (curry m) f g #align filter.map_prod_eq_map₂' Filter.map_prod_eq_map₂' @[simp] theorem map₂_mk_eq_prod (f : Filter α) (g : Filter β) : map₂ Prod.mk f g = f ×ˢ g := by simp only [← map_prod_eq_map₂, map_id'] #align filter.map₂_mk_eq_prod Filter.map₂_mk_eq_prod -- lemma image2_mem_map₂_iff (hm : injective2 m) : image2 m s t ∈ map₂ m f g ↔ s ∈ f ∧ t ∈ g := -- ⟨by { rintro ⟨u, v, hu, hv, h⟩, rw image2_subset_image2_iff hm at h, -- exact ⟨mem_of_superset hu h.1, mem_of_superset hv h.2⟩ }, λ h, image2_mem_map₂ h.1 h.2⟩ theorem map₂_mono (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) : map₂ m f₁ g₁ ≤ map₂ m f₂ g₂ := fun _ ⟨s, hs, t, ht, hst⟩ => ⟨s, hf hs, t, hg ht, hst⟩ #align filter.map₂_mono Filter.map₂_mono theorem map₂_mono_left (h : g₁ ≤ g₂) : map₂ m f g₁ ≤ map₂ m f g₂ := map₂_mono Subset.rfl h #align filter.map₂_mono_left Filter.map₂_mono_left theorem map₂_mono_right (h : f₁ ≤ f₂) : map₂ m f₁ g ≤ map₂ m f₂ g := map₂_mono h Subset.rfl #align filter.map₂_mono_right Filter.map₂_mono_right @[simp] theorem le_map₂_iff {h : Filter γ} : h ≤ map₂ m f g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → image2 m s t ∈ h := ⟨fun H _ hs _ ht => H <| image2_mem_map₂ hs ht, fun H _ ⟨_, hs, _, ht, hu⟩ => mem_of_superset (H hs ht) hu⟩ #align filter.le_map₂_iff Filter.le_map₂_iff @[simp] theorem map₂_eq_bot_iff : map₂ m f g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := by simp [← map_prod_eq_map₂] #align filter.map₂_eq_bot_iff Filter.map₂_eq_bot_iff @[simp] theorem map₂_bot_left : map₂ m ⊥ g = ⊥ := map₂_eq_bot_iff.2 <| .inl rfl #align filter.map₂_bot_left Filter.map₂_bot_left @[simp] theorem map₂_bot_right : map₂ m f ⊥ = ⊥ := map₂_eq_bot_iff.2 <| .inr rfl #align filter.map₂_bot_right Filter.map₂_bot_right @[simp]
Mathlib/Order/Filter/NAry.lean
103
103
theorem map₂_neBot_iff : (map₂ m f g).NeBot ↔ f.NeBot ∧ g.NeBot := by
simp [neBot_iff, not_or]
486
import Mathlib.Order.Filter.Prod #align_import order.filter.n_ary from "leanprover-community/mathlib"@"78f647f8517f021d839a7553d5dc97e79b508dea" open Function Set open Filter namespace Filter variable {α α' β β' γ γ' δ δ' ε ε' : Type*} {m : α → β → γ} {f f₁ f₂ : Filter α} {g g₁ g₂ : Filter β} {h h₁ h₂ : Filter γ} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {u : Set γ} {v : Set δ} {a : α} {b : β} {c : γ} def map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter γ := ((f ×ˢ g).map (uncurry m)).copy { s | ∃ u ∈ f, ∃ v ∈ g, image2 m u v ⊆ s } fun _ ↦ by simp only [mem_map, mem_prod_iff, image2_subset_iff, prod_subset_iff]; rfl #align filter.map₂ Filter.map₂ @[simp 900] theorem mem_map₂_iff : u ∈ map₂ m f g ↔ ∃ s ∈ f, ∃ t ∈ g, image2 m s t ⊆ u := Iff.rfl #align filter.mem_map₂_iff Filter.mem_map₂_iff theorem image2_mem_map₂ (hs : s ∈ f) (ht : t ∈ g) : image2 m s t ∈ map₂ m f g := ⟨_, hs, _, ht, Subset.rfl⟩ #align filter.image2_mem_map₂ Filter.image2_mem_map₂ theorem map_prod_eq_map₂ (m : α → β → γ) (f : Filter α) (g : Filter β) : Filter.map (fun p : α × β => m p.1 p.2) (f ×ˢ g) = map₂ m f g := by rw [map₂, copy_eq, uncurry_def] #align filter.map_prod_eq_map₂ Filter.map_prod_eq_map₂ theorem map_prod_eq_map₂' (m : α × β → γ) (f : Filter α) (g : Filter β) : Filter.map m (f ×ˢ g) = map₂ (fun a b => m (a, b)) f g := map_prod_eq_map₂ (curry m) f g #align filter.map_prod_eq_map₂' Filter.map_prod_eq_map₂' @[simp] theorem map₂_mk_eq_prod (f : Filter α) (g : Filter β) : map₂ Prod.mk f g = f ×ˢ g := by simp only [← map_prod_eq_map₂, map_id'] #align filter.map₂_mk_eq_prod Filter.map₂_mk_eq_prod -- lemma image2_mem_map₂_iff (hm : injective2 m) : image2 m s t ∈ map₂ m f g ↔ s ∈ f ∧ t ∈ g := -- ⟨by { rintro ⟨u, v, hu, hv, h⟩, rw image2_subset_image2_iff hm at h, -- exact ⟨mem_of_superset hu h.1, mem_of_superset hv h.2⟩ }, λ h, image2_mem_map₂ h.1 h.2⟩ theorem map₂_mono (hf : f₁ ≤ f₂) (hg : g₁ ≤ g₂) : map₂ m f₁ g₁ ≤ map₂ m f₂ g₂ := fun _ ⟨s, hs, t, ht, hst⟩ => ⟨s, hf hs, t, hg ht, hst⟩ #align filter.map₂_mono Filter.map₂_mono theorem map₂_mono_left (h : g₁ ≤ g₂) : map₂ m f g₁ ≤ map₂ m f g₂ := map₂_mono Subset.rfl h #align filter.map₂_mono_left Filter.map₂_mono_left theorem map₂_mono_right (h : f₁ ≤ f₂) : map₂ m f₁ g ≤ map₂ m f₂ g := map₂_mono h Subset.rfl #align filter.map₂_mono_right Filter.map₂_mono_right @[simp] theorem le_map₂_iff {h : Filter γ} : h ≤ map₂ m f g ↔ ∀ ⦃s⦄, s ∈ f → ∀ ⦃t⦄, t ∈ g → image2 m s t ∈ h := ⟨fun H _ hs _ ht => H <| image2_mem_map₂ hs ht, fun H _ ⟨_, hs, _, ht, hu⟩ => mem_of_superset (H hs ht) hu⟩ #align filter.le_map₂_iff Filter.le_map₂_iff @[simp] theorem map₂_eq_bot_iff : map₂ m f g = ⊥ ↔ f = ⊥ ∨ g = ⊥ := by simp [← map_prod_eq_map₂] #align filter.map₂_eq_bot_iff Filter.map₂_eq_bot_iff @[simp] theorem map₂_bot_left : map₂ m ⊥ g = ⊥ := map₂_eq_bot_iff.2 <| .inl rfl #align filter.map₂_bot_left Filter.map₂_bot_left @[simp] theorem map₂_bot_right : map₂ m f ⊥ = ⊥ := map₂_eq_bot_iff.2 <| .inr rfl #align filter.map₂_bot_right Filter.map₂_bot_right @[simp] theorem map₂_neBot_iff : (map₂ m f g).NeBot ↔ f.NeBot ∧ g.NeBot := by simp [neBot_iff, not_or] #align filter.map₂_ne_bot_iff Filter.map₂_neBot_iff protected theorem NeBot.map₂ (hf : f.NeBot) (hg : g.NeBot) : (map₂ m f g).NeBot := map₂_neBot_iff.2 ⟨hf, hg⟩ #align filter.ne_bot.map₂ Filter.NeBot.map₂ instance map₂.neBot [NeBot f] [NeBot g] : NeBot (map₂ m f g) := .map₂ ‹_› ‹_› theorem NeBot.of_map₂_left (h : (map₂ m f g).NeBot) : f.NeBot := (map₂_neBot_iff.1 h).1 #align filter.ne_bot.of_map₂_left Filter.NeBot.of_map₂_left theorem NeBot.of_map₂_right (h : (map₂ m f g).NeBot) : g.NeBot := (map₂_neBot_iff.1 h).2 #align filter.ne_bot.of_map₂_right Filter.NeBot.of_map₂_right
Mathlib/Order/Filter/NAry.lean
120
121
theorem map₂_sup_left : map₂ m (f₁ ⊔ f₂) g = map₂ m f₁ g ⊔ map₂ m f₂ g := by
simp_rw [← map_prod_eq_map₂, sup_prod, map_sup]
486
import Mathlib.CategoryTheory.Groupoid import Mathlib.Combinatorics.Quiver.Basic #align_import category_theory.groupoid.basic from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da" namespace CategoryTheory namespace Groupoid variable (C : Type*) [Groupoid C] section Thin
Mathlib/CategoryTheory/Groupoid/Basic.lean
23
30
theorem isThin_iff : Quiver.IsThin C ↔ ∀ c : C, Subsingleton (c ⟶ c) := by
refine ⟨fun h c => h c c, fun h c d => Subsingleton.intro fun f g => ?_⟩ haveI := h d calc f = f ≫ inv g ≫ g := by simp only [inv_eq_inv, IsIso.inv_hom_id, Category.comp_id] _ = f ≫ inv f ≫ g := by congr 1 simp only [inv_eq_inv, IsIso.inv_hom_id, eq_iff_true_of_subsingleton] _ = g := by simp only [inv_eq_inv, IsIso.hom_inv_id_assoc]
487
import Mathlib.Tactic.Ring set_option autoImplicit true namespace Mathlib.Tactic.LinearCombination open Lean hiding Rat open Elab Meta Term theorem pf_add_c [Add α] (p : a = b) (c : α) : a + c = b + c := p ▸ rfl theorem c_add_pf [Add α] (p : b = c) (a : α) : a + b = a + c := p ▸ rfl theorem add_pf [Add α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ + a₂ = b₁ + b₂ := p₁ ▸ p₂ ▸ rfl theorem pf_sub_c [Sub α] (p : a = b) (c : α) : a - c = b - c := p ▸ rfl theorem c_sub_pf [Sub α] (p : b = c) (a : α) : a - b = a - c := p ▸ rfl theorem sub_pf [Sub α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ - a₂ = b₁ - b₂ := p₁ ▸ p₂ ▸ rfl theorem neg_pf [Neg α] (p : (a:α) = b) : -a = -b := p ▸ rfl theorem pf_mul_c [Mul α] (p : a = b) (c : α) : a * c = b * c := p ▸ rfl theorem c_mul_pf [Mul α] (p : b = c) (a : α) : a * b = a * c := p ▸ rfl theorem mul_pf [Mul α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ * a₂ = b₁ * b₂ := p₁ ▸ p₂ ▸ rfl theorem inv_pf [Inv α] (p : (a:α) = b) : a⁻¹ = b⁻¹ := p ▸ rfl theorem pf_div_c [Div α] (p : a = b) (c : α) : a / c = b / c := p ▸ rfl theorem c_div_pf [Div α] (p : b = c) (a : α) : a / b = a / c := p ▸ rfl theorem div_pf [Div α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ / a₂ = b₁ / b₂ := p₁ ▸ p₂ ▸ rfl partial def expandLinearCombo (stx : Syntax.Term) : TermElabM (Option Syntax.Term) := do let mut result ← match stx with | `(($e)) => expandLinearCombo e | `($e₁ + $e₂) => do match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with | none, none => pure none | some p₁, none => ``(pf_add_c $p₁ $e₂) | none, some p₂ => ``(c_add_pf $p₂ $e₁) | some p₁, some p₂ => ``(add_pf $p₁ $p₂) | `($e₁ - $e₂) => do match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with | none, none => pure none | some p₁, none => ``(pf_sub_c $p₁ $e₂) | none, some p₂ => ``(c_sub_pf $p₂ $e₁) | some p₁, some p₂ => ``(sub_pf $p₁ $p₂) | `(-$e) => do match ← expandLinearCombo e with | none => pure none | some p => ``(neg_pf $p) | `(← $e) => do match ← expandLinearCombo e with | none => pure none | some p => ``(Eq.symm $p) | `($e₁ * $e₂) => do match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with | none, none => pure none | some p₁, none => ``(pf_mul_c $p₁ $e₂) | none, some p₂ => ``(c_mul_pf $p₂ $e₁) | some p₁, some p₂ => ``(mul_pf $p₁ $p₂) | `($e⁻¹) => do match ← expandLinearCombo e with | none => pure none | some p => ``(inv_pf $p) | `($e₁ / $e₂) => do match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with | none, none => pure none | some p₁, none => ``(pf_div_c $p₁ $e₂) | none, some p₂ => ``(c_div_pf $p₂ $e₁) | some p₁, some p₂ => ``(div_pf $p₁ $p₂) | e => do let e ← elabTerm e none let eType ← inferType e let .true := (← withReducible do whnf eType).isEq | pure none some <$> e.toSyntax return result.map fun r => ⟨r.raw.setInfo (SourceInfo.fromRef stx true)⟩ theorem eq_trans₃ (p : (a:α) = b) (p₁ : a = a') (p₂ : b = b') : a' = b' := p₁ ▸ p₂ ▸ p
Mathlib/Tactic/LinearCombination.lean
111
112
theorem eq_of_add [AddGroup α] (p : (a:α) = b) (H : (a' - b') - (a - b) = 0) : a' = b' := by
rw [← sub_eq_zero] at p ⊢; rwa [sub_eq_zero, p] at H
488
import Mathlib.Tactic.Ring set_option autoImplicit true namespace Mathlib.Tactic.LinearCombination open Lean hiding Rat open Elab Meta Term theorem pf_add_c [Add α] (p : a = b) (c : α) : a + c = b + c := p ▸ rfl theorem c_add_pf [Add α] (p : b = c) (a : α) : a + b = a + c := p ▸ rfl theorem add_pf [Add α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ + a₂ = b₁ + b₂ := p₁ ▸ p₂ ▸ rfl theorem pf_sub_c [Sub α] (p : a = b) (c : α) : a - c = b - c := p ▸ rfl theorem c_sub_pf [Sub α] (p : b = c) (a : α) : a - b = a - c := p ▸ rfl theorem sub_pf [Sub α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ - a₂ = b₁ - b₂ := p₁ ▸ p₂ ▸ rfl theorem neg_pf [Neg α] (p : (a:α) = b) : -a = -b := p ▸ rfl theorem pf_mul_c [Mul α] (p : a = b) (c : α) : a * c = b * c := p ▸ rfl theorem c_mul_pf [Mul α] (p : b = c) (a : α) : a * b = a * c := p ▸ rfl theorem mul_pf [Mul α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ * a₂ = b₁ * b₂ := p₁ ▸ p₂ ▸ rfl theorem inv_pf [Inv α] (p : (a:α) = b) : a⁻¹ = b⁻¹ := p ▸ rfl theorem pf_div_c [Div α] (p : a = b) (c : α) : a / c = b / c := p ▸ rfl theorem c_div_pf [Div α] (p : b = c) (a : α) : a / b = a / c := p ▸ rfl theorem div_pf [Div α] (p₁ : (a₁:α) = b₁) (p₂ : a₂ = b₂) : a₁ / a₂ = b₁ / b₂ := p₁ ▸ p₂ ▸ rfl partial def expandLinearCombo (stx : Syntax.Term) : TermElabM (Option Syntax.Term) := do let mut result ← match stx with | `(($e)) => expandLinearCombo e | `($e₁ + $e₂) => do match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with | none, none => pure none | some p₁, none => ``(pf_add_c $p₁ $e₂) | none, some p₂ => ``(c_add_pf $p₂ $e₁) | some p₁, some p₂ => ``(add_pf $p₁ $p₂) | `($e₁ - $e₂) => do match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with | none, none => pure none | some p₁, none => ``(pf_sub_c $p₁ $e₂) | none, some p₂ => ``(c_sub_pf $p₂ $e₁) | some p₁, some p₂ => ``(sub_pf $p₁ $p₂) | `(-$e) => do match ← expandLinearCombo e with | none => pure none | some p => ``(neg_pf $p) | `(← $e) => do match ← expandLinearCombo e with | none => pure none | some p => ``(Eq.symm $p) | `($e₁ * $e₂) => do match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with | none, none => pure none | some p₁, none => ``(pf_mul_c $p₁ $e₂) | none, some p₂ => ``(c_mul_pf $p₂ $e₁) | some p₁, some p₂ => ``(mul_pf $p₁ $p₂) | `($e⁻¹) => do match ← expandLinearCombo e with | none => pure none | some p => ``(inv_pf $p) | `($e₁ / $e₂) => do match ← expandLinearCombo e₁, ← expandLinearCombo e₂ with | none, none => pure none | some p₁, none => ``(pf_div_c $p₁ $e₂) | none, some p₂ => ``(c_div_pf $p₂ $e₁) | some p₁, some p₂ => ``(div_pf $p₁ $p₂) | e => do let e ← elabTerm e none let eType ← inferType e let .true := (← withReducible do whnf eType).isEq | pure none some <$> e.toSyntax return result.map fun r => ⟨r.raw.setInfo (SourceInfo.fromRef stx true)⟩ theorem eq_trans₃ (p : (a:α) = b) (p₁ : a = a') (p₂ : b = b') : a' = b' := p₁ ▸ p₂ ▸ p theorem eq_of_add [AddGroup α] (p : (a:α) = b) (H : (a' - b') - (a - b) = 0) : a' = b' := by rw [← sub_eq_zero] at p ⊢; rwa [sub_eq_zero, p] at H
Mathlib/Tactic/LinearCombination.lean
114
116
theorem eq_of_add_pow [Ring α] [NoZeroDivisors α] (n : ℕ) (p : (a:α) = b) (H : (a' - b')^n - (a - b) = 0) : a' = b' := by
rw [← sub_eq_zero] at p ⊢; apply pow_eq_zero (n := n); rwa [sub_eq_zero, p] at H
488
import Mathlib.Data.Finset.Basic variable {ι : Sort _} {π : ι → Sort _} {x : ∀ i, π i} [DecidableEq ι] namespace Function def updateFinset (x : ∀ i, π i) (s : Finset ι) (y : ∀ i : ↥s, π i) (i : ι) : π i := if hi : i ∈ s then y ⟨i, hi⟩ else x i open Finset Equiv theorem updateFinset_def {s : Finset ι} {y} : updateFinset x s y = fun i ↦ if hi : i ∈ s then y ⟨i, hi⟩ else x i := rfl @[simp] theorem updateFinset_empty {y} : updateFinset x ∅ y = x := rfl
Mathlib/Data/Finset/Update.lean
35
41
theorem updateFinset_singleton {i y} : updateFinset x {i} y = Function.update x i (y ⟨i, mem_singleton_self i⟩) := by
congr with j by_cases hj : j = i · cases hj simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset] · simp [hj, updateFinset]
489
import Mathlib.Data.Finset.Basic variable {ι : Sort _} {π : ι → Sort _} {x : ∀ i, π i} [DecidableEq ι] namespace Function def updateFinset (x : ∀ i, π i) (s : Finset ι) (y : ∀ i : ↥s, π i) (i : ι) : π i := if hi : i ∈ s then y ⟨i, hi⟩ else x i open Finset Equiv theorem updateFinset_def {s : Finset ι} {y} : updateFinset x s y = fun i ↦ if hi : i ∈ s then y ⟨i, hi⟩ else x i := rfl @[simp] theorem updateFinset_empty {y} : updateFinset x ∅ y = x := rfl theorem updateFinset_singleton {i y} : updateFinset x {i} y = Function.update x i (y ⟨i, mem_singleton_self i⟩) := by congr with j by_cases hj : j = i · cases hj simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset] · simp [hj, updateFinset]
Mathlib/Data/Finset/Update.lean
43
50
theorem update_eq_updateFinset {i y} : Function.update x i y = updateFinset x {i} (uniqueElim y) := by
congr with j by_cases hj : j = i · cases hj simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset] exact uniqueElim_default (α := fun j : ({i} : Finset ι) => π j) y · simp [hj, updateFinset]
489
import Mathlib.Data.Finset.Basic variable {ι : Sort _} {π : ι → Sort _} {x : ∀ i, π i} [DecidableEq ι] namespace Function def updateFinset (x : ∀ i, π i) (s : Finset ι) (y : ∀ i : ↥s, π i) (i : ι) : π i := if hi : i ∈ s then y ⟨i, hi⟩ else x i open Finset Equiv theorem updateFinset_def {s : Finset ι} {y} : updateFinset x s y = fun i ↦ if hi : i ∈ s then y ⟨i, hi⟩ else x i := rfl @[simp] theorem updateFinset_empty {y} : updateFinset x ∅ y = x := rfl theorem updateFinset_singleton {i y} : updateFinset x {i} y = Function.update x i (y ⟨i, mem_singleton_self i⟩) := by congr with j by_cases hj : j = i · cases hj simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset] · simp [hj, updateFinset] theorem update_eq_updateFinset {i y} : Function.update x i y = updateFinset x {i} (uniqueElim y) := by congr with j by_cases hj : j = i · cases hj simp only [dif_pos, Finset.mem_singleton, update_same, updateFinset] exact uniqueElim_default (α := fun j : ({i} : Finset ι) => π j) y · simp [hj, updateFinset]
Mathlib/Data/Finset/Update.lean
52
63
theorem updateFinset_updateFinset {s t : Finset ι} (hst : Disjoint s t) {y : ∀ i : ↥s, π i} {z : ∀ i : ↥t, π i} : updateFinset (updateFinset x s y) t z = updateFinset x (s ∪ t) (Equiv.piFinsetUnion π hst ⟨y, z⟩) := by
set e := Equiv.Finset.union s t hst congr with i by_cases his : i ∈ s <;> by_cases hit : i ∈ t <;> simp only [updateFinset, his, hit, dif_pos, dif_neg, Finset.mem_union, true_or_iff, false_or_iff, not_false_iff] · exfalso; exact Finset.disjoint_left.mp hst his hit · exact piCongrLeft_sum_inl (fun b : ↥(s ∪ t) => π b) e y z ⟨i, his⟩ |>.symm · exact piCongrLeft_sum_inr (fun b : ↥(s ∪ t) => π b) e y z ⟨i, hit⟩ |>.symm
489
import Mathlib.CategoryTheory.Opposites #align_import category_theory.eq_to_hom from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe v₁ v₂ v₃ u₁ u₂ u₃ -- morphism levels before object levels. See note [CategoryTheory universes]. namespace CategoryTheory open Opposite variable {C : Type u₁} [Category.{v₁} C] def eqToHom {X Y : C} (p : X = Y) : X ⟶ Y := by rw [p]; exact 𝟙 _ #align category_theory.eq_to_hom CategoryTheory.eqToHom @[simp] theorem eqToHom_refl (X : C) (p : X = X) : eqToHom p = 𝟙 X := rfl #align category_theory.eq_to_hom_refl CategoryTheory.eqToHom_refl @[reassoc (attr := simp)]
Mathlib/CategoryTheory/EqToHom.lean
52
56
theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) : eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by
cases p cases q simp
490
import Mathlib.CategoryTheory.Opposites #align_import category_theory.eq_to_hom from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe v₁ v₂ v₃ u₁ u₂ u₃ -- morphism levels before object levels. See note [CategoryTheory universes]. namespace CategoryTheory open Opposite variable {C : Type u₁} [Category.{v₁} C] def eqToHom {X Y : C} (p : X = Y) : X ⟶ Y := by rw [p]; exact 𝟙 _ #align category_theory.eq_to_hom CategoryTheory.eqToHom @[simp] theorem eqToHom_refl (X : C) (p : X = X) : eqToHom p = 𝟙 X := rfl #align category_theory.eq_to_hom_refl CategoryTheory.eqToHom_refl @[reassoc (attr := simp)] theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) : eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by cases p cases q simp #align category_theory.eq_to_hom_trans CategoryTheory.eqToHom_trans theorem comp_eqToHom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') : f ≫ eqToHom p = g ↔ f = g ≫ eqToHom p.symm := { mp := fun h => h ▸ by simp mpr := fun h => by simp [eq_whisker h (eqToHom p)] } #align category_theory.comp_eq_to_hom_iff CategoryTheory.comp_eqToHom_iff theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) : eqToHom p ≫ g = f ↔ g = eqToHom p.symm ≫ f := { mp := fun h => h ▸ by simp mpr := fun h => h ▸ by simp [whisker_eq _ h] } #align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff variable {β : Sort*} -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)]
Mathlib/CategoryTheory/EqToHom.lean
77
80
theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') : z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by
cases w simp
490
import Mathlib.CategoryTheory.Opposites #align_import category_theory.eq_to_hom from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe v₁ v₂ v₃ u₁ u₂ u₃ -- morphism levels before object levels. See note [CategoryTheory universes]. namespace CategoryTheory open Opposite variable {C : Type u₁} [Category.{v₁} C] def eqToHom {X Y : C} (p : X = Y) : X ⟶ Y := by rw [p]; exact 𝟙 _ #align category_theory.eq_to_hom CategoryTheory.eqToHom @[simp] theorem eqToHom_refl (X : C) (p : X = X) : eqToHom p = 𝟙 X := rfl #align category_theory.eq_to_hom_refl CategoryTheory.eqToHom_refl @[reassoc (attr := simp)] theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) : eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by cases p cases q simp #align category_theory.eq_to_hom_trans CategoryTheory.eqToHom_trans theorem comp_eqToHom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') : f ≫ eqToHom p = g ↔ f = g ≫ eqToHom p.symm := { mp := fun h => h ▸ by simp mpr := fun h => by simp [eq_whisker h (eqToHom p)] } #align category_theory.comp_eq_to_hom_iff CategoryTheory.comp_eqToHom_iff theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) : eqToHom p ≫ g = f ↔ g = eqToHom p.symm ≫ f := { mp := fun h => h ▸ by simp mpr := fun h => h ▸ by simp [whisker_eq _ h] } #align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff variable {β : Sort*} -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') : z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by cases w simp -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)]
Mathlib/CategoryTheory/EqToHom.lean
86
89
theorem eqToHom_iso_hom_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).hom ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').hom := by
cases w simp
490
import Mathlib.CategoryTheory.Opposites #align_import category_theory.eq_to_hom from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe v₁ v₂ v₃ u₁ u₂ u₃ -- morphism levels before object levels. See note [CategoryTheory universes]. namespace CategoryTheory open Opposite variable {C : Type u₁} [Category.{v₁} C] def eqToHom {X Y : C} (p : X = Y) : X ⟶ Y := by rw [p]; exact 𝟙 _ #align category_theory.eq_to_hom CategoryTheory.eqToHom @[simp] theorem eqToHom_refl (X : C) (p : X = X) : eqToHom p = 𝟙 X := rfl #align category_theory.eq_to_hom_refl CategoryTheory.eqToHom_refl @[reassoc (attr := simp)] theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) : eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by cases p cases q simp #align category_theory.eq_to_hom_trans CategoryTheory.eqToHom_trans theorem comp_eqToHom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') : f ≫ eqToHom p = g ↔ f = g ≫ eqToHom p.symm := { mp := fun h => h ▸ by simp mpr := fun h => by simp [eq_whisker h (eqToHom p)] } #align category_theory.comp_eq_to_hom_iff CategoryTheory.comp_eqToHom_iff theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) : eqToHom p ≫ g = f ↔ g = eqToHom p.symm ≫ f := { mp := fun h => h ▸ by simp mpr := fun h => h ▸ by simp [whisker_eq _ h] } #align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff variable {β : Sort*} -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') : z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by cases w simp -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_iso_hom_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).hom ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').hom := by cases w simp -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)]
Mathlib/CategoryTheory/EqToHom.lean
95
98
theorem eqToHom_iso_inv_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).inv ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').inv := by
cases w simp
490
import Mathlib.CategoryTheory.Opposites #align_import category_theory.eq_to_hom from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe v₁ v₂ v₃ u₁ u₂ u₃ -- morphism levels before object levels. See note [CategoryTheory universes]. namespace CategoryTheory open Opposite variable {C : Type u₁} [Category.{v₁} C] def eqToHom {X Y : C} (p : X = Y) : X ⟶ Y := by rw [p]; exact 𝟙 _ #align category_theory.eq_to_hom CategoryTheory.eqToHom @[simp] theorem eqToHom_refl (X : C) (p : X = X) : eqToHom p = 𝟙 X := rfl #align category_theory.eq_to_hom_refl CategoryTheory.eqToHom_refl @[reassoc (attr := simp)] theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) : eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by cases p cases q simp #align category_theory.eq_to_hom_trans CategoryTheory.eqToHom_trans theorem comp_eqToHom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') : f ≫ eqToHom p = g ↔ f = g ≫ eqToHom p.symm := { mp := fun h => h ▸ by simp mpr := fun h => by simp [eq_whisker h (eqToHom p)] } #align category_theory.comp_eq_to_hom_iff CategoryTheory.comp_eqToHom_iff theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) : eqToHom p ≫ g = f ↔ g = eqToHom p.symm ≫ f := { mp := fun h => h ▸ by simp mpr := fun h => h ▸ by simp [whisker_eq _ h] } #align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff variable {β : Sort*} -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') : z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by cases w simp -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_iso_hom_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).hom ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').hom := by cases w simp -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_iso_inv_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).inv ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').inv := by cases w simp @[simp, nolint simpNF]
Mathlib/CategoryTheory/EqToHom.lean
104
107
theorem congrArg_cast_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) : cast (congrArg (fun W : C => W ⟶ Z) p.symm) q = eqToHom p ≫ q := by
cases p simp
490
import Mathlib.CategoryTheory.Opposites #align_import category_theory.eq_to_hom from "leanprover-community/mathlib"@"dc6c365e751e34d100e80fe6e314c3c3e0fd2988" universe v₁ v₂ v₃ u₁ u₂ u₃ -- morphism levels before object levels. See note [CategoryTheory universes]. namespace CategoryTheory open Opposite variable {C : Type u₁} [Category.{v₁} C] def eqToHom {X Y : C} (p : X = Y) : X ⟶ Y := by rw [p]; exact 𝟙 _ #align category_theory.eq_to_hom CategoryTheory.eqToHom @[simp] theorem eqToHom_refl (X : C) (p : X = X) : eqToHom p = 𝟙 X := rfl #align category_theory.eq_to_hom_refl CategoryTheory.eqToHom_refl @[reassoc (attr := simp)] theorem eqToHom_trans {X Y Z : C} (p : X = Y) (q : Y = Z) : eqToHom p ≫ eqToHom q = eqToHom (p.trans q) := by cases p cases q simp #align category_theory.eq_to_hom_trans CategoryTheory.eqToHom_trans theorem comp_eqToHom_iff {X Y Y' : C} (p : Y = Y') (f : X ⟶ Y) (g : X ⟶ Y') : f ≫ eqToHom p = g ↔ f = g ≫ eqToHom p.symm := { mp := fun h => h ▸ by simp mpr := fun h => by simp [eq_whisker h (eqToHom p)] } #align category_theory.comp_eq_to_hom_iff CategoryTheory.comp_eqToHom_iff theorem eqToHom_comp_iff {X X' Y : C} (p : X = X') (f : X ⟶ Y) (g : X' ⟶ Y) : eqToHom p ≫ g = f ↔ g = eqToHom p.symm ≫ f := { mp := fun h => h ▸ by simp mpr := fun h => h ▸ by simp [whisker_eq _ h] } #align category_theory.eq_to_hom_comp_iff CategoryTheory.eqToHom_comp_iff variable {β : Sort*} -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_naturality {f g : β → C} (z : ∀ b, f b ⟶ g b) {j j' : β} (w : j = j') : z j ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ z j' := by cases w simp -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_iso_hom_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).hom ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').hom := by cases w simp -- The simpNF linter incorrectly claims that this will never apply. -- https://github.com/leanprover-community/mathlib4/issues/5049 @[reassoc (attr := simp, nolint simpNF)] theorem eqToHom_iso_inv_naturality {f g : β → C} (z : ∀ b, f b ≅ g b) {j j' : β} (w : j = j') : (z j).inv ≫ eqToHom (by simp [w]) = eqToHom (by simp [w]) ≫ (z j').inv := by cases w simp @[simp, nolint simpNF] theorem congrArg_cast_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) : cast (congrArg (fun W : C => W ⟶ Z) p.symm) q = eqToHom p ≫ q := by cases p simp
Mathlib/CategoryTheory/EqToHom.lean
116
119
theorem congrArg_mpr_hom_left {X Y Z : C} (p : X = Y) (q : Y ⟶ Z) : (congrArg (fun W : C => W ⟶ Z) p).mpr q = eqToHom p ≫ q := by
cases p simp
490